Commit Graph

59 Commits

Author SHA1 Message Date
Mark Spanbroek a7be363f04 [marketplace] Unlock collateral when list of slots is empty 2022-12-22 10:29:06 +01:00
Eric Mastro 47bf5d37cf remove slot from waitUntilStarted signature 2022-12-22 10:29:06 +01:00
Mark Spanbroek 9a6a321d5b [marketplace] Add method to get request end time 2022-10-25 14:49:37 +02:00
Eric Mastro fd74268a8a Remove proof extension, test clean up
1. Remove proof extension as it is not needed. Host are required to provide proofs from the moment they fill a slot, for the duration specified by the contract. This means that the ending of their requirements will be staggered at the end, as they were at the start, but this is more predicable for determining the cost of a request.
2. The proof end time was modified so that if the request state is not accepting proofs, it takes the min of the slot proof end time, the request end time, or block.timestamp - 1, which ensures that it returns a time in the past. If the slot is accepting proofs, it returns the slot end time.
3. Modify marketplace tests so that `waitUntilFinished` advances time to the proof ending of the last slot filled.
2022-10-25 12:38:19 +11:00
Eric Mastro 321132b6fa clean up tests
1. Replace all instances of `now()` with `await currentTime()` to get a more accurate representation of time from the block timestamp. Update examples.js to be async.
2. Move `RequestState` to `marketplace.js`
3. Delete `TestStorage` as `slashAmount` function no longer needed.
2022-10-25 12:38:19 +11:00
Eric Mastro ad040cfee6 [marketplace] extend proof ending
Allow proof ending to be extending once a contract is started, so that all filled slots share an ending time that is equal to the contract end time. Added tests.

Add a mapping for proof id to endId so that proof expectations can be extended for all proofs that share a given endId.

Add function modifiers that require the request state to allow proofs, with accompanying tests.

General clean up of each function’s request state context, with accompanying tests.

General clean up of all tests, including state change “wait” functions and normalising the time advancement functions.
2022-10-25 12:38:19 +11:00
Eric Mastro 1fff2f7295 [marketplace] add isFinished
Add function `isFinished` that checks whethere the state has been set to `RequestState.Finished` (which is not being set yet) or if the contract was started (`RequestState.Started`) and the contract duration has lapsed.

To facilitate `isFinished`, the contract start time (`startedAt`) was added to calculate the contract end time.
2022-10-25 12:38:19 +11:00
Eric Mastro 2170d6bd19 [marketplace] tests for Failed state 2022-10-25 12:38:19 +11:00
Eric Mastro 08e73d9348 [marketplace] Add tests for freeing a slot 2022-10-25 12:38:19 +11:00
Eric Mastro 1b216f6655 slash first then check collateral threshold
Once a proof is marked as missing, if that missing proof is enough to slash a host, first slash the host, then check the hosts balance. If the balance has dropped below the minimum allowable collateral threshold, then remove them from the slot.
2022-09-21 20:52:44 +10:00
Eric Mastro 7726db2a8d modify collateral threshold test to remove TestStorage dep 2022-09-21 20:52:44 +10:00
Eric Mastro 2b8c8fc42a [marketplace] tests for Failed state 2022-09-21 20:52:44 +10:00
Eric Mastro 9f8affdcaa [marketplace] Add tests for freeing a slot 2022-09-21 20:52:44 +10:00
Eric Mastro 716b864f02 [marketplace] update state getter
Update `Marketplace.state` getter to to take `isCancelled` into account. This state can then be used internally and externally.

Add checks to `proofEnd`, `isProofRequired`, `willProofBeRequired`, and `getChallenge` that understands if the request is in a state to accept proofs. If not, return other values.

Add `slotMustAcceptProofs` modifier, originally introduced in a later PR, which requires the request to be in state of the request accepting proofs.

Add tests for all the above.
2022-09-20 15:59:03 +10:00
Eric Mastro b580ffd8a3 [refactor] do not expose cancelled logic externally 2022-09-20 15:59:03 +10:00
Eric Mastro f16b9b07ae [marketplace] add more tests
Add missing tests for `isSlotCancelled`.

