nim-codex/vendor
Eric Mastro ccf349bd14
[marketplace] Add Reservations Module (#340)
* [marketplace] reservations module

- add de/serialization for Availability
- add markUsed/markUnused in persisted availability
- add query for unused
- add reserve/release
- reservation module tests
- split ContractInteractions into client contracts and host contracts
- remove reservations start/stop as the repo start/stop is being managed by the node
- remove dedicated reservations metadata store and use the metadata store from the repo instead
- Split ContractInteractions into:
  - ClientInteractions (with purchasing)
  - HostInteractions (with sales and proving)
- compilation fix for nim 1.2

[repostore] fix started flag, add tests

[marketplace] persist slot index
For loading the sales state from chain, the slot index was not previously persisted in the contract. Will retrieve the slot index from the contract when the sales state is loaded.

* Revert repostore changes

In favour of separate PR https://github.com/status-im/nim-codex/pull/374.

* remove warnings

* clean up

* tests: stop repostore during teardown

* change constructor type identifier

Change Contracts constructor to accept Contracts type instead of ContractInteractions.

* change constructor return type to Result instead of Option

* fix and split interactions tests

* clean up, fix tests

* find availability by slot id

* remove duplication in host/client interactions

* add test for finding availability by slotId

* log instead of raiseAssert when failed to mark availability as unused

* move to SaleErrored state instead of raiseAssert

* remove unneeded reverse

It appears that order is not preserved in the repostore, so reversing does not have the intended effect here.

* update open api spec for potential rest endpoint errors

* move functions about available bytes to repostore

* WIP: reserve and release availabilities as needed

WIP: not tested yet

Availabilities are marked as used when matched (just before downloading starts) so that future matching logic does not match an availability currently in use.

As the download progresses, batches of blocks are written to disk, and the equivalent bytes are released from the reservation module. The size of the availability is reduced as well.

During a reserve or release operation, availability updates occur after the repo is manipulated. If the availability update operation fails, the reserve or release is rolled back to maintain correct accounting of bytes.

Finally, once download completes, or if an error occurs, the availability is marked as unused so future matching can occur.

* delete availability when all bytes released

* fix tests + cleanup

* remove availability from SalesContext callbacks

Availability is no longer used past the SaleDownloading state in the state machine. Cleanup of Availability (marking unused) is handled directly in the SaleDownloading state, and no longer in SaleErrored or SaleFinished. Likewise, Availabilities shouldn’t need to be handled on node restart.

Additionally, Availability was being passed in SalesContext callbacks, and now that Availability is only used temporarily in the SaleDownloading state, Availability is contextually irrelevant to the callbacks, except in OnStore possibly, though it was not being consumed.

* test clean up

* - remove availability from callbacks and constructors from previous commit that needed to be removed (oopsie)
- fix integration test that checks availabilities
  - there was a bug fixed that crashed the node due to a missing `return success` in onStore
  - the test was fixed by ensuring that availabilities are remaining on the node, and the size has been reduced
- change Availability back to non-ref object and constructor back to init
- add trace logging of all state transitions in state machine
- add generally useful trace logging

* fixes after rebase

1. Fix onProve callbacks
2. Use Slot type instead of tuple for retrieving active slot.
3. Bump codex-contracts-eth that exposes getActivceSlot call.

* swap contracts branch to not support slot collateral

Slot collateral changes in the contracts require further changes in the client code, so we’ll skip those changes for now and add in a separate commit.

* modify Interactions and Deployment constructors

- `HostInteractions` and `ClientInteractions` constructors were simplified to take a contract address and no overloads
- `Interactions` prepared simplified so there are no overloads
- `Deployment` constructor updated so that it takes an optional string parameter, instead `Option[string]`

* Move `batchProc` declaration

`batchProc` needs to be consumed by both `node` and `salescontext`, and they can’t reference each other as it creates a circular dependency.

* [reservations] rename `available` to `hasAvailable`

* [reservations] default error message to inner error msg

* add SaleIngored state

When a storage request is handled but the request does match availabilities, the sales agent machine is sent to the SaleIgnored state. In addition, the agent is constructed in a way that if the request is ignored, the sales agent is removed from the list of active agents being tracked in the sales module.
2023-04-04 17:05:16 +10:00
..
asynctest@a236a5f0f3 Persist Dht providers (#257) 2022-09-29 20:16:59 -06:00
codex-contracts-eth@fb76f7d0b2 [marketplace] Add Reservations Module (#340) 2023-04-04 17:05:16 +10:00
combparser@ba4464c005 adding submodules 2021-11-25 09:37:12 +01:00
dnsclient.nim@fbb76f8af8 Add DHT (#75) 2022-04-13 10:32:35 -06:00
lrucache.nim@8767ade0b7 Add DHT (#75) 2022-04-13 10:32:35 -06:00
nim-bearssl@f4c4233de4 bump bearssl to latest 2022-09-27 12:56:07 +10:00
nim-blscurve@48d8668c5a Enable stylecheck (#353) 2023-03-10 08:02:54 +01:00
nim-chronicles@7631f7b2ee track latest nim-libp2p's master branch (#248) 2022-11-02 11:40:28 -06:00
nim-chronos@6525f4ce1d bumping chronos to latest master (#314) 2022-11-14 22:15:37 -06:00
nim-confutils@0435e67832 Minor cleanup and update deps (#42) 2022-01-12 16:19:37 -06:00
nim-contract-abi@61f8f59b39 Fix nimble requirements (#305) 2022-11-16 13:10:23 +01:00
nim-datastore@0cde8aeb67 Enable stylecheck (#353) 2023-03-10 08:02:54 +01:00
nim-eth@5885f638e4 Fix vendor/nim-eth (#246) 2022-09-12 21:30:16 -06:00
nim-ethers@3c12a65769 fix: approving tokens transfer when creating request (#385) 2023-03-30 11:34:38 +02:00
nim-faststreams@1b561a9e71 adding submodules 2021-11-25 09:37:12 +01:00
nim-http-utils@e88e231dfc track latest nim-libp2p's master branch (#248) 2022-11-02 11:40:28 -06:00
nim-json-rpc@5a28176080 feat: integrate dagger contracts 2022-02-04 15:34:56 +11:00
nim-json-serialization@e5b18fb710 track latest nim-libp2p's master branch (#248) 2022-11-02 11:40:28 -06:00
nim-leopard@1a6f2ab725 Enable stylecheck (#353) 2023-03-10 08:02:54 +01:00
nim-libbacktrace@b29c22ba0e Bump libbacktrace and secp256k1 2022-06-28 11:04:18 +03:00
nim-libp2p@a3e9d1ed80 track latest nim-libp2p's master branch (#248) 2022-11-02 11:40:28 -06:00
nim-libp2p-dht@4375b92298 Repo limits (#319) 2022-12-02 18:00:55 -06:00
nim-metrics@743f81d4f6 adding submodules 2021-11-25 09:37:12 +01:00
nim-nat-traversal@27d314d65c Speed up development (#303) 2022-11-14 14:50:00 +01:00
nim-nitro@6b4c455bf4 Fix version conflict on nimble install 2022-05-19 09:36:47 +02:00
nim-presto@3984431dc0 track latest nim-libp2p's master branch (#248) 2022-11-02 11:40:28 -06:00
nim-secp256k1@5340cf1881 Bump libbacktrace and secp256k1 2022-06-28 11:04:18 +03:00
nim-serialization@493d18b829 track latest nim-libp2p's master branch (#248) 2022-11-02 11:40:28 -06:00
nim-sqlite3-abi@fda455cfea [build] add github.com/arnetheduck/nim-sqlite3-abi to vendor 2022-08-08 02:12:43 -05:00
nim-stew@0c379cf1d8 track latest nim-libp2p's master branch (#248) 2022-11-02 11:40:28 -06:00
nim-taskpools@b3673c7a7a Enable stylecheck (#353) 2023-03-10 08:02:54 +01:00
nim-toml-serialization@4e15e00ed9 Node setup (#32) 2022-01-10 09:32:56 -06:00
nim-unittest2@02c49b8a99 Node setup (#32) 2022-01-10 09:32:56 -06:00
nim-websock@7b2ed397d6 track latest nim-libp2p's master branch (#248) 2022-11-02 11:40:28 -06:00
nim-zlib@74cdeb54b2 feat: integrate dagger contracts 2022-02-04 15:34:56 +11:00
nimbus-build-system@1cf6a1b18c Fix CI (#339) 2023-02-06 17:15:02 +01:00
nimcrypto@a5742a9a21 adding submodules 2021-11-25 09:37:12 +01:00
questionable@6cbbda7e4d [marketplace] Add Reservations Module (#340) 2023-04-04 17:05:16 +10:00
stint@036c71d06a adding submodules 2021-11-25 09:37:12 +01:00
upraises@ff4f8108e4 adding submodules 2021-11-25 09:37:12 +01:00