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
Next Next commit
chore: replace aztec_backend with acvm-backend-barretenberg
  • Loading branch information
TomAFrench committed Apr 25, 2023
commit 0f817dfd9476d37688f26897941803e917ad0537
40 changes: 16 additions & 24 deletions Cargo.lock

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

7 changes: 3 additions & 4 deletions crates/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 = "ba1d0d61b94de91b15044d97608907c21bfb5299", default-features=false }
vezenovm marked this conversation as resolved.
Show resolved Hide resolved

[dev-dependencies]
tempdir = "0.3.7"
@@ -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"
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/check_cmd.rs
Original file line number Diff line number Diff line change
@@ -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())?;

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
@@ -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
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
@@ -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 {
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/execute_cmd.rs
Original file line number Diff line number Diff line change
@@ -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)?;

2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/gates_cmd.rs
Original file line number Diff line number Diff line change
@@ -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();
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
@@ -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);
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/prove_cmd.rs
Original file line number Diff line number Diff line change
@@ -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)?,
4 changes: 2 additions & 2 deletions crates/nargo_cli/src/cli/test_cmd.rs
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion crates/nargo_cli/src/cli/verify_cmd.rs
Original file line number Diff line number Diff line change
@@ -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)?,