diff --git a/CHANGELOG.md b/CHANGELOG.md index ebbe3dfca1..61b31f8c77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ #### Upcoming Changes +* feat(BREAKING): Add `allow_missing_builtins` flag [#1600](https://github.com/lambdaclass/cairo-vm/pull/1600) + + This new flag will skip the check that all builtins used by the program need to be present in the selected layout if enabled. It will also be enabled by default when running in proof_mode. + + * Add `allow_missing_builtins` flag to `cairo-vm-cli` crate + * Add `allow_missing_builtins` field to `CairoRunConfig` struct + * Add `allow_missing_builtins` boolean argument to `CairoRunner` methods `initialize` & `initialize_builtins` + * feat: Append return values to the output segment when running cairo1-run in proof_mode [#1597](https://github.com/lambdaclass/cairo-vm/pull/1597) * Add instructions to the proof_mode header to copy return values to the output segment before initiating the infinite loop * Output builtin is now always included when running cairo 1 programs in proof_mode diff --git a/README.md b/README.md index 1d7d274d46..3f642d9623 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ The cairo-vm-cli supports the following optional arguments: - `--proof_mode`: Runs the program in proof_mode -- `--secure_run`: Runs security checks after execution. Enabled by default when not in proof_mode +- `--secure_run`: Runs security checks after execution. Enabled by default when not in proof_mode. - `--air_public_input `: Receives the name of a file and outputs the AIR public inputs into it. Can only be used if proof_mode is also enabled. @@ -177,6 +177,8 @@ The cairo-vm-cli supports the following optional arguments: - `--cairo_pie_output `: Receives the name of a file and outputs the Cairo PIE into it. Can only be used if proof_mode, is not enabled. +- `--allow_missing_builtins`: Disables the check that all builtins used by the program need to be included in the selected layout. Enabled by default when in proof_mode. + For example, to obtain the air public inputs from a fibonacci program run, we can run : ```bash diff --git a/bench/criterion_benchmark.rs b/bench/criterion_benchmark.rs index d1f4029a4f..5f4c4c1193 100644 --- a/bench/criterion_benchmark.rs +++ b/bench/criterion_benchmark.rs @@ -52,7 +52,9 @@ fn load_program_data(c: &mut Criterion) { VirtualMachine::new(false), ) }, - |(mut runner, mut vm)| _ = black_box(runner.initialize(black_box(&mut vm)).unwrap()), + |(mut runner, mut vm)| { + _ = black_box(runner.initialize(black_box(&mut vm), false).unwrap()) + }, BatchSize::SmallInput, ) }); diff --git a/bench/iai_benchmark.rs b/bench/iai_benchmark.rs index b12c209514..07fcf214b8 100644 --- a/bench/iai_benchmark.rs +++ b/bench/iai_benchmark.rs @@ -51,7 +51,7 @@ fn build_runner_helper() -> (CairoRunner, VirtualMachine) { #[inline(never)] fn load_program_data() { let (mut runner, mut vm) = build_runner_helper(); - _ = black_box(runner.initialize(black_box(&mut vm)).unwrap()); + _ = black_box(runner.initialize(black_box(&mut vm), false).unwrap()); } main!( diff --git a/cairo-vm-cli/src/main.rs b/cairo-vm-cli/src/main.rs index a3c349d79a..276dd6b70b 100644 --- a/cairo-vm-cli/src/main.rs +++ b/cairo-vm-cli/src/main.rs @@ -52,6 +52,8 @@ struct Args { conflicts_with_all = ["proof_mode", "air_private_input", "air_public_input"] )] cairo_pie_output: Option, + #[structopt(long = "allow_missing_builtins")] + allow_missing_builtins: Option, } fn validate_layout(value: &str) -> Result { @@ -132,6 +134,7 @@ fn run(args: impl Iterator) -> Result<(), Error> { layout: &args.layout, proof_mode: args.proof_mode, secure_run: args.secure_run, + allow_missing_builtins: args.allow_missing_builtins, ..Default::default() }; diff --git a/cairo1-run/src/main.rs b/cairo1-run/src/main.rs index 6c0214d7f7..3d1bf8fdca 100644 --- a/cairo1-run/src/main.rs +++ b/cairo1-run/src/main.rs @@ -404,7 +404,7 @@ fn run(args: impl Iterator) -> Result, Error> { let mut runner = CairoRunner::new_v2(&program, &args.layout, runner_mode)?; let mut vm = VirtualMachine::new(args.trace_file.is_some() || args.air_public_input.is_some()); - let end = runner.initialize(&mut vm)?; + let end = runner.initialize(&mut vm, args.proof_mode)?; additional_initialization(&mut vm, data_len)?; diff --git a/vm/src/cairo_run.rs b/vm/src/cairo_run.rs index 2ddb1c0de2..8293bc9625 100644 --- a/vm/src/cairo_run.rs +++ b/vm/src/cairo_run.rs @@ -28,6 +28,7 @@ pub struct CairoRunConfig<'a> { pub proof_mode: bool, pub secure_run: Option, pub disable_trace_padding: bool, + pub allow_missing_builtins: Option, } #[cfg(feature = "arbitrary")] @@ -56,6 +57,7 @@ impl<'a> Default for CairoRunConfig<'a> { proof_mode: false, secure_run: None, disable_trace_padding: false, + allow_missing_builtins: None, } } } @@ -69,6 +71,10 @@ pub fn cairo_run_program( .secure_run .unwrap_or(!cairo_run_config.proof_mode); + let allow_missing_builtins = cairo_run_config + .allow_missing_builtins + .unwrap_or(cairo_run_config.proof_mode); + let mut cairo_runner = CairoRunner::new( program, cairo_run_config.layout, @@ -76,7 +82,7 @@ pub fn cairo_run_program( )?; let mut vm = VirtualMachine::new(cairo_run_config.trace_enabled); - let end = cairo_runner.initialize(&mut vm)?; + let end = cairo_runner.initialize(&mut vm, allow_missing_builtins)?; // check step calculation cairo_runner @@ -133,7 +139,12 @@ pub fn cairo_run_fuzzed_program( let mut vm = VirtualMachine::new(cairo_run_config.trace_enabled); - let _end = cairo_runner.initialize(&mut vm)?; + let _end = cairo_runner.initialize( + &mut vm, + cairo_run_config + .allow_missing_builtins + .unwrap_or(cairo_run_config.proof_mode), + )?; let res = match cairo_runner.run_until_steps(steps_limit, &mut vm, hint_executor) { Err(VirtualMachineError::EndOfProgram(_remaining)) => Ok(()), // program ran OK but ended before steps limit @@ -230,7 +241,7 @@ mod tests { let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(true); let end = cairo_runner - .initialize(&mut vm) + .initialize(&mut vm, false) .map_err(CairoRunError::Runner)?; assert!(cairo_runner @@ -252,7 +263,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); let mut cairo_runner = cairo_runner!(program); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_ok()); @@ -372,7 +383,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_ok()); diff --git a/vm/src/vm/errors/vm_exception.rs b/vm/src/vm/errors/vm_exception.rs index 6e4e762ef4..f8ab67088c 100644 --- a/vm/src/vm/errors/vm_exception.rs +++ b/vm/src/vm/errors/vm_exception.rs @@ -659,7 +659,7 @@ mod test { let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_err()); @@ -673,7 +673,7 @@ mod test { let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_err()); @@ -711,7 +711,7 @@ cairo_programs/bad_programs/bad_usort.cairo:64:5: (pc=0:60) let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_err()); @@ -870,7 +870,7 @@ cairo_programs/bad_programs/bad_range_check.cairo:11:5: (pc=0:6) let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); let error = cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .unwrap_err(); @@ -915,7 +915,7 @@ cairo_programs/bad_programs/bad_usort.cairo:64:5: (pc=0:60) let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); let error = cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .unwrap_err(); @@ -954,7 +954,7 @@ cairo_programs/bad_programs/ec_recover_product_mod_m_zero.cairo:11:5: (pc=0:18) let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); let error = cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .unwrap_err(); @@ -993,7 +993,7 @@ cairo_programs/bad_programs/ec_recover_div_mod_n_packed_n_zero.cairo:11:5: (pc=0 let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); let error = cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .unwrap_err(); @@ -1032,7 +1032,7 @@ cairo_programs/bad_programs/uint512_unsigned_div_rem_div_is_zero.cairo:15:2: (pc let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); let error = cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .unwrap_err(); @@ -1069,7 +1069,7 @@ cairo_programs/bad_programs/uint256_sub_b_gt_256.cairo:10:2: (pc=0:12) let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); let error = cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .unwrap_err(); diff --git a/vm/src/vm/hooks.rs b/vm/src/vm/hooks.rs index d2f88e7eb7..13c7bb86ce 100644 --- a/vm/src/vm/hooks.rs +++ b/vm/src/vm/hooks.rs @@ -131,7 +131,7 @@ mod tests { let mut vm = vm!(); vm.hooks = Hooks::new(None, None, None); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_ok()); @@ -179,7 +179,7 @@ mod tests { let mut vm = vm!(); vm.hooks = Hooks::new(Some(Arc::new(before_first_step_hook)), None, None); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_err()); @@ -190,7 +190,7 @@ mod tests { let mut vm = vm!(); vm.hooks = Hooks::new(None, Some(Arc::new(pre_step_hook)), None); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_err()); @@ -201,7 +201,7 @@ mod tests { let mut vm = vm!(); vm.hooks = Hooks::new(None, None, Some(Arc::new(post_step_hook))); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_err()); @@ -252,7 +252,7 @@ mod tests { Some(Arc::new(post_step_hook)), ); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_ok()); diff --git a/vm/src/vm/runners/builtin_runner/bitwise.rs b/vm/src/vm/runners/builtin_runner/bitwise.rs index 825aab3942..e83bad24f1 100644 --- a/vm/src/vm/runners/builtin_runner/bitwise.rs +++ b/vm/src/vm/runners/builtin_runner/bitwise.rs @@ -393,7 +393,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) @@ -438,7 +438,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) diff --git a/vm/src/vm/runners/builtin_runner/ec_op.rs b/vm/src/vm/runners/builtin_runner/ec_op.rs index c824f0153d..37ec430e12 100644 --- a/vm/src/vm/runners/builtin_runner/ec_op.rs +++ b/vm/src/vm/runners/builtin_runner/ec_op.rs @@ -464,7 +464,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) @@ -509,7 +509,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) diff --git a/vm/src/vm/runners/builtin_runner/hash.rs b/vm/src/vm/runners/builtin_runner/hash.rs index f8e8fbe333..3ec2aabf27 100644 --- a/vm/src/vm/runners/builtin_runner/hash.rs +++ b/vm/src/vm/runners/builtin_runner/hash.rs @@ -381,7 +381,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) @@ -425,7 +425,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) diff --git a/vm/src/vm/runners/builtin_runner/keccak.rs b/vm/src/vm/runners/builtin_runner/keccak.rs index 244efa866d..17e6e3d638 100644 --- a/vm/src/vm/runners/builtin_runner/keccak.rs +++ b/vm/src/vm/runners/builtin_runner/keccak.rs @@ -421,7 +421,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) diff --git a/vm/src/vm/runners/builtin_runner/mod.rs b/vm/src/vm/runners/builtin_runner/mod.rs index 99778c6333..78eed172a2 100644 --- a/vm/src/vm/runners/builtin_runner/mod.rs +++ b/vm/src/vm/runners/builtin_runner/mod.rs @@ -826,7 +826,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) @@ -873,7 +873,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) @@ -917,7 +917,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) @@ -961,7 +961,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) diff --git a/vm/src/vm/runners/builtin_runner/poseidon.rs b/vm/src/vm/runners/builtin_runner/poseidon.rs index a668ba324b..3bc28ab228 100644 --- a/vm/src/vm/runners/builtin_runner/poseidon.rs +++ b/vm/src/vm/runners/builtin_runner/poseidon.rs @@ -365,7 +365,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) @@ -409,7 +409,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) diff --git a/vm/src/vm/runners/builtin_runner/range_check.rs b/vm/src/vm/runners/builtin_runner/range_check.rs index ba07f6f253..68809b8752 100644 --- a/vm/src/vm/runners/builtin_runner/range_check.rs +++ b/vm/src/vm/runners/builtin_runner/range_check.rs @@ -379,7 +379,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) @@ -423,7 +423,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); - let address = cairo_runner.initialize(&mut vm).unwrap(); + let address = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(address, &mut vm, &mut hint_processor) diff --git a/vm/src/vm/runners/cairo_runner.rs b/vm/src/vm/runners/cairo_runner.rs index 32335a9f6b..cadc1d02ba 100644 --- a/vm/src/vm/runners/cairo_runner.rs +++ b/vm/src/vm/runners/cairo_runner.rs @@ -228,15 +228,27 @@ impl CairoRunner { } } - pub fn initialize(&mut self, vm: &mut VirtualMachine) -> Result { - self.initialize_builtins(vm)?; + pub fn initialize( + &mut self, + vm: &mut VirtualMachine, + allow_missing_builtins: bool, + ) -> Result { + self.initialize_builtins(vm, allow_missing_builtins)?; self.initialize_segments(vm, None); let end = self.initialize_main_entrypoint(vm)?; self.initialize_vm(vm)?; Ok(end) } - pub fn initialize_builtins(&self, vm: &mut VirtualMachine) -> Result<(), RunnerError> { + /// Creates the builtin runners according to the builtins used by the program and the selected layout + /// When running in proof_mode, all builtins in the layout will be created, and only those in the program will be included + /// When not running in proof_mode, only program builtins will be created and included + /// Unless `allow_missing_builtins` is set to true, an error will be returned if a builtin is included in the program but not on the layout + pub fn initialize_builtins( + &self, + vm: &mut VirtualMachine, + allow_missing_builtins: bool, + ) -> Result<(), RunnerError> { let builtin_ordered_list = vec![ BuiltinName::output, BuiltinName::pedersen, @@ -316,7 +328,7 @@ impl CairoRunner { .push(PoseidonBuiltinRunner::new(instance_def.ratio, included).into()); } } - if !program_builtins.is_empty() { + if !program_builtins.is_empty() && !allow_missing_builtins { return Err(RunnerError::NoBuiltinForInstance(Box::new(( program_builtins.iter().map(|n| n.name()).collect(), self.layout._name.clone(), @@ -1563,7 +1575,6 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn check_memory_usage_ok_case() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::range_check, BuiltinName::output]; let cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1599,26 +1610,36 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_builtins_with_disordered_builtins() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::range_check, BuiltinName::output]; - let cairo_runner = cairo_runner!(program); + let cairo_runner = cairo_runner!(program, "plain"); + let mut vm = vm!(); + assert!(cairo_runner.initialize_builtins(&mut vm, false).is_err()); + } + + #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + fn initialize_builtins_missing_builtins_no_allow_missing() { + let program = program![BuiltinName::output, BuiltinName::ecdsa]; + let cairo_runner = cairo_runner!(program, "plain"); let mut vm = vm!(); - assert!(cairo_runner.initialize_builtins(&mut vm).is_err()); + assert_matches!( + cairo_runner.initialize_builtins(&mut vm, false), + Err(RunnerError::NoBuiltinForInstance(_)) + ) } #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] - fn create_cairo_runner_with_ordered_but_missing_builtins() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined + fn initialize_builtins_missing_builtins_allow_missing() { let program = program![BuiltinName::output, BuiltinName::ecdsa]; - //We only check that the creation doesnt panic - let _cairo_runner = cairo_runner!(program); + let cairo_runner = cairo_runner!(program); + let mut vm = vm!(); + assert!(cairo_runner.initialize_builtins(&mut vm, true).is_ok()) } #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_segments_with_base() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1627,7 +1648,7 @@ mod tests { offset: 9, }); add_segments!(vm, 6); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, program_base); assert_eq!( cairo_runner.program_base, @@ -1652,11 +1673,10 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_segments_no_base() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); assert_eq!( cairo_runner.program_base, @@ -1681,14 +1701,13 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_state_empty_data_and_stack() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); cairo_runner.program_base = Some(relocatable!(1, 0)); cairo_runner.execution_base = Some(relocatable!(2, 0)); let stack = Vec::new(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_state(&mut vm, 1, stack).unwrap(); assert_eq!( cairo_runner.initial_pc, @@ -1702,7 +1721,6 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_state_some_data_empty_stack() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program!( builtins = vec![BuiltinName::output], data = vec_data!((4), (6)), @@ -1725,7 +1743,6 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_state_empty_data_some_stack() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1742,7 +1759,6 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_state_no_program_base() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1763,7 +1779,6 @@ mod tests { #[test] #[should_panic] fn initialize_state_no_execution_base() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1781,7 +1796,6 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_function_entrypoint_empty_stack() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1803,7 +1817,6 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_function_entrypoint_some_stack() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1830,7 +1843,6 @@ mod tests { #[test] #[should_panic] fn initialize_function_entrypoint_no_execution_base() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1844,7 +1856,6 @@ mod tests { #[test] #[should_panic] fn initialize_main_entrypoint_no_main() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1854,7 +1865,6 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_main_entrypoint() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program!(main = Some(1),); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1879,7 +1889,7 @@ mod tests { let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); - cairo_runner.initialize(&mut vm).unwrap(); + cairo_runner.initialize(&mut vm, false).unwrap(); assert_eq!( vm.segments .memory @@ -1891,7 +1901,6 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_vm_no_builtins() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program!(main = Some(1),); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -1908,14 +1917,13 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_vm_with_range_check_valid() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program!(builtins = vec![BuiltinName::range_check], main = Some(1),); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); cairo_runner.initial_pc = Some(relocatable!(0, 1)); cairo_runner.initial_ap = Some(relocatable!(1, 2)); cairo_runner.initial_fp = Some(relocatable!(1, 2)); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); vm.segments = segments![((2, 0), 23), ((2, 1), 233)]; assert_eq!(vm.builtin_runners[0].name(), RANGE_CHECK_BUILTIN_NAME); @@ -1937,14 +1945,13 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn initialize_vm_with_range_check_invalid() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program!(builtins = vec![BuiltinName::range_check], main = Some(1),); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); cairo_runner.initial_pc = Some(relocatable!(0, 1)); cairo_runner.initial_ap = Some(relocatable!(1, 2)); cairo_runner.initial_fp = Some(relocatable!(1, 2)); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); vm.segments = segments![((2, 1), 23), ((2, 4), (-1))]; @@ -2068,7 +2075,7 @@ mod tests { let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); cairo_runner.initialize_vm(&mut vm).unwrap(); @@ -2157,7 +2164,7 @@ mod tests { let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); cairo_runner.initialize_vm(&mut vm).unwrap(); @@ -2322,7 +2329,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(true); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); let end = cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); cairo_runner.initialize_vm(&mut vm).unwrap(); @@ -2437,7 +2444,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(true); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); let end = cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); cairo_runner.initialize_vm(&mut vm).unwrap(); @@ -2576,7 +2583,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(true); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); let end = cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); cairo_runner.initialize_vm(&mut vm).unwrap(); @@ -2814,7 +2821,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(true); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); let end = cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); cairo_runner.initialize_vm(&mut vm).unwrap(); @@ -2953,7 +2960,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(true); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); let end = cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); cairo_runner.initialize_vm(&mut vm).unwrap(); @@ -3073,7 +3080,7 @@ mod tests { let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); assert_eq!(vm.builtin_runners[0].name(), OUTPUT_BUILTIN_NAME); assert_eq!(vm.builtin_runners[0].base(), 2); @@ -3128,7 +3135,7 @@ mod tests { ); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); let end = cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); cairo_runner.initialize_vm(&mut vm).unwrap(); @@ -3169,7 +3176,7 @@ mod tests { ); let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); let end = cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); cairo_runner.initialize_vm(&mut vm).unwrap(); @@ -3191,7 +3198,7 @@ mod tests { let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); assert_eq!(vm.builtin_runners[0].name(), OUTPUT_BUILTIN_NAME); assert_eq!(vm.builtin_runners[0].base(), 2); @@ -3245,7 +3252,7 @@ mod tests { let mut vm = vm!(); cairo_runner - .initialize_builtins(&mut vm) + .initialize_builtins(&mut vm, false) .expect("Couldn't initialize builtins."); // Swap the first and second builtins (first should be `output`). @@ -3283,7 +3290,7 @@ mod tests { ]; let cairo_runner = cairo_runner!(program); let mut vm = vm!(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); assert_eq!(vm.builtin_runners[0].name(), OUTPUT_BUILTIN_NAME); assert_eq!(vm.builtin_runners[1].name(), HASH_BUILTIN_NAME); assert_eq!(vm.builtin_runners[2].name(), RANGE_CHECK_BUILTIN_NAME); @@ -3341,7 +3348,7 @@ mod tests { let mut cairo_runner = cairo_runner!(&program); let mut vm = vm!(true); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); @@ -3365,7 +3372,7 @@ mod tests { let mut cairo_runner = cairo_runner!(&program); let mut vm = vm!(true); assert_matches!( - cairo_runner.initialize(&mut vm), + cairo_runner.initialize(&mut vm, false), Err(RunnerError::MissingMain) ); } @@ -3420,7 +3427,7 @@ mod tests { let mut cairo_runner = cairo_runner!(&program); let mut vm = vm!(true); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); @@ -3493,7 +3500,7 @@ mod tests { let mut cairo_runner = cairo_runner!(&program); let mut vm = vm!(true); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); cairo_runner.initialize_main_entrypoint(&mut vm).unwrap(); @@ -3765,7 +3772,7 @@ mod tests { let mut cairo_runner = cairo_runner!(program, "all_cairo", true); let mut vm = vm!(true); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .expect("Call to `CairoRunner::run_until_pc()` failed."); @@ -4180,7 +4187,6 @@ mod tests { #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn get_initial_fp_can_be_obtained() { - //This test works with basic Program definition, will later be updated to use Program::new() when fully defined let program = program![BuiltinName::output]; let mut cairo_runner = cairo_runner!(program); let mut vm = vm!(); @@ -4446,7 +4452,7 @@ mod tests { let mut vm = vm!(); let cairo_runner = cairo_runner!(program, "plain"); assert_eq!( - cairo_runner.initialize_builtins(&mut vm), + cairo_runner.initialize_builtins(&mut vm, false), Err(RunnerError::NoBuiltinForInstance(Box::new(( HashSet::from([BuiltinName::output.name()]), String::from("plain") @@ -4461,7 +4467,7 @@ mod tests { let mut vm = vm!(); let cairo_runner = cairo_runner!(program, "plain"); assert_eq!( - cairo_runner.initialize_builtins(&mut vm), + cairo_runner.initialize_builtins(&mut vm, false), Err(RunnerError::NoBuiltinForInstance(Box::new(( HashSet::from([BuiltinName::output.name(), HASH_BUILTIN_NAME]), String::from("plain") @@ -4476,7 +4482,7 @@ mod tests { let mut vm = vm!(); let cairo_runner = cairo_runner!(program, "small"); assert_eq!( - cairo_runner.initialize_builtins(&mut vm), + cairo_runner.initialize_builtins(&mut vm, false), Err(RunnerError::NoBuiltinForInstance(Box::new(( HashSet::from([BuiltinName::bitwise.name()]), String::from("small") @@ -4514,7 +4520,7 @@ mod tests { let mut runner = cairo_runner!(program); runner.runner_mode = RunnerMode::ProofModeCanonical; let mut vm = vm!(); - runner.initialize_builtins(&mut vm).unwrap(); + runner.initialize_builtins(&mut vm, false).unwrap(); runner.initialize_segments(&mut vm, None); assert_eq!(runner.execution_base, Some(Relocatable::from((1, 0)))); assert_eq!(runner.program_base, Some(Relocatable::from((0, 0)))); @@ -4850,7 +4856,7 @@ mod tests { .pc .unwrap(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); assert_matches!( cairo_runner.run_from_entrypoint( @@ -4871,7 +4877,9 @@ mod tests { let mut new_vm = vm!(true); //this true expression dictates that the trace is enabled let mut hint_processor = BuiltinHintProcessor::new_empty(); - new_cairo_runner.initialize_builtins(&mut new_vm).unwrap(); + new_cairo_runner + .initialize_builtins(&mut new_vm, false) + .unwrap(); new_cairo_runner.initialize_segments(&mut new_vm, None); let fib_entrypoint = program @@ -5038,7 +5046,7 @@ mod tests { .pc .unwrap(); - cairo_runner.initialize_builtins(&mut vm).unwrap(); + cairo_runner.initialize_builtins(&mut vm, false).unwrap(); cairo_runner.initialize_segments(&mut vm, None); let result = cairo_runner.run_from_entrypoint( @@ -5071,7 +5079,7 @@ mod tests { .unwrap(); let mut runner = cairo_runner!(program); let mut vm = vm!(); - let end = runner.initialize(&mut vm).unwrap(); + let end = runner.initialize(&mut vm, false).unwrap(); runner .run_until_pc(end, &mut vm, &mut BuiltinHintProcessor::new_empty()) .unwrap(); @@ -5094,7 +5102,7 @@ mod tests { .unwrap(); let mut runner = cairo_runner!(program); let mut vm = vm!(); - let end = runner.initialize(&mut vm).unwrap(); + let end = runner.initialize(&mut vm, false).unwrap(); runner .run_until_pc(end, &mut vm, &mut BuiltinHintProcessor::new_empty()) .unwrap(); @@ -5117,7 +5125,7 @@ mod tests { .unwrap(); let mut runner = cairo_runner!(program); let mut vm = vm!(); - let end = runner.initialize(&mut vm).unwrap(); + let end = runner.initialize(&mut vm, false).unwrap(); runner .run_until_pc(end, &mut vm, &mut BuiltinHintProcessor::new_empty()) .unwrap(); @@ -5141,7 +5149,7 @@ mod tests { .unwrap(); let mut runner = cairo_runner!(program); let mut vm = vm!(); - let end = runner.initialize(&mut vm).unwrap(); + let end = runner.initialize(&mut vm, false).unwrap(); runner .run_until_pc(end, &mut vm, &mut BuiltinHintProcessor::new_empty()) .unwrap(); @@ -5229,7 +5237,7 @@ mod tests { .unwrap(); let mut runner = cairo_runner!(program); let mut vm = vm!(); - let end = runner.initialize(&mut vm).unwrap(); + let end = runner.initialize(&mut vm, false).unwrap(); // program takes 80 steps assert_matches!( @@ -5248,7 +5256,7 @@ mod tests { .unwrap(); let mut runner = cairo_runner!(program); let mut vm = vm!(); - let end = runner.initialize(&mut vm).unwrap(); + let end = runner.initialize(&mut vm, false).unwrap(); let mut hint_processor = BuiltinHintProcessor::new(HashMap::new(), RunResources::new(81)); // program takes 81 steps assert_matches!( @@ -5269,7 +5277,7 @@ mod tests { .unwrap(); let mut runner = cairo_runner!(program); let mut vm = vm!(); - let end = runner.initialize(&mut vm).unwrap(); + let end = runner.initialize(&mut vm, false).unwrap(); let mut hint_processor = BuiltinHintProcessor::new(HashMap::new(), RunResources::new(80)); // program takes 80 steps assert_matches!( @@ -5290,7 +5298,7 @@ mod tests { .unwrap(); let mut runner = cairo_runner!(program); let mut vm = vm!(); - let end = runner.initialize(&mut vm).unwrap(); + let end = runner.initialize(&mut vm, false).unwrap(); let mut hint_processor = BuiltinHintProcessor::new(HashMap::new(), RunResources::new(9)); // program takes 9 steps assert_matches!( diff --git a/vm/src/vm/security.rs b/vm/src/vm/security.rs index a18e43421a..2749fcf154 100644 --- a/vm/src/vm/security.rs +++ b/vm/src/vm/security.rs @@ -120,7 +120,7 @@ mod test { let mut runner = cairo_runner!(program); let mut vm = vm!(); - runner.initialize(&mut vm).unwrap(); + runner.initialize(&mut vm, false).unwrap(); vm.segments.compute_effective_sizes(); assert_matches!(verify_secure_runner(&runner, true, None, &mut vm), Ok(())); } @@ -133,7 +133,7 @@ mod test { let mut runner = cairo_runner!(program); let mut vm = vm!(); - runner.initialize(&mut vm).unwrap(); + runner.initialize(&mut vm, false).unwrap(); vm.segments = segments![((0, 0), 100)]; vm.segments.segment_used_sizes = Some(vec![1]); @@ -152,7 +152,7 @@ mod test { let mut runner = cairo_runner!(program); let mut vm = vm!(); - runner.initialize(&mut vm).unwrap(); + runner.initialize(&mut vm, false).unwrap(); vm.segments = segments![((0, 0), 100)]; vm.segments.segment_used_sizes = Some(vec![1]); @@ -170,7 +170,7 @@ mod test { let mut runner = cairo_runner!(program); let mut vm = vm!(); - runner.initialize(&mut vm).unwrap(); + runner.initialize(&mut vm, false).unwrap(); vm.builtin_runners[0].set_stop_ptr(0); vm.segments.memory = memory![((2, 0), 1)]; vm.segments.segment_used_sizes = Some(vec![0, 0, 0, 0]); @@ -188,7 +188,7 @@ mod test { let mut runner = cairo_runner!(program); let mut vm = vm!(); - runner.initialize(&mut vm).unwrap(); + runner.initialize(&mut vm, false).unwrap(); let mut hint_processor = BuiltinHintProcessor::new_empty(); runner .end_run(false, false, &mut vm, &mut hint_processor) @@ -217,7 +217,7 @@ mod test { let mut runner = cairo_runner!(program); let mut vm = vm!(); - runner.initialize(&mut vm).unwrap(); + runner.initialize(&mut vm, false).unwrap(); vm.segments.memory = memory![ ((0, 0), (1, 0)), ((0, 1), (2, 1)), @@ -245,7 +245,7 @@ mod test { let mut runner = cairo_runner!(program); let mut vm = vm!(); - runner.initialize(&mut vm).unwrap(); + runner.initialize(&mut vm, false).unwrap(); vm.segments.memory = memory![ ((0, 1), (1, 0)), ((0, 2), (2, 1)), @@ -273,7 +273,7 @@ mod test { let mut runner = cairo_runner!(program); let mut vm = vm!(); - runner.initialize(&mut vm).unwrap(); + runner.initialize(&mut vm, false).unwrap(); vm.segments.memory = memory![ ((0, 0), (1, 0)), ((0, 1), (2, 1)), diff --git a/vm/src/vm/vm_core.rs b/vm/src/vm/vm_core.rs index 4def25700f..4dc6be0dcd 100644 --- a/vm/src/vm/vm_core.rs +++ b/vm/src/vm/vm_core.rs @@ -4266,7 +4266,7 @@ mod tests { let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_err()); @@ -4291,7 +4291,7 @@ mod tests { let mut cairo_runner = cairo_runner!(program, "all_cairo", false); let mut vm = vm!(); - let end = cairo_runner.initialize(&mut vm).unwrap(); + let end = cairo_runner.initialize(&mut vm, false).unwrap(); assert!(cairo_runner .run_until_pc(end, &mut vm, &mut hint_processor) .is_err()); @@ -4378,7 +4378,7 @@ mod tests { let mut hint_processor = BuiltinHintProcessor::new_empty(); let mut cairo_runner = cairo_runner!(program); let end = cairo_runner - .initialize(&mut virtual_machine_from_builder) + .initialize(&mut virtual_machine_from_builder, false) .unwrap(); assert!(cairo_runner