Skip to content

Add_run_and_prove_recursive_tree#348

Open
YairVaknin-starkware wants to merge 1 commit into
mainfrom
yairv/add_run_and_prove_recursive_tree
Open

Add_run_and_prove_recursive_tree#348
YairVaknin-starkware wants to merge 1 commit into
mainfrom
yairv/add_run_and_prove_recursive_tree

Conversation

@YairVaknin-starkware
Copy link
Copy Markdown
Contributor

@YairVaknin-starkware YairVaknin-starkware commented May 26, 2026

Adds a new crate (crates/stwo_run_and_prove_recursive_tree) that folds an entire applicative recursive proof tree above N leaf STWO proofs into a single root proof in one binary invocation. Used by SHARP's GPS prover when the parent CairoJob's spec is StwoInBinaryRecursiveTree (gated by enable_in_binary_recursive_tree), to skip O(n) per-node bootloader round-trips through the GPS pipeline.

Crate (876 LOC across lib.rs/main.rs/tests.rs):

  • stwo_run_and_prove_recursive_tree() performs layered 2-to-1 reductions: at each layer pairs of children are verified by a no-builtin-simulation simple-bootloader run (Cairo1Executable verifier tasks); odd entries are carried unchanged to the next layer. Outputs the single root proof, its flat program output, its root fact_topologies, and a nested CompositePackedOutput JSON for the on-chain unpacker bootloader.
  • LeafInput carries each leaf's proof_path, fact_topology, outputs, Python-computed per-leaf stats (n_non_recursive_jobs etc.), and a pre-computed PackedOutput so the binary doesn't have to know about whether each leaf is recursive — Python's packed_output_from_data handles that and the binary propagates it verbatim.
  • LayerEntry.fact_topologies mirrors what stwo_run_and_prove would have written (per-task entries from the bootloader hint), kept on the layer entry for the root disk write only — children's per-task fact_topologies in CompositePackedOutput come from the per-layer fact_topologies file written by the bootloader, not from a fabricated trivial value.
  • single_page=true is set on every reduce_pair's bootloader input.

cairo-program-runner-lib (hints/types.rs):

  • Adds Serialize to PackedOutput/CompositePackedOutput with #[serde(tag = "type")] discriminator matching Python's marshmallow PackedOutputSchema (PlainPackedOutput/CompositePackedOutput rename pairs).
  • Adds felt_decimal_vec::serialize so CompositePackedOutput.outputs emits decimal strings (Python's marshmallow.fields.Integer chokes on hex and on numbers exceeding the JSON safe-integer range).

Wiring:

  • Cargo workspace registers the new crate.
  • CI workflow uploads target/release/stwo_run_and_prove_recursive_tree to the GCS bucket stwo_run_and_prove_recursive_tree.

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

Adds a new crate (crates/stwo_run_and_prove_recursive_tree) that folds
an entire applicative recursive proof tree above N leaf STWO proofs into
a single root proof in one binary invocation. Used by SHARP's GPS
prover when the parent CairoJob's spec is `StwoInBinaryRecursiveTree`
(gated by `enable_in_binary_recursive_tree`), to skip O(n) per-node
bootloader round-trips through the GPS pipeline.

Crate (876 LOC across lib.rs/main.rs/tests.rs):
- `stwo_run_and_prove_recursive_tree()` performs layered 2-to-1
  reductions: at each layer pairs of children are verified by a
  `no-builtin-simulation` simple-bootloader run (Cairo1Executable
  verifier tasks); odd entries are carried unchanged to the next layer.
  Outputs the single root proof, its flat program output, its root
  fact_topologies, and a nested `CompositePackedOutput` JSON for the
  on-chain unpacker bootloader.
- `LeafInput` carries each leaf's proof_path, fact_topology, outputs,
  Python-computed per-leaf stats (`n_non_recursive_jobs` etc.), and a
  pre-computed `PackedOutput` so the binary doesn't have to know about
  whether each leaf is recursive — Python's `packed_output_from_data`
  handles that and the binary propagates it verbatim.
- `LayerEntry.fact_topologies` mirrors what `stwo_run_and_prove` would
  have written (per-task entries from the bootloader hint), kept on the
  layer entry for the root disk write only — children's per-task
  fact_topologies in `CompositePackedOutput` come from the per-layer
  fact_topologies file written by the bootloader, not from a fabricated
  trivial value.
- `single_page=true` is set on every reduce_pair's bootloader input.

cairo-program-runner-lib (`hints/types.rs`):
- Adds `Serialize` to `PackedOutput`/`CompositePackedOutput` with
  `#[serde(tag = "type")]` discriminator matching Python's marshmallow
  `PackedOutputSchema` (`PlainPackedOutput`/`CompositePackedOutput`
  rename pairs).
- Adds `felt_decimal_vec::serialize` so `CompositePackedOutput.outputs`
  emits decimal strings (Python's `marshmallow.fields.Integer` chokes
  on hex and on numbers exceeding the JSON safe-integer range).

Wiring:
- Cargo workspace registers the new crate.
- CI workflow uploads `target/release/stwo_run_and_prove_recursive_tree`
  to the GCS bucket `stwo_run_and_prove_recursive_tree`.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 15.84158% with 255 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.65%. Comparing base (9824175) to head (1650478).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...rates/stwo_run_and_prove_recursive_tree/src/lib.rs 15.38% 220 Missing ⚠️
...ates/stwo_run_and_prove_recursive_tree/src/main.rs 0.00% 35 Missing ⚠️

❌ Your patch check has failed because the patch coverage (15.84%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #348      +/-   ##
==========================================
- Coverage   53.16%   51.65%   -1.51%     
==========================================
  Files          35       37       +2     
  Lines        5295     5606     +311     
==========================================
+ Hits         2815     2896      +81     
- Misses       2480     2710     +230     
Files with missing lines Coverage Δ
crates/cairo-program-runner-lib/src/hints/types.rs 49.76% <100.00%> (+1.97%) ⬆️
...ates/stwo_run_and_prove_recursive_tree/src/main.rs 0.00% <0.00%> (ø)
...rates/stwo_run_and_prove_recursive_tree/src/lib.rs 15.38% <15.38%> (ø)

... and 3 files with indirect coverage changes

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

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