Skip to content

Commit

Permalink
Fix: remove "_builtin" appending logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaRedHand committed Apr 27, 2023
1 parent 67a8651 commit b36cc0b
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/cairo_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use cairo_vm::{
},
vm::{
errors::vm_exception::{get_error_attr_value, get_location, get_traceback},
runners::cairo_runner::{CairoRunner, ExecutionResources},
runners::{
builtin_runner::{HASH_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME},
cairo_runner::{CairoRunner, ExecutionResources},
},
security::verify_secure_runner,
},
};
Expand Down Expand Up @@ -622,7 +625,7 @@ impl PyCairoRunner {
let vm = (*self.pyvm.vm).borrow_mut();
vm.get_builtin_runners()
.iter()
.find(|b| b.name() == "pedersen")
.find(|b| b.name() == HASH_BUILTIN_NAME)
.ok_or_else(|| PyValueError::new_err("hash builtin not present"))
.map(|b| PyRelocatable::from((b.base() as isize, 0_usize)))
}
Expand All @@ -632,7 +635,7 @@ impl PyCairoRunner {
let vm = (*self.pyvm.vm).borrow_mut();
vm.get_builtin_runners()
.iter()
.find(|b| b.name() == "poseidon")
.find(|b| b.name() == POSEIDON_BUILTIN_NAME)
.ok_or_else(|| PyValueError::new_err("poseidon builtin not present"))
.map(|b| PyRelocatable::from((b.base() as isize, 0_usize)))
}
Expand All @@ -642,7 +645,7 @@ impl PyCairoRunner {
let vm = (*self.pyvm.vm).borrow_mut();
vm.get_builtin_runners()
.iter()
.find(|b| b.name() == "range_check")
.find(|b| b.name() == RANGE_CHECK_BUILTIN_NAME)
.ok_or_else(|| PyValueError::new_err("range_check builtin not present"))
.map(|b| PyRelocatable::from((b.base() as isize, 0_usize)))
}
Expand Down Expand Up @@ -714,17 +717,7 @@ impl PyExecutionResources {

#[getter]
fn builtin_instance_counter(&self) -> HashMap<String, usize> {
let mut instance_counters = self.0.builtin_instance_counter.clone();
// replace the builtin name with "<name>_builtin" as expected in the Starknet code.
for builtin_name in self.0.builtin_instance_counter.keys() {
if let Some((key, counter)) = instance_counters.remove_entry(builtin_name) {
instance_counters
.entry(format!("{key}_builtin").to_string())
.or_insert(counter);
}
}

instance_counters
self.0.builtin_instance_counter.clone()
}
}

Expand Down

0 comments on commit b36cc0b

Please sign in to comment.