diff --git a/acvm/src/lib.rs b/acvm/src/lib.rs index 0ad729b54..446fcd642 100644 --- a/acvm/src/lib.rs +++ b/acvm/src/lib.rs @@ -10,7 +10,7 @@ use acir::{ }; pub use blackbox_solver::{BlackBoxFunctionSolver, BlackBoxResolutionError}; use core::fmt::Debug; -use pwg::{OpcodeResolution, OpcodeResolutionError}; +use pwg::OpcodeResolutionError; // We re-export async-trait so consumers can attach it to their impl pub use async_trait::async_trait; diff --git a/acvm/src/pwg/arithmetic.rs b/acvm/src/pwg/arithmetic.rs index aa0a6de5e..ece0b30a5 100644 --- a/acvm/src/pwg/arithmetic.rs +++ b/acvm/src/pwg/arithmetic.rs @@ -4,7 +4,7 @@ use acir::{ FieldElement, }; -use super::{insert_value, OpcodeNotSolvable, OpcodeResolution, OpcodeResolutionError}; +use super::{insert_value, OpcodeNotSolvable, OpcodeResolutionError}; /// An Arithmetic solver will take a Circuit's arithmetic gates with witness assignments /// and create the other witness variables @@ -28,7 +28,7 @@ impl ArithmeticSolver { pub(super) fn solve( initial_witness: &mut WitnessMap, gate: &Expression, - ) -> Result { + ) -> Result<(), OpcodeResolutionError> { let gate = &ArithmeticSolver::evaluate(gate, initial_witness); // Evaluate multiplication term let mul_result = ArithmeticSolver::solve_mul_term(gate, initial_witness); @@ -37,9 +37,9 @@ impl ArithmeticSolver { match (mul_result, gate_status) { (MulTerm::TooManyUnknowns, _) | (_, GateStatus::GateUnsolvable) => { - Ok(OpcodeResolution::Stalled(OpcodeNotSolvable::ExpressionHasTooManyUnknowns( - gate.clone(), - ))) + Err(OpcodeResolutionError::OpcodeNotSolvable( + OpcodeNotSolvable::ExpressionHasTooManyUnknowns(gate.clone()), + )) } (MulTerm::OneUnknown(q, w1), GateStatus::GateSolvable(a, (b, w2))) => { if w1 == w2 { @@ -51,19 +51,19 @@ impl ArithmeticSolver { opcode_label: OpcodeLabel::Unresolved, }) } else { - Ok(OpcodeResolution::Solved) + Ok(()) } } else { let assignment = -total_sum / (q + b); // Add this into the witness assignments insert_value(&w1, assignment, initial_witness)?; - Ok(OpcodeResolution::Solved) + Ok(()) } } else { // TODO: can we be more specific with this error? - Ok(OpcodeResolution::Stalled(OpcodeNotSolvable::ExpressionHasTooManyUnknowns( - gate.clone(), - ))) + Err(OpcodeResolutionError::OpcodeNotSolvable( + OpcodeNotSolvable::ExpressionHasTooManyUnknowns(gate.clone()), + )) } } (MulTerm::OneUnknown(partial_prod, unknown_var), GateStatus::GateSatisfied(sum)) => { @@ -78,13 +78,13 @@ impl ArithmeticSolver { opcode_label: OpcodeLabel::Unresolved, }) } else { - Ok(OpcodeResolution::Solved) + Ok(()) } } else { let assignment = -(total_sum / partial_prod); // Add this into the witness assignments insert_value(&unknown_var, assignment, initial_witness)?; - Ok(OpcodeResolution::Solved) + Ok(()) } } (MulTerm::Solved(a), GateStatus::GateSatisfied(b)) => { @@ -95,7 +95,7 @@ impl ArithmeticSolver { opcode_label: OpcodeLabel::Unresolved, }) } else { - Ok(OpcodeResolution::Solved) + Ok(()) } } ( @@ -112,13 +112,13 @@ impl ArithmeticSolver { opcode_label: OpcodeLabel::Unresolved, }) } else { - Ok(OpcodeResolution::Solved) + Ok(()) } } else { let assignment = -(total_sum / coeff); // Add this into the witness assignments insert_value(&unknown_var, assignment, initial_witness)?; - Ok(OpcodeResolution::Solved) + Ok(()) } } } @@ -272,8 +272,8 @@ fn arithmetic_smoke_test() { values.insert(c, FieldElement::from(1_i128)); values.insert(d, FieldElement::from(1_i128)); - assert_eq!(ArithmeticSolver::solve(&mut values, &gate_a), Ok(OpcodeResolution::Solved)); - assert_eq!(ArithmeticSolver::solve(&mut values, &gate_b), Ok(OpcodeResolution::Solved)); + assert_eq!(ArithmeticSolver::solve(&mut values, &gate_a), Ok(())); + assert_eq!(ArithmeticSolver::solve(&mut values, &gate_b), Ok(())); assert_eq!(values.get(&a).unwrap(), &FieldElement::from(4_i128)); } diff --git a/acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs b/acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs index db65ff25a..6ace112e6 100644 --- a/acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs +++ b/acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs @@ -4,7 +4,7 @@ use acir::{ }; use crate::{ - pwg::{insert_value, witness_to_value, OpcodeResolution, OpcodeResolutionError}, + pwg::{insert_value, witness_to_value, OpcodeResolutionError}, BlackBoxFunctionSolver, }; @@ -13,7 +13,7 @@ pub(super) fn fixed_base_scalar_mul( initial_witness: &mut WitnessMap, input: FunctionInput, outputs: (Witness, Witness), -) -> Result { +) -> Result<(), OpcodeResolutionError> { let scalar = witness_to_value(initial_witness, input.witness)?; let (pub_x, pub_y) = backend.fixed_base_scalar_mul(scalar)?; @@ -21,5 +21,5 @@ pub(super) fn fixed_base_scalar_mul( insert_value(&outputs.0, pub_x, initial_witness)?; insert_value(&outputs.1, pub_y, initial_witness)?; - Ok(OpcodeResolution::Solved) + Ok(()) } diff --git a/acvm/src/pwg/blackbox/hash.rs b/acvm/src/pwg/blackbox/hash.rs index 4798a33f5..e2aecd0d1 100644 --- a/acvm/src/pwg/blackbox/hash.rs +++ b/acvm/src/pwg/blackbox/hash.rs @@ -6,7 +6,7 @@ use acir::{ use blackbox_solver::{hash_to_field_128_security, BlackBoxResolutionError}; use crate::pwg::{insert_value, witness_to_value}; -use crate::{pwg::OpcodeResolution, OpcodeResolutionError}; +use crate::OpcodeResolutionError; /// Attempts to solve a `HashToField128Security` opcode /// If successful, `initial_witness` will be mutated to contain the new witness assignment. @@ -14,13 +14,13 @@ pub(super) fn solve_hash_to_field( initial_witness: &mut WitnessMap, inputs: &[FunctionInput], output: &Witness, -) -> Result { +) -> Result<(), OpcodeResolutionError> { let message_input = get_hash_input(initial_witness, inputs, None)?; let field = hash_to_field_128_security(&message_input)?; insert_value(output, field, initial_witness)?; - Ok(OpcodeResolution::Solved) + Ok(()) } /// Attempts to solve a 256 bit hash function opcode. @@ -32,7 +32,7 @@ pub(super) fn solve_generic_256_hash_opcode( outputs: &[Witness], hash_function: fn(data: &[u8]) -> Result<[u8; 32], BlackBoxResolutionError>, black_box_func: BlackBoxFunc, -) -> Result { +) -> Result<(), OpcodeResolutionError> { let message_input = get_hash_input(initial_witness, inputs, var_message_size)?; let digest: [u8; 32] = hash_function(&message_input)?; @@ -44,7 +44,7 @@ pub(super) fn solve_generic_256_hash_opcode( })?; write_digest_to_outputs(initial_witness, outputs, digest)?; - Ok(OpcodeResolution::Solved) + Ok(()) } /// Reads the hash function input from a [`WitnessMap`]. diff --git a/acvm/src/pwg/blackbox/logic.rs b/acvm/src/pwg/blackbox/logic.rs index 094b33d55..432cac91b 100644 --- a/acvm/src/pwg/blackbox/logic.rs +++ b/acvm/src/pwg/blackbox/logic.rs @@ -1,5 +1,5 @@ use crate::pwg::{insert_value, witness_to_value}; -use crate::{pwg::OpcodeResolution, OpcodeResolutionError}; +use crate::OpcodeResolutionError; use acir::{ circuit::opcodes::FunctionInput, native_types::{Witness, WitnessMap}, @@ -13,7 +13,7 @@ pub(super) fn and( lhs: &FunctionInput, rhs: &FunctionInput, output: &Witness, -) -> Result { +) -> Result<(), OpcodeResolutionError> { assert_eq!( lhs.num_bits, rhs.num_bits, "number of bits specified for each input must be the same" @@ -30,7 +30,7 @@ pub(super) fn xor( lhs: &FunctionInput, rhs: &FunctionInput, output: &Witness, -) -> Result { +) -> Result<(), OpcodeResolutionError> { assert_eq!( lhs.num_bits, rhs.num_bits, "number of bits specified for each input must be the same" @@ -47,11 +47,10 @@ fn solve_logic_gate( b: &Witness, result: Witness, logic_op: impl Fn(&FieldElement, &FieldElement) -> FieldElement, -) -> Result { +) -> Result<(), OpcodeResolutionError> { let w_l_value = witness_to_value(initial_witness, *a)?; let w_r_value = witness_to_value(initial_witness, *b)?; let assignment = logic_op(w_l_value, w_r_value); - insert_value(&result, assignment, initial_witness)?; - Ok(OpcodeResolution::Solved) + insert_value(&result, assignment, initial_witness) } diff --git a/acvm/src/pwg/blackbox/mod.rs b/acvm/src/pwg/blackbox/mod.rs index c0280c60c..511a55f32 100644 --- a/acvm/src/pwg/blackbox/mod.rs +++ b/acvm/src/pwg/blackbox/mod.rs @@ -4,7 +4,7 @@ use acir::{ }; use blackbox_solver::{blake2s, keccak256, sha256}; -use super::{OpcodeNotSolvable, OpcodeResolution, OpcodeResolutionError}; +use super::{OpcodeNotSolvable, OpcodeResolutionError}; use crate::BlackBoxFunctionSolver; mod fixed_base_scalar_mul; @@ -50,14 +50,14 @@ pub(crate) fn solve( backend: &impl BlackBoxFunctionSolver, initial_witness: &mut WitnessMap, bb_func: &BlackBoxFuncCall, -) -> Result { +) -> Result<(), OpcodeResolutionError> { let inputs = bb_func.get_inputs_vec(); if !contains_all_inputs(initial_witness, &inputs) { let unassigned_witness = first_missing_assignment(initial_witness, &inputs) .expect("Some assignments must be missing because it does not contains all inputs"); - return Ok(OpcodeResolution::Stalled(OpcodeNotSolvable::MissingAssignment( - unassigned_witness.0, - ))); + return Err(OpcodeResolutionError::OpcodeNotSolvable( + OpcodeNotSolvable::MissingAssignment(unassigned_witness.0), + )); } match bb_func { @@ -150,6 +150,6 @@ pub(crate) fn solve( BlackBoxFuncCall::FixedBaseScalarMul { input, outputs } => { fixed_base_scalar_mul(backend, initial_witness, *input, *outputs) } - BlackBoxFuncCall::RecursiveAggregation { .. } => Ok(OpcodeResolution::Solved), + BlackBoxFuncCall::RecursiveAggregation { .. } => Ok(()), } } diff --git a/acvm/src/pwg/blackbox/pedersen.rs b/acvm/src/pwg/blackbox/pedersen.rs index 83ef33c23..44b4c91dc 100644 --- a/acvm/src/pwg/blackbox/pedersen.rs +++ b/acvm/src/pwg/blackbox/pedersen.rs @@ -4,7 +4,7 @@ use acir::{ }; use crate::{ - pwg::{insert_value, witness_to_value, OpcodeResolution, OpcodeResolutionError}, + pwg::{insert_value, witness_to_value, OpcodeResolutionError}, BlackBoxFunctionSolver, }; @@ -14,7 +14,7 @@ pub(super) fn pedersen( inputs: &[FunctionInput], domain_separator: u32, outputs: (Witness, Witness), -) -> Result { +) -> Result<(), OpcodeResolutionError> { let scalars: Result, _> = inputs.iter().map(|input| witness_to_value(initial_witness, input.witness)).collect(); let scalars: Vec<_> = scalars?.into_iter().cloned().collect(); @@ -24,5 +24,5 @@ pub(super) fn pedersen( insert_value(&outputs.0, res_x, initial_witness)?; insert_value(&outputs.1, res_y, initial_witness)?; - Ok(OpcodeResolution::Solved) + Ok(()) } diff --git a/acvm/src/pwg/blackbox/range.rs b/acvm/src/pwg/blackbox/range.rs index 5e2ecc5ec..86f3470a3 100644 --- a/acvm/src/pwg/blackbox/range.rs +++ b/acvm/src/pwg/blackbox/range.rs @@ -1,4 +1,4 @@ -use crate::{pwg::witness_to_value, pwg::OpcodeResolution, OpcodeResolutionError}; +use crate::{pwg::witness_to_value, OpcodeResolutionError}; use acir::{ circuit::{opcodes::FunctionInput, OpcodeLabel}, native_types::WitnessMap, @@ -7,12 +7,12 @@ use acir::{ pub(super) fn solve_range_opcode( initial_witness: &mut WitnessMap, input: &FunctionInput, -) -> Result { +) -> Result<(), OpcodeResolutionError> { let w_value = witness_to_value(initial_witness, input.witness)?; if w_value.num_bits() > input.num_bits { return Err(OpcodeResolutionError::UnsatisfiedConstrain { opcode_label: OpcodeLabel::Unresolved, }); } - Ok(OpcodeResolution::Solved) + Ok(()) } diff --git a/acvm/src/pwg/blackbox/signature/ecdsa.rs b/acvm/src/pwg/blackbox/signature/ecdsa.rs index 5828cb45b..5910a7a33 100644 --- a/acvm/src/pwg/blackbox/signature/ecdsa.rs +++ b/acvm/src/pwg/blackbox/signature/ecdsa.rs @@ -5,10 +5,7 @@ use acir::{ }; use blackbox_solver::{ecdsa_secp256k1_verify, ecdsa_secp256r1_verify}; -use crate::{ - pwg::{insert_value, OpcodeResolution}, - OpcodeResolutionError, -}; +use crate::{pwg::insert_value, OpcodeResolutionError}; use super::to_u8_vec; @@ -19,7 +16,7 @@ pub(crate) fn secp256k1_prehashed( signature_inputs: &[FunctionInput], hashed_message_inputs: &[FunctionInput], output: Witness, -) -> Result { +) -> Result<(), OpcodeResolutionError> { let hashed_message = to_u8_vec(initial_witness, hashed_message_inputs)?; // These errors should never be emitted in practice as they would imply malformed ACIR generation. @@ -50,7 +47,7 @@ pub(crate) fn secp256k1_prehashed( let is_valid = ecdsa_secp256k1_verify(&hashed_message, &pub_key_x, &pub_key_y, &signature)?; insert_value(&output, FieldElement::from(is_valid), initial_witness)?; - Ok(OpcodeResolution::Solved) + Ok(()) } pub(crate) fn secp256r1_prehashed( @@ -60,7 +57,7 @@ pub(crate) fn secp256r1_prehashed( signature_inputs: &[FunctionInput], hashed_message_inputs: &[FunctionInput], output: Witness, -) -> Result { +) -> Result<(), OpcodeResolutionError> { let hashed_message = to_u8_vec(initial_witness, hashed_message_inputs)?; let pub_key_x: [u8; 32] = @@ -90,5 +87,5 @@ pub(crate) fn secp256r1_prehashed( let is_valid = ecdsa_secp256r1_verify(&hashed_message, &pub_key_x, &pub_key_y, &signature)?; insert_value(&output, FieldElement::from(is_valid), initial_witness)?; - Ok(OpcodeResolution::Solved) + Ok(()) } diff --git a/acvm/src/pwg/blackbox/signature/schnorr.rs b/acvm/src/pwg/blackbox/signature/schnorr.rs index 05509bcb6..7f5381cee 100644 --- a/acvm/src/pwg/blackbox/signature/schnorr.rs +++ b/acvm/src/pwg/blackbox/signature/schnorr.rs @@ -1,6 +1,6 @@ use super::to_u8_vec; use crate::{ - pwg::{insert_value, witness_to_value, OpcodeResolution, OpcodeResolutionError}, + pwg::{insert_value, witness_to_value, OpcodeResolutionError}, BlackBoxFunctionSolver, }; use acir::{ @@ -18,7 +18,7 @@ pub(crate) fn schnorr_verify( signature: &[FunctionInput], message: &[FunctionInput], output: Witness, -) -> Result { +) -> Result<(), OpcodeResolutionError> { let public_key_x: &FieldElement = witness_to_value(initial_witness, public_key_x.witness)?; let public_key_y: &FieldElement = witness_to_value(initial_witness, public_key_y.witness)?; @@ -31,5 +31,5 @@ pub(crate) fn schnorr_verify( insert_value(&output, FieldElement::from(valid_signature), initial_witness)?; - Ok(OpcodeResolution::Solved) + Ok(()) } diff --git a/acvm/src/pwg/brillig.rs b/acvm/src/pwg/brillig.rs index acdc59322..41c880c9a 100644 --- a/acvm/src/pwg/brillig.rs +++ b/acvm/src/pwg/brillig.rs @@ -7,7 +7,7 @@ use acir::{ use blackbox_solver::BlackBoxFunctionSolver; use brillig_vm::{Registers, VMStatus, VM}; -use crate::{pwg::OpcodeNotSolvable, OpcodeResolution, OpcodeResolutionError}; +use crate::{pwg::OpcodeNotSolvable, OpcodeResolutionError}; use super::{get_value, insert_value}; @@ -18,24 +18,18 @@ impl BrilligSolver { initial_witness: &mut WitnessMap, brillig: &Brillig, bb_solver: &B, - ) -> Result { + ) -> Result, OpcodeResolutionError> { // If the predicate is `None`, then we simply return the value 1 // If the predicate is `Some` but we cannot find a value, then we return stalled let pred_value = match &brillig.predicate { Some(pred) => get_value(pred, initial_witness), None => Ok(FieldElement::one()), - }; - let pred_value = match pred_value { - Ok(pred_value) => pred_value, - Err(OpcodeResolutionError::OpcodeNotSolvable(unsolved)) => { - return Ok(OpcodeResolution::Stalled(unsolved)) - } - Err(err) => return Err(err), - }; + }?; // A zero predicate indicates the oracle should be skipped, and its outputs zeroed. if pred_value.is_zero() { - return Self::zero_out_brillig_outputs(initial_witness, brillig); + Self::zero_out_brillig_outputs(initial_witness, brillig)?; + return Ok(None); } // Set input values @@ -50,7 +44,7 @@ impl BrilligSolver { BrilligInputs::Single(expr) => match get_value(expr, initial_witness) { Ok(value) => input_register_values.push(value.into()), Err(_) => { - return Ok(OpcodeResolution::Stalled( + return Err(OpcodeResolutionError::OpcodeNotSolvable( OpcodeNotSolvable::ExpressionHasTooManyUnknowns(expr.clone()), )) } @@ -62,7 +56,7 @@ impl BrilligSolver { match get_value(expr, initial_witness) { Ok(value) => input_memory.push(value.into()), Err(_) => { - return Ok(OpcodeResolution::Stalled( + return Err(OpcodeResolutionError::OpcodeNotSolvable( OpcodeNotSolvable::ExpressionHasTooManyUnknowns(expr.clone()), )) } @@ -93,7 +87,7 @@ impl BrilligSolver { // It may be finished, in-progress, failed, or may be waiting for results of a foreign call. // Return the "resolution" to the caller who may choose to make subsequent calls // (when it gets foreign call results for example). - let result = match vm_status { + match vm_status { VMStatus::Finished => { for (i, output) in brillig.outputs.iter().enumerate() { let register_value = vm.get_registers().get(RegisterIndex::from(i)); @@ -110,25 +104,23 @@ impl BrilligSolver { } } } - OpcodeResolution::Solved + Ok(None) } VMStatus::InProgress => unreachable!("Brillig VM has not completed execution"), VMStatus::Failure { message } => { - return Err(OpcodeResolutionError::BrilligFunctionFailed(message)) + Err(OpcodeResolutionError::BrilligFunctionFailed(message)) } VMStatus::ForeignCallWait { function, inputs } => { - OpcodeResolution::InProgressBrillig(ForeignCallWaitInfo { function, inputs }) + Ok(Some(ForeignCallWaitInfo { function, inputs })) } - }; - - Ok(result) + } } /// Assigns the zero value to all outputs of the given [`Brillig`] bytecode. fn zero_out_brillig_outputs( initial_witness: &mut WitnessMap, brillig: &Brillig, - ) -> Result { + ) -> Result<(), OpcodeResolutionError> { for output in &brillig.outputs { match output { BrilligOutputs::Simple(witness) => { @@ -141,7 +133,7 @@ impl BrilligSolver { } } } - Ok(OpcodeResolution::Solved) + Ok(()) } } diff --git a/acvm/src/pwg/directives/mod.rs b/acvm/src/pwg/directives/mod.rs index 0794daff7..9528f7fb5 100644 --- a/acvm/src/pwg/directives/mod.rs +++ b/acvm/src/pwg/directives/mod.rs @@ -11,7 +11,7 @@ use acir::{ use num_bigint::BigUint; use num_traits::Zero; -use crate::{pwg::OpcodeResolution, OpcodeResolutionError}; +use crate::OpcodeResolutionError; use super::{get_value, insert_value, witness_to_value}; @@ -26,24 +26,12 @@ mod sorting; pub(super) fn solve_directives( initial_witness: &mut WitnessMap, directive: &Directive, -) -> Result { - match solve_directives_internal(initial_witness, directive) { - Ok(_) => Ok(OpcodeResolution::Solved), - Err(OpcodeResolutionError::OpcodeNotSolvable(unsolved)) => { - Ok(OpcodeResolution::Stalled(unsolved)) - } - Err(err) => Err(err), - } -} - -fn solve_directives_internal( - initial_witness: &mut WitnessMap, - directive: &Directive, ) -> Result<(), OpcodeResolutionError> { match directive { Directive::Invert { x, result } => { let val = witness_to_value(initial_witness, *x)?; - insert_value(result, val.inverse(), initial_witness) + insert_value(result, val.inverse(), initial_witness)?; + Ok(()) } Directive::Quotient(QuotientDirective { a, b, q, r, predicate }) => { let val_a = get_value(a, initial_witness)?; @@ -197,7 +185,7 @@ mod tests { FieldElement, }; - use super::solve_directives_internal; + use super::solve_directives; #[test] fn divisor_is_zero() { @@ -212,7 +200,7 @@ mod tests { let mut witness_map = WitnessMap::new(); witness_map.insert(Witness(0), FieldElement::zero()); - solve_directives_internal(&mut witness_map, &Directive::Quotient(quotient_directive)) + solve_directives(&mut witness_map, &Directive::Quotient(quotient_directive)) .expect("expected 0/0 to return 0"); } } diff --git a/acvm/src/pwg/mod.rs b/acvm/src/pwg/mod.rs index 7754456a9..136ed7c92 100644 --- a/acvm/src/pwg/mod.rs +++ b/acvm/src/pwg/mod.rs @@ -50,18 +50,6 @@ pub enum ACVMStatus { RequiresForeignCall(ForeignCallWaitInfo), } -#[derive(Debug, PartialEq)] -pub enum OpcodeResolution { - /// The opcode is resolved - Solved, - /// The opcode is not solvable - Stalled(OpcodeNotSolvable), - /// The opcode is not solvable but could resolved some witness - InProgress, - /// The brillig oracle opcode is not solved but could be resolved given some values - InProgressBrillig(brillig::ForeignCallWaitInfo), -} - // This enum represents the different cases in which an // opcode can be unsolvable. // The most common being that one of its input has not been @@ -227,21 +215,16 @@ impl ACVM { Opcode::Directive(directive) => solve_directives(&mut self.witness_map, directive), Opcode::MemoryInit { block_id, init } => { let solver = self.block_solvers.entry(*block_id).or_default(); - solver.init(init, &self.witness_map).map(|_| OpcodeResolution::Solved) + solver.init(init, &self.witness_map) } Opcode::MemoryOp { block_id, op } => { let solver = self.block_solvers.entry(*block_id).or_default(); - solver.solve_memory_op(op, &mut self.witness_map).map(|_| OpcodeResolution::Solved) + solver.solve_memory_op(op, &mut self.witness_map) } Opcode::Brillig(brillig) => { - let resolution = - BrilligSolver::solve(&mut self.witness_map, brillig, &self.backend); - - match resolution { - Ok(OpcodeResolution::InProgressBrillig(foreign_call)) => { - return self.wait_for_foreign_call(foreign_call) - } - res => res, + match BrilligSolver::solve(&mut self.witness_map, brillig, &self.backend) { + Ok(Some(foreign_call)) => return self.wait_for_foreign_call(foreign_call), + res => res.map(|_| ()), } } Opcode::Block(_) | Opcode::ROM(_) | Opcode::RAM(_) => { @@ -249,7 +232,7 @@ impl ACVM { } }; match resolution { - Ok(OpcodeResolution::Solved) => { + Ok(()) => { self.instruction_pointer += 1; if self.instruction_pointer == self.opcodes.len() { self.status(ACVMStatus::Solved) @@ -257,15 +240,6 @@ impl ACVM { self.status(ACVMStatus::InProgress) } } - Ok(OpcodeResolution::InProgress) => { - unreachable!("Opcodes_and_labels should be immediately solvable"); - } - Ok(OpcodeResolution::InProgressBrillig(_)) => { - unreachable!("Handled above") - } - Ok(OpcodeResolution::Stalled(not_solvable)) => { - self.fail(OpcodeResolutionError::OpcodeNotSolvable(not_solvable)) - } Err(mut error) => { let opcode_label = OpcodeLabel::Resolved(self.instruction_pointer.try_into().unwrap());