feat: add complete Flock Stage 3 compression for aggregate roots - #604
Open
johnchandlerburnham wants to merge 6 commits into
Open
feat: add complete Flock Stage 3 compression for aggregate roots#604johnchandlerburnham wants to merge 6 commits into
johnchandlerburnham wants to merge 6 commits into
Conversation
Remove the fixed eight-round FRI ceiling, add deep-round relation regressions, and expose aggregate-root preflight diagnostics. Add the optional Flock CLI/FFI bridge with shared canonical root preparation, statement pinning, proof verification, and atomic artifact output.
Instrument the complete production regression across setup, proving, artifact transport, valid verification, and negative checks. Document the measured 524.315-second breakdown and clarify that corrupted-proof rejection performs a second full verifier run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack
This PR is stacked on
jcb/sp1-compressorand should target that branch:The base branches supply the shard-to-root aggregation pipeline, canonical
Stage 2 aggregate root, and the existing SP1 terminal-compression experiment.
This PR adds an independent no-RISC-V Stage 3 backend: it verifies the complete
specialised Stage 2 relation directly in Flock over
F128with BLAKE3.Summary
The resulting pipeline is:
Stage 3 is intentionally an off-chain intermediate proof. It removes the
general-purpose RISC-V verifier overhead and leaves Stage 4 with one fixed
Flock verification relation suitable for a universal-setup PLONK/FFLONK
development backend. A circuit-specific Groth16 endpoint remains available
once that relation stabilises and sub-kilobyte settlement is the overriding
constraint.
The complete production relation now proves and verifies successfully. The
latest prover work also removes padded witness generation from the critical
path: the release CLI-shaped round trip now takes approximately 2.12
seconds, versus 39.62 seconds for the previous release proving path,
without changing the 326,019-byte Stage 3 artifact.
Protocol configuration
The backend pins the proof-system configuration as part of the Stage 3
statement:
b310f35f35f68095537150a1c8c0a43caca9a29e;F128binary field;Fast128Ligerito profile;Changing the upstream revision or any of these parameters is a protocol
change and changes the configuration digest. Poseidon2 is not used anywhere
in this path.
Complete Stage 2 verifier relation
The Flock relation constrains all eleven registered verifier phases,
including:
recombination;
final-polynomial check; and
The BLAKE3 lowering supports multi-block rows and messages beyond one
1,024-byte chunk. Transcript sampling matches Plonky3 rejection sampling,
including the constrained chained refill.
Native Stage 2 verification remains an inexpensive fail-fast guard before
allocating the production relation. It is not part of the soundness boundary:
the Flock relation repeats the relevant verification constraints.
Statement and artifact binding
Stage3StatementV1binds three independent values:Verification requires an externally expected Stage 3 statement. In
particular, the verifier does not accept a relation digest supplied only by
the prover. Deployments and the eventual Stage 4 verifier must pin the
expected relation digest.
Stage3ArtifactV1adds strict versioned framing and bounded parsing. Theproduction payload carries the canonical Stage 2 transport, compiled-circuit
digest, and Flock proof bundle needed to reconstruct and verify the relation.
Production aggregate integration
The SP1 and Flock root commands share one canonical
AggregateRootInputspreparation path. This prevents the two compression backends from drifting
on:
A new optional
flockFFI feature exposes the backend without adding Flock tothe normal Ix build.
Preflight a persisted aggregate root with:
Preflight performs all of the following without starting the cryptographic
Flock prover:
CheckEnvaggregate;nu, gate-rowcounts, and all relevant digests.
After successful preflight, generate an artifact with:
Proof mode preflights, proves the complete relation, checks that the resulting
statement exactly matches the preflighted root/relation/configuration,
cryptographically verifies the artifact, and only then installs it through an
atomic rename.
The Lake build traces the nested
flock-stage3Rust sources so changes to theoptional connector cannot silently reuse a stale static archive. The Nix
inputs also use public, immutable sources so CI does not depend on an
interactive GitHub credential.
Full FRI schedules
This removes the former eight-round implementation ceiling.
The accepted commit-phase length is derived from the initial FRI height and
remains bounded by
MAX_LOG_HEIGHT = 31. With the current binary FRIproduction parameters, schedules through the current 30-round maximum are
supported.
Circuit-level regressions construct and evaluate valid transcript-bound
relations at 9, 16, and 30 rounds. Negative tests reject a missing final round
and a corrupted deepest Merkle path.
Prover architecture and optimization
The initial complete prover was correct but spent almost all of its time
materialising padded Boolean witnesses. Every table has uniform
2^nucapacity, while the current complete fixture uses only a small live prefix.
The allocating path constructed logical
z,Az, andBzvectors across theentire capacity, packed them, copied them into the union, and later cleared the
large buffers.
This PR now uses a generic live-row in-place Boolean driver:
stripe layout;
z,Az, andBzare written directly into Flock's union buffers;(Az) * (Bz) = zbefore proving;stripe equality, including a partial final group.
Additional setup improvements include:
and verification;
TableTypeinstead of deep-copied;proving, and post-hoc verification; and
IX_FLOCK_TIMING=1, with Flock's internal phasetracing available under
PCS_TRACE=1.The relation cache compares the complete witness for equality rather than
using a digest, so a hit cannot substitute a relation for different proof
values. It retains only the most recent relation and therefore cannot grow
without bound.
Measured complete proof
The ignored complete regression uses a real canonical multi-STARK proof with:
The artifact remains byte-for-byte the same size after the prover rewrite:
The latest release run, shaped like the real CLI (
preflight → prove → verify → negative checks), reported:Within proof generation, the Flock prover itself took 177.84 ms. The largest
improvements versus the preceding release trace were:
Counting both one-time relation setup and proof generation, the previous
39.615-second release proving path is now approximately 2.076 seconds: about
a 19× end-to-end improvement. The distinction between setup and proof is
reported explicitly because the immutable relation can be reused, while a
one-shot process must still pay setup once.
This fixture is deliberately complete but small; it is not a substitute for
the pending full production
ix_aggrcapacity and memory run. Stage 3 is alsonot intended for Ethereum calldata. Stage 4 must compress verification of this
fixed relation into the sub-kilobyte terminal proof.
Run the expensive regression explicitly with:
Validation performed
The final optimization pass was validated with:
cargo check -p flock-stage3-host;cargo test -p flock-stage3-host:cargo fmt --all; andgit diff --check.The broader branch integration also includes:
cargo clippy -p flock-stage3-host --all-targets -- -D warnings;cargo check -p flock-stage3-host --all-targets;cargo check -p ix-ffi;cargo check -p ix-ffi --features flock;cargo clippy -p ix-ffi --features flock -- -D warnings;nix develop --command lake build Ix.Cli.FlockRootCmd Main;IX_FLOCK=1 nix develop --command lake exe ix flock-root --help; andflock-rootandcompress-root.Scope and remaining work
The relation is deliberately specialised to the current Ix protocol:
Before freezing a deployment relation, we still need to:
ix_aggrroot;profile; and
The remaining local setup bottleneck is immutable shape construction: in the
latest run, table declaration and final circuit wiring consumed almost all of
the 1.896-second preflight. The exact-witness cache eliminates repeated work
for the CLI's preflight/prove/verify sequence. Reuse across different aggregate
proof values with the same structural layout will require separating
per-proof input/public extraction from Flock's immutable
CircuitShapesetup.The next architectural boundary is Stage 4: compile verification of this fixed
Flock relation into the universal-setup FFLONK/PLONK development backend,
measure constraints and Ethereum gas, and retain the ability to switch the
same stable statement to a circuit-specific Groth16 endpoint if required.