Skip to content

Add multiverifier folding to the recursive tree prover#381

Open
YairVaknin-starkware wants to merge 1 commit into
adar/leaf_proverfrom
yairv/add_multiverifier_support_for_recursive_tree_prover
Open

Add multiverifier folding to the recursive tree prover#381
YairVaknin-starkware wants to merge 1 commit into
adar/leaf_proverfrom
yairv/add_multiverifier_support_for_recursive_tree_prover

Conversation

@YairVaknin-starkware

@YairVaknin-starkware YairVaknin-starkware commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Replace the per-pair Cairo simple-bootloader run with a circuit-world fold: for each pair, build a circuit_multiverifier circuit that verifies both child circuit proofs, prove it, and make the resulting proof the parent for the next layer. The tree is balanced with odd-carry; there is no Cairo bootloader or wrapping step anymore.

The tree is homogeneous: the leaf cairo-verifier circuit and the multiverifier circuit are both padded to one shared TARGET_PADDING_SIZES, so they share a preprocessed-trace layout and a single SharedConfig verifies every layer (leaf proofs at layer 0, multiverifier proofs above).

Module layout:

  • canonical: one-time CanonicalCircuit setup (circuit shape + shared config).
  • fold: LayerEntry + reduce_pair (deserialize children, build/prove the multiverifier, reserialize the parent proof in memory).
  • leaf_io: typed LeafInput manifest — inline output_values and preprocessed_root plus a path to a pure Proof<QM31>. Both are inline because neither is recoverable from the serialized proof; the per-leaf root also keeps the fold agnostic to the leaf's circuit type.
  • output: root proof + flat output-values JSON + nested PackedNode tree.

Intermediate proofs are held in memory (no scratch dir). Drops the Cairo bootloader machinery and its resources/.

The circuit is TEMPORARILY configured to the privacy cairo-verifier fixture so the slow-tests e2e can fold a pre-generated leaf proof (duped 2/3/4x) without running leaf_prover; wiring in leaf_prover as the real leaf producer is the follow-up.

Type

  • feature
  • bugfix
  • dev (no functional changes, no API changes)
  • fmt (formatting, renaming)
  • build
  • docs
  • testing

Description

Breaking changes?

  • yes
  • no

This change is Reviewable

@cursor

cursor Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes which cryptographic crates back recursive proof folding and pins external git revisions for stwo/stwo-circuits—errors here break proof compatibility or verification correctness.

Overview
Dependency wiring for the recursive-tree binary’s circuit-world fold: the workspace pins stwo-circuits at ee9b130, adds workspace entries for circuits, circuit-verifier, circuit-multiverifier, and pulls stwo directly (5ea05973, parallel + prover) so folding matches what those circuits use. Cargo.lock picks up the new circuit-multiverifier package and minor transitive bumps.

stwo_run_and_prove_recursive_tree crate manifest drops the Cairo VM / bootloader stack (cairo-air, cairo-program-runner-lib, stwo-run-and-prove-common, etc.) and depends on the stwo-circuits prover/verifier/multiverifier stack plus leaf-proof-format and stwo. The slow-tests feature comment now describes an e2e multiverifier fold over a leaf fixture (with tracing-subscriber, tempfile, and host blake2 only in dev-deps for that test), not a Cairo bootloader run.

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

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.21429% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.04%. Comparing base (fb876d7) to head (b7e0fd0).

Files with missing lines Patch % Lines
...ates/stwo_run_and_prove_recursive_tree/src/fold.rs 96.29% 3 Missing ⚠️
...stwo_run_and_prove_recursive_tree/src/canonical.rs 98.36% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           adar/leaf_prover     #381      +/-   ##
====================================================
- Coverage             65.62%   64.04%   -1.59%     
====================================================
  Files                    41       45       +4     
  Lines                  5775     5777       +2     
