Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(debugger): Inject abstract foreign call executor to debugger #3550

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions tooling/debugger/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use nargo::artifacts::debug::DebugArtifact;
use nargo::errors::{ExecutionError, Location};
use nargo::ops::{DefaultForeignCallExecutor, ForeignCallExecutor};
use nargo::ops::ForeignCallExecutor;
use nargo::NargoError;

use std::collections::{hash_set::Iter, HashSet};
Expand All @@ -24,7 +24,7 @@
pub(super) struct DebugContext<'a, B: BlackBoxFunctionSolver> {
acvm: ACVM<'a, B>,
brillig_solver: Option<BrilligSolver<'a, B>>,
foreign_call_executor: DefaultForeignCallExecutor,
foreign_call_executor: Box<dyn ForeignCallExecutor + 'a>,
debug_artifact: &'a DebugArtifact,
breakpoints: HashSet<OpcodeLocation>,
}
Expand All @@ -35,11 +35,12 @@
circuit: &'a Circuit,
debug_artifact: &'a DebugArtifact,
initial_witness: WitnessMap,
foreign_call_executor: Box<dyn ForeignCallExecutor + 'a>,
) -> Self {
Self {
acvm: ACVM::new(blackbox_solver, &circuit.opcodes, initial_witness),
brillig_solver: None,
foreign_call_executor: DefaultForeignCallExecutor::new(true),
foreign_call_executor,
debug_artifact,
breakpoints: HashSet::new(),
}
Expand Down Expand Up @@ -75,7 +76,7 @@
}
}

/// Returns the callstack in source code locations for the currently

Check warning on line 79 in tooling/debugger/src/context.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (callstack)
/// executing opcode. This can be `None` if the execution finished (and
/// `get_current_opcode_location()` returns `None`) or if the opcode is not
/// mapped to a specific source location in the debug artifact (which can
Expand Down Expand Up @@ -370,6 +371,8 @@
native_types::Expression,
};

use nargo::ops::DefaultForeignCallExecutor;

let fe_0 = FieldElement::zero();
let fe_1 = FieldElement::one();
let w_x = Witness(1);
Expand Down Expand Up @@ -404,7 +407,13 @@

let initial_witness = BTreeMap::from([(Witness(1), fe_1)]).into();

let mut context = DebugContext::new(blackbox_solver, circuit, debug_artifact, initial_witness);
let mut context = DebugContext::new(
blackbox_solver,
circuit,
debug_artifact,
initial_witness,
Box::new(DefaultForeignCallExecutor::new(true)),
);

assert_eq!(context.get_current_opcode_location(), Some(OpcodeLocation::Acir(0)));

Expand Down Expand Up @@ -449,6 +458,7 @@
native_types::Expression,
};
use acvm::brillig_vm::brillig::BinaryFieldOp;
use nargo::ops::DefaultForeignCallExecutor;

let fe_0 = FieldElement::zero();
let fe_1 = FieldElement::one();
Expand Down Expand Up @@ -502,7 +512,13 @@

let initial_witness = BTreeMap::from([(Witness(1), fe_1), (Witness(2), fe_1)]).into();

let mut context = DebugContext::new(blackbox_solver, circuit, debug_artifact, initial_witness);
let mut context = DebugContext::new(
blackbox_solver,
circuit,
debug_artifact,
initial_witness,
Box::new(DefaultForeignCallExecutor::new(true)),
);

// set breakpoint
let breakpoint_location = OpcodeLocation::Brillig { acir_index: 0, brillig_index: 1 };
Expand Down
13 changes: 9 additions & 4 deletions tooling/debugger/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use acvm::acir::native_types::{Witness, WitnessMap};
use acvm::{BlackBoxFunctionSolver, FieldElement};

use nargo::artifacts::debug::DebugArtifact;
use nargo::NargoError;
use nargo::{artifacts::debug::DebugArtifact, ops::DefaultForeignCallExecutor, NargoError};

use easy_repl::{command, CommandStatus, Repl};
use std::cell::RefCell;
Expand Down Expand Up @@ -33,8 +32,13 @@
debug_artifact: &'a DebugArtifact,
initial_witness: WitnessMap,
) -> Self {
let context =
DebugContext::new(blackbox_solver, circuit, debug_artifact, initial_witness.clone());
let context = DebugContext::new(
blackbox_solver,
circuit,
debug_artifact,
initial_witness.clone(),
Box::new(DefaultForeignCallExecutor::new(true)),
);
Self {
context,
blackbox_solver,
Expand Down Expand Up @@ -274,6 +278,7 @@
self.circuit,
self.debug_artifact,
self.initial_witness.clone(),
Box::new(DefaultForeignCallExecutor::new(true)),
);
for opcode_location in breakpoints {
self.context.add_breakpoint(opcode_location);
Expand Down Expand Up @@ -521,7 +526,7 @@
},
)
.add(
"regset",

Check warning on line 529 in tooling/debugger/src/repl.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (regset)
command! {
"update a Brillig register with the given value",
(index: usize, value: String) => |index, value| {
Expand Down
Loading