Commit Graph

210 Commits

Author SHA1 Message Date
Eric Mastro c03206c2b8
add tests for DAL 2022-12-07 20:37:05 +11:00
Eric Mastro 2aa50eabbf
add clearing of host slots with MAX_SLOTS boundary 2022-12-05 17:25:21 +11:00
Eric Mastro 641892ccfa
refactor the DAL api for readability 2022-12-01 21:42:27 +11:00
Eric Mastro 407d51bc9a
Refactor to data access layer
Create a DAL lib with a Database struct that contains all tables and relationships. Referential integrity is guaranteed.
2022-12-01 15:53:28 +11:00
Eric Mastro e80b5b80ef
clean up 2022-11-28 15:50:44 +11:00
Eric Mastro 3502632909
Update inspiration acknowledgement 2022-11-28 14:40:49 +11:00
Eric Mastro 8fde295b73
refactor Mappings.Mapping, add ClearableBytes32Set
- refactor Mappings.Mapping to use a ClearableBytes32Set and multiple EnumerableSet.Bytes32Sets instead of implementing that code directly in Mappings.Mapping.
- update the api for better readability and reasoning.

This should be much cleaner now.
2022-11-28 14:39:11 +11:00
Eric Mastro b0bdf5fafe
add Mappings tests
- add tests for Mappings.Mapping
- remove SetMap.test.js (no longer used)
- rename getManyCount to getValueCount
2022-11-25 15:17:08 +11:00
Eric Mastro d9958d493a
remove tests that check cancelled slots and requests were filtered 2022-11-24 22:13:06 +11:00
Eric Mastro 0dd02ef31a
remove cancelled request filtering 2022-11-24 22:11:28 +11:00
Eric Mastro af7f0dd8cf
remove SetMap and EnumerableSets 2022-11-24 22:07:23 +11:00
Eric Mastro 42e69d592f
add user defined types for bytes32 keys and values in Mappings 2022-11-24 22:04:18 +11:00
Eric Mastro e063041d69
WIP: cleanup checkpoint 2022-11-24 19:47:29 +11:00
Eric Mastro d4a0521f33
WIP: initial implementation of one-to-many
Needs to be cleaned up and reorganised.
2022-11-24 18:49:16 +11:00
Eric Mastro d70efad7bd
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-11-23 00:14:39 +11:00
Eric Mastro a51491a6cb
Add SetMap tests 2022-11-22 16:49:08 +11:00
Eric Mastro 7e937a1e02
rename AddressSetMap to Bytes32AddressSetMap 2022-11-21 16:19:50 +11:00
Eric Mastro 5974ec00a7
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-11-18 18:46:03 +11:00
Eric Mastro 3ec0412f72
Add SetMap type for mapping all requests 2022-11-17 23:11:23 +11:00
Eric Mastro ea0164ee0e
add ability to get all requests 2022-11-17 17:39:17 +11:00
Eric Mastro 0890081d11
switch to a lib, and generalise the api 2022-11-17 16:25:45 +11:00
Eric Mastro c03871f8f5
move activeslots to separate contract 2022-11-17 12:39:41 +11:00
Eric Mastro b3af02ae1a
PR comments
- remove ActiveSlotId type and instead use an additional mapping for readability
- simplify _activeSlotsForHost for readability
2022-11-17 12:23:06 +11:00
Eric Mastro 410102b404
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-11-16 15:52:22 +11:00
Eric Mastro 0599a6e08b
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-11-15 21:18:18 +11:00
Eric Mastro 6303b54e2a
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-11-15 16:53:31 +11:00
Eric Mastro 17a04d6c09
remove slot from waitUntilStarted signature 2022-11-11 13:36:11 +11:00
Eric Mastro 75c5b04f82
add tests for active slots 2022-11-11 13:33:02 +11:00
Eric Mastro a94f152727
list active sales 2022-11-11 11:49:21 +11: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
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 2ac6c0b2de
remove duplicate _toProofId function 2022-10-25 13:13:31 +11:00
Eric Mastro 51a02c09ba
[marketplace] remove request from list of active requests 2022-10-25 13:06:52 +11:00
Eric Mastro 29dcfb52b4
[marketplace] formatting
reformatting using prettier
2022-10-25 13:04:16 +11:00
Eric Mastro b2f9e07c56
[marketplace] add list of active requests 2022-10-25 13:00:48 +11:00
Eric Mastro e97583befd
[marketplace] alias bytes32 types
`RequestId`, `SlotId`, `LockId`, `ProofId`, `EndId` types were created to avoid confusion and enforce compiler restrictions.
2022-10-25 13:00:24 +11:00
Eric Mastro 2478e36aba add back proof end mappings 2022-10-25 12:47:50 +11:00
Eric Mastro cfb70897f8 [marketplace] alias bytes32 types
`RequestId`, `SlotId`, `LockId`, `ProofId`, `EndId` types were created to avoid confusion and enforce compiler restrictions.
2022-10-25 12:47:50 +11:00
Eric Mastro bac2675bb2 set proof end when storage requested
1. set proof end to now + duration when storage is requested
2. set proof end to past when contract is failed
3. add back proof end mappings
2022-10-25 12:38:19 +11: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 0ffe5d7697 [marketplace] free slot after too many proofs missed
Needs tests
2022-10-25 12:38:19 +11:00