Skip to content

fix(akita): load verifier bundles without prover setup - #57

Closed
bochunbai wants to merge 1 commit into
mainfrom
fix/offline-verifier-setup
Closed

bochunbai wants to merge 1 commit into
mainfrom
fix/offline-verifier-setup

Conversation

@bochunbai

@bochunbai bochunbai commented Oct 18, 2026 •

Copy link
Copy Markdown

Summary

Loading a serialized Akita verifier setup currently calls setup_prover, rebuilding setup-prefix commitments and allocating prover state. Carry the commitments already produced by offline setup in the verifier bundle, and load them without constructing a prover setup.

Changes

  • Serialize each backend's setup-prefix commitments with its exact schedule catalog, including program-specific grouped advice rows.
  • Load the stored commitments and derive only the public matrix prefix required by the admitted verifier rows. Missing or malformed commitments fail without a prover fallback.
  • Add AkitaVerifierSetup::prepare_verifier() for startup preparation; lazy first verification uses the same loader.
  • Keep the existing Akita dependency, schedule catalogs, and trace limits unchanged. The existing ELF/bundle export pipeline carries the new data automatically.

Testing

  • RAYON_NUM_THREADS=4 CARGO_BUILD_JOBS=6 cargo nextest run --locked -p jolt-akita --lib -E 'test(scheme::tests) | test(verifier_artifact::tests)' --test-threads 2 --no-fail-fast — 12 passed.
  • CARGO_BUILD_JOBS=6 cargo clippy --locked -p jolt-akita --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • python3 scripts/check_style_invariants.py --base layerzero/main

Coverage includes verification after binary transport across one-hot profiles, dense and recursive grouped setup transport, missing commitments, malformed registry bytes, and the existing transcript digest fixture.

Manual EVM-zone / VID / validator integration used local consumer adapters and aligned VID to Jolt's existing Akita revision d98400c5; no Akita source patch was needed.

  • Built the real EVM guest ELF and exported its existing verifier bundle with all eleven setups for trace lengths 2^20..=2^30 (90,784,588 bytes).
  • Proved and self-verified a three-transaction EVM block through the generic CPU prover service: 6,503,503 cycles, padded to 2^23, with a 95,855-byte proof.
  • Independently encoded the payload and verified its VID dispersal. The resulting VID commitment passed cold and warm verification through the production validator's admission, authenticated bundle startup, and ModularJoltVerifier paths in a fresh process.
  • Rejected an altered root, altered VID commitment, wrong bundle digest, and truncated proof. Verification passed with a tracing guard that fails on any new_prover_setup call; external schedule and VID cache paths remained absent throughout verification.
  • Consumer regressions: consensus make check and the full make test target passed, including 1,756 workspace tests, 309 DA tests, and the debug malformed-proof check. Both standalone VID/Jolt interoperability tests and EVM make example passed.

The consumer adapters remain local and are not part of this PR. A live EVM-zone/consensus chain was not run: the full EVM service's make check, make test, and make build remain blocked by zone-core's compatibility with newer consensus APIs. The actual proof exercises the 2^23 setup; this run does not establish proving at 2^30 or worst-case memory with every setup warm. The 2^30 limit is unchanged.

Security Considerations

Callers must authenticate the containing bundle against a trusted pinned digest before preparing or using the verifier. Loading checks registry structure, the setup seed, and required commitment presence; it does not prove the stored commitments were honestly derived. Public matrix coefficients are derived locally from the fixed seed.

Breaking Changes

Verifier setup serialization changes. Regenerate verifier bundles from the same ELF and update their pinned digests; old bundles have no fallback. Proof encoding and transcript binding are unchanged.

@github-actions

Copy link
Copy Markdown

📏 PR diff

Note

Actual code changed: 261 lines

🟢 +213 added    🔴 −48 removed

Tests, docs, fixtures, and helper scripts excluded.

Category 🟢 Added 🔴 Removed
⌨️ Actual code +213 −48
🧪 Tests +115 −102
📚 Docs +33 −7
📦 Fixtures 0 0
🔧 Helper scripts 0 0
Total diff +361 −157

Every changed line is classified once.

@github-actions github-actions Bot added the no-spec PR has no spec file label Oct 18, 2026
@bochunbai
bochunbai marked this pull request as ready for review October 18, 2026 01:37
@cursor

cursor Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

PR Summary

High Risk
Changes verifier setup serialization and trust model for setup-prefix commitments; deployments must regenerate bundles and authenticate digests before use.

Overview
Akita verifier bundles now ship offline setup-prefix commitments so verification no longer runs setup_prover when loading a serialized setup. Each backend stores its schedule catalog plus serialized prefix commitments in AkitaVerifierBackendArtifact; loading reconstructs only the public matrix prefix and required verifier keys.

