Skip to content

proof: bridge zero-offset storage word writes#2163

Open
Th0rgal wants to merge 3 commits into
mainfrom
codex/2081-storageword-single-slot
Open

proof: bridge zero-offset storage word writes#2163
Th0rgal wants to merge 3 commits into
mainfrom
codex/2081-storageword-single-slot

Conversation

@Th0rgal

@Th0rgal Th0rgal commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds private runtimeStateMatchesIR_writeStorageWordSlot_zeroOffset for zero-offset single-slot writeStorageWordSlots preservation.
  • Adds public compiledStmtStep_setStorageWord_singleSlot_zeroOffset proving .setStorageWord fieldName 0 value lowers to the expected singleton sstore when the resolved field is a non-address, non-dynamic, non-transient, unaliased uint slot.
  • Adds private stmtListGenericCore_singleton_setStorageWord_zeroOffset_singleSlot consumer/regression coverage.
  • Regenerates PrintAxioms.lean.

Validation

  • lake build Compiler.Proofs.IRGeneration.GenericInduction.Storage
  • lake build Compiler.Proofs.IRGeneration.GenericInduction
  • lake build PrintAxioms
  • python3 scripts/lean_lint.py --only lean_hygiene
  • python3 scripts/generate_print_axioms.py --check
  • python3 scripts/lean_lint.py --only axioms
  • git diff --check

Notes


Note

Low Risk
Proof-only changes in the formal verification layer; no compiler or runtime behavior is modified.

Overview
Extends the generic storage induction proofs so zero-offset storage-word writes are covered the same way scalar setStorage already is.

A private lemma runtimeStateMatchesIR_writeStorageWordSlot_zeroOffset shows that updating the source world via writeStorageWordSlots with offset 0 stays in sync with abstractStoreStorageOrMapping on the IR side (including the non-written-slot case via encodeStorageAt_congr).

The public theorem compiledStmtStep_setStorageWord_singleSlot_zeroOffset proves that .setStorageWord fieldName 0 value lowers to a single sstore with a literal slot when the field is a resolved, unaliased, unpacked, non-address, non-dynamic, non-transient uint slot with no write-slot conflicts, and that execution preserves runtime state, fuel, bindings, and scope discipline.

A private stmtListGenericCore_singleton_setStorageWord_zeroOffset_singleSlot hooks this into the stmt-list generic core for regression-style coverage. PrintAxioms.lean is regenerated to export the new compiled-step theorem, and check_proof_length.py allowlists the long coupled preservation witness.

Reviewed by Cursor Bugbot for commit 5e4b958. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
verity Ready Ready Preview, Comment Jul 11, 2026 1:48pm

Request Review

@cursor

cursor Bot commented Jul 11, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_970364c3-711e-4eb8-ba38-135a6b20617e)

@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview first-pass review

Status: scout_triage · Mode: large-lean-hotspots · 8 finding(s) · 4 files · 0 tokens · 0 tool calls

Large Lean diff routed to bounded packet review: 5 Lean file(s), 1503 changed supported line(s). Scout model ranked 8/8 packet(s) for stronger review. Scout triage success; strong packet review required. Full-file OCR was not attempted.

⚠️ Large Lean scout mode covers ranked packets/checklists only; it is not a full-file OCR review and must not be read as LGTM.
✅ Posted 8 inline comment(s).
⚠️ 1 OCR warning(s) reported.

Warnings

  • coverage : Large Lean scout mode covers ranked hotspots only. Codex/human review must cover skipped hunks and proof obligations; OCR strong packet review is not wired yet.

OCR pilot metrics

  • Routing: large-lean-hotspots (router-v8)
  • Changed files: 6 supported / 6 total; Lean 5, trust docs 0, workflow/scripts 1, contracts 0, docs 0
  • Changed lines: 1503 supported; thresholds large Lean >=3 files or >800 lines
  • OCR: status scout_triage; comments 8; files 4; tokens 0; tool calls 0; warnings 1; duration 37s
  • Largest changed files: Compiler/Proofs/IRGeneration/Function.lean (+0/-768), Compiler/Proofs/IRGeneration/HelperSummaryEvidence.lean (+0/-513), Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean (+163/-0), PrintAxioms.lean (+4/-48), scripts/check_proof_length.py (+0/-6)

