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(nargo): replace aztec_backend with acvm-backend-barretenberg #1226

Merged
merged 10 commits into from
May 1, 2023
144 changes: 28 additions & 116 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ edition = "2021"
rust-version = "1.66"

[workspace.dependencies]
acvm = "0.9.0"
acvm = "0.10.3"
arena = { path = "crates/arena" }
fm = { path = "crates/fm" }
iter-extended = { path = "crates/iter-extended" }
Expand Down
7 changes: 3 additions & 4 deletions crates/nargo/src/ops/execute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use acvm::PartialWitnessGenerator;
use acvm::{acir::circuit::Circuit, pwg::block::Blocks};
use acvm::{PartialWitnessGenerator, PartialWitnessGeneratorStatus};
use noirc_abi::WitnessMap;

use crate::NargoError;
Expand All @@ -10,9 +10,8 @@ pub fn execute_circuit(
mut initial_witness: WitnessMap,
) -> Result<WitnessMap, NargoError> {
let mut blocks = Blocks::default();
let (unresolved_opcodes, oracles) =
backend.solve(&mut initial_witness, &mut blocks, circuit.opcodes)?;
if !unresolved_opcodes.is_empty() || !oracles.is_empty() {
let solver_status = backend.solve(&mut initial_witness, &mut blocks, circuit.opcodes)?;
if matches!(solver_status, PartialWitnessGeneratorStatus::RequiresOracleData { .. }) {
todo!("Add oracle support to nargo execute")
}

Expand Down
7 changes: 3 additions & 4 deletions crates/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ termcolor = "1.1.2"
color-eyre = "0.6.2"

# Backends
aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "e3d4504f15e1295e637c4da80b1d08c87c267c45" }
aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "e3d4504f15e1295e637c4da80b1d08c87c267c45" }
acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "c9fb9e806f1400a2ff7594a0669bec56025220bb", default-features=false }

[dev-dependencies]
tempdir = "0.3.7"
Expand All @@ -49,6 +48,6 @@ predicates = "2.1.5"
[features]
default = ["plonk_bn254"]
# The plonk backend can only use bn254, so we do not specify the field
plonk_bn254 = ["aztec_backend"]
plonk_bn254_wasm = ["aztec_wasm_backend"]
plonk_bn254 = ["acvm-backend-barretenberg/native"]
plonk_bn254_wasm = ["acvm-backend-barretenberg/wasm"]

14 changes: 4 additions & 10 deletions crates/nargo_cli/src/backends.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
cfg_if::cfg_if! {
if #[cfg(feature = "plonk_bn254")] {
pub(crate) use aztec_backend::Plonk as ConcreteBackend;
} else if #[cfg(feature = "plonk_bn254_wasm")] {
pub(crate) use aztec_wasm_backend::Plonk as ConcreteBackend;
} else {
compile_error!("please specify a backend to compile with");
}
}
pub(crate) use acvm_backend_barretenberg::Barretenberg as ConcreteBackend;

#[cfg(not(any(feature = "plonk_bn254", feature = "plonk_bn254_wasm")))]
compile_error!("please specify a backend to compile with");

// As we have 3 feature flags we must test all 3 potential pairings to ensure they're mutually exclusive.
#[cfg(all(feature = "plonk_bn254", feature = "plonk_bn254_wasm"))]
compile_error!(
"feature \"plonk_bn254\" and feature \"plonk_bn254_wasm\" cannot be enabled at the same time"
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/check_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn run(args: CheckCommand, config: NargoConfig) -> Result<(), CliErro
}

fn check_from_path<P: AsRef<Path>>(p: P, compile_options: &CompileOptions) -> Result<(), CliError> {
let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

let mut driver = Resolver::resolve_root_manifest(p.as_ref(), backend.np_language())?;

Expand Down
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/codegen_verifier_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) struct CodegenVerifierCommand {
}

pub(crate) fn run(args: CodegenVerifierCommand, config: NargoConfig) -> Result<(), CliError> {
let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

// TODO(#1201): Should this be a utility function?
let circuit_build_path = args
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(crate) struct CompileCommand {
pub(crate) fn run(args: CompileCommand, config: NargoConfig) -> Result<(), CliError> {
let circuit_dir = config.program_dir.join(TARGET_DIR);

let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

// If contracts is set we're compiling every function in a 'contract' rather than just 'main'.
if args.contracts {
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/execute_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn execute_with_path(
program_dir: &Path,
compile_options: &CompileOptions,
) -> Result<(Option<InputValue>, WitnessMap), CliError> {
let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

let compiled_program = compile_circuit(&backend, program_dir, compile_options)?;

Expand Down
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/gates_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn count_gates_with_path<P: AsRef<Path>>(
program_dir: P,
compile_options: &CompileOptions,
) -> Result<(), CliError> {
let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

let compiled_program = compile_circuit(&backend, program_dir.as_ref(), compile_options)?;
let num_opcodes = compiled_program.circuit.opcodes.len();
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/print_acir_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn print_acir_with_path<P: AsRef<Path>>(
program_dir: P,
compile_options: &CompileOptions,
) -> Result<(), CliError> {
let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

let compiled_program = compile_circuit(&backend, program_dir.as_ref(), compile_options)?;
println!("{}", compiled_program.circuit);
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/prove_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) fn prove_with_path<P: AsRef<Path>>(
check_proof: bool,
compile_options: &CompileOptions,
) -> Result<Option<PathBuf>, CliError> {
let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

let preprocessed_program = match circuit_build_path {
Some(circuit_build_path) => read_program_from_file(circuit_build_path)?,
Expand Down
4 changes: 2 additions & 2 deletions crates/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn run_tests(
test_name: &str,
compile_options: &CompileOptions,
) -> Result<(), CliError> {
let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

let mut driver = Resolver::resolve_root_manifest(program_dir, backend.np_language())?;

Expand Down Expand Up @@ -79,7 +79,7 @@ fn run_test(
driver: &Driver,
config: &CompileOptions,
) -> Result<(), CliError> {
let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

let program = driver
.compile_no_check(config, main)
Expand Down
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/verify_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn verify_with_path<P: AsRef<Path>>(
circuit_build_path: Option<P>,
compile_options: CompileOptions,
) -> Result<(), CliError> {
let backend = crate::backends::ConcreteBackend;
let backend = crate::backends::ConcreteBackend::default();

let preprocessed_program = match circuit_build_path {
Some(circuit_build_path) => read_program_from_file(circuit_build_path)?,
Expand Down
Loading