382 Commits

Author SHA1 Message Date
Eric Mastro
a3f9e54cc1
[marketplace] sales state machine tests 2022-11-10 19:45:46 +11:00
Eric Mastro
fb96a9eb17
[marketplace] move sale process to async state machine 2022-11-10 16:45:33 +11:00
Eric Mastro
7c87b72bce
[marketplace] add async state machine
Allows for `enterAsync` to be cancelled.
2022-11-10 15:55:37 +11:00
Eric Mastro
0a4c1c7e22
[marketplace] make availability optional for node restart 2022-11-10 15:54:40 +11:00
Eric Mastro
e2ceb431e2
[marketplace] make on chain event callbacks async 2022-11-10 15:50:19 +11:00
Eric Mastro
8066c902e6
[marketplace] get active slots from chain 2022-11-10 15:45:14 +11:00
Eric Mastro
f889426ec0
[marketplace] Fix test with longer sleepAsync 2022-10-28 11:22:02 +11:00
Eric Mastro
3885e0ab27
[marketplace] move to failed state once request fails
- Add support for subscribing to request failure events.
- Add supporting contract tests for subscribing to request failure events.
- Allow the PurchaseStarted state to move to PurchaseFailure once a request failure event is emitted
- Add supporting tests for moving from PurchaseStarted to PurchaseFailure
- Add state transition tests for PurchaseUnknown.
2022-10-27 15:22:30 +11:00
Mark Spanbroek
6d1f2fa843 [purchasing] Handle 'finished' and 'failed' states 2022-10-25 16:20:15 +02:00
Mark Spanbroek
fc7958412e [purchasing] wait until purchase is finished
Purchase.wait() would previously wait until purchase
was started, now we wait until it is finished.
2022-10-25 16:20:15 +02:00
Mark Spanbroek
ecad72c57a [market] Add method to get request end time 2022-10-25 15:54:16 +02:00
Mark Spanbroek
eb7c2fdc64 [contracts] Fix failing test
With the new solidity contracts update, a contract can only
be paid out after it started.
2022-10-25 08:59:42 +02:00
Mark Spanbroek
e05dcdd3f4 [proofs] Fix intermittently failing tests
Ensures that examples of proofs in tests are never of length 0;
these are considered invalid proofs by the smart contract logic.
2022-10-25 08:31:05 +02:00
Eric Mastro
cc1c00e3ce
Implement myRequest() and getState() methods for OnChainMarket 2022-10-25 17:04:14 +11:00
Mark Spanbroek
79f6f81766
[purchasing] load purchase states 2022-10-25 15:26:36 +11:00
Mark Spanbroek
b470799586
[purchasing] Load purchases from market 2022-10-25 15:26:36 +11:00
Mark Spanbroek
c02a89e4ac
[utils] Move StorageRequest.example up one level 2022-10-25 15:26:35 +11:00
Mark Spanbroek
b990f9a47d
[purchasing] Simplify test 2022-10-25 15:26:35 +11:00
Mark Spanbroek
92eecb0702 [purchasing] Rework purchasing as a state machine 2022-10-25 15:10:35 +11:00
Mark Spanbroek
7841a9692c [utils] Add AsyncState to state machine 2022-10-25 15:10:35 +11:00
Mark Spanbroek
b52d291785 [utils] Add state machine implementation 2022-10-25 15:10:35 +11:00
Mark Spanbroek
e648c26340 [utils] Add operator as for optional casting 2022-10-25 15:10:35 +11:00
Mark Spanbroek
bc3734b1a8 [purchasing] move Purchase and PurchaseId into separate modules 2022-10-25 15:10:35 +11:00
Eric Mastro
16024f21e9 bump nim-ethers (to main) 2022-10-25 15:10:35 +11:00
Eric Mastro
1f50612b68 bump dagger-contracts (to main) 2022-10-25 15:10:35 +11:00
Eric Mastro
25df599c08 Update to new reverts API, add tests
1. use `ProviderError` to catch contract errors instaed of `JsonRpcProviderError`.
2. Add tests for `isProofRequired`, `willProofBeRequired`, and `getProofEnd` when slot is empty (and is call is reverted)
3. bump nim-ethers to branch that has new `reverts` API and `ProviderError` support.
4. Update to new `reverts` API.
2022-10-25 15:10:35 +11:00
Eric Mastro
a9cea802ff bump dagger-contracts 2022-10-25 15:10:35 +11:00
Eric Mastro
a7277e90fb update market test 2022-10-25 15:10:35 +11:00
Eric Mastro
38643c9709 fix revert check on storage test 2022-10-25 15:10:35 +11:00
Eric Mastro
5eb65336fd catch and check revert reasons
Ensure specific contract reverts are handled and returned as booleans or default values

