Skip to content

Commit

Permalink
feat(nargo)!: retire print-acir in favour of flag (#1328)
Browse files Browse the repository at this point in the history
feat!(nargo): retire print-acir in favour of flag
  • Loading branch information
joss-aztec committed May 16, 2023
1 parent a830ce5 commit dffa3c5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 44 deletions.
8 changes: 3 additions & 5 deletions crates/nargo_cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ mod compile_cmd;
mod execute_cmd;
mod gates_cmd;
mod new_cmd;
mod print_acir_cmd;
mod prove_cmd;
mod test_cmd;
mod verify_cmd;
Expand Down Expand Up @@ -56,7 +55,6 @@ enum NargoCommand {
Verify(verify_cmd::VerifyCommand),
Test(test_cmd::TestCommand),
Gates(gates_cmd::GatesCommand),
PrintAcir(print_acir_cmd::PrintAcirCommand),
}

pub fn start_cli() -> eyre::Result<()> {
Expand All @@ -79,18 +77,18 @@ pub fn start_cli() -> eyre::Result<()> {
NargoCommand::Test(args) => test_cmd::run(&backend, args, config),
NargoCommand::Gates(args) => gates_cmd::run(&backend, args, config),
NargoCommand::CodegenVerifier(args) => codegen_verifier_cmd::run(&backend, args, config),
NargoCommand::PrintAcir(args) => print_acir_cmd::run(&backend, args, config),
}?;

Ok(())
}

// helper function which tests noir programs by trying to generate a proof and verify it
pub fn prove_and_verify(proof_name: &str, program_dir: &Path, show_ssa: bool) -> bool {
pub fn prove_and_verify(proof_name: &str, program_dir: &Path) -> bool {
let backend = crate::backends::ConcreteBackend::default();

let compile_options = CompileOptions {
show_ssa,
show_ssa: false,
print_acir: false,
allow_warnings: false,
show_output: false,
experimental_ssa: false,
Expand Down
35 changes: 0 additions & 35 deletions crates/nargo_cli/src/cli/print_acir_cmd.rs

This file was deleted.

2 changes: 1 addition & 1 deletion crates/nargo_cli/tests/prove_and_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ mod tests {
println!("Running test {test_name}");

let verified = std::panic::catch_unwind(|| {
nargo_cli::cli::prove_and_verify("pp", test_program_dir, false)
nargo_cli::cli::prove_and_verify("pp", test_program_dir)
});

let r = match verified {
Expand Down
34 changes: 31 additions & 3 deletions crates/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ pub struct CompileOptions {
#[arg(short, long)]
pub show_ssa: bool,

/// Display the ACIR for compiled circuit
#[arg(short, long)]
pub print_acir: bool,

/// Issue a warning for each unused variable instead of an error
#[arg(short, long)]
pub allow_warnings: bool,
Expand All @@ -51,7 +55,13 @@ pub struct CompileOptions {

impl Default for CompileOptions {
fn default() -> Self {
Self { show_ssa: false, allow_warnings: false, show_output: true, experimental_ssa: false }
Self {
show_ssa: false,
print_acir: false,
allow_warnings: false,
show_output: true,
experimental_ssa: false,
}
}
}

Expand Down Expand Up @@ -188,7 +198,12 @@ impl Driver {
return Err(e);
}
};
self.compile_no_check(options, main)
let compiled_program = self.compile_no_check(options, main)?;
if options.print_acir {
println!("Compiled ACIR for main:");
println!("{}", compiled_program.circuit);
}
Ok(compiled_program)
}

/// Run the frontend to check the crate for errors then compile all contracts if there were none
Expand All @@ -198,7 +213,20 @@ impl Driver {
) -> Result<Vec<CompiledContract>, ReportedError> {
self.check_crate(options)?;
let contracts = self.get_all_contracts();
try_vecmap(contracts, |contract| self.compile_contract(contract, options))
let compiled_contracts =
try_vecmap(contracts, |contract| self.compile_contract(contract, options))?;
if options.print_acir {
for compiled_contract in &compiled_contracts {
for contract_function in &compiled_contract.functions {
println!(
"Compiled ACIR for {}::{}:",
compiled_contract.name, contract_function.name
);
println!("{}", contract_function.bytecode);
}
}
}
Ok(compiled_contracts)
}

/// Compile all of the functions associated with a Noir contract.
Expand Down

0 comments on commit dffa3c5

Please sign in to comment.