Skip to content

proof(L2): admit calldatacopy into the proved statement surface (#2084 slice 1) - #2385

Merged
Th0rgal merged 12 commits into
mainfrom
feat/2084-returndata-surface
Aug 19, 2026
Merged

proof(L2): admit calldatacopy into the proved statement surface (#2084 slice 1)#2385
Th0rgal merged 12 commits into
mainfrom
feat/2084-returndata-surface

Conversation

@Th0rgal

@Th0rgal Th0rgal commented Aug 18, 2026

Copy link
Copy Markdown
Member

First slice of #2084 (Tier 4). Takes Stmt.calldatacopy out of the unsupported
low-level surface by giving it real semantics on every interpreter in the chain,
rather than by weakening a predicate.

What changed

calldatacopy used to be a codegen no-op on the source side and an opaque
fallthrough on the IR side, which is why it sat in
stmtTouchesUnsupportedLowLevelSurface (and in the core / state / call / helper
/ internal-helper / foreign / contract / constructor-raw-calldata surfaces) as an
unconditional true.

  • Semantics. The word-granular calldata->memory copy is now modeled in the
    compiler-free denotation (Verity/Core/Model/Denote.lean), in both source
    interpreters (basic and fuel, SourceSemantics.lean), and in the IR
    interpreter (IRInterpreter.lean), all sharing
    YulGeneration.calldatacopyWritesAt / calldatacopyMemory so the three
    layers agree by construction.
  • Surface flip. Every ...TouchesUnsupported*Surface arm for calldatacopy
    now recurses into its three operand expressions instead of returning true,
    so a calldatacopy whose destination, source, and size are ExprCompileCore
    is inside the supported fragment.
  • Fragment + bridge. New SupportedStmtList.calldatacopySingle constructor,
    matching BridgedSafeStmts coverage
    (bridgedSafeStmts_calldatacopySingle_of_exprCompileCore), generic-induction
    arms (stmtListGenericCore_of_supportedStmtList_calldatacopySingle_of_surface),
    scope discipline, and the native-harness preservation arm.
  • IRStmtPreservesObsAt_of_calldatacopy is strengthened: it no longer claims the
    state is unchanged, it produces the actual copied state, and the opaque
    expr_call fallthrough lemma now explicitly excludes "calldatacopy".

Scope / what is deferred

Of the four builtins named in the issue's low-level bullet, returndataSize and
returndataOptionalBoolAt were already off the low-level surface on main; this
slice lands calldatacopy. returndataCopy and revertReturndata remain
true: they need returndata modeled as an observable component of the call
frame, which is the CallFrame line from #2362 and is left to a following slice.
The call / foreign surfaces are untouched.

Docs

The interpreter feature matrix listed calldatacopy as no_op/n/a/
not_modeled; it moves to the proved tier (statement features 24 -> 25 proved,
6 -> 5 not-modeled), and it is dropped from the not-modeled proof-boundary
catalog and from the linear-memory boundary notes in docsync.py and the
docs-site pages those notes are checked against.

Test plan

All at head 9e9d00c2:

  • lake build -> exit 0 (2473 jobs)
  • lake build PrintAxioms -> exit 0 (2617 jobs); 6709 theorems/lemmas, 0 sorry'd (was 6696; +13, all calldatacopy arms). Axiom surface unchanged from main: propext / Classical.choice / Quot.sound plus the three pre-existing native_decide contract witnesses and solidityMappingSlot_injective.
  • make check -> exit 0 ("All checks passed.")
  • python3 scripts/generate_trust_surface_report.py --check -> exit 0 (no native_decide / implemented_by delta, report already up to date)
  • Forbidden-token scan of added Lean lines (sorry/admit/axiom/native_decide/implemented_by/unsafe) -> only match is the regenerated -- Total: ... 0 sorry'd header comment
  • git diff --check -> exit 0

No merge, no thread resolution.


Note

Medium Risk
Large, cross-cutting proof and interpreter changes to memory/calldata semantics; risk is mitigated by aligned helpers across layers and parity with existing mstore/tstore patterns, but regressions in IR/source agreement would affect correctness claims.

Overview
Stmt.calldatacopy is no longer a no-op / opaque IR fallthrough. Destination, source, and size are evaluated and memory is updated via shared helpers calldatacopyWritesAt, calldataloadWord, and calldatacopyMemory in YulGeneration/Calldata.lean, mirrored in Verity/Core/Model/Denote.lean, SourceSemantics.lean, and IRInterpreter.lean.

Unsupported-surface predicates now recurse on the three operands instead of marking calldatacopy unconditionally unsupported (including the former low-level surface), so bodies in the SupportedFragment.calldatacopySingle shape enter the proved fragment. New proof plumbing matches mstore/tstore: CompiledStmtStep_calldatacopy_single, runtimeStateMatchesIR_calldatacopyBothMemory, scope discipline, generic induction, BridgedSafeStmts / Yul bridge predicates, and a dedicated denote_stmt_arm in DenoteAgreement.lean. IR lemmas treat calldatacopy as a real builtin (not opaque expr_call), including updated IRStmtPreservesObsAt_of_calldatacopy.

Docs and artifacts: interpreter feature matrix and docs-site copy move calldatacopy to proved; linear-memory boundary text no longer lists it among partially modeled intrinsics. PrintAxioms registers the new public theorems (+13 lemmas, still 0 sorry).

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

Th0rgal and others added 10 commits August 18, 2026 22:01
…evel surface

Add a shared word-granular calldatacopy memory model and wire it through the
source executors and IR interpreter so the low-level surface no longer has to
reject calldatacopy outright. Fan-out to induction sites is still pending.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…d native bridge

Adds the runtime/IR memory transfer lemma, the CompiledStmtStep witness, the
BridgedStraightStmt/BridgedSourceCalldatacopyStmt bridge chain, and the
calldatacopySingle arms at every SupportedStmtList induction site.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…mmas

The new 3-arg `calldatacopy` case in execIRStmt/execIRStmtWithInternals
overlaps the generic `.call func args` arms, so the conservative-extension
and opaque-call lemmas now split on it explicitly.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…cipline

Extends Denote.execStmt with the calldatacopy memory write so the
denotation/source-semantics agreement stays definitional, and adds the
matching StmtListScopeCore constructor now that the contract surface
recurses into calldatacopy's subexpressions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Records the new BridgedSafeStmts coverage for singleton calldatacopy bodies
in the EndToEnd trust-boundary summary, so the doc tracks the surface flip.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds the seven new public calldatacopy lemmas (and six private helpers) to the
axiom audit list. Total moves 6696 -> 6709 with the sorry count still at zero.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Restores returnValues/returnArray to the rfl group in execStmt_eq, which an
earlier edit had accidentally rerouted through denote_stmt_arm, and recompacts
the arm so the theorem stays at its original length. Allowlists the calldatacopy
preserves proof alongside its mstore/tstore siblings.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Making the core surface recurse into calldatacopy's subexpressions removed the
hcore contradiction that previously discharged this case through the catch-all
arm, so derive the contract surface from the three subexpression witnesses the
way the mstore/tstore arm does.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
StmtListScopeCore gained a calldatacopy constructor without its
StmtListScopeDiscipline counterpart, leaving the two Core-to-Discipline
conversions with no constructor to produce. Adds the constructor and the
matching alternative in all three inductions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The interpreter feature matrix still listed `Stmt.calldatacopy` as a codegen
no-op outside the proof-backed subset. Both source interpreters, the IR
interpreter, and the supported-fragment now model the word-granular
calldata->memory copy, so move it to the proved tier and drop it from the
not-modeled proof-boundary catalog and the linear-memory boundary notes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Th0rgal

Th0rgal commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

@codex review

@vercel

vercel Bot commented Aug 18, 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 Aug 19, 2026 1:34am

Request Review

@cursor

cursor Bot commented Aug 18, 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_76c02d1a-8b7e-4eab-9344-04c66da05af7)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@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

🟡 Scout triage only — not a full review. no findings; a human or Codex must still cover the unflagged hunks and proof obligations.

Lean packet budget exceeded: 21 Lean file(s), 1040 changed supported line(s).

Warnings

  • routing : Diff exceeded bounded packet review capability; full OCR not attempted.
OCR pilot metrics & packet coverage

OCR pilot metrics

  • Routing: large-lean-hotspots (router-v10)
  • Changed files: 25 supported / 27 total; Lean 21, trust docs 0, workflow/scripts 3, contracts 0, docs 1
  • Changed lines: 1040 supported; thresholds large Lean >=3 files or >800 lines
  • OCR: status large-lean-hotspots; comments 0; files 0; tokens 0; tool calls 0; warnings 1; duration 0s
  • Largest changed files: Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean (+203/-0), Compiler/Proofs/IRGeneration/IRInterpreter.lean (+123/-32), Compiler/Proofs/IRGeneration/SupportedSpec.lean (+135/-14), Compiler/Proofs/YulGeneration/Backends/EvmYulLeanBodyClosure/Base.lean (+120/-0), Compiler/Proofs/IRGeneration/GenericInduction/Scope.lean (+105/-1)

Packet coverage

  • Packet review: not used; selected 0/8 packet(s)
  • Scout: configured; status skipped_no_packets; model builtin/assistant
  • Scout lenses: provenance, verification-independence, environment-determinism, proof-soundness; rubric items checked 3
  • Strong review: required; status blocked_packet_input
  • Residual risk: Diff exceeded packet budget; use top changed files and deterministic signals as required Codex/human review checklist.
  • Strong packet-review blocker: OpenCodeReview 1.7.9 supports --from/--to full diff ranges, but this workflow does not have a safe packet/window input bridge for Lean hunks yet.

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

Th0rgal and others added 2 commits August 19, 2026 01:55
@cursor

cursor Bot commented Aug 19, 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_0afc4213-8651-4d98-ae6f-8fbebe75a02c)

