Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
chore: update acvm_js
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Sep 20, 2023
1 parent 09dff7c commit 24d382b
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions acvm_js/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub async fn execute_circuit_with_black_box_solver(
console_error_panic_hook::set_once();
let circuit: Circuit = Circuit::read(&*circuit).expect("Failed to deserialize circuit");

let mut acvm = ACVM::new(&solver.0, circuit.opcodes, initial_witness.into());
let mut acvm = ACVM::new(&solver.0, &circuit.opcodes, initial_witness.into());

loop {
let solver_status = acvm.solve();
Expand All @@ -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),
};
Expand All @@ -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<String> {
assert_messages
.iter()
.find(|(loc, _)| loc == opcode_location)
.map(|(_, message)| message.clone())
}

0 comments on commit 24d382b

Please sign in to comment.