starknet_os_runner: prove CairoPie in memory#12709
starknet_os_runner: prove CairoPie in memory#12709avi-starkware wants to merge 1 commit intoavi/privacy/stwo-proving-feature-gatesfrom
Conversation
621fe36 to
f154ccc
Compare
371dca2 to
9905d53
Compare
f154ccc to
24179e3
Compare
9905d53 to
25ae321
Compare
|
Artifacts upload workflows: |
24179e3 to
0058dfb
Compare
1549f14 to
c5adae0
Compare
0058dfb to
bb7f513
Compare
AvivYossef-starkware
left a comment
There was a problem hiding this comment.
@AvivYossef-starkware reviewed 5 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on avi-starkware, noaov1, and Yoni-Starkware).
crates/starknet_os_runner/src/proving/prover.rs line 44 at r2 (raw file):
/// Passes CairoPie directly to the prover library, avoiding disk I/O for the input. /// The proof output is still written to a temporary file. The synchronous proving work /// is offloaded to a blocking thread inside `prove_pie_in_memory`.
Suggestion:
/// Proves a Cairo PIE using the stwo prover lib.
/// The synchronous proving work
/// is offloaded to a blocking thread inside `prove_pie_in_memory`.crates/starknet_os_runner/src/proving/prover_test.rs line 22 at r2 (raw file):
/// Run with: `cargo test -p starknet_os_runner -- --ignored test_prove_cairo_pie_10_transfers` #[tokio::test] #[ignore]
Can devs run it locally without OOM?
Code quote:
#[ignore]crates/starknet_os_runner/src/proving/stwo_run_and_prove.rs line 24 at r2 (raw file):
let task_spec = TaskSpec { task: Rc::new(task), program_hash_function: HashFunc::Blake }; SimpleBootloaderInput { fact_topologies_path: None, single_page: true, tasks: vec![task_spec] } }
SimpleBootloaderInput::from(cairo_pie)
Code quote:
/// Creates a `SimpleBootloaderInput` from a `CairoPie` for in-memory proving.
///
/// This wraps the CairoPie in the appropriate task structures expected by the
/// simple bootloader, avoiding the need to serialize to disk.
fn create_bootloader_input_from_pie(cairo_pie: CairoPie) -> SimpleBootloaderInput {
let task = Task::Pie(cairo_pie);
let task_spec = TaskSpec { task: Rc::new(task), program_hash_function: HashFunc::Blake };
SimpleBootloaderInput { fact_topologies_path: None, single_page: true, tasks: vec![task_spec] }
}crates/starknet_os_runner/src/proving/stwo_run_and_prove.rs line 52 at r2 (raw file):
}) .await??) }
consider deleting it
Code quote:
/// Runs the stwo prover on a CairoPie in-memory.
///
/// The synchronous proving work is offloaded to a blocking thread via
/// `tokio::task::spawn_blocking`.
///
/// # Arguments
///
/// * `bootloader_program_path` - Path to the compiled simple bootloader program.
/// * `cairo_pie` - The CairoPie to prove.
/// * `program_output_path` - Optional path for program output (proof facts).
/// * `prove_config` - Configuration for the prover.
pub(crate) async fn prove_pie_in_memory(
bootloader_program_path: PathBuf,
cairo_pie: CairoPie,
program_output_path: Option<PathBuf>,
prove_config: ProveConfig,
) -> Result<(), StwoRunAndProveError> {
Ok(tokio::task::spawn_blocking(move || {
prove_pie_in_memory_sync(
bootloader_program_path,
cairo_pie,
program_output_path,
prove_config,
)
})
.await??)
}
Yoni-Starkware
left a comment
There was a problem hiding this comment.
@Yoni-Starkware made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on avi-starkware and noaov1).
crates/starknet_os_runner/src/proving/prover.rs line 11 at r2 (raw file):
use cairo_air::utils::ProofFormat; use cairo_vm::vm::runners::cairo_pie::CairoPie; use proving_utils::proof_encoding::ProofBytes;
Are you planning to remove this crate at the end? its name is problematic (similar to stwo's repo) so easier is to merge the leftovers with the starknet_os_runner (and maybe rename this one to *_prover)
Code quote:
proving_utilsc5adae0 to
2fb5f63
Compare
dfb2fc9 to
b8c3814
Compare
2fb5f63 to
88d7b14
Compare
b8c3814 to
bbfce30
Compare
88d7b14 to
abf0d3c
Compare
bbfce30 to
d5460a7
Compare
Replace the subprocess-based prover invocation with an in-memory call to the stwo_run_and_prove library, removing the need for temporary Cairo PIE files and the external stwo_run_and_prove binary. Changes: - Add stwo_run_and_prove module that passes CairoPie directly to the prover via SimpleBootloaderInput, offloading sync work to spawn_blocking. - Add proving::error module with StwoRunAndProveError. - Simplify prover::prove to create temp files only for outputs (proof, program_output) and call prove_pie_in_memory. - Remove ProvingError variants for disk-based input (WriteCairoPie, WriteProgramInput, SerializeProgramInput). - Un-ignore the integration test (no external binary needed). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
abf0d3c to
73bc9ab
Compare
Summary
stwo_run_and_provemodule that passes CairoPie directly to the prover library viaSimpleBootloaderInput, offloading sync work tospawn_blocking.proving::errormodule withStwoRunAndProveError.prover::proveto create temp files only for outputs and callprove_pie_in_memory.Stack: 3/4 — pure behavior PR for the in-memory proving path (no workflow/container noise).
Depends on: #12708
Test plan
cargo test -p starknet_os_runner --features stwo_proving --releasecargo test -p starknet_os_runner(default features still compile)🤖 Generated with Claude Code
Note
Medium Risk
Touches the core proving execution path and changes how inputs are constructed and passed into the prover, which could affect correctness/performance and error propagation despite limited surface area.
Overview
Updates
prover::proveto use a new in-memory proving path: it no longer writes the Cairo PIE and bootloader input to temp files, and instead callsprove_pie_in_memorywhile still emitting proof and program output to temporary files.Adds
proving::stwo_run_and_proveas a thin wrapper aroundstwo_run_and_prove_libthat buildsSimpleBootloaderInputfrom aCairoPieand runs the synchronous prover viatokio::task::spawn_blocking, plus a dedicatedStwoRunAndProveErrortype for join/prover failures. The previously ignored proving integration test is un-ignored since it no longer depends on an externalstwo_run_and_provebinary.Written by Cursor Bugbot for commit 73bc9ab. This will update automatically on new commits. Configure here.