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): Run debugger REPL in thread #3611

Merged
merged 3 commits into from
Nov 29, 2023
Merged
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
47 changes: 32 additions & 15 deletions tooling/nargo_cli/src/cli/debug_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::path::PathBuf;

use acvm::acir::native_types::WitnessMap;
use clap::Args;

Expand Down Expand Up @@ -64,27 +66,42 @@ pub(crate) fn run(
&opcode_support,
)?;

println!("[{}] Starting debugger", package.name);
let (return_value, solved_witness) =
debug_program_and_decode(compiled_program, package, &args.prover_name)?;
run_async(package, compiled_program, &args.prover_name, &args.witness_name, target_dir)
}

fn run_async(
package: &Package,
program: CompiledProgram,
prover_name: &str,
witness_name: &Option<String>,
target_dir: &PathBuf,
) -> Result<(), CliError> {
use tokio::runtime::Builder;
let runtime = Builder::new_current_thread().enable_all().build().unwrap();

runtime.block_on(async {
println!("[{}] Starting debugger", package.name);
let (return_value, solved_witness) =
debug_program_and_decode(program, package, prover_name)?;

if let Some(solved_witness) = solved_witness {
println!("[{}] Circuit witness successfully solved", package.name);
if let Some(solved_witness) = solved_witness {
println!("[{}] Circuit witness successfully solved", package.name);

if let Some(return_value) = return_value {
println!("[{}] Circuit output: {return_value:?}", package.name);
}
if let Some(return_value) = return_value {
println!("[{}] Circuit output: {return_value:?}", package.name);
}

if let Some(witness_name) = &args.witness_name {
let witness_path = save_witness_to_dir(solved_witness, witness_name, target_dir)?;
if let Some(witness_name) = witness_name {
let witness_path = save_witness_to_dir(solved_witness, witness_name, target_dir)?;

println!("[{}] Witness saved to {}", package.name, witness_path.display());
println!("[{}] Witness saved to {}", package.name, witness_path.display());
}
} else {
println!("Debugger execution halted.");
}
} else {
println!("Debugger execution halted.");
}

Ok(())
Ok(())
})
}

fn debug_program_and_decode(
Expand Down
Loading