Skip to content

Add the circuit-unpacking applicative bootloader's hints#395

Open
YairVaknin-starkware wants to merge 1 commit into
yairv/add_mock_circuit_verifier_hintfrom
yairv/add_hints_for_circuit_applicative_flow
Open

Add the circuit-unpacking applicative bootloader's hints#395
YairVaknin-starkware wants to merge 1 commit into
yairv/add_mock_circuit_verifier_hintfrom
yairv/add_hints_for_circuit_applicative_flow

Conversation

@YairVaknin-starkware

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

Copy link
Copy Markdown
Contributor

Implements the hints of the circuit-unpacking applicative bootloader and its circuit-tree unpacker (starkware/cairo/bootloaders/circuit_applicative_bootloader/, added on the main-repo side):

  • Input loading and per-run setup: LOAD_CIRCUIT_APPLICATIVE_BOOTLOADER_INPUT, CIRCUIT_APPLICATIVE_SETUP_VERIFIER_RUN (single-task simple bootloader runs for the aggregator and the circuit verifier, saving/restoring the applicative output builtin state), and CIRCUIT_APPLICATIVE_SETUP_UNPACK (builds the unpacker's supported-roots config in Cairo memory and enters the packed-output root node scope).
  • The unpacker's node hints (CIRCUIT_UNPACK_*): tree navigation via nested node scopes, leaf data reveal, nine-bit limb splitting, and SET_ROOT_INDEX — each packed node carries its proof's preprocessed root, which the hint locates in the supported-roots list (read back from Cairo memory, matched across all eight words), keeping the hints role-agnostic.
  • CIRCUIT_APPLICATIVE_WRITE_FACT_TOPOLOGY: the final fact topology (the aggregator's, page 0 resized for the removed tasks output and the added two-felt header).

The wire types mirror the recursive tree prover's: PackedNode (externally tagged, one node per hash layer, see proving-utils #392) and CircuitApplicativeBootloaderInput. All hints are unit-tested; the full flow is exercised by the main-repo bootloader flow test.

Stack (3/3): aggregator scope var (#393) ← mock verifier hint (#394) ← this.

🤖 Generated with Claude Code


This change is Reviewable

@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes affect proof output layout (fact topologies, output builtin pages) and trust anchoring via supported preprocessed roots; mistakes could break verifier runs or produce incorrect GPS facts, though behavior is heavily unit-tested and mirrors existing applicative-bootloader patterns.

Overview
Adds Rust hint handlers for the circuit-unpacking applicative bootloader and its circuit-tree unpacker, wired through codes.rs, hint_processors.rs, and new scope/types (CircuitApplicativeBootloaderInput, PackedNode, CIRCUIT_APPLICATIVE_BOOTLOADER_INPUT).

Bootloader flow hints load program input and orchestrate phased runs: aggregator-only simple bootloader (output segment + saved applicative output builtin state), verifier-only run (stash aggregator fact topologies, switch output segment), unpack setup (restore output builtin, lay out tasks output + supported-roots config in VM memory, enter root PackedNode scope), and final fact topology (resize aggregator page 0 for removed tasks output vs. a two-felt header, configure output pages, optional JSON dump).

CIRCUIT_UNPACK_* hints walk the packed tree via nested scopes: leaf vs internal node, subtask enter/exit, full 8-word Blake2s root lookup in config memory for root_index, leaf preimage segments from decimal felts, and 28×9-bit limb splitting for felts.

Extensive unit tests cover happy paths, malformed nodes/roots, missing ids, and fact-topology edge cases; MOCK_CIRCUIT_VERIFIER_LOAD_INPUT is regrouped with the other circuit hint constants.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 027b905. Configure here.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.70436% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.24%. Comparing base (4fb6a87) to head (1c1713b).

Files with missing lines Patch % Lines
...ro-program-runner-lib/src/hints/hint_processors.rs 57.89% 8 Missing ⚠️
.../src/hints/circuit_applicative_bootloader_hints.rs 99.63% 3 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                            @@
##           yairv/add_mock_circuit_verifier_hint     #395      +/-   ##
========================================================================
+ Coverage                                 68.42%   72.24%   +3.82%     
========================================================================
  Files                                        42       42              
  Lines                                      6011     6860     +849     
========================================================================
+ Hits                                       4113     4956     +843     
- Misses                                     1898     1904       +6     
Files with missing lines Coverage Δ
crates/cairo-program-runner-lib/src/hints/types.rs 71.06% <ø> (ø)
.../src/hints/circuit_applicative_bootloader_hints.rs 99.68% <99.63%> (-0.32%) ⬇️
...ro-program-runner-lib/src/hints/hint_processors.rs 62.91% <57.89%> (-0.34%) ⬇️

... and 2 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_hints_for_circuit_applicative_flow branch from 027b905 to fd3451a Compare July 16, 2026 12:06
@YairVaknin-starkware
YairVaknin-starkware force-pushed the yairv/add_mock_circuit_verifier_hint branch from d2650b2 to 646f18a Compare July 16, 2026 12:32
@YairVaknin-starkware
YairVaknin-starkware force-pushed the yairv/add_hints_for_circuit_applicative_flow branch from fd3451a to 0a74d65 Compare July 16, 2026 12:32
Implements the hints of the circuit-unpacking applicative bootloader and its
circuit-tree unpacker
(starkware/cairo/bootloaders/circuit_applicative_bootloader/):
- Input loading and per-run setup: LOAD_CIRCUIT_APPLICATIVE_BOOTLOADER_INPUT,
  CIRCUIT_APPLICATIVE_SETUP_VERIFIER_RUN (single-task simple bootloader runs
  for the aggregator and the circuit verifier, saving/restoring the
  applicative output builtin state), and CIRCUIT_APPLICATIVE_SETUP_UNPACK
  (builds the unpacker's supported-roots config in Cairo memory and enters
  the packed-output root node scope).
- The unpacker's node hints (CIRCUIT_UNPACK_*): tree navigation via nested
  node scopes, leaf preimage reveal, nine-bit limb splitting, and
  SET_ROOT_INDEX — each packed node carries its proof's preprocessed root,
  which the hint locates in the supported-roots list (read back from Cairo
  memory, matched across all eight words), keeping the hints role-agnostic.
- CIRCUIT_APPLICATIVE_WRITE_FACT_TOPOLOGY: the final fact topology (the
  aggregator's, page 0 resized for the removed tasks output and the added
  two-felt header).

The wire types mirror the recursive tree prover's: PackedNode (externally
tagged; `Composite { preprocessed_root, subtasks }` verifier nodes down to
each leaf's `Plain { output_preimage }` reveal — only underivable data, the
unpacker recomputes every digest from the preimages) and
CircuitApplicativeBootloaderInput.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@YairVaknin-starkware
YairVaknin-starkware force-pushed the yairv/add_mock_circuit_verifier_hint branch from 646f18a to 4fb6a87 Compare July 16, 2026 21:20
@YairVaknin-starkware
YairVaknin-starkware force-pushed the yairv/add_hints_for_circuit_applicative_flow branch from 0a74d65 to 1c1713b Compare July 16, 2026 21:20

@OmriEshhar1 OmriEshhar1 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.

@OmriEshhar1 partially reviewed 4 files and made 1 comment.
Reviewable status: 4 of 5 files reviewed, 1 unresolved discussion (waiting on Gali-StarkWare and YairVaknin-starkware).


crates/cairo-program-runner-lib/src/hints/types.rs line 571 at r3 (raw file):

/// (the leaf's hashed output and each fold's circuit output) bottom-up from the preimages.
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub enum PackedNode {

enum PackedNode already appears in stwo_run_and_prove_recursive_tree crate.
isn't there a shared location where you can define it?
(is this temporary until you'll merge both PR stacks?)

@OmriEshhar1 OmriEshhar1 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.

@OmriEshhar1 reviewed 1 file and all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on Gali-StarkWare and YairVaknin-starkware).

@YairVaknin-starkware YairVaknin-starkware left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@YairVaknin-starkware made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on Gali-StarkWare and OmriEshhar1).


crates/cairo-program-runner-lib/src/hints/types.rs line 571 at r3 (raw file):

Previously, OmriEshhar1 wrote…

enum PackedNode already appears in stwo_run_and_prove_recursive_tree crate.
isn't there a shared location where you can define it?
(is this temporary until you'll merge both PR stacks?)

Yes, basically until the first is merged. Didn't want to build 2 stacks on a commit that isn't on main.

@OmriEshhar1 OmriEshhar1 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.

@OmriEshhar1 resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Gali-StarkWare).

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