Eric Mastro
087c13a7fc
update fillSlot and freeSlot state requirements
...
`fillSlot` and `freeSlot` must both be in a state of New or Started and not Cancelled (Finished to be added later).
Update tests to support the above.
2022-09-21 20:52:44 +10:00
Eric Mastro
cce70b44a1
reorder fillSlot and freeSlot to be chronological
2022-09-21 20:52:44 +10: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
cf0ab20b6c
[chore/marketplace] update coment
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
980647876f
[marketplace] update contract state to failed
...
Update contract state to failed when too many slots have been freed.
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
7487663534
[marketplace] free slot after too many proofs missed
...
Needs tests
2022-09-21 20:52:44 +10:00
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
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
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
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
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
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
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
6d726fc2cc
Require a block height of at least 256
2022-03-15 10:01:12 +01:00
Mark Spanbroek
07d0e33789
Disable solhint about relying on timestamp
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
ee4683e50c
Add proof probability to Request
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
e818d70b85
Remove Contracts in favor of Marketplace
2022-03-15 10:01:12 +01:00
Mark Spanbroek
7e7134b99d
Allow events to be filtered by request id
2022-03-15 10:01:12 +01:00
Mark Spanbroek
c835ac1cc4
Emit event when offer is selected
2022-03-15 10:01:12 +01:00
Mark Spanbroek
05fbd244e2
Formatting
2022-03-15 10:01:12 +01:00
Mark Spanbroek
6e6cc1a230
Reject offer for expired request
2022-03-15 10:01:12 +01:00
Mark Spanbroek
85b212c703
Select a storage offer
2022-03-15 10:01:12 +01:00
Mark Spanbroek
cc57155792
Lock collateral of host that offers storage
2022-03-15 10:01:12 +01:00
Mark Spanbroek
980e2343ed
Add expiry to storage requests
2022-03-15 10:01:12 +01:00
Mark Spanbroek
18e667bf19
Use client/host address to check for duplicates
...
Removes the need for the extra correctness checks
on request size and offer expiry, since these are
no longer used to check for duplicates.
2022-03-15 10:01:12 +01:00
Mark Spanbroek
ae92f63987
Add host address to offers
2022-03-15 10:01:12 +01:00
Mark Spanbroek
51e2d65596
Add client address to requests
2022-03-15 10:01:12 +01:00
Mark Spanbroek
b349b76ab7
Offer storage using Marketplace contract
2022-03-15 10:01:12 +01:00
Mark Spanbroek
f9cc73d62f
Rename invariants to avoid name clashes
2022-03-15 10:01:12 +01:00
Mark Spanbroek
e1ef2a2216
Request storage using Marketplace contract
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
1f01704afd
Document the account locking design
2022-03-01 09:38:53 +01:00
Mark Spanbroek
91a976a007
Prevent withdrawal of locked collateral
2022-03-01 09:38:53 +01:00
Mark Spanbroek
c5fab40535
Account locking
2022-03-01 09:38:53 +01:00
Mark Spanbroek
ab38473688
Slash collateral
2022-03-01 09:38:53 +01:00
Mark Spanbroek
2f59927b30
Check result of ERC20 transferFrom call
2022-03-01 09:38:53 +01:00
Mark Spanbroek
9e0d05965d
Update collateral totals and balance at the same time
2022-03-01 09:38:53 +01:00
Mark Spanbroek
c86fdfbec1
Withdraw collateral
2022-03-01 09:38:53 +01:00
Mark Spanbroek
3d50e56fe7
Collateral invariant
2022-03-01 09:38:53 +01:00
Mark Spanbroek
6e0aded775
Deposit collateral
2022-03-01 09:38:53 +01:00
Mark Spanbroek
f7af18eb2d
Lint with solhint
2022-02-10 07:46:03 +01:00
Mark Spanbroek
78755ecaa2
Format using prettier
2022-02-10 07:46:03 +01:00
Mark Spanbroek
0fedd8875f
Use standard ABI encoding instead of the non-standard
...
packing mode.
2021-11-24 11:43:31 +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
8bb8441bce
Slash host stake when too many proofs are missing
2021-11-04 14:19:58 +01:00
Mark Spanbroek
50bab88447
Allow slashing of stake
2021-11-04 13:16:11 +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
aa673ff71c
Unlock host stake at end of contract
2021-11-04 10:19:23 +01:00
Mark Spanbroek
6de82709ca
Only host can call start on a contract
2021-11-04 10:00:41 +01:00
Mark Spanbroek
376962322d
Only expect proofs when the contract is started
2021-11-04 10:00:41 +01:00
Mark Spanbroek
c0fb0c725c
Do not require proofs before start of contract
2021-11-03 17:15:03 +01:00
Mark Spanbroek
8efa9fe162
Stop requiring proofs when contract has ended
2021-11-03 17:02:12 +01:00
Mark Spanbroek
2784800c3e
Add end time to proofs based on contract duration
2021-11-03 17:01:11 +01:00
Mark Spanbroek
3326c4fe74
Make isProofRequired() work for the current block
...
The block hash of the current block is not known yet, so
we use the block hash of the previous block to determine
whether a proof is required for a block.
2021-11-03 13:20:40 +01:00
Mark Spanbroek
e7f3dc3dae
Define contract duration in number of blocks
...
This makes calculation with duration in Solidity simpler
and less prone to errors.
2021-11-03 11:10:42 +01:00
Mark Spanbroek
65c3cacb66
Host stake is locked up when contract is created
2021-11-02 12:50:20 +01:00
Mark Spanbroek
d49c75a74b
Make amount of stake configurable
2021-11-02 12:45:53 +01:00
Mark Spanbroek
8736e5a1aa
Host has to put up stake before entering into a contract
2021-11-02 11:25:01 +01:00
Mark Spanbroek
3b6ec4126d
Fix comments
2021-11-02 11:22:34 +01:00
Mark Spanbroek
7b6c6c2fc5
Rename: StorageContracts -> Storage
2021-11-01 16:34:01 +01:00
Mark Spanbroek
eefa23ff02
Change parameter order
...
Move parameters belonging to the bid together.
2021-11-01 16:23:37 +01:00
Mark Spanbroek
650f5d1f1a
Checking of new storage contracts is moved to Contracts.sol
2021-11-01 16:17:42 +01:00
Mark Spanbroek
aa0def1127
Move timeout validity check to Proofs contract
2021-11-01 15:28:22 +01:00
Mark Spanbroek
d5dede6e6b
Change visibility of stake functions to 'internal'
...
This ensures that any contract that inherits from Stakes
doesn't expose its functions by default.
2021-11-01 15:17:19 +01:00
Mark Spanbroek
d1f5ce0786
Extract logic around proofs into separate contract
2021-11-01 15:12:05 +01:00
Mark Spanbroek
c013a37229
Add contract for keeping track of stakes in ERC20 tokens
2021-10-21 14:09:37 +02:00
Mark Spanbroek
23887f9190
Do not mark proof as missing twice
2021-10-21 10:32:29 +02:00
Mark Spanbroek
c3e85c675a
Use bid hash as contract id
...
Adds nonce to storage request to ensure uniqueness.
2021-10-20 14:30:31 +02:00
Mark Spanbroek
08cedae4bf
Multiple storage contracts in solidity contract
2021-10-20 14:30:31 +02:00
Mark Spanbroek
d005bf7c3c
Rename StorageContract -> StorageContracts
2021-10-20 10:59:08 +02:00
Mark Spanbroek
4913edb6ce
Allow anyone to mark missing proofs
2021-10-19 09:37:03 +02:00
Mark Spanbroek
47f0746f06
Add expiration time to bids
2021-10-18 15:31:19 +02:00
Mark Spanbroek
71efdd36c7
Add (dummy) proof submission
2021-10-18 14:55:59 +02:00
Mark Spanbroek
04b2a31f74
Add hash of data that is to be stored to the contract
2021-10-14 14:49:29 +02:00
Mark Spanbroek
23a4b84816
Add proof period and timeout to request for storage
2021-10-14 14:01:28 +02:00
Mark Spanbroek
cbf34df013
Require proofs on average once every proof period
2021-10-14 12:37:14 +02:00
Mark Spanbroek
550fcf4afe
Add proof period and timeout to contract
2021-10-14 09:10:57 +02:00
Mark Spanbroek
6ef71f0419
Introduces StorageContract
...
A StorageContract can only be instantiated when a request
for storage and a bid have been signed.
2021-10-12 16:59:34 +02:00