Commit Graph

278 Commits

Author SHA1 Message Date
Mark Spanbroek 19f93500ea [Marketplace] Combine host getters
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
2023-01-11 10:27:08 +01:00
Mark Spanbroek ce335d0568 [Proofs] Improved naming
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
2023-01-10 12:15:22 +01:00
Mark Spanbroek afad73d588 [Markeplace] Linting 2023-01-10 12:15:22 +01:00
Mark Spanbroek afb89c9233 [Storage] Remove Storage
Rationale: it was already a very thin wrapper
around Marketplace, and now that its remaining
functionality has been moved to Proofs and
Marketplace, we no longer need it.
2023-01-10 12:15:22 +01:00
Mark Spanbroek 6ea2b77a8f [Storage] Move markProofAsMissing() to Marketplace 2023-01-10 12:15:22 +01:00
Mark Spanbroek a7397981bb [Collateral] Inline slashAmount() function 2023-01-10 12:15:22 +01:00
Mark Spanbroek 39da450c2a [Storage] Move submitProof() to Proofs 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 c9cf47f327 [Storage] Move missingProofs() to Proofs 2023-01-10 12:15:22 +01:00
Mark Spanbroek 154cc00277 [Proofs] remove unused imports 2023-01-10 12:15:22 +01:00
Mark Spanbroek d5d99515fc [Proofs] Remove ProofId and EndId, use SlotId and RequestId
Rationale: in practice, a ProofId was always a slot id, and
an EndId was always a request id. Now that the definitons
of SlotId and RequestId are separated from the Marketplace,
we can import and use them.
2023-01-10 12:15:22 +01:00
Mark Spanbroek 27ccb1e2bc [Marketplace] Extract Request struct into separate file 2023-01-10 12:15:22 +01:00
Mark Spanbroek ac98689892 [Storage] Remove getSlot()
Rationale: Slot is struct that is used by the contract
to keep track of the state of a slot, it doesn't need
to be exposed on the API
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 124457608d [build] Update NodeJS dependencies 2023-01-09 12:04:23 +01:00
Mark Spanbroek 4e11549a54 [build] Update to NodeJS 18.13.0 (latest LTS) 2023-01-09 12:04:23 +01:00
Mark Spanbroek dfc53fb272 Rename: dagger -> codex 2023-01-09 11:42:18 +01:00
Mark Spanbroek 71656f6a95 [collateral] Remove AccountLocks
AccountLocks is replaced by the isWithDrawAllowed()
implementation in Marketplace.
2022-12-22 10:29:06 +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 0ecce3094a [utils] Remove Utils
No longer required
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 a7be363f04 [marketplace] Unlock collateral when list of slots is empty 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 6c52f60381 [marketplace] Formatting 2022-12-22 10:29:06 +01:00
Mark Spanbroek 6e0dfdf7db [marketplace] Rename _freeSlot() -> _forciblyFreeSlot() 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 3fbc851a8d [marketplace] Cleanup 2022-12-22 10:29:06 +01:00
Mark Spanbroek a19e3f4198 [marketplace] Remove SetMap
No longer needed
2022-12-22 10:29:06 +01:00
Mark Spanbroek 0f6eb306ea [marketplace] Remove resize()
No longer needed
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 429b9034d8 Add SetMap tests 2022-12-22 10:29:06 +01:00
Eric Mastro b08169198a rename AddressSetMap to Bytes32AddressSetMap 2022-12-22 10:29:06 +01:00
Eric Mastro f6991d6933 add Bytes32AddressSetMap for active requests by host
Add `Bytes32AddressSetMap` which maps addresses to a requestId. This is used in `Marketplace.activeRequestsForHost`, where all addresses for a particular requestId are listed. This can then be used to iterate and list out the actives requests for a particular address in a view function only. This allows for all addresses for a request to be cleared in situations such as when a request fails or is cancelled.
2022-12-22 10:29:06 +01:00
Eric Mastro eebf3a0709 Add SetMap type for mapping all requests 2022-12-22 10:29:06 +01:00
Eric Mastro 81dd4c203f add ability to get all requests 2022-12-22 10:29:06 +01:00
Eric Mastro 6397835635 switch to a lib, and generalise the api 2022-12-22 10:29:06 +01:00
Eric Mastro 20111c2ec1 move activeslots to separate contract 2022-12-22 10:29:06 +01:00
Eric Mastro 74c2d91b69 PR comments
- remove ActiveSlotId type and instead use an additional mapping for readability
- simplify _activeSlotsForHost for readability
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 5b6187afc4 list active sales 2022-12-22 10:29:06 +01:00
markspanbroek a4057d712f
Merge pull request #22 from status-im/list-of-active-requests
List of active requests
2022-11-10 05:23:18 -05:00
Mark Spanbroek fb47176450 [marketplace] formatting
reformatting using prettier
2022-10-26 10:58:29 +02:00
Mark Spanbroek c29fb75a48 [marketplace] Remove duplication 2022-10-26 10:58:05 +02:00