Commit Graph

231 Commits

Author SHA1 Message Date
Eric 44fe265a12
fix(slot-reservations): ensure slot is free
Ensure that the slot state is free before allowing reservations
2024-10-22 19:44:32 +11:00
Adam Uhlíř 7e6187d4b1
feat: hosts payed by actual time hosting a slot (#160)
Co-authored-by: Eric <5089238+emizzle@users.noreply.github.com>
Co-authored-by: r4bbit <445106+0x-r4bbit@users.noreply.github.com>
2024-10-08 09:38:19 +02:00
Eric f5a54c7ed4
feat(slot-reservations): require slots to be reserved before filling slot (#185)
* Require slots to be reserved before filling slot

* Add test that checks filling slot fails without reservation
2024-10-08 15:55:17 +11:00
Eric 807fc973c8
feat(slot-reservations): Add `SlotReservationsFull` event (#183)
`SlotReservationsFull` event is emitted once a slot has reached its capacity for slot reservations (3 reservations at this time).

`SlotReservationsFull` event emists `requestId` and `slotIndex`.
2024-10-04 13:28:39 +10:00
Eric 33010bd20c
feat(slot-reservations): Allow slots to be reserved (#177)
* feat(slot-reservations): Allow slots to be reserved

Closes #175.

Allows reservation of slots, without an implementation of the expanding window.

- Add a function called `reserveSlot(address, SlotId)`, that allows three unique addresses per slot to be reserved, that returns bool if successful.
       - Use `mapping(SlotId => EnumerableSet.AddressSet)`
       - Return false if the address could not be added to the set (if `EnumerableSet.add` returns false)
- Add `canReserveSlot(address, SlotId)`
        - Return `true` if set of reservations is less than 3 and the set doesn't already contain the address
        - Return `true` otherwise (for now, later add in logic for checking the address is inside the expanding window)
        - Call `canReserveSlot` from `reserveSlot` as a `require` or invariant
- Add `SlotReservations` configuration struct to the network-level config, with `maxReservations`
2024-10-03 11:01:21 +10:00
r4bbit cc0b2732ad fix(Marketplace): ensure requests include ask with sufficient slots
There is a missing check in `requestStorage()` on whether the `Request`
contains an `Ask` where its `slots` is `> 0`.

This allows for making storage request without slots. Not harmful but
not a valid state of the system either.

This commit adds that check and a test with batteries included.
2024-08-27 17:14:52 +02:00
Eric 73a2ca0bd3
feat: adds an optional `payoutAddress` to allow payouts to be paid to separate address (#144)
* initial commit for splitting payouts

Collateral goes to slot's host address, while reward payouts go to the slot's host payoutAddress

* Add fillSlot overload to make payoutAddress "optional"

* add tests for payoutAddress

* add doc to patchFillSlotOverloads

* formatting

* remove optional payoutAddress parameter

* Move payoutAddress to freeSlot

- remove payoutAddress parameter from `fillSlot`
- remove `payoutAddress` from slot struct and storage
- add payoutAddress parameter to `freeSlot`, preventing the need for storage

* formatting

* update certora spec to match updated function signature

* Add withdrawAddress to withdrawFunds

- prevent erc20 msg.sender blacklisting

* Update tests for paying out to withdrawAddress

* formatting

* Add collateralRecipient

* refactor: change withdrawFunds and freeSlot overloads

- `withdrawFunds` now has an option withdrawRecipient parameter
- `freeSlot` now has two optional parameters: rewardRecipient, and collateralRecipient. Both or none must be specified.

* update certora spec for new sigs
2024-08-19 17:09:48 +10:00
Eric ed428767b3
chore: add `downtimeProduct` configuration parameter (#138)
* add `downtimeProduct` configuration parameter

* formatting
2024-08-14 15:50:32 +10:00
r4bbit e62ebf6b0e
fix: ensure requestStorage() reverts if maxSlotloss > slots (#140) 2024-08-05 10:58:51 +02:00
Adam Uhlíř 57e8cd5013
feat: expiry specified as duration (#99) 2024-05-06 15:13:32 +02:00
Mark Spanbroek 601ed18455 Verifier returns false when one of the operations fails 2024-03-13 15:25:59 +01:00
Mark Spanbroek c7b18af7cd Deploy 2 versions of the marketplace on local network
One with the real Groth16 verifier,
and one with a dummy verifier used for testing.
2024-01-31 15:45:01 +01:00
Mark Spanbroek ec803adb3d Test verifier accepts any proof, except all 0 values 2024-01-31 15:45:01 +01:00
Adam Uhlíř 331bc56e8f
feat: zkey hash in marketplace config (#81) 2024-01-30 06:36:27 +01:00
Mark Spanbroek a186cb4045 Formatting 2024-01-25 13:16:49 +01:00
Mark Spanbroek 5d2842c69b Deploy verifier with verifier key per network 2024-01-25 13:08:10 +01:00
Mark Spanbroek a066b6a007 Refactor verifier contract: fix linter warnings 2024-01-25 13:08:10 +01:00
Mark Spanbroek 6baf80d6f4 Refactor verifier contract: remove preprocessing 2024-01-25 13:08:10 +01:00
Mark Spanbroek 39a2d56a63 Refactor verifier contract: verification key as parameter 2024-01-25 13:08:10 +01:00
Mark Spanbroek 862ea56e8b Formatting 2024-01-25 13:08:10 +01:00
Mark Spanbroek 33614ee218 Calculate public inputs for ZK proof verificition 2024-01-25 13:08:10 +01:00
Mark Spanbroek 1b3b258ccc Conversion between little and big endian 2024-01-25 13:08:10 +01:00
Mark Spanbroek 38411c27ca Move submitProof() function to Marketplace 2024-01-25 13:08:10 +01:00
Mark Spanbroek e6a918fed9 Submit proof as Groth16Proof struct 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 1af40f1790 Read proof from file in test 2024-01-25 13:08:10 +01:00
Mark Spanbroek 3e3f2307d8 Remove GPL'ed verifier, replace by MIT verifier 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íř 0d9b67bb31 feat: verifier integration 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
Mark Spanbroek b625f0d519 Merkle root is 32 bytes 2023-11-22 14:43:11 +01:00
Mark Spanbroek efafa43910 Remove PoR parameters, add merkle root for storage proofs 2023-11-22 14:43:11 +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
Mark Spanbroek 24ef30bd2a [proofs] improve test to check proof probability
- avoid bias due to pointer downtime
- use statistical binomial test
2023-01-30 14:47:37 +01:00
Mark Spanbroek c9b51695aa [proofs] support probability 1 (proofs always required) 2023-01-30 14:47:37 +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