Skip to content

Commit

Permalink
feat: migrate to unified acvm-backend-barretenberg
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Apr 21, 2023
1 parent ef2ca28 commit ad822e6
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 44 deletions.
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.

8 changes: 3 additions & 5 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 = "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"
Expand All @@ -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"]

8 changes: 3 additions & 5 deletions crates/nargo_cli/src/backends.rs
Original file line number Diff line number Diff line change
@@ -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"
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(blaine): 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

0 comments on commit ad822e6

Please sign in to comment.