Packet coverage

  • Packet review: enabled; selected 8/8 packet(s)
  • Scout: configured; status success; model reviewer_scout
  • Strong review: required; status blocked_packet_input
  • Residual risk: Triaged top 8 scout-ranked packet(s); remaining changed hunks/files require Codex or human proof review, and selected packets still need strong reviewer analysis.
  • Strong packet-review blocker: OpenCodeReview 1.7.5 supports --from/--to full diff ranges, but this workflow does not have a safe packet/window input bridge for Lean hunks yet.
  • Covered packets:
    • Compiler/Proofs/IRGeneration/Function.lean:2878 score 109 — large deleted proof obligation, public declaration/signature changed; ask: Confirm that compileStmtList_legacyCompatible_of_interface and the enclosing FunctionBody pipeline no longer depend on the deleted legacyCompatibleExternalStmtList_map_exprStmt*, legacyCompatibleExternalStmtList_map_let, legacyCompatibleExternalStmtList_block_*, and revertWithMessage_legacyCompatible theorems; verify whether any caller of the deleted interface lemmas was rewritten or is silently broken, and check for newly introduced sorries/admits in the surrounding Function.lean region (lines
    • Compiler.lean:31 score 42 — changed imports; ask: Grep the entire repository for any remaining reference to Compiler.Proofs.IRGeneration.HelperSummaryEvidence.* symbols (e.g. eraseDups_nodup_and_mem_aux_local, List.mem_of_mem_eraseDups_local) and confirm none survive; verify that the 513-line deletion of HelperSummaryEvidence.lean does not remove a lemma relied on by an externally-visible theorem in Compiler.lean or its transitive imports.
    • PrintAxioms.lean:55 score 42 — changed imports; ask: Confirm that removing the HelperSummaryEvidence import from PrintAxioms.lean (and commenting out its tracking entries at lines ~3162–3164) does not silently hide any axioms/sorries that were previously enumerated; verify the corresponding entries in PrintAxioms.lean near line 3162 are deleted in lockstep with the module.
    • PrintAxioms.lean:2128 score 13 — hotspot path/churn; ask: Confirm that every Commented-out private theorem around lines 2134–2148/2148–2152 has a corresponding deletion in Compiler/Proofs/IRGeneration/Function.lean, and that none of these lemmas is invoked by any remaining public theorem in the FunctionBody / GenericInduction / SupportedSpec pipeline (especially compileStmtList_legacyCompatible_of_interface callers).
    • Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean:2577 score 68 — public declaration/signature changed; ask: Audit compiledStmtStep_setStorageWord_singleSlot_zeroOffset for sorry/admit usage, ensure it is consistent with the existing compiledStmtStep_setStorage* lemmas, and verify it does not require any helper that was just deleted from HelperSummaryEvidence.lean.
    • Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean:7569 score 31 — hotspot path/churn; ask: Confirm stmtListGenericCore_singleton_setStorageWord_zeroOffset_singleSlot is reachable from a non-private caller and that the strong 'some ({ name := fieldName, ty := FieldType.uint256 }, slot)' shape in hfind is satisfiable by the surface pipeline; check for sorry/admits in the body.
    • Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean:1374 score 32 — hotspot path/churn; ask: Audit the zero-offset case: verify the use of Nat.mod_eq_of_lt and the abstractStoreStorageOrMapping_eq rewrite is sound and that no sorry/admit is introduced; ensure the hypothesis set (hnotAddr, hnotDyn, value < modulus, findResolvedFieldAtSlotCopy) is achievable from a real setStorageWord compile path.
    • PrintAxioms.lean:3129 score 13 — hotspot path/churn; ask: Confirm the roster entry on line ~3129 matches the new private lemma body and that no other new private theorem in Storage.lean (including pkt-5/pkt-6 and any sibling additions) is missing from the PrintAxioms listing.

Pilot mode: advisory only. Codex Review remains the merge gate.

⚠️ Inline publication failed, so OCR findings are summarized here instead.

Inline findings that could not be posted

  • Compiler/Proofs/IRGeneration/Function.lean:2878 — Large Lean packet selected for stronger review: large deleted proof obligation, public declaration/signature changed; 768 changed line(s) near Compiler/Proofs/IRGeneration/Function.lean:2878.
  • Compiler.lean:31 — Large Lean packet selected for stronger review: changed imports; 1 changed line(s) near Compiler.lean:31.
  • PrintAxioms.lean:55 — Large Lean packet selected for stronger review: changed imports; 1 changed line(s) near PrintAxioms.lean:55.
  • PrintAxioms.lean:2128 — Large Lean packet selected for stronger review: hotspot path/churn; 26 changed line(s) near PrintAxioms.lean:2128.
  • Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean:2663 — Large Lean packet selected for stronger review: public declaration/signature changed; 87 changed line(s) near Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean:2577.
  • Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean:7597 — Large Lean packet selected for stronger review: hotspot path/churn; 29 changed line(s) near Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean:7569.
  • Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean:1420 — Large Lean packet selected for stronger review: hotspot path/churn; 47 changed line(s) near Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean:1374.
  • PrintAxioms.lean:3129 — Large Lean packet selected for stronger review: hotspot path/churn; 21 changed line(s) near PrintAxioms.lean:3129.
Unprocessable Entity: "Path could not be resolved, Path could not be resolved, Line could not be resolved, and Line could not be resolved"

@Th0rgal Th0rgal force-pushed the codex/2081-storageword-single-slot branch from 861b721 to 51b524c Compare July 11, 2026 05:34
@cursor

cursor Bot commented Jul 11, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_975a70a9-2202-409a-aaa7-bcc9be4ed3c4)

