Skip to content

Required invariant minimal example #166

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

Merged
merged 4 commits into from
May 29, 2025

Conversation

nivcertora
Copy link
Contributor

@nivcertora nivcertora requested a review from nd-certora April 7, 2025 09:03
@nivcertora nivcertora self-assigned this Apr 7, 2025
Copy link
Contributor

@nd-certora nd-certora left a comment

Choose a reason for hiding this comment

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

maybe someone can help explain the new require invariant, is it not quite as written here.

2. A **CVL specification** (`DataInvariant.spec`) that declares an invariant requiring **nonnegative** balances.
3. A **configuration file** (`DataInvariant.conf`) used to run the Certora Prover with our spec.

Under the **old** semantics, the invariant won't be enforced at the time the hook triggered, leading to a **false passing** invariant execution. Under the **new** `requireInvariant` semantics, the invariant is checked at rule boundaries or after calls/havocs for strong invariants, correctly **failing** when a negative balance occurs.
Copy link
Contributor

Choose a reason for hiding this comment

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

can we say which version of certora?

the requireinvariant is checked at the rule boundaries on the arguments passed...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new version isn't published yet so i am not sure how to mention specific version here, @yoav-el-certora maybe you know how we should handle this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Once @johspaeth merge his PR, we will know the release version for this example.
Please keep us updated.

(Both this PR and the other one should not merge before Johannes merge his PR)

@nivcertora nivcertora requested a review from nd-certora April 7, 2025 17:13
@yoav-el-certora yoav-el-certora requested a review from johspaeth May 19, 2025 13:19
Copy link
Contributor

@johspaeth johspaeth left a comment

Choose a reason for hiding this comment

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

Some nits, we must make the difference more explicit.


- **`DataInvariant.spec`**
- **Invariant**: `alwaysPositive(address a)` states `currentContract.balance[a] >= 0`.
The invariant is violated when `breakInvariant` is called under the new semantics but not under the old semantics.
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of new and old use versions

@nivcertora nivcertora merged commit 4360f39 into cli-beta May 29, 2025
@nivcertora nivcertora deleted the niv/CERT-8686-Minimal-Example branch May 29, 2025 16:05
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.

4 participants