Skip to content

fix(prover): deterministic blob layout tag + continuation tamper coverage#851

Open
diegokingston wants to merge 3 commits into
mainfrom
fix/continuation-rkyv-review
Open

fix(prover): deterministic blob layout tag + continuation tamper coverage#851
diegokingston wants to merge 3 commits into
mainfrom
fix/continuation-rkyv-review

Conversation

@diegokingston

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #845 — fixes for the findings from its review:

  1. Deterministic layout discrimination. The first reserved prefix byte is now a layout kind (RECURSION_INPUT_KIND_MONOLITHIC = 0, RECURSION_INPUT_KIND_CONTINUATION = 1). Both blob verifiers check it at the prefix stage via the new recursion_archive_bytes_for_kind, so a blob of the wrong layout is rejected deterministically instead of relying on the rkyv bytecheck happening to fail on a differently-shaped archive. Backwards compatible: blobs encoded before this change have zeros there, which is exactly KIND_MONOLITHIC.
  2. Tamper coverage for the continuation blob path.
    • test_recursion_continuation_rejects_corrupted_commitment — the continuation analog of the monolithic corrupted-commitment guard: honest bundle + corrupted DECODE root → Ok(None).
    • test_recursion_blob_kind_byte_discriminates_layouts — continuation blob rejected by the monolithic verifier and vice versa at the prefix stage, plus kind-byte tamper rejection.
  3. KEEP IN SYNC notes between verify_continuation_with_roots and verify_continuation_archived (the two must apply the same validation in the same order), and a doc note that owned verify_continuation_and_attest is the host-side symmetric counterpart of the _blob entry point.
  4. Stale doc: docs/continuations_design.md now references compute_expected_commit_bus_balance_view (the owned variant was deleted in perf(prover): verify continuation proofs in place via rkyv #845).

Test plan

  • cargo test -p lambda-vm-prover --lib recursion_smoke — 5 passed, 0 failed (includes both new tests; pre-existing monolithic + continuation blob tests unaffected)
  • cargo clippy -p lambda-vm-prover --all-targets -- -D warnings — clean
  • rustfmt clean

Oppen and others added 3 commits July 16, 2026 18:09
…e input for continuation verify

Mirrors #782's monolithic mechanism for the continuation path: a caller
(the recursion guest) can supply the DECODE preprocessed root and each
touched data page's genesis root instead of the verifier recomputing
them from the ELF, skipping the in-VM FFT + Merkle build. Supplied
roots are used verbatim; the binding shifts to the consumer's
recompute-and-compare of the folded identity, exactly like the
monolithic path.

verify_global's genesis-page classification (ELF-backed vs zero-init)
is derived from ELF segment address ranges instead of materializing a
full byte-level image when roots are supplied, since the real bytes are
never read once a root covers that page. Page lookups are keyed by
page number (page_base >> log2(page_size)) rather than the raw
page-aligned address, since the low bits are always zero.

verify_continuation keeps its existing signature (trustless recompute);
verify_continuation_with_roots is the new supplied-roots entry point,
and continuation_precomputed_commitments lets a caller derive the roots
to supply for a given bundle.
Adapts continuation verification to the same in-place rkyv pattern
verify_recursion_blob already uses for the monolithic path (#769):
verify_epoch/verify_global take a StarkProofView slice (owned or
archived) instead of an owned MultiProof/EpochProof, so the new guest
entry point (verify_continuation_and_attest_blob, via
verify_continuation_archived) reads every per-epoch/global STARK proof
straight out of the archive. Only small per-epoch metadata (table
counts, reg_fini, l2g_root, public output) is materialized - the
(large) per-epoch/global proof data is never copied into an owned
MultiProof just to verify it.

Adds the continuation guest's wire format (ContinuationGuestInput,
encode_continuation_guest_input) mirroring GuestInput's magic-prefixed
rkyv layout, and verify_continuation_and_attest[_blob] mirroring
verify_and_attest_blob's program_id fold.

replay_transcript_phase_a/compute_expected_commit_bus_balance (owned)
lose their last production caller to this refactor; deleted rather
than kept as compatibility wrappers now that every caller (production
and test) goes through the _view variants already introduced by #769.
…ion tamper coverage

Stacked on #845, addressing review findings:

- Reuse the first reserved prefix byte as a layout kind
  (RECURSION_INPUT_KIND_MONOLITHIC=0, KIND_CONTINUATION=1). Both blob
  verifiers now check it at the prefix stage via the new
  recursion_archive_bytes_for_kind, so a blob of the wrong layout is
  rejected deterministically instead of relying on the rkyv bytecheck
  happening to fail on a differently-shaped archive. Backwards
  compatible: pre-kind blobs have zeros there (= KIND_MONOLITHIC).
- New tests: test_recursion_continuation_rejects_corrupted_commitment
  (continuation analog of the monolithic corrupted-commitment guard)
  and test_recursion_blob_kind_byte_discriminates_layouts (both
  directions + kind-byte tamper).
- KEEP IN SYNC notes between verify_continuation_with_roots and
  verify_continuation_archived; note that owned
  verify_continuation_and_attest is the host-side symmetric counterpart.
- docs/continuations_design.md: update the deleted
  compute_expected_commit_bus_balance reference to the _view variant.
@Oppen
Oppen force-pushed the perf/continuation-rkyv-zero-copy branch 3 times, most recently from 9e9f790 to 995f971 Compare July 17, 2026 22:17
Base automatically changed from perf/continuation-rkyv-zero-copy to main July 17, 2026 23:07
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.

2 participants