463 Commits

Author SHA1 Message Date
Mark Spanbroek
9c6224a370 update solhint to 5.0.5 2025-01-22 14:51:43 +01:00
Mark Spanbroek
922121e659 vault: allow recipient to withdraw 2025-01-22 11:59:51 +01:00
Mark Spanbroek
834255c871 vault: further test for locks 2025-01-22 11:59:51 +01:00
Mark Spanbroek
572ada3c83 vault: remove duplication in tests 2025-01-22 11:59:51 +01:00
Mark Spanbroek
9dd5d7bc5f vault: simplify test setup 2025-01-22 11:59:51 +01:00
Mark Spanbroek
bd9d88443c vault: lock is deleted upon withdrawal 2025-01-22 11:59:51 +01:00
Mark Spanbroek
bfd3c43555 vault: lock up tokens until expiry time 2025-01-22 11:59:51 +01:00
Mark Spanbroek
43f310518f vault: designate tokens for a single recipient 2025-01-22 11:59:51 +01:00
Mark Spanbroek
2412eb092e vault: transfer tokens from one recipient to the other 2025-01-22 11:59:51 +01:00
Mark Spanbroek
69b2b4fd90 vault: burning funds 2025-01-22 11:59:51 +01:00
Mark Spanbroek
7e6bc18b19 vault: change data structure to be recipient oriented 2025-01-22 11:59:51 +01:00
Mark Spanbroek
5a2e183610 vault: deposit and withdraw 2025-01-22 11:59:51 +01:00
Mark Spanbroek
44fcab0fc5 update solidity to version 0.8.28 2025-01-22 11:59:51 +01:00
r4bbit
02e3b8d22b
refactor(Marketplace): Use custom errors instead of string messages (#141)
Co-authored-by: Adam Uhlíř <adam@uhlir.dev>
2025-01-15 14:11:40 +01:00
Adam Uhlíř
dfab6102e7
feat: repair reward (#193) 2024-12-12 18:39:42 +01:00
Adam Uhlíř
06f9f56cd2
ci: tweaks run triggers and checkout hash (#205) 2024-12-05 11:10:29 +01:00
Slava
b181639bb6
Add codex_testnet deployment artifacts (#204)
https://github.com/codex-storage/nim-codex/issues/1000
2024-11-26 11:43:22 +02:00
Slava
c970c632b8
Add codex_testnet deployment artifacts (#199)
https://github.com/codex-storage/nim-codex/issues/983
2024-11-25 20:27:00 +02:00
Mark Spanbroek
945f6008c8 Increase proof period to 90 seconds on hardhat network
reason: on windows, integration tests run so slow that
they cannot fill a slot within 60 seconds
2024-11-14 14:53:37 +01:00
Mark Spanbroek
11ccefd720 Different configurations for different networks
By default we have a proof period of 2 minutes,
but on hardhat it's 1 minute.
2024-11-08 06:36:31 +01:00
Eric
1ce3d10fa2
fix(slot-reservations): ensure slot is free (#196)
Ensure that the slot state is free before allowing reservations
2024-10-30 15:48:37 +11:00
Eric
7645df19ab
renames config to configuration (#198)
This is not the right reason to be making this kind of change, but a very hard to debug symbol clash in codex for `config`. Changing this to `configuration` is the easiest way to fix the issue.
2024-10-29 19:02:42 +11:00
r4bbit
0b39274ed5 refactor(certora): extract allowedRequestStateChanges rule into own
file

Closes #192
2024-10-21 15:36:29 +02:00
Slava
c3e4fdd321
Add codex_testnet deployment artifacts (#197)
https://github.com/codex-storage/infra-codex/issues/248
2024-10-21 10:00:46 +02:00
Andrea Franz
2a1bef5255 chore(certora): verify slots transitions and that a slot can be paid only once 2024-10-15 11:06:46 +02:00
Slava
997696a20e
Add codex_testnet deployment artifacts (#190) 2024-10-08 14:27:06 +02: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
Andrea Franz
3a074abd20 chore(certora): verify possible slot state transitions 2024-09-30 12:53:06 +02:00
Slava
a5aa19453e
Add codex_testnet deployment artifacts (#181)
https://github.com/codex-storage/infra-codex/issues/223
2024-09-24 13:31:07 +03:00
Slava
9722753e54
Update circuit files for codex_testnet (#180) 2024-09-23 18:30:02 +03:00
Ben Bierens
558bf645c3
Updates circuit file hash (#178)
* wasm and r1cs files appear to be unchanged

* Updates example proof
2024-09-20 11:08:23 +02:00
r4bbit
bba8736132 refactor(certora): use ghost variables for requestContext and slots
Instead of having additional harness code in `MarketplaceHarness` to
access fields in `requestContext` and `slots` objects, this introduces
dedicated ghost variables that keep track of the field changes and let
us read the values from there.

Prover run: https://prover.certora.com/output/6199/8343693dfc3f4ca38435f5aa10fa2345?anonymousKey=db5eaee6c688651132d1671919fb73544affa269

Closes #165
2024-08-28 10:51:42 +02:00
r4bbit
38caabeee3 fix(certora): remove incorrect requirment in
`paidSlotAlwaysHasCancelledOrFinishedRequest`

The mentioned invariant uses a `preserved` block with a `require
SlotState == Paid`, which essentially excludes all cases where
`SlotState != Paid`.

This was incorrectly applied. Removing that requirement causes the
prover to find a counter example where it starts with `RequestState == Started`
and `SlotState == Cancelled`.

This ultimately results in `SlotState == PAID` while `RequestState`
stays `Started`.

Counter example link: https://prover.certora.com/output/6199/a38c9bd665d544dabcffd07335c05420?anonymousKey=119a850a4d1d65ccbe8f95298615592835801d2b

A slot that is `Cancelled` however, can never belong to a request that
is `Started`. So requiring the invariant that
`cancelledSlotAlwaysHasCancelledRequest` fixes this and the rule is
passing.

Passing rule: https://prover.certora.com/output/6199/d0e165ed5d594f9fb477602af06cfeb1?anonymousKey=01ffaad46027786c38d78e5a41c03ce002032200

Closes #164
2024-08-28 07:56:32 +02: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
r4bbit
6d319c76b9 fix(certora): make vacuous rule pass
The rule `slotIsFailedOrFreeIfRequestHasFailed` currently has violations
as it is vacuous for some functions in the `Marketplace` contract.

The rule being vacuous means that the function on which the rule is
tested either doesn't have a case where the required conditions work (it
reverts), or, in this case, where any given function doesn't have a case
where it reaches the required state change.

There's various functions where this applies because the rule requires
that the request being tested is first any state that is `!= Failed`,
then for any function `f`, when `f` is executed, the required state of
the request is `Failed`.

Prover run that confirms this: https://prover.certora.com/output/6199/82ed96aac5014cb9a7485fc3752fb399?anonymousKey=28c97adbbe14ead331dc8e4b8ed05e94528075a3

There's two options to go about this:

1. Either filter out all functions from the rule where the rule is
   vacuous (this is dangerous because we'd exclude those functions
   entirely from the rule)
2. Or, rewrite the rule such that the requirements are relaxed

This commit implements option 2.
Instead of requiring that the starting request state has to be `!=
Failed`, we simply assert that **if** it **was** not `Failed` and then
**is** `Failed`, the corresponding slot is either failed or free.

Prover run that passes: https://prover.certora.com/output/6199/16fa074bd23146e59c21964c98bbb3e0?anonymousKey=229d721cf35873bed5eae67696eed803ce75fd18
2024-08-27 15:08:52 +02:00
r4bbit
50e90b6816 chore(CI): update certora-cli to 7.10.2
This should fix the bug of certora-cli not properly completing with non
zero exit codes on errors, which ultimately results in CI tasks to give
false positives.
2024-08-27 15:08:52 +02:00
r4bbit
3a6249e886 fix(certora): make rule for allowed request state changes work again 2024-08-23 14:01:43 +02:00
r4bbit
7dc26ccc47 chore(certora): add rule that cancelled requests stay cancelled and finished requests stay finished 2024-08-23 14:01:43 +02:00
r4bbit
09ca8481fb fix(certora): fix rule that describes allowed request state changes
This broke due to a newly introduced signature for `fillSlot()`
2024-08-23 14:01:43 +02:00
r4bbit
faeb808d41 fix(certora): fix invariant that requests are started when slots filled 2024-08-23 14:01:43 +02:00
r4bbit
7c542e72b6 chore(certora); add rule to verify slot is failed or free when request
has failed
2024-08-23 14:01:43 +02:00
r4bbit
7dc5566cd9 chore(certora): add invariant that cancelled slots always belong to cancelled requests 2024-08-23 14:01:43 +02:00
r4bbit
0acb522fe7 chore(certora): add invariant that paid slots always have a finished or cancelled request 2024-08-23 14:01:43 +02:00
r4bbit
a1229b5af3 chore(certora): introduce invariant that finished slots always belong to finished requests 2024-08-23 14:01:43 +02:00
r4bbit
5b5a3c9e2e chore(certora): introduce invariant that failed requests are always ended 2024-08-23 14:01:43 +02:00
r4bbit
7ce7a5dda0 chore(certora): add invariant that cancelled requests are always expired 2024-08-23 14:01:43 +02:00
r4bbit
ebdf9ed366 fix(certora): fix rule that missed slots == number of issed periods 2024-08-23 14:01:43 +02:00