diff --git a/stwo_cairo_prover/crates/adapted_prover/src/main.rs b/stwo_cairo_prover/crates/adapted_prover/src/main.rs index f6be1068..ad48e100 100644 --- a/stwo_cairo_prover/crates/adapted_prover/src/main.rs +++ b/stwo_cairo_prover/crates/adapted_prover/src/main.rs @@ -5,7 +5,7 @@ use clap::Parser; use stwo_cairo_prover::cairo_air::air::CairoProof; use stwo_cairo_prover::cairo_air::prove_cairo; use stwo_cairo_prover::input::vm_import::{adapt_vm_output, VmImportError}; -use stwo_cairo_prover::input::CairoInput; +use stwo_cairo_prover::input::ProverInput; use stwo_cairo_utils::binary_utils::run_binary; use stwo_prover::core::prover::ProvingError; use stwo_prover::core::vcs::blake2_merkle::{Blake2sMerkleChannel, Blake2sMerkleHasher}; @@ -55,7 +55,7 @@ fn run(args: impl Iterator) -> Result Self { + pub fn new(input: ProverInput) -> Self { let initial_state = input.state_transitions.initial_state; let final_state = input.state_transitions.final_state; let opcodes = OpcodesClaimGenerator::new(input.state_transitions); diff --git a/stwo_cairo_prover/crates/prover/src/cairo_air/mod.rs b/stwo_cairo_prover/crates/prover/src/cairo_air/mod.rs index a875b15d..8107ada8 100644 --- a/stwo_cairo_prover/crates/prover/src/cairo_air/mod.rs +++ b/stwo_cairo_prover/crates/prover/src/cairo_air/mod.rs @@ -18,7 +18,7 @@ use stwo_prover::core::prover::{prove, verify, ProvingError, VerificationError}; use thiserror::Error; use tracing::{span, Level}; -use crate::input::CairoInput; +use crate::input::ProverInput; const LOG_MAX_ROWS: u32 = 22; @@ -27,7 +27,7 @@ const IS_FIRST_LOG_SIZES: [u32; 19] = [ ]; pub fn prove_cairo( - input: CairoInput, + input: ProverInput, // TODO(Ohad): wrap these flags in a struct. track_relations: bool, display_components: bool, @@ -185,11 +185,11 @@ mod tests { use stwo_prover::core::vcs::blake2_merkle::Blake2sMerkleChannel; use stwo_prover::core::vcs::poseidon252_merkle::Poseidon252MerkleChannel; - use crate::cairo_air::{prove_cairo, verify_cairo, CairoInput}; + use crate::cairo_air::{prove_cairo, verify_cairo, ProverInput}; use crate::input::plain::input_from_plain_casm; use crate::input::vm_import::tests::small_cairo_input; - fn test_input() -> CairoInput { + fn test_input() -> ProverInput { let u128_max = u128::MAX; let instructions = casm! { // TODO(AlonH): Add actual range check segment. diff --git a/stwo_cairo_prover/crates/prover/src/input/mod.rs b/stwo_cairo_prover/crates/prover/src/input/mod.rs index 60e63966..04657f6f 100644 --- a/stwo_cairo_prover/crates/prover/src/input/mod.rs +++ b/stwo_cairo_prover/crates/prover/src/input/mod.rs @@ -12,10 +12,9 @@ pub mod vm_import; pub const N_REGISTERS: usize = 3; -// TODO(Stav): rename to StwoInput. /// Externally provided inputs for the Stwo prover. #[derive(Debug)] -pub struct CairoInput { +pub struct ProverInput { pub state_transitions: StateTransitions, pub memory: Memory, pub public_memory_addresses: Vec, diff --git a/stwo_cairo_prover/crates/prover/src/input/plain.rs b/stwo_cairo_prover/crates/prover/src/input/plain.rs index d9d9e465..1a23c535 100644 --- a/stwo_cairo_prover/crates/prover/src/input/plain.rs +++ b/stwo_cairo_prover/crates/prover/src/input/plain.rs @@ -8,17 +8,17 @@ use itertools::Itertools; use super::memory::{MemoryBuilder, MemoryConfig}; use super::vm_import::{adapt_to_stwo_input, MemoryEntry}; -use super::CairoInput; +use super::ProverInput; // TODO(Ohad): remove dev_mode after adding the rest of the opcodes. -/// Translates a plain casm into a CairoInput by running the program and extracting the memory and +/// Translates a plain casm into a ProverInput by running the program and extracting the memory and /// the state transitions. /// When dev mod is enabled, the opcodes generated from the plain casm will /// be mapped to the generic component only. pub fn input_from_plain_casm( casm: Vec, dev_mode: bool, -) -> CairoInput { +) -> ProverInput { let felt_code = casm .into_iter() .flat_map(|instruction| instruction.assemble().encode()) @@ -54,13 +54,13 @@ pub fn input_from_plain_casm( // TODO(yuval): consider returning a result instead of panicking. // TODO(Ohad): remove dev_mode after adding the rest of the opcodes. -/// Translates a CairoRunner that finished its run into a CairoInput by extracting the relevant +/// Translates a CairoRunner that finished its run into a ProverInput by extracting the relevant /// input to the adapter. /// When dev mod is enabled, the opcodes generated from the plain casm will be mapped to the generic /// component only. /// # Panics /// - if the memory or the trace are not relocated. -pub fn adapt_finished_runner(runner: CairoRunner, dev_mode: bool) -> CairoInput { +pub fn adapt_finished_runner(runner: CairoRunner, dev_mode: bool) -> ProverInput { let _span = tracing::info_span!("adapt_finished_runner").entered(); let memory_iter = runner .relocated_memory diff --git a/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs b/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs index a79a7cfb..804f5fc3 100644 --- a/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs +++ b/stwo_cairo_prover/crates/prover/src/input/vm_import/mod.rs @@ -14,7 +14,7 @@ use tracing::{span, Level}; use super::builtin_segments::BuiltinSegments; use super::memory::MemoryConfig; use super::state_transitions::StateTransitions; -use super::CairoInput; +use super::ProverInput; use crate::input::memory::MemoryBuilder; #[derive(Debug, Error)] @@ -33,7 +33,7 @@ pub fn adapt_vm_output( public_input_json: &Path, private_input_json: &Path, dev_mode: bool, -) -> Result { +) -> Result { let _span = span!(Level::INFO, "adapt_vm_output").entered(); let public_input_string = std::fs::read_to_string(public_input_json)?; let public_input: PublicInput<'_> = sonic_rs::from_str(&public_input_string)?; @@ -84,8 +84,8 @@ pub fn adapt_to_stwo_input( public_memory_addresses: Vec, memory_segments: &HashMap<&str, MemorySegmentAddresses>, dev_mode: bool, -) -> Result { - Ok(CairoInput { +) -> Result { + Ok(ProverInput { state_transitions: StateTransitions::from_iter(trace_iter, &mut memory, dev_mode), memory: memory.build(), public_memory_addresses, @@ -154,7 +154,7 @@ pub mod tests { use super::*; - pub fn large_cairo_input() -> CairoInput { + pub fn large_cairo_input() -> ProverInput { let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); d.push("test_data/test_read_from_large_files"); @@ -169,7 +169,7 @@ pub mod tests { ) } - pub fn small_cairo_input() -> CairoInput { + pub fn small_cairo_input() -> ProverInput { let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); d.push("test_data/test_read_from_small_files"); adapt_vm_output( diff --git a/stwo_cairo_prover/crates/vm_runner/src/main.rs b/stwo_cairo_prover/crates/vm_runner/src/main.rs index 00c63c65..db791ee9 100644 --- a/stwo_cairo_prover/crates/vm_runner/src/main.rs +++ b/stwo_cairo_prover/crates/vm_runner/src/main.rs @@ -3,7 +3,7 @@ use std::process::ExitCode; use clap::Parser; use stwo_cairo_prover::input::plain::adapt_finished_runner; -use stwo_cairo_prover::input::CairoInput; +use stwo_cairo_prover::input::ProverInput; use stwo_cairo_utils::binary_utils::run_binary; use stwo_cairo_utils::vm_utils::{run_vm, VmArgs, VmError}; use thiserror::Error; @@ -41,7 +41,7 @@ fn main() -> ExitCode { run_binary(run) } -fn run(args: impl Iterator) -> Result { +fn run(args: impl Iterator) -> Result { let _span = span!(Level::INFO, "run").entered(); let args = Args::try_parse_from(args)?; let cairo_runner = run_vm(&args.vm_args)?;