Commit Graph

299 Commits

Author SHA1 Message Date
Eric Mastro fdc0e7d58a proofEnd returns end or past timestamp 2022-09-20 15:59:03 +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 4cb7ad79a5 [marketplace] add indexing to RequestCancelled event
Index the `RequestCancelled.requestId` field so that subscriptions to this event can be made.
2022-09-20 15:59:03 +10:00
Eric Mastro 8be756808c [marketplace] address various PR comments
- Remove `FundsWithdrawn` event
- do not copy request to memory
- todo for changing withdraw amount to not include proof payments
- test lock expiry border
- in tests, move `RequestState` to exported const in marketplace.js
- move test for state checks on `fillSlot` to the “filling a slot” section.
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
Eric Mastro 34553ad7d9 [marketplace] add slot/request mapping, cancelled check
Add a requestId mapping to the Slot type. This allows the requestId to be obtained for a slot and the StorageRequest can be looked up from the id.

Add `isSlotCancelled` to check if the request that a slot belongs to has been cancelled (not enough slots filled before expiry).
2022-09-20 15:59:03 +10:00
Eric Mastro 20938ab448 [marketplace] Add cancelled check for marking missing proofs
Add check for cancelled requests when marking proofs as missing.

Add NatSpec documentation for `withdrawFunds` and `isCancelled`.
2022-09-20 15:59:03 +10:00
Eric Mastro 949a359626 [marketplace] Add isCancelled check for slot
Add cancelled check for slot state which checks the contract state and also the slot expiry time. This handles the case where the client may not have withdrawn funds yet (which sets the contract state to Cancelled).

Add tests for contract state.
2022-09-20 15:59:03 +10:00
Eric Mastro 3a97330e72 [marketplace] extend lock expiry
Add ability to extend lock expiry once all slots are filled.

Tests to support lock expiry.
2022-09-20 15:59:03 +10:00
Eric Mastro 37004e0e1f [marketplace] Allow client to withdraw when cancelled
Adds ability for client to withdraw funds from a cancelled storage request.

Tests to check if request has timed out, if the client address is requesting withdraw, if the request state is new, and the funds were successfully transferred.
2022-09-20 15:59:03 +10:00
Eric Mastro 1933ed489a [marketplace] set request state to started once fulfilled
Once all slots are filled, the request state is set to Started.
2022-09-20 15:59:03 +10:00
Eric Mastro 08a3fbb12b [chore] clean up bytes32 parameters
Change the names of some bytes32 parameters to `slotId` and `requestId` to avoid confusion.
2022-08-26 11:03:56 +10:00
Mark Spanbroek 9ab65ae5a6 [marketplace] Specify size per slot, instead of total size
Reasoning: it was unclear exactly how much storage a
host should have available for a slot. The division
size/slots can have a non-integer value.
2022-08-08 11:51:14 +02: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 b3fededbad [marketplace] Remove nodeId from Request
No longer needed now that we have slots.
2022-08-08 11:51:14 +02:00
Mark Spanbroek 9a76c04d45 [marketplace] Emit RequestFulfilled when all slots are filled 2022-08-08 11:51:14 +02:00
Mark Spanbroek f32974b496 [marketplace] Remove fulfillRequest() 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 9bc84dafe0 [marketplace] payout reward for a slot 2022-08-08 11:51:14 +02:00
Mark Spanbroek 141abce186 [marketplace] Add slots 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 1227ce8658 [readme] contract starts when first proof is submitted 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 f3b969fd7c [marketplace] require storage proofs when fulfilling request 2022-07-20 11:12:00 +02:00
Mark Spanbroek 83291ef06b [marketplace] fulfill request by presenting proof of storage 2022-07-20 11:12:00 +02:00
Mark Spanbroek 2bf01da728 [proofs] Submitting proof emits event containing proof 2022-04-12 09:04:29 +02:00
Mark Spanbroek 7cbb717de7 Fix tests that weren't running 2022-04-12 09:04:29 +02:00
Mark Spanbroek 6aa2894521 [marketplace] Use dynamically sized arrays for PoR
ABI encoding sometimes fails on large byte arrays of fixed size.
2022-04-11 12:10:57 +02:00
Mark Spanbroek b145e66a68 [storage] add getRequest() and getOffer() 2022-04-11 12:10:57 +02:00
Mark Spanbroek 169a446769 Enable solidity optimizer
Contract size was becoming too large without optimization.
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 29b5775951 [proofs] willProofBeRequired() predicts proof requirement 2022-04-05 11:36:31 +02:00
Mark Spanbroek 111dce58e8 [proofs] Test that pointer increases by one every block 2022-04-05 11:36:31 +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 0587c2d585 Fix filename in Windows 2022-03-22 10:53: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 29698fee71 Fix tests after OpenZeppelin update 2022-03-15 17:01:04 +01:00
Mark Spanbroek c79059e470 npm update 2022-03-15 17:01:04 +01:00
Mark Spanbroek 743d1cdb07 Update Readme now that storage requests and offers are on-chain 2022-03-15 10:17:55 +01:00
Mark Spanbroek 3fd7c756d9 Fix flaky tests
By ensuring that there's enough blocks left
for submitting a proof.
2022-03-15 10:01:12 +01:00
Mark Spanbroek f8ddc4a2f6 Add getChallenge() to Storage contract 2022-03-15 10:01:12 +01:00
Mark Spanbroek fd55afcc5a Make pointer downtime configurable 2022-03-15 10:01:12 +01:00
Mark Spanbroek 476956c4d5 Replace pointer duos with pointer downtime design 2022-03-15 10:01:12 +01:00
Mark Spanbroek 241fcf10a5 Unlock host collateral at end of contract 2022-03-15 10:01:12 +01:00