Adds AkitaVerifierSetup::prepare_verifier() for eager startup (lazy first verify uses the same loader). Missing, malformed, or incomplete prefix data errors out with no prover fallback. Offline setup calls prime_backend_cache to embed prefixes before export.

Breaking: verifier setup encoding changes—regenerate bundles and pinned digests; legacy bundles are not supported. Proof encoding and transcript binding are unchanged. Book docs describe bundle authentication and the new preparation flow.

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

@bochunbai
bochunbai requested review from SaeidL0 and omibo October 18, 2026 01:57

@qun-huang qun-huang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed all 6 changed files and the exact Akita dependency, including offline registry transport, required-slot checks, canonical matrix sizing, eager/lazy preparation and transcript identity. No runtime correctness defects or structural quality blockers were found. All 12 affected nextest tests passed; 30 other unit tests were not selected. The current 66 CI checks are successful or accepted/skipped. One nonblocking stale compatibility comment is noted inline. Authenticated pinned bundle installation remains the required caller contract.

///
/// The exact validated schedule artifacts are serialized; derived scheme
/// objects, prepared keys, and caches are rebuilt lazily after transport.
/// The exact catalogs and setup-prefix commitments are serialized. The bundle

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P3, nonblocking] Remove the stale legacy verifier-format promise

The new offline catalog-plus-prefix format and the book correctly require regenerated bundles, but the public AkitaSetupParams rustdoc at lines 362–363 still says the legacy Single verifier encoding is preserved. That now gives callers contradictory migration guidance. Delete that final sentence, leaving /// bincode backward compatibility. at the end of the paragraph. The same sweep found stale shape-only reconstruction wording in tests/scheme_surface.rs:81 and its assertion message at line 118; those should describe loading offline commitments and deriving the public matrix prefix.

This is a documentation cleanup; both source passes found no additional runtime or soundness defect.

@bochunbai bochunbai left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Self-review

Verdict: merge after fixes. This change fixes zero-consensus#286. No blocker or major issue survived independent verification; five minor items should land before the bundle bytes are pinned at re-genesis.

Scope: commit 02098a7d3 (Akita 252abb89), this PR's content before the rebase; line numbers refer to it. On the rebased head 136b5e268 (Akita d98400c5), only byte identity across CPU backends was re-checked.

Full write-up with evidence, measurements and a status column per finding: https://claude.ai/artifact/Fi3vSon1JutMtBPiL9n5H2

What it achieves (measured)

before with patch
Verifier key kept per setup, 2^25–2^30 1–8 GiB 128 MiB
First key build at 2^28 641 s, 9.7 GiB peak 2.6 s, 139 MiB
All 11 setups warm, 2^20–2^30 ~21.6 GiB ~1.1 GiB

Proof bytes and transcripts are byte-identical to base. An exact-size key verifies and a key one element shorter fails without a panic, up to a K256 nv39 chain with two offloaded levels. The new 2^26 cap has 8–16× headroom at production shapes.

Fix before merge

  1. Test the narrowed key (crates/jolt-akita/src/scheme.rs:1093-1199). Every serde round-trip test runs at shapes where the narrowed key equals the prover's, so a mutant that sizes the key from SetupRequirements::matrix_capacity (undoing the fix) passes the suite. Add a K16 nv31 real-proof test through a reloaded setup with exact length asserts, plus a grouped K16 nv16 test.
  2. Document the trust model (book/src/how/akita.md:54-63). The shipped commitments are trusted setup material: neither the preprocessing digest nor the transcript binds them, and a well-formed wrong registry was shown to let one commitment open to two values. Require an independent regenerate-and-compare of every setup section before pinning; generation is deterministic.
  3. Run the validator load path at generation (scheme.rs:625). Call prepare_verifier() on a cache-less clone inside AkitaScheme::setup (≤145 MiB, 1–2 s), so an unloadable section fails at bundle build instead of after genesis.
  4. Validate at decode (verifier_artifact.rs:18-24, 63-104). Version, registry decode and seed are only checked lazily in build(), and libeacon would cache the resulting error as "proof invalid". Check them in a serde try_from.
  5. Tighten the new tests (scheme.rs:1107-1125, 1188-1198). The dense test compares two empty registries; .skip(1) empties a one-slot registry; the decode test only uses the empty registry; nothing verifies from a cold cache.