@Th0rgal
Th0rgal merged commit c008b4a into main Aug 19, 2026
6 of 8 checks passed

@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

🟡 Scout triage only — not a full review. no findings; a human or Codex must still cover the unflagged hunks and proof obligations.

Lean packet budget exceeded: 21 Lean file(s), 1040 changed supported line(s).

Warnings

  • routing : Diff exceeded bounded packet review capability; full OCR not attempted.
OCR pilot metrics & packet coverage

OCR pilot metrics

  • Routing: large-lean-hotspots (router-v10)
  • Changed files: 25 supported / 27 total; Lean 21, trust docs 0, workflow/scripts 3, contracts 0, docs 1
  • Changed lines: 1040 supported; thresholds large Lean >=3 files or >800 lines
  • OCR: status large-lean-hotspots; comments 0; files 0; tokens 0; tool calls 0; warnings 1; duration 0s
  • Largest changed files: Compiler/Proofs/IRGeneration/GenericInduction/Storage.lean (+203/-0), Compiler/Proofs/IRGeneration/IRInterpreter.lean (+123/-32), Compiler/Proofs/IRGeneration/SupportedSpec.lean (+135/-14), Compiler/Proofs/YulGeneration/Backends/EvmYulLeanBodyClosure/Base.lean (+120/-0), Compiler/Proofs/IRGeneration/GenericInduction/Scope.lean (+105/-1)

Packet coverage

  • Packet review: not used; selected 0/8 packet(s)
  • Scout: configured; status skipped_no_packets; model builtin/assistant
  • Scout lenses: provenance, verification-independence, environment-determinism, proof-soundness; rubric items checked 3
  • Strong review: required; status blocked_packet_input
  • Residual risk: Diff exceeded packet budget; use top changed files and deterministic signals as required Codex/human review checklist.
  • Strong packet-review blocker: OpenCodeReview 1.7.9 supports --from/--to full diff ranges, but this workflow does not have a safe packet/window input bridge for Lean hunks yet.

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