# Conflicts:
#	codex/contracts/proofs.nim
2022-10-25 15:10:35 +11:00
Eric Mastro
10d4dcd70d bump nim-ethers, fix tests
# Conflicts:
#	vendor/nim-ethers
2022-10-25 15:10:35 +11:00
Eric Mastro
dab65eb6bd catch contract errors to return bool
# Conflicts:
#	codex/contracts/proofs.nim
#	vendor/nim-ethers
2022-10-25 15:10:35 +11:00
Eric Mastro
ae9467b780 simplify getRequest 2022-10-25 15:10:35 +11:00
Eric Mastro
eb14ca6166 bump dagger-contracts
# Conflicts:
#	vendor/dagger-contracts
2022-10-25 15:10:35 +11:00
Eric Mastro
b9e53e182f [marketplace] support freeing of slots and failed state
Support storage contract parameters to free slots after too many proofs missed, as well as fail a contract after too many slots have been freed.

# Conflicts:
#	vendor/dagger-contracts
2022-10-25 15:10:35 +11:00
Eric Mastro
8dd110765f [marketplace] Catch slot empty, return default values 2022-10-25 15:10:35 +11:00
Eric Mastro
9d218c88a5 [marketplace] Remove isSlotCancelled and isCancelled
Remove `isSlotCancelled` and `isCancelled` from proving, as it did not fit in the module.

Update the proving module to not rely on checking the contract to understand if a request was cancelled. Instead, `proofEnd` was modified in `dagger-contracts` such that it returns a past timestamp when the contract is cancelled. This successfully removes
2022-10-25 15:10:35 +11:00
Eric Mastro
b4a14e00f7 [marketplace] address more PR comments
- remove RequestState as no longer being used
- remove RequestState check on purchase timeout
- add tests for `withdrawFunds` and `subscribeRequestCancelled`
- update `dagger-contracts` so that `RequestCancelled.requestId` property is indexed in the event
2022-10-25 15:10:35 +11:00
Eric Mastro
2db0131fa4 [fix] fix tests 2022-10-25 15:10:35 +11:00
Eric Mastro
5cb74b6638 [chore] additional clean up of array[32, byte] types
- rename `ContractId` to `SlotId`
- rename `Proving.contracts` to `Proving.slots`
- change signatures of `isSlotCancelled` and `isCancelled` to use `SlotId` and `RequestId` types, respectively.
- change all references to `RequestId`, `SlotId`
2022-10-25 15:10:35 +11:00
Eric Mastro
1039e27524 [marketplace] bump dagger contracts after rebase 2022-10-25 15:10:35 +11:00
Eric Mastro
372f827982 [marketplace] add/remove proofs for contract state
Add or remove proof requirements when a request contract’s state changes. When a request sale has completed (for a slot), the host who purchased that slot now must provide regular proofs for the data they are contracted to hold. This is now enforced by adding the slotId to the HashSet of Ids for which to require proofs. When a request has been cancelled (not all slots were filled before the request expired), proofs no longer need to be provided and the slotId is removed from teh HashSet.

Add `isCancelled` and `isSlotCancelled` checks to query the contract state without relying the on the state context variable in the contract. Because contract state can only be updated in a transaction, and the client withdrawing funds is responsible for changing the contract state to “Cancelled”, the `isCancelled` and `isSlotCancelled` functions were introduced to check the state regardless of whether or not the client had already withdrawn their funds.
2022-10-25 15:10:35 +11:00
Eric Mastro
0c3fbad470 [purchasing] Withdraw funds when request times out
When a request for storage times out (not enough slots filled), the client will initiate a withdraw request to retrieve its funds out of the contract, setting the state of the request to RequestState.Cancelled. The client will also emit a RequestCancelled event for others to listen to (ie hosts will need to listen for this event to withdraw its collateral).

Add unit test that checks for emission of RequestCancelled after request is purchased request expires.

Update dagger-contracts dependency to commit that holds the changes supporting withdrawing of funds.
2022-10-25 15:10:35 +11:00
Bulat-Ziganshin
9939d85b74
Replace protobuf serialization for Block exchange with minprotobuf (#271)
* minprotobuf serialization for Block exchange

* Handle decoding errors by stopping peer connection
2022-10-13 18:58:57 -05:00
Bulat-Ziganshin
6e6f40016c
Changes required for reasonable upload/download speed (#265)
Increase blocksize from ~8KiB to ~64KiB and remove useless unbounded prefetching on download
* increased upload/download speed on my Win10 Zen3 box to 50/150 MB/s (with FSStore)
* made manifest files 8x smaller
* two more changes in the tests to make them pass
Closes #263
2022-10-06 23:01:25 +03:00
Dmitriy Ryajov
106b04340a
Remove local providers (#268)
* add remove provider method

* remove failed providers

* bumping dht to latest master
2022-10-05 10:01:21 -06:00
Mark Spanbroek
58f0439f37 [contracts] Use Duration instead of float for clock offset
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
2022-10-03 15:17:03 +02:00
Mark Spanbroek
4e6d84850a [contracts] Fix intermittently failing clock test
Use a sub-second offset to avoid off-by-one errors in the
test at the second boundary.

Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
2022-10-03 15:17:03 +02:00
Dmitriy Ryajov
8d315b38b8
Dht maintenance (#267)
* protocol start is now async

* bumping to maintenance branch
2022-10-01 11:08:44 -06:00
Dmitriy Ryajov
f190bfb96e
bump datastore (#266)
* updating datastore to batched version

* bumping datastore
2022-09-30 17:57:57 -06:00