Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(certora): add invariant that totalSent is <= totalReceived #147

Closed
wants to merge 2 commits into from

Conversation

0x-r4bbit
Copy link
Collaborator

This commit adds an invariant that verifies marketplaceTotals.sent <= marketplceTotals.received.

The invariant relies on the Token.totalSupply() which has previously been verified to be the sum of all balances.

The invariant uses <= as there could be donations sent to the marketplace.

Closes #132

This PR depends on #146

@0x-r4bbit 0x-r4bbit requested review from emizzle and AuHau August 9, 2024 08:04
@@ -72,6 +72,22 @@ invariant totalSupplyIsSumOfBalances()
invariant requestStartedWhenSlotsFilled(env e, Marketplace.RequestId requestId, Marketplace.SlotId slotId)
to_mathint(currentContract.requestContext(e, requestId).slotsFilled) == to_mathint(currentContract.getRequest(e, requestId).ask.slots) => currentContract.requestState(e, requestId) == Marketplace.RequestState.Started;

// STATUS - in progress (fails on constructor state due to a strange behaviour in the tool)
// _marketplaceTotals.received - _marketplaceTotals.sent == tokenBalanceOfContract
// https://prover.certora.com/output/3106/4e6cac8055ac45bb92840e14d9b095eb/?anonymousKey=655a42ca6306a023db78914d5a188d8ec2882771
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As pointed out here, there's a bug in the prover that causes this invariant to file after the constructor has been called.

I'd leave this pending until the bug in certora has been fixed.

@0x-r4bbit 0x-r4bbit force-pushed the certora-sum-of-balances branch from 02dfe5c to b41c3a1 Compare August 12, 2024 13:27
Base automatically changed from certora-sum-of-balances to master August 12, 2024 13:55
@0x-r4bbit 0x-r4bbit force-pushed the certora-totalsent-le-totalreceived branch from 19379eb to 02b9c1f Compare August 12, 2024 13:56
@0x-r4bbit
Copy link
Collaborator Author

While this is green on CI, it should actually fail because there's a bug in the prover that will find a counter example on one of the rules.

We need to change the GH action in this repo so it has a proper exit code or something.

@0x-r4bbit 0x-r4bbit force-pushed the certora-totalsent-le-totalreceived branch from 02b9c1f to d6555cc Compare August 13, 2024 07:59
@0x-r4bbit 0x-r4bbit force-pushed the certora-totalsent-le-totalreceived branch from d6555cc to 018ed25 Compare August 27, 2024 13:14
This commit adds an invariant that verifies `marketplaceTotals.sent <=
marketplceTotals.received`.

The invariant relies on the `Token.totalSupply()` which has previously
been verified to be the sum of all balances.

The invariant uses `<=` as there could be donations sent to the
marketplace.

Closes #132
@0x-r4bbit 0x-r4bbit force-pushed the certora-totalsent-le-totalreceived branch from 018ed25 to b413d77 Compare October 21, 2024 10:09
@AuHau
Copy link
Member

AuHau commented Dec 2, 2024

As per #132 (comment) we won't merge this.

@AuHau AuHau closed this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement application property: marketplaceTotals.sent <= maketplaceTotals.received
2 participants