Add test ensuring that proofs cannot be marked as missed when a contract is cancelled.
2022-09-20 15:59:03 +10:00
Mark Spanbroek 3e9fffb526 [marketplace] Reward is paid out per second per slot 2022-08-08 11:51:14 +02:00
Mark Spanbroek 1d951ef8f8 [marketplace] Rename Erasure.totalNodes -> Ask.slots 2022-08-08 11:51:14 +02:00
Mark Spanbroek 80f0cc6005 [storage] Slash based on slots 2022-08-08 11:51:14 +02:00
Mark Spanbroek e5ed3bd59d [storage] Remove finishContract()
Is superceded by Marketplace.payoutSlot().
2022-08-08 11:51:14 +02:00
Mark Spanbroek 97ef1bcd9f Add getHost() to retrieve host that fulfills request 2022-07-20 11:12:00 +02:00
Mark Spanbroek 389f5299d6 [marketplace] Rename maxPrice -> reward 2022-07-20 11:12:00 +02:00
Mark Spanbroek 8d7b7aed1d [marketplace] remove `offer`, `select` and `startContract`
Contract is started when first proof is submitted.
2022-07-20 11:12:00 +02:00
Mark Spanbroek b145e66a68 [storage] add getRequest() and getOffer() 2022-04-11 12:10:57 +02:00
Mark Spanbroek b8ce6c3682 [marketplace] Add erasure coding and PoR attributes to request 2022-04-11 12:10:57 +02:00
Mark Spanbroek 81c7dcd25a Disallow finishing of contract that wasn't started 2022-03-22 12:41:13 +01:00
Mark Spanbroek c606b455d6 Disallow starting an offer that was not selected 2022-03-22 12:41:13 +01:00
Mark Spanbroek 2a745d7abe Fix flaky test
Ensure that when we check whether a proof is required,
the pointer isn't about to wrap.
2022-03-15 17:01:04 +01:00
Mark Spanbroek 438fb605c0 Ensure local ethereum node has at least 256 blocks
Storage contract cannot be deployed when block height
is less than 256 blocks.
2022-03-15 17:01:04 +01:00
Mark Spanbroek 241fcf10a5 Unlock host collateral at end of contract 2022-03-15 10:01:12 +01:00
Mark Spanbroek 6d726fc2cc Require a block height of at least 256 2022-03-15 10:01:12 +01:00
Mark Spanbroek fd06bc00b3 Move periodOf(), periodStart(), periodEnd() into time module 2022-03-15 10:01:12 +01:00
Mark Spanbroek 78eaaa7812 Replace Proof implementation with new design
More info: https://github.com/status-im/dagger-research/pull/66
2022-03-15 10:01:12 +01:00
Mark Spanbroek 22e8ea50e2 Add EVM snapshots including time for tests 2022-03-15 10:01:12 +01:00
Mark Spanbroek 036a214427 Proof period and proof timeout are network constants now 2022-03-15 10:01:12 +01:00
Mark Spanbroek c181195487 Temporarily disable test 2022-03-15 10:01:12 +01:00
Mark Spanbroek e818d70b85 Remove Contracts in favor of Marketplace 2022-03-15 10:01:12 +01:00
Mark Spanbroek e963a25c94 Replace Stakes with Collateral
Removes the old Stakes implementation in favor of the
new Collateral implementation.
2022-03-01 09:38:53 +01:00
Mark Spanbroek 78755ecaa2 Format using prettier 2022-02-10 07:46:03 +01:00
Mark Spanbroek b9a9be350a Simplify signature of TestToken.mint
To be compatible with nim-web3, which doesn't
support arrays in a method signature.
2021-11-23 14:35:00 +01:00
Mark Spanbroek a69a6d6975 Use deployment fixture for Storage contract tests 2021-11-18 13:56:12 +01:00
Mark Spanbroek 7b16841534 Change test token to allow arbitrary minting 2021-11-18 13:56:12 +01:00
Mark Spanbroek 2277fd1366 Add TODO 2021-11-04 14:28:02 +01:00
Mark Spanbroek 8bb8441bce Slash host stake when too many proofs are missing 2021-11-04 14:19:58 +01:00
Mark Spanbroek 38fee6d83a Pay host when contract is finished 2021-11-04 11:55:47 +01:00
Mark Spanbroek d2a3cc4a89 Client pays price when creating contract 2021-11-04 11:40:03 +01:00
Mark Spanbroek afad0e49ec Mint test tokens for both client and host 2021-11-04 11:32:21 +01:00
Mark Spanbroek 54cc2987df Ensure that finishing a contract can only be done once 2021-11-04 11:18:05 +01:00
Mark Spanbroek 8fbb99630c Ensure that starting a contract can only be done once 2021-11-04 10:23:00 +01:00
Mark Spanbroek aa673ff71c Unlock host stake at end of contract 2021-11-04 10:19:23 +01:00