certora: prove a market is not read before it is created#1076
Open
claude[bot] wants to merge 14 commits into
Open
certora: prove a market is not read before it is created#1076claude[bot] wants to merge 14 commits into
claude[bot] wants to merge 14 commits into
Conversation
Add a Certora rule showing that no code path reads a non-empty market or position field before the market is created (its tickSpacing is still zero). A persistent ghost is flipped by Sload hooks on every non-sentinel market state and position field, gated on the market being uncreated and the loaded value being non-zero. A parametric non-view rule asserts the ghost stays false across every entry point, filtering out the raw storage getters that legitimately read a field without requiring the market to exist.
MathisGD
reviewed
Jul 24, 2026
…otCreatedMarket invariants Drop the val != 0 guard from every Sload hook so a read of an uncreated market's field is flagged regardless of value (previously near-vacuous, since uncreated fields are all zero). Assume the NotCreatedMarket empty-if-not-created invariants via requireInvariant to exclude unreachable prover states, and drop the redundant view-getter selector exclusions (already covered by !f.isView). Restrict the conf to the read rule so the assumed invariants are not re-verified here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XBDthGpRnNF7tdNvCPhCXB
Inline the now-short filtered clause on the rule signature to satisfy the Certora CVL formatter (format CI check). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XBDthGpRnNF7tdNvCPhCXB
MathisGD
reviewed
Jul 24, 2026
MathisGD
reviewed
Jul 24, 2026
…the read rule; clarify hook comment per review
MathisGD
reviewed
Jul 24, 2026
MathisGD
reviewed
Jul 24, 2026
… verified (review)
…ed markets Exclude the two computed views from marketNotReadBeforeCreated (they read position fields before any createdness check) and instead prove their uncreated-market behavior is benign: updatePositionView returns (0,0,0) and isHealthy returns true. Redeclare only the required empty-if-not-created invariants (proven in NotCreatedMarket.conf) as requireInvariant hypotheses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XBDthGpRnNF7tdNvCPhCXB
Deduplicate by relocating updatePositionViewIsZeroIfMarketNotCreated and marketIsHealthyIfNotCreated into NotCreatedMarket.spec, reusing its in-file 'empty if not created' invariants instead of redeclaring them. Remove the isHealthy/mulDivDown/mulDivUp NONDET summaries there so the rules prove against the real functions. Strip the now-unused scaffolding (redeclared invariants, helpers, envfree getters) from MarketNotReadBeforeCreated.spec, keeping only marketNotReadBeforeCreated, and narrow its conf rule list accordingly.
MathisGD
reviewed
Jul 24, 2026
Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
MathisGD
reviewed
Jul 24, 2026
Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
MathisGD
reviewed
Jul 24, 2026
Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
MathisGD
reviewed
Jul 24, 2026
MathisGD
reviewed
Jul 24, 2026
Co-authored-by: MathisGD <74971347+MathisGD@users.noreply.github.com> Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
MathisGD
approved these changes
Jul 24, 2026
MathisGD
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Mathis GD · Slack thread
Adds a Certora rule proving that no code path reads a market or position field before that market is created (its
tickSpacingis still zero). This covers the "show that a market is not read before it is created" item in the verification wishlist (#109).Interesting find: