Skip to content

wip: state-transition record-rotation specs and partial proofs - #11

Draft
adust09 wants to merge 1 commit into
mainfrom
feat/state-transition-logic
Draft

adust09 wants to merge 1 commit into
mainfrom
feat/state-transition-logic

Conversation

@adust09

@adust09 adust09 commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Status: work in progress (draft)

This branch carries the in-progress state-transition work; it is opened as a draft at the user's request so the partial state is visible while development continues. It is not ready for review-based merge. Before this PR is marked ready: the remaining Lean proofs land, the generated ELF is wired into the build/runners, official-reference differential tests are added, the full CI validation sequence covers the new modules, and the mandatory implementation_done review gate runs on the complete diff.

What this branch adds

ClAsm/Progress/ — a new module family for the record-rotation core of process_epoch (the pinned altair semantics at consensus-specs 530cf56), which the caller-side state transition needs:

  • Layout.lean: fixed-region internal ABI (participation arrays reused from the aggregate layout, randao mixes / slashings / eth1 vote-count regions at sub-0x80000000 bases so lui sign-extension stays non-negative), region-disjointness and capacity theorems.
  • Program.lean: the 40-instruction program = eth1 vote-record reset (conditional, (epoch+1) % 64 = 0), slashings reset (slashings[(epoch+1) % 8192] := 0), randao mix rotation (mixes[(epoch+1) % 65536] := mixes[epoch % 65536]), participation rotation loop (previous[i] := current[i]; current[i] := 0), with the guarded-loop addresses and the stepBound n = 8 * n + 33 bound.
  • State.lean: Addresses/Registers/Input, ValidAddresses (concrete pinned regions, alignment, no-wrap, pairwise disjoint), ValidInput (count bound, the two offset-coincidence exclusions: randao self-overwrite epoch and the slashings-target-equals-base epoch), precondition, postcondition.
  • Correctness.lean: per-segment bounded triples fully proved for the eth1 (conditional branch store), slashings (single-cell zeroing) and randao (mask, shift, load-store rotation) segments — 13-instruction composition with seqFrame chains, closed via simpa [sepConj_assoc'].
  • LoopProof.lean: loop-guard fall-through and taken specs, back-jump return spec, ofProg code-membership lemmas; the one-iteration and loop-induction theorems are next.

Proof-status detail

Segment spec Status
eth1Reset_spec proved (by_cases over the voting-period condition, cpsTripleWithin_mono_nSteps on the taken path)
slashingsReset_spec proved (13-step seqFrame chain; x18 runs t18 → LUI-raw → 8191; two memory cells + untouched registers carried through every piece)
randaoReset_spec pieces, frames and extensions written; seqFrame chain still fails on one atom at the g1→g2 join (under investigation; atoms match by inspection)
participation rotation loop (rotBody_spec/rotIter/induction) guard/back/code-membership proved; body and induction next

Known-good proof recipes (documented after debugging): per-piece extendBlock with literal base + 4 * k entries and ha = (by simp)/rfl, seqFrame chains closed with rw [hcode]; exact ... + simpa [sepConj_assoc'], mem-cell atoms kept in one written form everywhere (memIs displays as (ptr + signExtend12 0) mem v), LUI-value literals proved by rfl/bv_decide.

Trust boundaries (unchanged rule)

Lean proves the modeled instruction sequences only. ELF emission, assembly, linking, loading, interpreter conversion, and agreement with the official pinned Python functions are test responsibilities, as for weigh and aggregate. The modules are not yet wired into ClAsm.lean/targets, so this draft does not change any generated artifact; CI exercises the same pipeline as main.

Validation on this commit

  • lake --no-cache --wfail build: pass (147 jobs, 0 warnings).
  • lake env lean scripts/CheckAxioms.lean: pass, 4,848 declarations, only Classical.choice, Quot.sound, propext.
  • .lake/build/bin/cl-asm build / cl-asm-test build and python -m unittest discover -s tests: pass; weigh 4,796 official differential cases (the existing regression is untouched).

Remaining for ready (tracked continuation)

  1. Close the randao seqFrame join; finish rotBody_spec, rotIter, the loop induction and rotLoop_empty.
  2. Whole-program Proof.lean composing prologue/segments/loop/return within stepBound.
  3. Calling witness, harness, ELF emission and runner wiring, ClAsm.lean/targets/axiom-audit updates.
  4. Vendored pinned epoch-record reference, differential cases, negative tests, docs.
  5. Full CI validation on the wired build + the mandatory review gate before ready/merge.

Lay down the Progress module skeleton for the caller-side state transition work: fixed-region layout, the 40-instruction epoch-record rotation program (eth1 reset, slashings reset, randao mix rotation, participation rotation), its internal contract, and partial bounded-triple proofs. Register and loop specs are not wired into any executable yet; this branch is a work-in-progress base for the remaining transition logic.
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