Skip to content

Commit

Permalink
Use ForeignCallExecutor from debug op
Browse files Browse the repository at this point in the history
  • Loading branch information
mverzilli committed Oct 3, 2023
1 parent fb7ad12 commit 0588df9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tooling/nargo/src/ops/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::artifacts::debug::DebugArtifact;
use crate::errors::ExecutionError;
use crate::NargoError;

use super::foreign_calls::ForeignCall;
use super::foreign_calls::ForeignCallExecutor;

use std::io::{self, Write};

Expand All @@ -30,6 +30,7 @@ pub fn debug_circuit<B: BlackBoxFunctionSolver>(
show_output: bool,
) -> Result<WitnessMap, NargoError> {
let mut acvm = ACVM::new(blackbox_solver, circuit.opcodes, initial_witness);
let mut foreign_call_executor = ForeignCallExecutor::default();

'outer: loop {
show_current_vm_status(&acvm, &debug_artifact);
Expand All @@ -43,15 +44,15 @@ pub fn debug_circuit<B: BlackBoxFunctionSolver>(
match command {
Command::Stop => return Err(NargoError::ExecutionError(ExecutionError::Halted)),
Command::Step => {
match step_opcode(&mut acvm, &circuit.assert_messages, show_output)? {
match step_opcode(&mut acvm, &circuit.assert_messages, show_output, &mut foreign_call_executor)? {
SolveResult::Done => break,
SolveResult::Ok => {},
}
}
Command::Continue => {
println!("(Continuing execution...)");
loop {
match step_opcode(&mut acvm, &circuit.assert_messages, show_output)? {
match step_opcode(&mut acvm, &circuit.assert_messages, show_output, &mut foreign_call_executor)? {
SolveResult::Done => break 'outer,
SolveResult::Ok => {},
}
Expand All @@ -68,6 +69,7 @@ fn step_opcode<B: BlackBoxFunctionSolver>(
acvm: &mut ACVM<B>,
assert_messages: &Vec<(OpcodeLocation, String)>,
show_output: bool,
foreign_call_executor: &mut ForeignCallExecutor,
) -> Result<SolveResult, NargoError> {
// Assert messages are not a map due to https://github.com/noir-lang/acvm/issues/522
let get_assert_message = |opcode_location| {
Expand Down Expand Up @@ -107,7 +109,7 @@ fn step_opcode<B: BlackBoxFunctionSolver>(
}))
}
ACVMStatus::RequiresForeignCall(foreign_call) => {
let foreign_call_result = ForeignCall::execute(&foreign_call, show_output)?;
let foreign_call_result = foreign_call_executor.execute(&foreign_call, show_output)?;
acvm.resolve_pending_foreign_call(foreign_call_result);
Ok(SolveResult::Ok)
}
Expand Down

0 comments on commit 0588df9

Please sign in to comment.