13 nits
  • Capacity covers rows Jolt never selects, so keys are 1.33–4× larger than needed; the book overstates the narrowing (verifier_artifact.rs:80-99).
  • Setups that compare equal hold different keys: full prover matrix in-process, narrowed matrix once loaded (scheme.rs:586-625).
  • One-hot setups with max_num_vars < log2 K fail with an unclear "missing offline one-hot verifier"; no real caller reaches this (adapters.rs:609-612).
  • build() keeps the whole decoded registry, including extra or non-canonically ordered slots (verifier_artifact.rs:73-79, 116).
  • The capacity loop duplicates Akita's admitted-row logic; the slot check is vacuous for dense (verifier_artifact.rs:70-99).
  • version: u32 is an unnamed literal 1, checked only at key build (verifier_artifact.rs:21, 29, 63).
  • Akita errors map to VerificationFailed, so an undersized key looks like a forged proof (native_batching.rs:459, 923).
  • Concurrent first callers each build the key, now ≤128 MiB and ~1 s each (adapters.rs:679-683).
  • No test reaches the version check, the 2^26 cap, the no-rows branch, or a reloaded Both setup's one-hot key (verifier_artifact.rs:63-67, 100-104).
  • Stale or inaccurate docs: the key also depends on commitments the transcript does not absorb; "called only by offline setup"; two meanings of "bundle" (adapters.rs:757-760 and others).
  • Two-phase construction: artifacts are born without commitments and completed by a &mut, fallible cache primer; pub(crate) fields (adapters.rs:589-618).
  • Naming drift: schedule_artifacts holds commitments, "artifact" has three meanings, the seed is sampled twice (adapters.rs:517).
  • Moving to this fork means every hard-coded a16z/jolt reference downstream must change together.

Downstream, for adoption

  • zero-consensus: call prepare_verifier() per setup at startup and map errors to unavailable; regenerate jolt-advice-v1; rewrite the memory model, which would still log ~69 GiB.
  • zero-evm-zone: make check-bundle decode and prepare every setup section; add an independent regenerate-and-compare; compare one IFMA-host bundle with the CI build.
  • zero-deploy: add the regenerate-and-compare step to the re-genesis runbook; re-size validators.
  • zero-zone-core: pin bump.

@SaeidL0

SaeidL0 commented Oct 18, 2026

Copy link
Copy Markdown

i think we should have this at verifier binary not necessary part of jolt protocol cc @qun-huang @bochunbai

@SaeidL0 SaeidL0 closed this Oct 18, 2026
@SaeidL0 SaeidL0 reopened this Oct 18, 2026

@bochunbai bochunbai left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Self-review, rebased head

Verdict: one blocker, on the bundle encoding rather than correctness, plus five nits. Scope: head 136b5e268 (Akita d98400c5). The earlier review of 02098a7d3 found no blocker in correctness or safety; this one adds the encoding question.

Blocker: collapse AkitaVerifierArtifacts to Dense | OneHot | Both in this PR (crates/jolt-akita/src/adapters.rs:605-625)

a16z#1976 added OneHotChunked and BothChunked beside OneHot and Both so that Single-profile bundles kept their bincode bytes; adapters.rs:362-363 and schedules/README.md:38 say so. This PR changes those bytes anyway: every variant now wraps AkitaVerifierBackendArtifact instead of Vec<u8>, so every bundle is regenerated at re-genesis. Collapsing now costs nothing extra. Collapsing later means a second encoding break, regenerating every bundle again (zero-evm-zone apps/proving/host/src/bundle.rs), and a new set of pinned digests.

The split also gives one setup two encodings: nothing rejects OneHotChunked { profile: Single, .. }, which loads exactly like OneHot. Carry the chunk profile as a plain field, as AkitaSetupParams already does. The five-arm matches in adapters.rs:627-654, adapters.rs:697-740 and scheme.rs:484-505 then shrink to three.

Nits

  1. adapters.rs:362-363 (@qun-huang's inline P3) and crates/jolt-akita/schedules/README.md:38 still promise that the legacy Single encoding is preserved. The collapse removes what they describe.
  2. adapters.rs grows from 1,518 to 1,577 lines. Move the artifact enum and the verifier-loading methods (prepare_verifier, prime_backend_cache, dense_verifier, one_hot_verifier) into verifier_artifact.rs.

The last three restate items from the earlier review at their locations on this head, each with a concrete fix:

  1. Artifacts are built half-empty (verifier_artifact.rs:27-42) and completed later by prime_backend_cache(&mut self) (scheme.rs:509-572, adapters.rs:697-740). Build each artifact with its key instead.
  2. build (verifier_artifact.rs:57-111) re-implements Akita's setup sizing as a hand-written fold (:80-95). Use an iterator max() now, and an Akita-owned helper at the next Akita bump.
  3. version is always 1 and is checked only in build (verifier_artifact.rs:21, 29, 63). Drop it, or check it at decode (earlier review, fix 4).

@bochunbai

Copy link
Copy Markdown
Author

On hold: no further review needed. Omid is reworking this fix across akita and jolt together, which replaces this jolt-only workaround. The PR stays open for reference only.

Reviewers and review agents can stop monitoring this PR: don't re-review it, post findings or approve it. The open findings here (the AkitaVerifierArtifacts encoding blocker and the nits) won't be fixed on this branch.

@bochunbai bochunbai closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-spec PR has no spec file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants