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 23, 2024
1 parent 0beebdc commit 95ad8ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cairo1-run/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use cairo_lang_utils::{
bigint::BigIntAsHex, casts::IntoOrPanic, unordered_hash_map::UnorderedHashMap,
};
use cairo_vm::{
cairo_run,
hint_processor::cairo_1_hint_processor::hint_processor::Cairo1HintProcessor,
math_utils::signed_felt,
serde::deserialize_program::{ApTracking, FlowTrackingData, HintParams, ReferenceManager},
Expand All @@ -51,7 +52,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 +87,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 +108,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 +251,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 95ad8ae

Please sign in to comment.