Skip to content

Commit

Permalink
Remove CairoRunner::add_additional_hash_builtin & `VirtualMachine::…
Browse files Browse the repository at this point in the history
…disable_trace` (#1658)

* Remove add_additional_hash_builtin

* Remove disable_trace

* Add changelog entry

* Remove tests
  • Loading branch information
fmoletta authored Apr 3, 2024
1 parent 1725f0c commit 22a97dc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 54 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 0 additions & 42 deletions vm/src/vm/runners/cairo_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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() {
Expand Down
12 changes: 0 additions & 12 deletions vm/src/vm/vm_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<usize>, MemoryError> {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 22a97dc

Please sign in to comment.