====================================================
- Hits                   3790     3700      -90     
- Misses                 1985     2077      +92     
Files with missing lines Coverage Δ
...s/stwo_run_and_prove_recursive_tree/src/leaf_io.rs 100.00% <100.00%> (ø)
...rates/stwo_run_and_prove_recursive_tree/src/lib.rs 96.72% <100.00%> (+4.38%) ⬆️
...ates/stwo_run_and_prove_recursive_tree/src/main.rs 94.73% <100.00%> (-1.56%) ⬇️
...es/stwo_run_and_prove_recursive_tree/src/output.rs 100.00% <100.00%> (ø)
...stwo_run_and_prove_recursive_tree/src/canonical.rs 98.36% <98.36%> (ø)
...ates/stwo_run_and_prove_recursive_tree/src/fold.rs 96.29% <96.29%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@YairVaknin-starkware YairVaknin-starkware force-pushed the yairv/add_multiverifier_support_for_recursive_tree_prover branch from 558da8a to 985cba7 Compare July 2, 2026 14:31
@az-starkware az-starkware force-pushed the adar/leaf_prover branch 14 times, most recently from 50c33f4 to dd68cc3 Compare July 6, 2026 14:13

@Gali-StarkWare Gali-StarkWare 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.

You have all the leaf prover stuff here, rebase it on Adar's branch

@Gali-StarkWare partially reviewed 7 files and made 1 comment.
Reviewable status: 5 of 19 files reviewed, all discussions resolved (waiting on OmriEshhar1).

@YairVaknin-starkware YairVaknin-starkware force-pushed the yairv/add_multiverifier_support_for_recursive_tree_prover branch 4 times, most recently from 6cced69 to 229036b Compare July 9, 2026 10:22
@az-starkware az-starkware force-pushed the adar/leaf_prover branch 3 times, most recently from ed97add to 33675fe Compare July 9, 2026 11:27
@YairVaknin-starkware YairVaknin-starkware force-pushed the yairv/add_multiverifier_support_for_recursive_tree_prover branch from 229036b to 1b1121a Compare July 9, 2026 12:50
@az-starkware az-starkware force-pushed the adar/leaf_prover branch 2 times, most recently from f9ad153 to 74b51d2 Compare July 9, 2026 13:03
Replace the per-pair Cairo simple-bootloader run with a circuit-world fold:
for each pair, build a `circuit_multiverifier` circuit that verifies both
child circuit proofs, prove it, and make the resulting proof the parent for
the next layer. The tree is balanced with odd-carry; there is no Cairo
bootloader or wrapping step anymore.

The tree is homogeneous: the leaf cairo-verifier circuit and the multiverifier
circuit are both padded to one shared `TARGET_PADDING_SIZES`, so they share a
preprocessed-trace layout and a single `SharedConfig` verifies every layer
(leaf proofs at layer 0, multiverifier proofs above).

Module layout:
- canonical: one-time `CanonicalCircuit` setup (circuit shape + shared config).
- fold: `LayerEntry` + `reduce_pair` (deserialize children, build/prove the
  multiverifier, reserialize the parent proof in memory) plus the `PackedNode`
  output tree, a `Plain`/`Composite` enum mirroring Cairo `PackedOutput`.
- leaf_io: leaves are `leaf_proof_format::SerializedLeafProof` (the shared
  output type `leaf_prover` produces — program output, circuit outputs,
  preprocessed root, and the serialized `Proof<QM31>` inline as base64), loaded
  from a `{"leaves": ["<path>", ...]}` manifest of per-leaf output files.
  `LeafProofExt` adds the fold-side conversions. Each leaf declares its own
  preprocessed root, so the fold is agnostic to the leaf's circuit type.
- output: root proof + flat circuit-output JSON + the nested `PackedNode` tree.

Each leaf becomes `Composite(circuit_out, [Plain(program_output)])` and every
fold builds `Composite(mv_hash, [left, right])`, so the packed tree carries each
leaf's Cairo program output down to its `Plain` node for a future per-leaf
unpacker.

Intermediate proofs are held in memory (no scratch dir). Drops the Cairo
bootloader machinery and its `resources/`.

The circuit is TEMPORARILY configured to the privacy cairo-verifier fixture so
the `slow-tests` e2e can fold a pre-generated leaf proof (duped 2/3/4x) without
running `leaf_prover`; wiring in `leaf_prover` as the real leaf producer is the
follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@YairVaknin-starkware YairVaknin-starkware force-pushed the yairv/add_multiverifier_support_for_recursive_tree_prover branch from 1b1121a to b7e0fd0 Compare July 9, 2026 15:43
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