From 22a97dcedd58da60ceb2ae64f8c021208edc50b5 Mon Sep 17 00:00:00 2001 From: fmoletta <99273364+fmoletta@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:29:12 -0300 Subject: [PATCH] Remove `CairoRunner::add_additional_hash_builtin` & `VirtualMachine::disable_trace` (#1658) * Remove add_additional_hash_builtin * Remove disable_trace * Add changelog entry * Remove tests --- CHANGELOG.md | 2 ++ vm/src/vm/runners/cairo_runner.rs | 42 ------------------------------- vm/src/vm/vm_core.rs | 12 --------- 3 files changed, 2 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4da03eec2..0619cbc798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ #### Upcoming Changes +* BREAKING: Remove `CairoRunner::add_additional_hash_builtin` & `VirtualMachine::disable_trace`[#1658](https://github.com/lambdaclass/cairo-vm/pull/1658) + * feat: output builtin add_attribute method [#1691](https://github.com/lambdaclass/cairo-vm/pull/1691) * feat: Add zero segment [#1668](https://github.com/lambdaclass/cairo-vm/pull/1668) diff --git a/vm/src/vm/runners/cairo_runner.rs b/vm/src/vm/runners/cairo_runner.rs index 7becd79eea..af4048697a 100644 --- a/vm/src/vm/runners/cairo_runner.rs +++ b/vm/src/vm/runners/cairo_runner.rs @@ -1256,22 +1256,6 @@ impl CairoRunner { Ok(()) } - //NOTE: No longer needed in 0.11 - /// Add (or replace if already present) a custom hash builtin. Returns a Relocatable - /// with the new builtin base as the segment index. - pub fn add_additional_hash_builtin(&self, vm: &mut VirtualMachine) -> Relocatable { - // Create, initialize and insert the new custom hash runner. - let mut builtin: BuiltinRunner = HashBuiltinRunner::new(Some(32), true).into(); - builtin.initialize_segments(&mut vm.segments); - let segment_index = builtin.base() as isize; - vm.builtin_runners.push(builtin); - - Relocatable { - segment_index, - offset: 0, - } - } - // Iterates over the program builtins in reverse, calling BuiltinRunner::final_stack on each of them and returns the final pointer // This method is used by cairo-vm-py to replace starknet functionality pub fn get_builtins_final_stack( @@ -4799,32 +4783,6 @@ mod tests { assert_eq!(bitwise_builtin.stop_ptr, Some(5)); } - /// Test that add_additional_hash_builtin() creates an additional builtin. - #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] - fn add_additional_hash_builtin() { - let program = program!(); - let cairo_runner = cairo_runner!(program); - let mut vm = vm!(); - - let num_builtins = vm.builtin_runners.len(); - cairo_runner.add_additional_hash_builtin(&mut vm); - assert_eq!(vm.builtin_runners.len(), num_builtins + 1); - - let builtin = vm - .builtin_runners - .last() - .expect("missing last builtin runner"); - match builtin { - BuiltinRunner::Hash(builtin) => { - assert_eq!(builtin.base(), 0); - assert_eq!(builtin.ratio(), Some(32)); - assert!(builtin.included); - } - _ => unreachable!(), - } - } - #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn run_from_entrypoint_custom_program_test() { diff --git a/vm/src/vm/vm_core.rs b/vm/src/vm/vm_core.rs index 8bd47ea1df..9a20d8887a 100644 --- a/vm/src/vm/vm_core.rs +++ b/vm/src/vm/vm_core.rs @@ -942,9 +942,6 @@ impl VirtualMachine { Err(VirtualMachineError::NoSignatureBuiltin) } - pub fn disable_trace(&mut self) { - self.trace = None - } #[cfg(feature = "with_tracer")] pub fn relocate_segments(&self) -> Result, MemoryError> { @@ -3842,15 +3839,6 @@ mod tests { assert_eq!(builtins[1].name(), BITWISE_BUILTIN_NAME); } - #[test] - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] - fn disable_trace() { - let mut vm = VirtualMachine::new(true); - assert!(vm.trace.is_some()); - vm.disable_trace(); - assert!(vm.trace.is_none()); - } - #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn get_range_for_continuous_memory() {