diff --git a/Cargo.lock b/Cargo.lock index 16617855169..58637dd7eb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,6 +46,20 @@ dependencies = [ "thiserror", ] +[[package]] +name = "acvm-backend-barretenberg" +version = "0.1.0" +source = "git+https://github.com/noir-lang/aztec_backend?rev=9fed6e52778d993d7742c46bbeec66087958c075#9fed6e52778d993d7742c46bbeec66087958c075" +dependencies = [ + "barretenberg-sys", + "cfg-if 1.0.0", + "common", + "getrandom", + "pkg-config", + "rust-embed", + "wasmer", +] + [[package]] name = "acvm_stdlib" version = "0.9.0" @@ -305,27 +319,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "barretenberg_static_lib" -version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=680457cf59ccd3f0b6db6fc545c606294964c72d#680457cf59ccd3f0b6db6fc545c606294964c72d" -dependencies = [ - "barretenberg-sys", - "common", -] - -[[package]] -name = "barretenberg_wasm" -version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=680457cf59ccd3f0b6db6fc545c606294964c72d#680457cf59ccd3f0b6db6fc545c606294964c72d" -dependencies = [ - "common", - "getrandom", - "pkg-config", - "rust-embed", - "wasmer", -] - [[package]] name = "base64" version = "0.21.0" @@ -621,7 +614,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=680457cf59ccd3f0b6db6fc545c606294964c72d#680457cf59ccd3f0b6db6fc545c606294964c72d" +source = "git+https://github.com/noir-lang/aztec_backend?rev=9fed6e52778d993d7742c46bbeec66087958c075#9fed6e52778d993d7742c46bbeec66087958c075" dependencies = [ "acvm", "blake2", @@ -1901,10 +1894,9 @@ name = "nargo_cli" version = "0.4.1" dependencies = [ "acvm", + "acvm-backend-barretenberg", "assert_cmd", "assert_fs", - "barretenberg_static_lib", - "barretenberg_wasm", "build-data", "cfg-if 1.0.0", "clap", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 7e7bcd87d3e..3d2bfe8754f 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -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 = "680457cf59ccd3f0b6db6fc545c606294964c72d" } -aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "680457cf59ccd3f0b6db6fc545c606294964c72d" } +aztec_backend = { optional = true, package = "acvm-backend-barretenberg", default-features = false, git = "https://github.com/noir-lang/aztec_backend", rev = "9fed6e52778d993d7742c46bbeec66087958c075" } [dev-dependencies] tempdir = "0.3.7" @@ -48,7 +47,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 = ["aztec_backend/native"] +plonk_bn254_wasm = ["aztec_backend/wasm"] diff --git a/crates/nargo_cli/src/backends.rs b/crates/nargo_cli/src/backends.rs index e1113279f80..25dd724ef5c 100644 --- a/crates/nargo_cli/src/backends.rs +++ b/crates/nargo_cli/src/backends.rs @@ -1,14 +1,12 @@ 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; + if #[cfg(any(feature = "plonk_bn254", feature = "plonk_bn254_wasm"))] { + pub(crate) use aztec_backend::Barretenberg as ConcreteBackend; } else { 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. +// Backend usage is mutually exclusive so we only want a single feature to be activated. #[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" diff --git a/crates/nargo_cli/src/cli/check_cmd.rs b/crates/nargo_cli/src/cli/check_cmd.rs index 557093444a1..3049c830def 100644 --- a/crates/nargo_cli/src/cli/check_cmd.rs +++ b/crates/nargo_cli/src/cli/check_cmd.rs @@ -24,7 +24,7 @@ pub(crate) fn run(args: CheckCommand, config: NargoConfig) -> Result<(), CliErro } fn check_from_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())?; diff --git a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs index 442f24c4b3b..97feb4c5286 100644 --- a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -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(blaine): Should this be a utility function? let circuit_build_path = args diff --git a/crates/nargo_cli/src/cli/compile_cmd.rs b/crates/nargo_cli/src/cli/compile_cmd.rs index 50c21486385..78b52003166 100644 --- a/crates/nargo_cli/src/cli/compile_cmd.rs +++ b/crates/nargo_cli/src/cli/compile_cmd.rs @@ -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 { diff --git a/crates/nargo_cli/src/cli/execute_cmd.rs b/crates/nargo_cli/src/cli/execute_cmd.rs index 9d1429bbda7..adeefc860a5 100644 --- a/crates/nargo_cli/src/cli/execute_cmd.rs +++ b/crates/nargo_cli/src/cli/execute_cmd.rs @@ -46,7 +46,7 @@ fn execute_with_path( program_dir: &Path, compile_options: &CompileOptions, ) -> Result<(Option, WitnessMap), CliError> { - let backend = crate::backends::ConcreteBackend; + let backend = crate::backends::ConcreteBackend::default(); let compiled_program = compile_circuit(&backend, program_dir, compile_options)?; diff --git a/crates/nargo_cli/src/cli/gates_cmd.rs b/crates/nargo_cli/src/cli/gates_cmd.rs index a5093b4d775..9fe9f5c7a53 100644 --- a/crates/nargo_cli/src/cli/gates_cmd.rs +++ b/crates/nargo_cli/src/cli/gates_cmd.rs @@ -23,7 +23,7 @@ fn count_gates_with_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(); diff --git a/crates/nargo_cli/src/cli/print_acir_cmd.rs b/crates/nargo_cli/src/cli/print_acir_cmd.rs index 589cc490f40..38b841121bc 100644 --- a/crates/nargo_cli/src/cli/print_acir_cmd.rs +++ b/crates/nargo_cli/src/cli/print_acir_cmd.rs @@ -22,7 +22,7 @@ fn print_acir_with_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); diff --git a/crates/nargo_cli/src/cli/prove_cmd.rs b/crates/nargo_cli/src/cli/prove_cmd.rs index fd60f004e2b..cecdee23fee 100644 --- a/crates/nargo_cli/src/cli/prove_cmd.rs +++ b/crates/nargo_cli/src/cli/prove_cmd.rs @@ -65,7 +65,7 @@ pub(crate) fn prove_with_path>( check_proof: bool, 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)?, diff --git a/crates/nargo_cli/src/cli/test_cmd.rs b/crates/nargo_cli/src/cli/test_cmd.rs index d168e6c39ca..65f8265a862 100644 --- a/crates/nargo_cli/src/cli/test_cmd.rs +++ b/crates/nargo_cli/src/cli/test_cmd.rs @@ -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())?; @@ -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) diff --git a/crates/nargo_cli/src/cli/verify_cmd.rs b/crates/nargo_cli/src/cli/verify_cmd.rs index cf2e4859091..07b7e351ee9 100644 --- a/crates/nargo_cli/src/cli/verify_cmd.rs +++ b/crates/nargo_cli/src/cli/verify_cmd.rs @@ -43,7 +43,7 @@ fn verify_with_path>( circuit_build_path: Option

, 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)?,