Commit Graph

96 Commits

Author SHA1 Message Date
Adam Uhlíř 57e8cd5013
feat: expiry specified as duration (#99) 2024-05-06 15:13:32 +02:00
Mark Spanbroek ec803adb3d Test verifier accepts any proof, except all 0 values 2024-01-31 15:45:01 +01:00
Mark Spanbroek 33614ee218 Calculate public inputs for ZK proof verificition 2024-01-25 13:08:10 +01:00
Mark Spanbroek ae03690d51 Submit proof as field elements, not bytes 2024-01-25 13:08:10 +01:00
Mark Spanbroek e1657acdd0 Stub out zk proof verification in marketplace tests 2024-01-25 13:08:10 +01:00
Mark Spanbroek e59f0f961e Submit proofs as array of bytes 2024-01-25 13:08:10 +01:00
Mark Spanbroek 327ae14112 Formatting with prettier 2024-01-25 13:08:10 +01:00
Mark Spanbroek db124ddbd9 Re-arrange marketplace constructor parameters
first configuration, then contracts that we depend on
2024-01-25 13:08:10 +01:00
Adam Uhlíř 87461f6b83
fix: check expiration is before request end (#77) 2023-12-05 11:18:43 +01:00
Adam Uhlíř 14e453ac31
feat: partial payouts for cancelled requests (#69) 2023-10-16 11:14:02 +02:00
Eric Mastro 230e7276e2
Support slot queue (#61)
* feat: add request expiry to StorageRequested event

* add slot index to SlotFreed event

* copy slotIndex before delete for emit

* Update tests
2023-06-22 06:18:33 +10:00
Mark Spanbroek 03e5546121 [marketplace] formatting 2023-06-19 14:58:47 +02:00
Eric Mastro 6e66abbfcd
retreive active slot for sales state restoration (#51)
Store slotIndex in slot struct and expose the slot via getActiveSlot. This is to be used when restoring state in the sales module after a node restart.
2023-04-14 09:28:39 +10:00
Adam Uhlíř 2b5d079882
feat: collateral fractions (#47)
Co-authored-by: Eric Mastro <github@egonat.me>
2023-03-30 11:11:21 +02:00
Adam Uhlíř 8b39ef8f4a
fix: reset missed counter when slot is freed (#48) 2023-03-08 17:19:49 +01:00
Adam Uhlíř dfdbd16d5b
feat: collateral per slot (#44) 2023-03-08 12:02:34 +01:00
Eric Mastro cde5436262
get request from slot id (#34)
* get request from slot id

- Add public function to get request from slot id.
- Add chai test assertion that compares requests. Usage: `expect(await marketplace.getRequestFromSlotId(slotId(slot))).to.be.request(request)`

This is used when restoring active sales, and a node calls `mySlots`, then iterates the slots and needs originating request details.

* merge upstream changes
2023-01-24 15:59:56 +11:00
Mark Spanbroek b81e6e6532 [marketplace] better wording
Avoids the word 'expired' which is associated
with cancelling a request

Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
2023-01-23 15:10:23 +01:00
Mark Spanbroek 019c1c34c0 [marketplace] rewrite slot freeing test
To make it independent of values chosen in exampleRequest().
Uses the recently introduced slotState().
2023-01-23 15:10:23 +01:00
Mark Spanbroek b62eeb564a [marketplace] test & fix slotState() 2023-01-23 15:10:23 +01:00
Mark Spanbroek 334da1144d [marketplace] renaming and reshuffling of request state test 2023-01-23 15:10:23 +01:00
Mark Spanbroek ae70fd7c6f [marketplace] introduce MarketplaceConfiguration struct
Container for all configuration values, replaces separate
constructor parameters and getters.
2023-01-23 15:10:23 +01:00
Mark Spanbroek 8c6891f1e2 [marketplace] slotIsNotFree() modifier
Replaces _slot getter
2023-01-23 15:10:23 +01:00
Mark Spanbroek 1316682a6f [marketplace] remove slotMustAcceptProofs modifier
Replaced by checks on slot state
2023-01-23 15:10:23 +01:00
Mark Spanbroek 7d377a3739 [marketplace] remove requestMustAcceptProofs modifier
Is already covered by the slot state check later on
2023-01-23 15:10:23 +01:00
Mark Spanbroek 5eeac8a782 [marketplace] remove unused import 2023-01-23 15:10:23 +01:00
Mark Spanbroek c8dda37300 [marketplace] introduce SlotState
- replace proofEnd() by slotState()
- replace _slotAcceptsProofs() by slotState()
- remove _stopRequiringProofs()
2023-01-23 15:10:23 +01:00
Mark Spanbroek de0595edb3 [marketplace] rename state(id) -> requestState(id) 2023-01-23 15:10:23 +01:00
Mark Spanbroek e496ac3550 [marketplace] remove _isCancelled and _isFinished 2023-01-23 15:10:23 +01:00
Mark Spanbroek 9aa4773392 [marketplace] remove unused _isSlotCancelled() 2023-01-23 15:10:23 +01:00
Mark Spanbroek 6ea2b77a8f [Storage] Move markProofAsMissing() to Marketplace 2023-01-10 12:15:22 +01:00
Mark Spanbroek 31d109f0d3 [Storage] Move isProofRequired() et al to Marketplace 2023-01-10 12:15:22 +01:00
Mark Spanbroek 9b8bcc0bc7 [Storage] Move getRequest() and getHost() to Marketplace 2023-01-10 12:15:22 +01:00
Mark Spanbroek dbc5e3738e [marketplace] Add tests for collateral locking
The collateral locking check was moved from Collateral
and AccountLocks to Marketplace. This tests the new
locking mechanism.
2022-12-22 10:29:06 +01:00
Mark Spanbroek d5d4dba442 [marketplace] Add missing tests for freeSlot()
Removes unnecessary double removal from slotsPerHost.
2022-12-22 10:29:06 +01:00
Mark Spanbroek 4f75159e02 [marketplace] Slots of failed request remain in mySlots()
Until hosts calls freeSlot()
2022-12-22 10:29:06 +01:00
Mark Spanbroek c46c268880 [marketplace] freeSlot() can be called by host
Handles payout, slashing and removal from mySlots
2022-12-22 10:29:06 +01:00
Mark Spanbroek a96333ce5f [marketplace] mySlots() returns slots of cancelled request
Reasoning: the node will want to call payoutSlot() for
cancelled requests, at which point it will be removed
from the list.
2022-12-22 10:29:06 +01:00
Mark Spanbroek c832dfbb7c [marketplace] Simplify myRequests() 2022-12-22 10:29:06 +01:00
Mark Spanbroek c0a1e11b87 [marketplace] replace mySlots(requestId) by mySlots()
Allows a host to get all slots that it participates in
in a single call.
2022-12-22 10:29:06 +01:00
Eric Mastro 7f59e545b2 Add more tests
- Marketplace tests for requestsForHost, and additional tests for myRequests and mySlots
- Added Utils lib with tests
- Added additional Bytes32AddressSetMap.keys expectations
2022-12-22 10:29:06 +01:00
Eric Mastro a99827ed39 Reinstate mapping index, add ActiveSlotId
Reinstate the index mapping for `activeSlots`, however with a modified data structure. The main difference comes from a change in `mySlots`: it now requires a `RequestId` as a parameter (which can be obtained using `myRequests`. This allowed for the `activeSlots` mapping to be keyed on `RequestId`, which gives a mapping of `ActiveSlotId => EnumerableSet.Bytes32`. `ActiveSlotId` is a keccak hash of `address + activeSlotIdx`, which not only allows retrieval of all active slot ids per request, but also allows clearing of all active slot ids for a request by incrementing the `activeSlotIdx`.
```
requestId => [ keccak(address + activeSlotIdx) => EnumerableSet.Bytes32 ]
```
2022-12-22 10:29:06 +01:00
Eric Mastro 5f056b055a Revert mapping index for clearing active slots
Instead, iterate all active slots and remove them individually, only if they are part of a specific request. This is only for the case of request failure.
2022-12-22 10:29:06 +01:00
Eric Mastro 48eba1fe27 Clear active slots by host
Allow for clearing of active slots by host, by incrementing an mapping index. The new index points to a fresh instance of EnumerableSet, effectively wiping it clean.
2022-12-22 10:29:06 +01:00
Eric Mastro 47bf5d37cf remove slot from waitUntilStarted signature 2022-12-22 10:29:06 +01:00
Eric Mastro b2de745d9a add tests for active slots 2022-12-22 10:29:06 +01:00
Eric Mastro 61b8f5fc35
[test] Remove lastSlot return from waitUntilStarted
This is a remnant from a staggered ending of slots. All slots will end at the request end time now, and thus this is no longer needed.
2022-10-26 13:37:30 +11:00
Eric Mastro 4a470c7dc7
[marketplace] improve requestEnd to check all states
There may be cases where the the request end is not accurate as the state of the request hasn’t yet been updated. For example, when a request is cancelled, the request end would not have been updated to be in the past, and would still be set for the end of the request (which could be in the future).
2022-10-26 13:36:32 +11:00
Mark Spanbroek 9a6a321d5b [marketplace] Add method to get request end time 2022-10-25 14:49:37 +02:00
Eric Mastro 51a02c09ba
[marketplace] remove request from list of active requests 2022-10-25 13:06:52 +11:00