diff --git a/acvm-repo/acvm_js/src/execute.rs b/acvm-repo/acvm_js/src/execute.rs index eff9dcf8c25..ebbfc4297c3 100644 --- a/acvm-repo/acvm_js/src/execute.rs +++ b/acvm-repo/acvm_js/src/execute.rs @@ -1,5 +1,5 @@ use acvm::{ - acir::circuit::{Circuit, OpcodeLocation}, + acir::circuit::Circuit, pwg::{ACVMStatus, ErrorLocation, OpcodeResolutionError, ACVM}, }; #[allow(deprecated)] @@ -84,17 +84,13 @@ pub async fn execute_circuit_with_black_box_solver( | OpcodeResolutionError::IndexOutOfBounds { opcode_location: ErrorLocation::Resolved(opcode_location), .. - } => ( - get_assert_message(&circuit.assert_messages, opcode_location), - Some(vec![*opcode_location]), - ), + } => { + (circuit.get_assert_message(*opcode_location), Some(vec![*opcode_location])) + } OpcodeResolutionError::BrilligFunctionFailed { call_stack, .. } => { let failing_opcode = call_stack.last().expect("Brillig error call stacks cannot be empty"); - ( - get_assert_message(&circuit.assert_messages, failing_opcode), - Some(call_stack.clone()), - ) + (circuit.get_assert_message(*failing_opcode), Some(call_stack.clone())) } _ => (None, None), }; @@ -117,15 +113,3 @@ pub async fn execute_circuit_with_black_box_solver( let witness_map = acvm.finalize(); Ok(witness_map.into()) } - -// Searches the slice for `opcode_location`. -// This is functionality equivalent to .get on a map. -fn get_assert_message( - assert_messages: &[(OpcodeLocation, String)], - opcode_location: &OpcodeLocation, -) -> Option { - assert_messages - .iter() - .find(|(loc, _)| loc == opcode_location) - .map(|(_, message)| message.clone()) -} diff --git a/tooling/nargo/src/ops/execute.rs b/tooling/nargo/src/ops/execute.rs index 5fd130c9412..cf14934d61e 100644 --- a/tooling/nargo/src/ops/execute.rs +++ b/tooling/nargo/src/ops/execute.rs @@ -15,15 +15,6 @@ pub fn execute_circuit( ) -> Result { let mut acvm = ACVM::new(blackbox_solver, &circuit.opcodes, initial_witness); - // Assert messages are not a map due to https://github.com/noir-lang/acvm/issues/522 - let get_assert_message = |opcode_location| { - circuit - .assert_messages - .iter() - .find(|(loc, _)| loc == opcode_location) - .map(|(_, message)| message.clone()) - }; - let mut foreign_call_executor = ForeignCallExecutor::default(); loop { @@ -47,10 +38,10 @@ pub fn execute_circuit( return Err(NargoError::ExecutionError(match call_stack { Some(call_stack) => { - if let Some(assert_message) = get_assert_message( - call_stack.last().expect("Call stacks should not be empty"), + if let Some(assert_message) = circuit.get_assert_message( + *call_stack.last().expect("Call stacks should not be empty"), ) { - ExecutionError::AssertionFailed(assert_message, call_stack) + ExecutionError::AssertionFailed(assert_message.to_owned(), call_stack) } else { ExecutionError::SolvingError(error) }