Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reverted cairo pie handling change #351

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions stwo_cairo_prover/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion stwo_cairo_prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cairo-lang-casm = "2.7.1"
# TODO(yuval): Use an official version, not a specific commit.
cairo-vm = { git = "https://github.com/lambdaclass/cairo-vm", rev = "83bfdcf", features = [
"mod_builtin",
], default-features = false }
], default-features = true }
clap = { version = "4.3.10", features = ["derive"] }
env_logger = { version = "0.11.5", default-features = false }
hex = "0.4.3"
Expand Down
2 changes: 1 addition & 1 deletion stwo_cairo_prover/crates/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ stwo-air-utils-derive = { git = "https://github.com/starkware-libs/stwo", rev =
stwo-air-utils = { git = "https://github.com/starkware-libs/stwo", rev = "af5475cb" }
bytemuck.workspace = true
cairo-lang-casm.workspace = true
cairo-vm.workspace = true
cairo-vm = { workspace = true, default-features = false }
hex.workspace = true
itertools.workspace = true
num-traits.workspace = true
Expand Down
27 changes: 19 additions & 8 deletions stwo_cairo_prover/crates/utils/src/vm_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::path::PathBuf;
use cairo_vm::cairo_run;
use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor;
use cairo_vm::types::layout_name::LayoutName;
use cairo_vm::vm::runners::cairo_runner::CairoRunner;
use cairo_vm::vm::errors::cairo_run_errors::CairoRunError;
use cairo_vm::vm::runners::cairo_pie::CairoPie;
use cairo_vm::vm::runners::cairo_runner::{CairoRunner, RunResources};
use clap::{Parser, ValueHint};
use thiserror::Error;
use tracing::span;
Expand Down Expand Up @@ -55,8 +57,8 @@ pub struct VmArgs {
pub enum VmError {
#[error("Failed to interact with the file system")]
IO(#[from] std::io::Error),
#[error("Cairo program execution failed: {0}")]
Runner(String),
#[error("The cairo program execution failed")]
Runner(#[from] CairoRunError),
}

// This function's logic is copied-then-modified from cairo-vm-cli/src/main.rs:run in cairo-vm repo.
Expand All @@ -74,15 +76,24 @@ pub fn run_vm(args: &VmArgs) -> Result<CairoRunner, VmError> {
..Default::default()
};

let program_content = std::fs::read(args.filename.clone()).map_err(VmError::IO)?;
let mut hint_processor = BuiltinHintProcessor::new_empty();
let cairo_runner_result =
cairo_run::cairo_run(&program_content, &cairo_run_config, &mut hint_processor);
let cairo_runner_result = if args.run_from_cairo_pie {
let pie = CairoPie::read_zip_file(&args.filename)?;
let mut hint_processor = BuiltinHintProcessor::new(
Default::default(),
RunResources::new(pie.execution_resources.n_steps),
);
cairo_run::cairo_run_pie(&pie, &cairo_run_config, &mut hint_processor)
} else {
let program_content = std::fs::read(args.filename.clone()).map_err(VmError::IO)?;
let mut hint_processor = BuiltinHintProcessor::new_empty();
cairo_run::cairo_run(&program_content, &cairo_run_config, &mut hint_processor)
};

let cairo_runner = match cairo_runner_result {
Ok(runner) => runner,
Err(error) => {
return Err(VmError::Runner(error.to_string()));
eprintln!("{error}");
return Err(VmError::Runner(error));
}
};

Expand Down
Loading