Skip to content

Commit

Permalink
Add cli dynamic support for cairo 1
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Aug 26, 2024
1 parent ad97bd0 commit 11edca3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cairo1-run/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use cairo_vm::{
use itertools::{chain, Itertools};
use num_bigint::{BigInt, Sign};
use num_traits::{cast::ToPrimitive, Zero};
use std::{collections::HashMap, iter::Peekable};
use std::{collections::HashMap, iter::Peekable, path::PathBuf};

/// Representation of a cairo argument
/// Can consist of a single Felt or an array of Felts
Expand Down Expand Up @@ -86,6 +86,7 @@ pub struct Cairo1RunConfig<'a> {
pub relocate_mem: bool,
/// Cairo layout chosen for the run
pub layout: LayoutName,
pub cairo_layout_params_file: Option<PathBuf>,
/// Run in proof_mode
pub proof_mode: bool,
/// Should be true if either air_public_input or cairo_pie_output are needed
Expand All @@ -106,6 +107,7 @@ impl Default for Cairo1RunConfig<'_> {
proof_mode: false,
finalize_builtins: false,
append_return_values: false,
cairo_layout_params_file: None,
}
}
}
Expand Down Expand Up @@ -248,7 +250,7 @@ pub fn cairo_run_program(
let mut runner = CairoRunner::new_v2(
&program,
cairo_run_config.layout,
None,
cairo_run_config.cairo_layout_params_file.clone(),
runner_mode,
cairo_run_config.trace_enabled,
)?;
Expand Down
6 changes: 6 additions & 0 deletions cairo1-run/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ struct Args {
trace_file: Option<PathBuf>,
#[structopt(long = "memory_file")]
memory_file: Option<PathBuf>,
/// When using dynamic layout, it's parameters must be specified through a layout params file.
#[clap(long = "layout", default_value = "plain", value_enum)]
layout: LayoutName,
/// Required when using with dynamic layout.
/// Ignored otherwise.
#[clap(long = "cairo_layout_params_file", required_if_eq("layout", "dynamic"))]
cairo_layout_params_file: Option<PathBuf>,
#[clap(long = "proof_mode", value_parser)]
proof_mode: bool,
#[clap(long = "air_public_input", requires = "proof_mode")]
Expand Down Expand Up @@ -162,6 +167,7 @@ fn run(args: impl Iterator<Item = String>) -> Result<Option<String>, Error> {
args: &args.args.0,
finalize_builtins: args.air_public_input.is_some() || args.cairo_pie_output.is_some(),
append_return_values: args.append_return_values,
cairo_layout_params_file: args.cairo_layout_params_file,
};

// Try to parse the file as a sierra program
Expand Down

0 comments on commit 11edca3

Please sign in to comment.