@github-actions

Copy link
Copy Markdown
Contributor
\n### CI Failure Hints\n\nFailed jobs: `checks`\n\nCopy-paste local triage:\n```bash\nmake check\nlake build\nFOUNDRY_PROFILE=difftest forge test -vv\n```

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OpenCodeReview first-pass review

Status: success · Mode: medium-lean · 0 finding(s) · 2 files · 1249840 tokens · 88 tool calls

No comments generated. Looks good to me.

OCR pilot metrics

  • Routing: medium-lean (router-v8)
  • Changed files: 2 supported / 2 total; Lean 2, trust docs 0, workflow/scripts 0, contracts 0, docs 0
  • Changed lines: 168 supported; thresholds large Lean >=3 files or >800 lines
  • OCR: status success; comments 0; files 2; tokens 1249840; tool calls 88; warnings 0; duration 1264s
  • Largest changed files: Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean (+163/-0), PrintAxioms.lean (+4/-1)

Pilot mode: advisory only. Codex Review remains the merge gate.

@Th0rgal

Th0rgal commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 51b524c8f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Th0rgal

Th0rgal commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

Recovery gate disposition for current head 51b524c8f4296f52d02b17e6bfccec53ef031198: semantic/full-diff audit is clean; zero unresolved non-outdated threads; latest-head Codex review is clean; generated PrintAxioms, proof-length, axiom registry/lint, Lean hygiene, and added-diff forbidden-token checks passed; focused Compiler.Proofs.IRGeneration.GenericInduction.Storage build passed. Exact blockers: latest-head Verify proofs is red because self-hosted checks exited 143 during artifact regeneration, and executable PrintAxioms.lean cannot run in the isolated dependency closure because Compiler/Proofs/YulGeneration/Backends/EvmYulLeanNativeStepLemmas.olean is absent, so the axiom-output audit is unavailable. Do not merge until both gates are green.

@Th0rgal

Th0rgal commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

@codex review

@cursor

cursor Bot commented Jul 11, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_d7c6650b-1f2b-46be-8023-d63707bfd68d)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 5e4b958d5c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OpenCodeReview first-pass review

Status: success · Mode: medium-lean · 0 finding(s) · 3 files · 641972 tokens · 50 tool calls

No comments generated. Looks good to me.

OCR pilot metrics

  • Routing: medium-lean (router-v8)
  • Changed files: 3 supported / 3 total; Lean 2, trust docs 0, workflow/scripts 1, contracts 0, docs 0
  • Changed lines: 173 supported; thresholds large Lean >=3 files or >800 lines
  • OCR: status success; comments 0; files 3; tokens 641972; tool calls 50; warnings 0; duration 696s
  • Largest changed files: Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean (+163/-0), PrintAxioms.lean (+4/-1), scripts/check_proof_length.py (+5/-0)

Pilot mode: advisory only. Codex Review remains the merge gate.

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.

1 participant