From de6448ddb49ddfa5a7260483ef60a0745952aadb Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 8 May 2023 14:05:49 -0700 Subject: [PATCH 01/12] chore!: Update to acvm 0.11.0 --- Cargo.lock | 78 +++++++++++++++++++++++++++++++++++++++++++++--------- Cargo.toml | 2 +- 2 files changed, 67 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a631368870..7c0fe5eefd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,7 +8,19 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "510b65efd4d20bf266185ce0a5dc7d29bcdd196a6a1835c20908fd88040de76c" dependencies = [ - "acir_field", + "acir_field 0.10.3", + "flate2", + "rmp-serde", + "serde", +] + +[[package]] +name = "acir" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "084577e67b44c72d1cdfabe286d48adac6f5e0ad441ef134c5c467f4b6eee291" +dependencies = [ + "acir_field 0.11.0", "flate2", "rmp-serde", "serde", @@ -28,14 +40,28 @@ dependencies = [ "serde", ] +[[package]] +name = "acir_field" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a267ef529f4b132293199ecdf8c232ade817f01d916039f2d34562cab39e75e9" +dependencies = [ + "ark-bn254", + "ark-ff", + "cfg-if 1.0.0", + "hex", + "num-bigint", + "serde", +] + [[package]] name = "acvm" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2611266039740ffd1978f23258bd6ce3166c22cf15b8227685c2f3bb20ae2ee0" dependencies = [ - "acir", - "acvm_stdlib", + "acir 0.10.3", + "acvm_stdlib 0.10.3", "blake2", "crc32fast", "indexmap", @@ -46,12 +72,31 @@ dependencies = [ "thiserror", ] +[[package]] +name = "acvm" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e1d6795105b50b13fa0dd1779b5191c4d8e9cd98b357b0b9a0b04a847baacf0" +dependencies = [ + "acir 0.11.0", + "acvm_stdlib 0.11.0", + "blake2", + "crc32fast", + "indexmap", + "k256", + "num-bigint", + "num-traits", + "sha2 0.9.9", + "sha3", + "thiserror", +] + [[package]] name = "acvm-backend-barretenberg" version = "0.0.0" source = "git+https://github.com/noir-lang/aztec_backend?rev=677f10e07011849f8aa0d75fe80390bb3081b1e5#677f10e07011849f8aa0d75fe80390bb3081b1e5" dependencies = [ - "acvm", + "acvm 0.10.3", "barretenberg-sys", "blake2", "dirs 3.0.2", @@ -72,7 +117,16 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5ec51160c66eba75dc15a028a2391675386fd395b3897478d89a386c64a48dd" dependencies = [ - "acir", + "acir 0.10.3", +] + +[[package]] +name = "acvm_stdlib" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3131af53d17ac12340c0ff50f8555d8e040321f8078b8ee3cd8846560b6a44a9" +dependencies = [ + "acir 0.11.0", ] [[package]] @@ -1857,7 +1911,7 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" name = "nargo" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0", "iter-extended", "noirc_abi", "noirc_driver", @@ -1871,7 +1925,7 @@ dependencies = [ name = "nargo_cli" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0", "acvm-backend-barretenberg", "assert_cmd", "assert_fs", @@ -1902,7 +1956,7 @@ dependencies = [ name = "noir_wasm" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0", "build-data", "console_error_panic_hook", "gloo-utils", @@ -1918,7 +1972,7 @@ dependencies = [ name = "noirc_abi" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0", "iter-extended", "serde", "serde_json", @@ -1930,7 +1984,7 @@ dependencies = [ name = "noirc_driver" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0", "clap", "fm", "iter-extended", @@ -1956,7 +2010,7 @@ dependencies = [ name = "noirc_evaluator" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0", "arena", "iter-extended", "noirc_abi", @@ -1972,7 +2026,7 @@ dependencies = [ name = "noirc_frontend" version = "0.5.1" dependencies = [ - "acvm", + "acvm 0.11.0", "arena", "chumsky", "fm", diff --git a/Cargo.toml b/Cargo.toml index badaab032ce..4169aa9b6eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2021" rust-version = "1.66" [workspace.dependencies] -acvm = "0.10.3" +acvm = "0.11.0" arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } From b780236d854395c2e6ae17ed4ddbcb42d9144752 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 8 May 2023 14:07:10 -0700 Subject: [PATCH 02/12] chore: Update nargo core to return backend errors --- Cargo.lock | 1 - crates/nargo/Cargo.toml | 1 - crates/nargo/src/ops/codegen_verifier.rs | 10 +++---- crates/nargo/src/ops/preprocess.rs | 37 ++++++++++++------------ crates/nargo/src/ops/prove.rs | 12 +++----- crates/nargo/src/ops/verify.rs | 12 +++----- 6 files changed, 30 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c0fe5eefd7..609fa9e21da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1912,7 +1912,6 @@ name = "nargo" version = "0.5.1" dependencies = [ "acvm 0.11.0", - "iter-extended", "noirc_abi", "noirc_driver", "rustc_version", diff --git a/crates/nargo/Cargo.toml b/crates/nargo/Cargo.toml index 8d3c9fbd3cd..77c881835dc 100644 --- a/crates/nargo/Cargo.toml +++ b/crates/nargo/Cargo.toml @@ -14,7 +14,6 @@ rustc_version = "0.4.0" acvm.workspace = true noirc_abi.workspace = true noirc_driver.workspace = true -iter-extended.workspace = true toml.workspace = true serde.workspace = true thiserror.workspace = true diff --git a/crates/nargo/src/ops/codegen_verifier.rs b/crates/nargo/src/ops/codegen_verifier.rs index ead125699b4..44b44598c51 100644 --- a/crates/nargo/src/ops/codegen_verifier.rs +++ b/crates/nargo/src/ops/codegen_verifier.rs @@ -1,10 +1,8 @@ use acvm::SmartContract; -use crate::NargoError; - -pub fn codegen_verifier( - backend: &impl SmartContract, +pub fn codegen_verifier( + backend: &Backend, verification_key: &[u8], -) -> Result { - Ok(backend.eth_contract_from_vk(verification_key)) +) -> Result { + backend.eth_contract_from_vk(verification_key) } diff --git a/crates/nargo/src/ops/preprocess.rs b/crates/nargo/src/ops/preprocess.rs index f8d4eb5a825..4c058251680 100644 --- a/crates/nargo/src/ops/preprocess.rs +++ b/crates/nargo/src/ops/preprocess.rs @@ -1,26 +1,22 @@ use acvm::ProofSystemCompiler; -use iter_extended::vecmap; use noirc_driver::{CompiledContract, CompiledProgram}; -use crate::{ - artifacts::{ - contract::{PreprocessedContract, PreprocessedContractFunction}, - program::PreprocessedProgram, - }, - NargoError, +use crate::artifacts::{ + contract::{PreprocessedContract, PreprocessedContractFunction}, + program::PreprocessedProgram, }; // TODO: pull this from backend. const BACKEND_IDENTIFIER: &str = "acvm-backend-barretenberg"; -pub fn preprocess_program( - backend: &impl ProofSystemCompiler, +pub fn preprocess_program( + backend: &Backend, compiled_program: CompiledProgram, -) -> Result { +) -> Result { // TODO: currently `compiled_program`'s bytecode is already optimized for the backend. // In future we'll need to apply those optimizations here. let optimized_bytecode = compiled_program.circuit; - let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode); + let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode)?; Ok(PreprocessedProgram { backend: String::from(BACKEND_IDENTIFIER), @@ -31,17 +27,18 @@ pub fn preprocess_program( }) } -pub fn preprocess_contract( - backend: &impl ProofSystemCompiler, +pub fn preprocess_contract( + backend: &Backend, compiled_contract: CompiledContract, -) -> Result { - let preprocessed_contract_functions = vecmap(compiled_contract.functions, |func| { +) -> Result { + let mut preprocessed_contract_functions = vec![]; + for func in compiled_contract.functions.into_iter() { // TODO: currently `func`'s bytecode is already optimized for the backend. // In future we'll need to apply those optimizations here. let optimized_bytecode = func.bytecode; - let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode); + let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode)?; - PreprocessedContractFunction { + let preprocessed = PreprocessedContractFunction { name: func.name, function_type: func.function_type, abi: func.abi, @@ -49,8 +46,10 @@ pub fn preprocess_contract( bytecode: optimized_bytecode, proving_key, verification_key, - } - }); + }; + + preprocessed_contract_functions.push(preprocessed); + } Ok(PreprocessedContract { name: compiled_contract.name, diff --git a/crates/nargo/src/ops/prove.rs b/crates/nargo/src/ops/prove.rs index 376220a8a74..4f305e329d4 100644 --- a/crates/nargo/src/ops/prove.rs +++ b/crates/nargo/src/ops/prove.rs @@ -2,15 +2,11 @@ use acvm::acir::circuit::Circuit; use acvm::ProofSystemCompiler; use noirc_abi::WitnessMap; -use crate::NargoError; - -pub fn prove_execution( - backend: &impl ProofSystemCompiler, +pub fn prove_execution( + backend: &Backend, circuit: &Circuit, solved_witness: WitnessMap, proving_key: &[u8], -) -> Result, NargoError> { - let proof = backend.prove_with_pk(circuit, solved_witness, proving_key); - - Ok(proof) +) -> Result, Backend::Error> { + backend.prove_with_pk(circuit, solved_witness, proving_key) } diff --git a/crates/nargo/src/ops/verify.rs b/crates/nargo/src/ops/verify.rs index 5109d2291db..9bb06a2f317 100644 --- a/crates/nargo/src/ops/verify.rs +++ b/crates/nargo/src/ops/verify.rs @@ -2,16 +2,12 @@ use acvm::acir::circuit::Circuit; use acvm::ProofSystemCompiler; use noirc_abi::WitnessMap; -use crate::NargoError; - -pub fn verify_proof( - backend: &impl ProofSystemCompiler, +pub fn verify_proof( + backend: &Backend, circuit: &Circuit, proof: &[u8], public_inputs: WitnessMap, verification_key: &[u8], -) -> Result { - let valid_proof = backend.verify_with_vk(proof, public_inputs, circuit, verification_key); - - Ok(valid_proof) +) -> Result { + backend.verify_with_vk(proof, public_inputs, circuit, verification_key) } From 383e7b8ebe3a2afb13340ab55428c93eeeed4bd8 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 8 May 2023 14:13:47 -0700 Subject: [PATCH 03/12] chore: Make CliError generic over a Backend chore!: Split filesystem errors off from CliError chore!: Make all run functions take a backend and pass it from the CLI entry --- Cargo.lock | 81 ++++--------------- crates/nargo_cli/Cargo.toml | 2 +- crates/nargo_cli/src/cli/check_cmd.rs | 27 ++++--- .../nargo_cli/src/cli/codegen_verifier_cmd.rs | 17 ++-- crates/nargo_cli/src/cli/compile_cmd.rs | 36 +++++---- crates/nargo_cli/src/cli/execute_cmd.rs | 27 ++++--- crates/nargo_cli/src/cli/fs/inputs.rs | 8 +- crates/nargo_cli/src/cli/fs/mod.rs | 10 +-- crates/nargo_cli/src/cli/fs/program.rs | 7 +- crates/nargo_cli/src/cli/fs/proof.rs | 4 +- crates/nargo_cli/src/cli/fs/witness.rs | 4 +- crates/nargo_cli/src/cli/gates_cmd.rs | 23 +++--- crates/nargo_cli/src/cli/mod.rs | 25 +++--- crates/nargo_cli/src/cli/new_cmd.rs | 10 ++- crates/nargo_cli/src/cli/print_acir_cmd.rs | 18 +++-- crates/nargo_cli/src/cli/prove_cmd.rs | 29 ++++--- crates/nargo_cli/src/cli/test_cmd.rs | 28 ++++--- crates/nargo_cli/src/cli/verify_cmd.rs | 23 ++++-- crates/nargo_cli/src/errors.rs | 37 ++++++--- 19 files changed, 220 insertions(+), 196 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 609fa9e21da..13b78dc5e88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,44 +2,18 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "acir" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510b65efd4d20bf266185ce0a5dc7d29bcdd196a6a1835c20908fd88040de76c" -dependencies = [ - "acir_field 0.10.3", - "flate2", - "rmp-serde", - "serde", -] - [[package]] name = "acir" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "084577e67b44c72d1cdfabe286d48adac6f5e0ad441ef134c5c467f4b6eee291" dependencies = [ - "acir_field 0.11.0", + "acir_field", "flate2", "rmp-serde", "serde", ] -[[package]] -name = "acir_field" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f032e710c67fd146caedc8fe1dea6e95f01ab59453e42d59b604a51fef3dfe" -dependencies = [ - "ark-bn254", - "ark-ff", - "cfg-if 1.0.0", - "hex", - "num-bigint", - "serde", -] - [[package]] name = "acir_field" version = "0.11.0" @@ -54,32 +28,14 @@ dependencies = [ "serde", ] -[[package]] -name = "acvm" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2611266039740ffd1978f23258bd6ce3166c22cf15b8227685c2f3bb20ae2ee0" -dependencies = [ - "acir 0.10.3", - "acvm_stdlib 0.10.3", - "blake2", - "crc32fast", - "indexmap", - "k256", - "num-bigint", - "num-traits", - "sha2 0.9.9", - "thiserror", -] - [[package]] name = "acvm" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e1d6795105b50b13fa0dd1779b5191c4d8e9cd98b357b0b9a0b04a847baacf0" dependencies = [ - "acir 0.11.0", - "acvm_stdlib 0.11.0", + "acir", + "acvm_stdlib", "blake2", "crc32fast", "indexmap", @@ -94,9 +50,9 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.0.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=677f10e07011849f8aa0d75fe80390bb3081b1e5#677f10e07011849f8aa0d75fe80390bb3081b1e5" +source = "git+https://github.com/noir-lang/aztec_backend?rev=7af612c8542a41901c6744f7cf33d704ba7d2ea3#7af612c8542a41901c6744f7cf33d704ba7d2ea3" dependencies = [ - "acvm 0.10.3", + "acvm", "barretenberg-sys", "blake2", "dirs 3.0.2", @@ -106,27 +62,18 @@ dependencies = [ "pkg-config", "reqwest", "rust-embed", - "sha3", + "thiserror", "tokio", "wasmer", ] -[[package]] -name = "acvm_stdlib" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ec51160c66eba75dc15a028a2391675386fd395b3897478d89a386c64a48dd" -dependencies = [ - "acir 0.10.3", -] - [[package]] name = "acvm_stdlib" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3131af53d17ac12340c0ff50f8555d8e040321f8078b8ee3cd8846560b6a44a9" dependencies = [ - "acir 0.11.0", + "acir", ] [[package]] @@ -1911,7 +1858,7 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" name = "nargo" version = "0.5.1" dependencies = [ - "acvm 0.11.0", + "acvm", "noirc_abi", "noirc_driver", "rustc_version", @@ -1924,7 +1871,7 @@ dependencies = [ name = "nargo_cli" version = "0.5.1" dependencies = [ - "acvm 0.11.0", + "acvm", "acvm-backend-barretenberg", "assert_cmd", "assert_fs", @@ -1955,7 +1902,7 @@ dependencies = [ name = "noir_wasm" version = "0.5.1" dependencies = [ - "acvm 0.11.0", + "acvm", "build-data", "console_error_panic_hook", "gloo-utils", @@ -1971,7 +1918,7 @@ dependencies = [ name = "noirc_abi" version = "0.5.1" dependencies = [ - "acvm 0.11.0", + "acvm", "iter-extended", "serde", "serde_json", @@ -1983,7 +1930,7 @@ dependencies = [ name = "noirc_driver" version = "0.5.1" dependencies = [ - "acvm 0.11.0", + "acvm", "clap", "fm", "iter-extended", @@ -2009,7 +1956,7 @@ dependencies = [ name = "noirc_evaluator" version = "0.5.1" dependencies = [ - "acvm 0.11.0", + "acvm", "arena", "iter-extended", "noirc_abi", @@ -2025,7 +1972,7 @@ dependencies = [ name = "noirc_frontend" version = "0.5.1" dependencies = [ - "acvm 0.11.0", + "acvm", "arena", "chumsky", "fm", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 6e8801301b1..d92dae31f80 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -37,7 +37,7 @@ termcolor = "1.1.2" color-eyre = "0.6.2" # Backends -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "677f10e07011849f8aa0d75fe80390bb3081b1e5", default-features = false } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "7af612c8542a41901c6744f7cf33d704ba7d2ea3", default-features = false } [dev-dependencies] tempdir = "0.3.7" diff --git a/crates/nargo_cli/src/cli/check_cmd.rs b/crates/nargo_cli/src/cli/check_cmd.rs index 3049c830def..1297742c450 100644 --- a/crates/nargo_cli/src/cli/check_cmd.rs +++ b/crates/nargo_cli/src/cli/check_cmd.rs @@ -1,5 +1,5 @@ use crate::{errors::CliError, resolver::Resolver}; -use acvm::ProofSystemCompiler; +use acvm::Backend; use clap::Args; use iter_extended::btree_map; use noirc_abi::{AbiParameter, AbiType, MAIN_RETURN_NAME}; @@ -17,15 +17,21 @@ pub(crate) struct CheckCommand { compile_options: CompileOptions, } -pub(crate) fn run(args: CheckCommand, config: NargoConfig) -> Result<(), CliError> { - check_from_path(config.program_dir, &args.compile_options)?; +pub(crate) fn run( + backend: &ConcreteBackend, + args: CheckCommand, + config: NargoConfig, +) -> Result<(), CliError> { + check_from_path(backend, config.program_dir, &args.compile_options)?; println!("Constraint system successfully built!"); Ok(()) } -fn check_from_path>(p: P, compile_options: &CompileOptions) -> Result<(), CliError> { - let backend = crate::backends::ConcreteBackend::default(); - +fn check_from_path>( + backend: &ConcreteBackend, + p: P, + compile_options: &CompileOptions, +) -> Result<(), CliError> { let mut driver = Resolver::resolve_root_manifest(p.as_ref(), backend.np_language())?; driver.check_crate(compile_options).map_err(|_| CliError::CompilationError)?; @@ -148,12 +154,13 @@ d2 = ["", "", ""] let pass_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("{TEST_DATA_DIR}/pass")); + let backend = crate::backends::ConcreteBackend::default(); let config = CompileOptions::default(); let paths = std::fs::read_dir(pass_dir).unwrap(); for path in paths.flatten() { let path = path.path(); assert!( - super::check_from_path(path.clone(), &config).is_ok(), + super::check_from_path(&backend, path.clone(), &config).is_ok(), "path: {}", path.display() ); @@ -166,12 +173,13 @@ d2 = ["", "", ""] let fail_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("{TEST_DATA_DIR}/fail")); + let backend = crate::backends::ConcreteBackend::default(); let config = CompileOptions::default(); let paths = std::fs::read_dir(fail_dir).unwrap(); for path in paths.flatten() { let path = path.path(); assert!( - super::check_from_path(path.clone(), &config).is_err(), + super::check_from_path(&backend, path.clone(), &config).is_err(), "path: {}", path.display() ); @@ -183,13 +191,14 @@ d2 = ["", "", ""] let pass_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join(format!("{TEST_DATA_DIR}/pass_dev_mode")); + let backend = crate::backends::ConcreteBackend::default(); let config = CompileOptions { allow_warnings: true, ..Default::default() }; let paths = std::fs::read_dir(pass_dir).unwrap(); for path in paths.flatten() { let path = path.path(); assert!( - super::check_from_path(path.clone(), &config).is_ok(), + super::check_from_path(&backend, path.clone(), &config).is_ok(), "path: {}", path.display() ); diff --git a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs index f23502a15b5..658d18b669d 100644 --- a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -4,6 +4,7 @@ use crate::{ cli::compile_cmd::compile_circuit, constants::CONTRACT_DIR, constants::TARGET_DIR, errors::CliError, }; +use acvm::Backend; use clap::Args; use nargo::ops::{codegen_verifier, preprocess_program}; use noirc_driver::CompileOptions; @@ -18,9 +19,11 @@ pub(crate) struct CodegenVerifierCommand { compile_options: CompileOptions, } -pub(crate) fn run(args: CodegenVerifierCommand, config: NargoConfig) -> Result<(), CliError> { - let backend = crate::backends::ConcreteBackend::default(); - +pub(crate) fn run( + backend: &ConcreteBackend, + args: CodegenVerifierCommand, + config: NargoConfig, +) -> Result<(), CliError> { // TODO(#1201): Should this be a utility function? let circuit_build_path = args .circuit_name @@ -30,12 +33,14 @@ pub(crate) fn run(args: CodegenVerifierCommand, config: NargoConfig) -> Result<( Some(circuit_build_path) => read_program_from_file(circuit_build_path)?, None => { let compiled_program = - compile_circuit(&backend, config.program_dir.as_ref(), &args.compile_options)?; - preprocess_program(&backend, compiled_program)? + compile_circuit(backend, config.program_dir.as_ref(), &args.compile_options)?; + preprocess_program(backend, compiled_program) + .map_err(CliError::ProofSystemCompilerError)? } }; - let smart_contract_string = codegen_verifier(&backend, &preprocessed_program.verification_key)?; + let smart_contract_string = codegen_verifier(backend, &preprocessed_program.verification_key) + .map_err(CliError::SmartContractError)?; let contract_dir = config.program_dir.join(CONTRACT_DIR); create_named_dir(&contract_dir, "contract"); diff --git a/crates/nargo_cli/src/cli/compile_cmd.rs b/crates/nargo_cli/src/cli/compile_cmd.rs index 78b52003166..f9bc3d5cd11 100644 --- a/crates/nargo_cli/src/cli/compile_cmd.rs +++ b/crates/nargo_cli/src/cli/compile_cmd.rs @@ -1,5 +1,4 @@ -use acvm::ProofSystemCompiler; -use iter_extended::try_vecmap; +use acvm::Backend; use noirc_driver::{CompileOptions, CompiledProgram, Driver}; use std::path::Path; @@ -27,19 +26,25 @@ pub(crate) struct CompileCommand { compile_options: CompileOptions, } -pub(crate) fn run(args: CompileCommand, config: NargoConfig) -> Result<(), CliError> { +pub(crate) fn run( + backend: &ConcreteBackend, + args: CompileCommand, + config: NargoConfig, +) -> Result<(), CliError> { let circuit_dir = config.program_dir.join(TARGET_DIR); - 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 { - let mut driver = setup_driver(&backend, &config.program_dir)?; + let mut driver = setup_driver(backend, &config.program_dir)?; let compiled_contracts = driver .compile_contracts(&args.compile_options) .map_err(|_| CliError::CompilationError)?; - let preprocessed_contracts = - try_vecmap(compiled_contracts, |contract| preprocess_contract(&backend, contract))?; + let mut preprocessed_contracts = vec![]; + for contract in compiled_contracts { + let preprocessed = preprocess_contract(backend, contract) + .map_err(CliError::ProofSystemCompilerError)?; + preprocessed_contracts.push(preprocessed); + } for contract in preprocessed_contracts { save_contract_to_file( &contract, @@ -48,25 +53,26 @@ pub(crate) fn run(args: CompileCommand, config: NargoConfig) -> Result<(), CliEr ); } } else { - let program = compile_circuit(&backend, &config.program_dir, &args.compile_options)?; - let preprocessed_program = preprocess_program(&backend, program)?; + let program = compile_circuit(backend, &config.program_dir, &args.compile_options)?; + let preprocessed_program = + preprocess_program(backend, program).map_err(CliError::ProofSystemCompilerError)?; save_program_to_file(&preprocessed_program, &args.circuit_name, circuit_dir); } Ok(()) } -fn setup_driver( - backend: &impl ProofSystemCompiler, +fn setup_driver( + backend: &ConcreteBackend, program_dir: &Path, ) -> Result { Resolver::resolve_root_manifest(program_dir, backend.np_language()) } -pub(crate) fn compile_circuit( - backend: &impl ProofSystemCompiler, +pub(crate) fn compile_circuit( + backend: &ConcreteBackend, program_dir: &Path, compile_options: &CompileOptions, -) -> Result { +) -> Result> { let mut driver = setup_driver(backend, program_dir)?; driver.compile_main(compile_options).map_err(|_| CliError::CompilationError) } diff --git a/crates/nargo_cli/src/cli/execute_cmd.rs b/crates/nargo_cli/src/cli/execute_cmd.rs index b9b2be3febf..52ce468b174 100644 --- a/crates/nargo_cli/src/cli/execute_cmd.rs +++ b/crates/nargo_cli/src/cli/execute_cmd.rs @@ -1,7 +1,7 @@ use std::path::Path; use acvm::acir::circuit::Circuit; -use acvm::PartialWitnessGenerator; +use acvm::Backend; use clap::Args; use noirc_abi::input_parser::{Format, InputValue}; use noirc_abi::{Abi, InputMap, WitnessMap}; @@ -25,9 +25,13 @@ pub(crate) struct ExecuteCommand { compile_options: CompileOptions, } -pub(crate) fn run(args: ExecuteCommand, config: NargoConfig) -> Result<(), CliError> { +pub(crate) fn run( + backend: &ConcreteBackend, + args: ExecuteCommand, + config: NargoConfig, +) -> Result<(), CliError> { let (return_value, solved_witness) = - execute_with_path(&config.program_dir, &args.compile_options)?; + execute_with_path(backend, &config.program_dir, &args.compile_options)?; println!("Circuit witness successfully solved"); if let Some(return_value) = return_value { @@ -43,19 +47,18 @@ pub(crate) fn run(args: ExecuteCommand, config: NargoConfig) -> Result<(), CliEr Ok(()) } -fn execute_with_path( +fn execute_with_path( + backend: &ConcreteBackend, program_dir: &Path, compile_options: &CompileOptions, -) -> Result<(Option, WitnessMap), CliError> { - let backend = crate::backends::ConcreteBackend::default(); - - let CompiledProgram { abi, circuit } = compile_circuit(&backend, program_dir, compile_options)?; +) -> Result<(Option, WitnessMap), CliError> { + let CompiledProgram { abi, circuit } = compile_circuit(backend, program_dir, compile_options)?; // Parse the initial witness values from Prover.toml let (inputs_map, _) = read_inputs_from_file(program_dir, PROVER_INPUT_FILE, Format::Toml, &abi)?; - let solved_witness = execute_program(&backend, circuit, &abi, &inputs_map)?; + let solved_witness = execute_program(backend, circuit, &abi, &inputs_map)?; let public_abi = abi.public_abi(); let (_, return_value) = public_abi.decode(&solved_witness)?; @@ -63,12 +66,12 @@ fn execute_with_path( Ok((return_value, solved_witness)) } -pub(crate) fn execute_program( - backend: &impl PartialWitnessGenerator, +pub(crate) fn execute_program( + backend: &ConcreteBackend, circuit: Circuit, abi: &Abi, inputs_map: &InputMap, -) -> Result { +) -> Result> { let initial_witness = abi.encode(inputs_map, None)?; let solved_witness = nargo::ops::execute_circuit(backend, circuit, initial_witness)?; diff --git a/crates/nargo_cli/src/cli/fs/inputs.rs b/crates/nargo_cli/src/cli/fs/inputs.rs index dd9ce199720..eaf94cc22fd 100644 --- a/crates/nargo_cli/src/cli/fs/inputs.rs +++ b/crates/nargo_cli/src/cli/fs/inputs.rs @@ -4,7 +4,7 @@ use noirc_abi::{ }; use std::{collections::BTreeMap, path::Path}; -use crate::errors::CliError; +use crate::errors::FilesystemError; use super::write_to_file; @@ -20,14 +20,14 @@ pub(crate) fn read_inputs_from_file>( file_name: &str, format: Format, abi: &Abi, -) -> Result<(InputMap, Option), CliError> { +) -> Result<(InputMap, Option), FilesystemError> { if abi.is_empty() { return Ok((BTreeMap::new(), None)); } let file_path = path.as_ref().join(file_name).with_extension(format.ext()); if !file_path.exists() { - return Err(CliError::MissingTomlFile(file_name.to_owned(), file_path)); + return Err(FilesystemError::MissingTomlFile(file_name.to_owned(), file_path)); } let input_string = std::fs::read_to_string(file_path).unwrap(); @@ -43,7 +43,7 @@ pub(crate) fn write_inputs_to_file>( path: P, file_name: &str, format: Format, -) -> Result<(), CliError> { +) -> Result<(), FilesystemError> { let file_path = path.as_ref().join(file_name).with_extension(format.ext()); // We must insert the return value into the `InputMap` in order for it to be written to file. diff --git a/crates/nargo_cli/src/cli/fs/mod.rs b/crates/nargo_cli/src/cli/fs/mod.rs index d860f722fd1..4ebce3b3325 100644 --- a/crates/nargo_cli/src/cli/fs/mod.rs +++ b/crates/nargo_cli/src/cli/fs/mod.rs @@ -4,7 +4,7 @@ use std::{ path::{Path, PathBuf}, }; -use crate::errors::CliError; +use crate::errors::FilesystemError; pub(super) mod inputs; pub(super) mod program; @@ -32,11 +32,11 @@ pub(super) fn write_to_file(bytes: &[u8], path: &Path) -> String { } } -pub(super) fn load_hex_data>(path: P) -> Result, CliError> { - let hex_data: Vec<_> = - std::fs::read(&path).map_err(|_| CliError::PathNotValid(path.as_ref().to_path_buf()))?; +pub(super) fn load_hex_data>(path: P) -> Result, FilesystemError> { + let hex_data: Vec<_> = std::fs::read(&path) + .map_err(|_| FilesystemError::PathNotValid(path.as_ref().to_path_buf()))?; - let raw_bytes = hex::decode(hex_data).map_err(CliError::HexArtifactNotValid)?; + let raw_bytes = hex::decode(hex_data).map_err(FilesystemError::HexArtifactNotValid)?; Ok(raw_bytes) } diff --git a/crates/nargo_cli/src/cli/fs/program.rs b/crates/nargo_cli/src/cli/fs/program.rs index a3b5f4026bd..871a6023837 100644 --- a/crates/nargo_cli/src/cli/fs/program.rs +++ b/crates/nargo_cli/src/cli/fs/program.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use nargo::artifacts::{contract::PreprocessedContract, program::PreprocessedProgram}; -use crate::errors::CliError; +use crate::errors::FilesystemError; use super::{create_named_dir, write_to_file}; @@ -35,10 +35,11 @@ fn save_build_artifact_to_file, T: ?Sized + serde::Serialize>( pub(crate) fn read_program_from_file>( circuit_path: P, -) -> Result { +) -> Result { let file_path = circuit_path.as_ref().with_extension("json"); - let input_string = std::fs::read(&file_path).map_err(|_| CliError::PathNotValid(file_path))?; + let input_string = + std::fs::read(&file_path).map_err(|_| FilesystemError::PathNotValid(file_path))?; let program = serde_json::from_slice(&input_string).expect("could not deserialize program"); diff --git a/crates/nargo_cli/src/cli/fs/proof.rs b/crates/nargo_cli/src/cli/fs/proof.rs index 4a77595a54b..3a54aa908f8 100644 --- a/crates/nargo_cli/src/cli/fs/proof.rs +++ b/crates/nargo_cli/src/cli/fs/proof.rs @@ -1,6 +1,6 @@ use std::path::{Path, PathBuf}; -use crate::{constants::PROOF_EXT, errors::CliError}; +use crate::{constants::PROOF_EXT, errors::FilesystemError}; use super::{create_named_dir, write_to_file}; @@ -8,7 +8,7 @@ pub(crate) fn save_proof_to_dir>( proof: &[u8], proof_name: &str, proof_dir: P, -) -> Result { +) -> Result { create_named_dir(proof_dir.as_ref(), "proof"); let proof_path = proof_dir.as_ref().join(proof_name).with_extension(PROOF_EXT); diff --git a/crates/nargo_cli/src/cli/fs/witness.rs b/crates/nargo_cli/src/cli/fs/witness.rs index f3a5d3ea469..d41123e74fa 100644 --- a/crates/nargo_cli/src/cli/fs/witness.rs +++ b/crates/nargo_cli/src/cli/fs/witness.rs @@ -4,13 +4,13 @@ use acvm::acir::native_types::Witness; use noirc_abi::WitnessMap; use super::{create_named_dir, write_to_file}; -use crate::{constants::WITNESS_EXT, errors::CliError}; +use crate::{constants::WITNESS_EXT, errors::FilesystemError}; pub(crate) fn save_witness_to_dir>( witness: WitnessMap, witness_name: &str, witness_dir: P, -) -> Result { +) -> Result { create_named_dir(witness_dir.as_ref(), "witness"); let witness_path = witness_dir.as_ref().join(witness_name).with_extension(WITNESS_EXT); diff --git a/crates/nargo_cli/src/cli/gates_cmd.rs b/crates/nargo_cli/src/cli/gates_cmd.rs index 9fe9f5c7a53..8c57858d347 100644 --- a/crates/nargo_cli/src/cli/gates_cmd.rs +++ b/crates/nargo_cli/src/cli/gates_cmd.rs @@ -1,4 +1,4 @@ -use acvm::ProofSystemCompiler; +use acvm::Backend; use clap::Args; use noirc_driver::CompileOptions; use std::path::Path; @@ -15,17 +15,20 @@ pub(crate) struct GatesCommand { compile_options: CompileOptions, } -pub(crate) fn run(args: GatesCommand, config: NargoConfig) -> Result<(), CliError> { - count_gates_with_path(config.program_dir, &args.compile_options) +pub(crate) fn run( + backend: &ConcreteBackend, + args: GatesCommand, + config: NargoConfig, +) -> Result<(), CliError> { + count_gates_with_path(backend, config.program_dir, &args.compile_options) } -fn count_gates_with_path>( +fn count_gates_with_path>( + backend: &ConcreteBackend, program_dir: P, compile_options: &CompileOptions, -) -> Result<(), CliError> { - let backend = crate::backends::ConcreteBackend::default(); - - let compiled_program = compile_circuit(&backend, program_dir.as_ref(), compile_options)?; +) -> Result<(), CliError> { + let compiled_program = compile_circuit(backend, program_dir.as_ref(), compile_options)?; let num_opcodes = compiled_program.circuit.opcodes.len(); println!( @@ -34,7 +37,9 @@ fn count_gates_with_path>( num_opcodes ); - let exact_circuit_size = backend.get_exact_circuit_size(&compiled_program.circuit); + let exact_circuit_size = backend + .get_exact_circuit_size(&compiled_program.circuit) + .map_err(CliError::ProofSystemCompilerError)?; println!("Backend circuit size: {exact_circuit_size}"); Ok(()) diff --git a/crates/nargo_cli/src/cli/mod.rs b/crates/nargo_cli/src/cli/mod.rs index 5450bb39660..d41dc1a815a 100644 --- a/crates/nargo_cli/src/cli/mod.rs +++ b/crates/nargo_cli/src/cli/mod.rs @@ -67,17 +67,19 @@ pub fn start_cli() -> eyre::Result<()> { config.program_dir = find_package_root(&config.program_dir)?; } + let backend = crate::backends::ConcreteBackend::default(); + match command { - NargoCommand::New(args) => new_cmd::run(args, config), - NargoCommand::Check(args) => check_cmd::run(args, config), - NargoCommand::Compile(args) => compile_cmd::run(args, config), - NargoCommand::Execute(args) => execute_cmd::run(args, config), - NargoCommand::Prove(args) => prove_cmd::run(args, config), - NargoCommand::Verify(args) => verify_cmd::run(args, config), - NargoCommand::Test(args) => test_cmd::run(args, config), - NargoCommand::Gates(args) => gates_cmd::run(args, config), - NargoCommand::CodegenVerifier(args) => codegen_verifier_cmd::run(args, config), - NargoCommand::PrintAcir(args) => print_acir_cmd::run(args, config), + NargoCommand::New(args) => new_cmd::run(&backend, args, config), + NargoCommand::Check(args) => check_cmd::run(&backend, args, config), + NargoCommand::Compile(args) => compile_cmd::run(&backend, args, config), + NargoCommand::Execute(args) => execute_cmd::run(&backend, args, config), + NargoCommand::Prove(args) => prove_cmd::run(&backend, args, config), + NargoCommand::Verify(args) => verify_cmd::run(&backend, args, config), + 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(()) @@ -85,6 +87,8 @@ pub fn start_cli() -> eyre::Result<()> { // 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 { + let backend = crate::backends::ConcreteBackend::default(); + let compile_options = CompileOptions { show_ssa, allow_warnings: false, @@ -94,6 +98,7 @@ pub fn prove_and_verify(proof_name: &str, program_dir: &Path, show_ssa: bool) -> let proof_dir = program_dir.join(PROOFS_DIR); match prove_cmd::prove_with_path( + &backend, Some(proof_name.to_owned()), program_dir, &proof_dir, diff --git a/crates/nargo_cli/src/cli/new_cmd.rs b/crates/nargo_cli/src/cli/new_cmd.rs index 36146028454..bef6f088264 100644 --- a/crates/nargo_cli/src/cli/new_cmd.rs +++ b/crates/nargo_cli/src/cli/new_cmd.rs @@ -5,6 +5,7 @@ use crate::{ use super::fs::{create_named_dir, write_to_file}; use super::{NargoConfig, CARGO_PKG_VERSION}; +use acvm::Backend; use clap::Args; use const_format::formatcp; use std::path::{Path, PathBuf}; @@ -33,13 +34,18 @@ const EXAMPLE: &str = r#"fn main(x : Field, y : pub Field) { #[test] fn test_main() { main(1, 2); - + // Uncomment to make test fail // main(1, 1); } "#; -pub(crate) fn run(args: NewCommand, config: NargoConfig) -> Result<(), CliError> { +pub(crate) fn run( + // Backend is currently unused, but we might want to use it to inform the "new" template in the future + _backend: &ConcreteBackend, + args: NewCommand, + config: NargoConfig, +) -> Result<(), CliError> { let package_dir = config.program_dir.join(args.package_name); if package_dir.exists() { diff --git a/crates/nargo_cli/src/cli/print_acir_cmd.rs b/crates/nargo_cli/src/cli/print_acir_cmd.rs index 38b841121bc..2f8e64ccdd8 100644 --- a/crates/nargo_cli/src/cli/print_acir_cmd.rs +++ b/crates/nargo_cli/src/cli/print_acir_cmd.rs @@ -1,3 +1,4 @@ +use acvm::Backend; use clap::Args; use noirc_driver::CompileOptions; use std::path::Path; @@ -14,17 +15,20 @@ pub(crate) struct PrintAcirCommand { compile_options: CompileOptions, } -pub(crate) fn run(args: PrintAcirCommand, config: NargoConfig) -> Result<(), CliError> { - print_acir_with_path(config.program_dir, &args.compile_options) +pub(crate) fn run( + backend: &ConcreteBackend, + args: PrintAcirCommand, + config: NargoConfig, +) -> Result<(), CliError> { + print_acir_with_path(backend, config.program_dir, &args.compile_options) } -fn print_acir_with_path>( +fn print_acir_with_path>( + backend: &ConcreteBackend, program_dir: P, compile_options: &CompileOptions, -) -> Result<(), CliError> { - let backend = crate::backends::ConcreteBackend::default(); - - let compiled_program = compile_circuit(&backend, program_dir.as_ref(), compile_options)?; +) -> Result<(), CliError> { + let compiled_program = compile_circuit(backend, program_dir.as_ref(), compile_options)?; println!("{}", compiled_program.circuit); Ok(()) diff --git a/crates/nargo_cli/src/cli/prove_cmd.rs b/crates/nargo_cli/src/cli/prove_cmd.rs index 2b9ed4b067a..8a7c2c9882c 100644 --- a/crates/nargo_cli/src/cli/prove_cmd.rs +++ b/crates/nargo_cli/src/cli/prove_cmd.rs @@ -1,5 +1,6 @@ use std::path::{Path, PathBuf}; +use acvm::Backend; use clap::Args; use nargo::artifacts::program::PreprocessedProgram; use nargo::ops::{preprocess_program, prove_execution, verify_proof}; @@ -38,7 +39,11 @@ pub(crate) struct ProveCommand { compile_options: CompileOptions, } -pub(crate) fn run(args: ProveCommand, config: NargoConfig) -> Result<(), CliError> { +pub(crate) fn run( + backend: &ConcreteBackend, + args: ProveCommand, + config: NargoConfig, +) -> Result<(), CliError> { let proof_dir = config.program_dir.join(PROOFS_DIR); let circuit_build_path = args @@ -46,6 +51,7 @@ pub(crate) fn run(args: ProveCommand, config: NargoConfig) -> Result<(), CliErro .map(|circuit_name| config.program_dir.join(TARGET_DIR).join(circuit_name)); prove_with_path( + backend, args.proof_name, config.program_dir, proof_dir, @@ -57,22 +63,21 @@ pub(crate) fn run(args: ProveCommand, config: NargoConfig) -> Result<(), CliErro Ok(()) } -pub(crate) fn prove_with_path>( +pub(crate) fn prove_with_path>( + backend: &ConcreteBackend, proof_name: Option, program_dir: P, proof_dir: P, circuit_build_path: Option, check_proof: bool, compile_options: &CompileOptions, -) -> Result, CliError> { - let backend = crate::backends::ConcreteBackend::default(); - +) -> Result, CliError> { let preprocessed_program = match circuit_build_path { Some(circuit_build_path) => read_program_from_file(circuit_build_path)?, None => { - let compiled_program = - compile_circuit(&backend, program_dir.as_ref(), compile_options)?; - preprocess_program(&backend, compiled_program)? + let compiled_program = compile_circuit(backend, program_dir.as_ref(), compile_options)?; + preprocess_program(backend, compiled_program) + .map_err(CliError::ProofSystemCompilerError)? } }; @@ -83,7 +88,7 @@ pub(crate) fn prove_with_path>( let (inputs_map, _) = read_inputs_from_file(&program_dir, PROVER_INPUT_FILE, Format::Toml, &abi)?; - let solved_witness = execute_program(&backend, bytecode.clone(), &abi, &inputs_map)?; + let solved_witness = execute_program(backend, bytecode.clone(), &abi, &inputs_map)?; // Write public inputs into Verifier.toml let public_abi = abi.public_abi(); @@ -97,12 +102,14 @@ pub(crate) fn prove_with_path>( Format::Toml, )?; - let proof = prove_execution(&backend, &bytecode, solved_witness, &proving_key)?; + let proof = prove_execution(backend, &bytecode, solved_witness, &proving_key) + .map_err(CliError::ProofSystemCompilerError)?; if check_proof { let public_inputs = public_abi.encode(&public_inputs, return_value)?; let valid_proof = - verify_proof(&backend, &bytecode, &proof, public_inputs, &verification_key)?; + verify_proof(backend, &bytecode, &proof, public_inputs, &verification_key) + .map_err(CliError::ProofSystemCompilerError)?; if !valid_proof { return Err(CliError::InvalidProof("".into())); diff --git a/crates/nargo_cli/src/cli/test_cmd.rs b/crates/nargo_cli/src/cli/test_cmd.rs index 65f8265a862..ad0a0b005bc 100644 --- a/crates/nargo_cli/src/cli/test_cmd.rs +++ b/crates/nargo_cli/src/cli/test_cmd.rs @@ -1,6 +1,6 @@ use std::{collections::BTreeMap, io::Write, path::Path}; -use acvm::ProofSystemCompiler; +use acvm::Backend; use clap::Args; use nargo::ops::execute_circuit; use noirc_driver::{CompileOptions, Driver}; @@ -21,19 +21,22 @@ pub(crate) struct TestCommand { compile_options: CompileOptions, } -pub(crate) fn run(args: TestCommand, config: NargoConfig) -> Result<(), CliError> { +pub(crate) fn run( + backend: &ConcreteBackend, + args: TestCommand, + config: NargoConfig, +) -> Result<(), CliError> { let test_name: String = args.test_name.unwrap_or_else(|| "".to_owned()); - run_tests(&config.program_dir, &test_name, &args.compile_options) + run_tests(backend, &config.program_dir, &test_name, &args.compile_options) } -fn run_tests( +fn run_tests( + backend: &ConcreteBackend, program_dir: &Path, test_name: &str, compile_options: &CompileOptions, -) -> Result<(), CliError> { - let backend = crate::backends::ConcreteBackend::default(); - +) -> Result<(), CliError> { let mut driver = Resolver::resolve_root_manifest(program_dir, backend.np_language())?; driver.check_crate(compile_options).map_err(|_| CliError::CompilationError)?; @@ -50,7 +53,7 @@ fn run_tests( writeln!(writer, "Testing {test_name}...").expect("Failed to write to stdout"); writer.flush().ok(); - match run_test(test_name, test_function, &driver, compile_options) { + match run_test(backend, test_name, test_function, &driver, compile_options) { Ok(_) => { writer.set_color(ColorSpec::new().set_fg(Some(Color::Green))).ok(); writeln!(writer, "ok").ok(); @@ -73,21 +76,20 @@ fn run_tests( Ok(()) } -fn run_test( +fn run_test( + backend: &ConcreteBackend, test_name: &str, main: FuncId, driver: &Driver, config: &CompileOptions, -) -> Result<(), CliError> { - let backend = crate::backends::ConcreteBackend::default(); - +) -> Result<(), CliError> { let program = driver .compile_no_check(config, main) .map_err(|_| CliError::Generic(format!("Test '{test_name}' failed to compile")))?; // Run the backend to ensure the PWG evaluates functions like std::hash::pedersen, // otherwise constraints involving these expressions will not error. - match execute_circuit(&backend, program.circuit, BTreeMap::new()) { + match execute_circuit(backend, program.circuit, BTreeMap::new()) { Ok(_) => Ok(()), Err(error) => { let writer = StandardStream::stderr(ColorChoice::Always); diff --git a/crates/nargo_cli/src/cli/verify_cmd.rs b/crates/nargo_cli/src/cli/verify_cmd.rs index 84a6416d44e..82580fc55a4 100644 --- a/crates/nargo_cli/src/cli/verify_cmd.rs +++ b/crates/nargo_cli/src/cli/verify_cmd.rs @@ -6,6 +6,7 @@ use crate::{ errors::CliError, }; +use acvm::Backend; use clap::Args; use nargo::artifacts::program::PreprocessedProgram; use nargo::ops::preprocess_program; @@ -26,7 +27,11 @@ pub(crate) struct VerifyCommand { compile_options: CompileOptions, } -pub(crate) fn run(args: VerifyCommand, config: NargoConfig) -> Result<(), CliError> { +pub(crate) fn run( + backend: &ConcreteBackend, + args: VerifyCommand, + config: NargoConfig, +) -> Result<(), CliError> { let proof_path = config.program_dir.join(PROOFS_DIR).join(&args.proof).with_extension(PROOF_EXT); @@ -35,6 +40,7 @@ pub(crate) fn run(args: VerifyCommand, config: NargoConfig) -> Result<(), CliErr .map(|circuit_name| config.program_dir.join(TARGET_DIR).join(circuit_name)); verify_with_path( + backend, &config.program_dir, proof_path, circuit_build_path.as_ref(), @@ -42,20 +48,20 @@ pub(crate) fn run(args: VerifyCommand, config: NargoConfig) -> Result<(), CliErr ) } -fn verify_with_path>( +fn verify_with_path>( + backend: &ConcreteBackend, program_dir: P, proof_path: PathBuf, circuit_build_path: Option

, compile_options: CompileOptions, -) -> Result<(), CliError> { - let backend = crate::backends::ConcreteBackend::default(); - +) -> Result<(), CliError> { let preprocessed_program = match circuit_build_path { Some(circuit_build_path) => read_program_from_file(circuit_build_path)?, None => { let compiled_program = - compile_circuit(&backend, program_dir.as_ref(), &compile_options)?; - preprocess_program(&backend, compiled_program)? + compile_circuit(backend, program_dir.as_ref(), &compile_options)?; + preprocess_program(backend, compiled_program) + .map_err(CliError::ProofSystemCompilerError)? } }; @@ -70,7 +76,8 @@ fn verify_with_path>( let proof = load_hex_data(&proof_path)?; let valid_proof = - nargo::ops::verify_proof(&backend, &bytecode, &proof, public_inputs, &verification_key)?; + nargo::ops::verify_proof(backend, &bytecode, &proof, public_inputs, &verification_key) + .map_err(CliError::ProofSystemCompilerError)?; if valid_proof { Ok(()) diff --git a/crates/nargo_cli/src/errors.rs b/crates/nargo_cli/src/errors.rs index f6537b550ea..69752d2c245 100644 --- a/crates/nargo_cli/src/errors.rs +++ b/crates/nargo_cli/src/errors.rs @@ -1,17 +1,14 @@ +use acvm::{Backend, ProofSystemCompiler, SmartContract}; use hex::FromHexError; use nargo::NargoError; use noirc_abi::errors::{AbiError, InputParserError}; -use std::path::PathBuf; +use std::{fmt::Debug, path::PathBuf}; use thiserror::Error; use crate::resolver::DependencyResolutionError; #[derive(Debug, Error)] -pub(crate) enum CliError { - #[error("{0}")] - Generic(String), - #[error("Error: destination {} already exists", .0.display())] - DestinationAlreadyExists(PathBuf), +pub(crate) enum FilesystemError { #[error("Error: {} is not a valid path\nRun either `nargo compile` to generate missing build artifacts or `nargo prove` to construct a proof", .0.display())] PathNotValid(PathBuf), #[error("Error: could not parse hex build artifact (proof, proving and/or verification keys, ACIR checksum) ({0})")] @@ -21,6 +18,18 @@ pub(crate) enum CliError { )] MissingTomlFile(String, PathBuf), + /// Input parsing error + #[error(transparent)] + InputParserError(#[from] InputParserError), +} + +#[derive(Debug, Error)] +pub(crate) enum CliError { + #[error("{0}")] + Generic(String), + #[error("Error: destination {} already exists", .0.display())] + DestinationAlreadyExists(PathBuf), + #[error("Failed to verify proof {}", .0.display())] InvalidProof(PathBuf), @@ -31,15 +40,23 @@ pub(crate) enum CliError { #[error("Failed to compile circuit")] CompilationError, - /// Input parsing error - #[error(transparent)] - InputParserError(#[from] InputParserError), - /// ABI encoding/decoding error #[error(transparent)] AbiError(#[from] AbiError), + /// Filesystem errors + #[error(transparent)] + FilesystemError(#[from] FilesystemError), + /// Error from Nargo #[error(transparent)] NargoError(#[from] NargoError), + + /// Backend error caused by a function on the SmartContract trait + #[error(transparent)] + SmartContractError(::Error), // Unfortunately, Rust won't let us `impl From` over an Associated Type on a generic + + /// Backend error caused by a function on the ProofSystemCompiler trait + #[error(transparent)] + ProofSystemCompilerError(::Error), // Unfortunately, Rust won't let us `impl From` over an Associated Type on a generic } From 37dd357c1189686116f304853fc78c4191d1206b Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 9 May 2023 13:23:42 -0700 Subject: [PATCH 04/12] update to latest commit --- Cargo.lock | 2 +- crates/nargo_cli/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13b78dc5e88..1e83eaddf54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.0.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=7af612c8542a41901c6744f7cf33d704ba7d2ea3#7af612c8542a41901c6744f7cf33d704ba7d2ea3" +source = "git+https://github.com/noir-lang/aztec_backend?rev=0aa72dec1367b4f546ba96a83894b8ae062240f4#0aa72dec1367b4f546ba96a83894b8ae062240f4" dependencies = [ "acvm", "barretenberg-sys", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index d92dae31f80..179076c22c1 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -37,7 +37,7 @@ termcolor = "1.1.2" color-eyre = "0.6.2" # Backends -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "7af612c8542a41901c6744f7cf33d704ba7d2ea3", default-features = false } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "0aa72dec1367b4f546ba96a83894b8ae062240f4", default-features = false } [dev-dependencies] tempdir = "0.3.7" From d3c2eaf9c99670b8c033fe10a797e84d0abf98f1 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 9 May 2023 23:10:12 +0100 Subject: [PATCH 05/12] chore: replace long `Backend` type parameters with `B` --- crates/nargo/src/ops/codegen_verifier.rs | 6 +++--- crates/nargo/src/ops/preprocess.rs | 12 ++++++------ crates/nargo/src/ops/prove.rs | 6 +++--- crates/nargo/src/ops/verify.rs | 6 +++--- crates/nargo_cli/src/cli/check_cmd.rs | 18 +++++++++--------- .../nargo_cli/src/cli/codegen_verifier_cmd.rs | 6 +++--- crates/nargo_cli/src/cli/compile_cmd.rs | 16 ++++++++-------- crates/nargo_cli/src/cli/execute_cmd.rs | 18 +++++++++--------- crates/nargo_cli/src/cli/gates_cmd.rs | 12 ++++++------ crates/nargo_cli/src/cli/new_cmd.rs | 6 +++--- crates/nargo_cli/src/cli/print_acir_cmd.rs | 12 ++++++------ crates/nargo_cli/src/cli/prove_cmd.rs | 12 ++++++------ crates/nargo_cli/src/cli/test_cmd.rs | 18 +++++++++--------- crates/nargo_cli/src/cli/verify_cmd.rs | 12 ++++++------ 14 files changed, 80 insertions(+), 80 deletions(-) diff --git a/crates/nargo/src/ops/codegen_verifier.rs b/crates/nargo/src/ops/codegen_verifier.rs index 44b44598c51..125f22a1d33 100644 --- a/crates/nargo/src/ops/codegen_verifier.rs +++ b/crates/nargo/src/ops/codegen_verifier.rs @@ -1,8 +1,8 @@ use acvm::SmartContract; -pub fn codegen_verifier( - backend: &Backend, +pub fn codegen_verifier( + backend: B, verification_key: &[u8], -) -> Result { +) -> Result { backend.eth_contract_from_vk(verification_key) } diff --git a/crates/nargo/src/ops/preprocess.rs b/crates/nargo/src/ops/preprocess.rs index 4c058251680..55b42c8a03d 100644 --- a/crates/nargo/src/ops/preprocess.rs +++ b/crates/nargo/src/ops/preprocess.rs @@ -9,10 +9,10 @@ use crate::artifacts::{ // TODO: pull this from backend. const BACKEND_IDENTIFIER: &str = "acvm-backend-barretenberg"; -pub fn preprocess_program( - backend: &Backend, +pub fn preprocess_program( + backend: &B, compiled_program: CompiledProgram, -) -> Result { +) -> Result { // TODO: currently `compiled_program`'s bytecode is already optimized for the backend. // In future we'll need to apply those optimizations here. let optimized_bytecode = compiled_program.circuit; @@ -27,10 +27,10 @@ pub fn preprocess_program( }) } -pub fn preprocess_contract( - backend: &Backend, +pub fn preprocess_contract( + backend: &B, compiled_contract: CompiledContract, -) -> Result { +) -> Result { let mut preprocessed_contract_functions = vec![]; for func in compiled_contract.functions.into_iter() { // TODO: currently `func`'s bytecode is already optimized for the backend. diff --git a/crates/nargo/src/ops/prove.rs b/crates/nargo/src/ops/prove.rs index 4f305e329d4..80771bc9cb7 100644 --- a/crates/nargo/src/ops/prove.rs +++ b/crates/nargo/src/ops/prove.rs @@ -2,11 +2,11 @@ use acvm::acir::circuit::Circuit; use acvm::ProofSystemCompiler; use noirc_abi::WitnessMap; -pub fn prove_execution( - backend: &Backend, +pub fn prove_execution( + backend: &B, circuit: &Circuit, solved_witness: WitnessMap, proving_key: &[u8], -) -> Result, Backend::Error> { +) -> Result, B::Error> { backend.prove_with_pk(circuit, solved_witness, proving_key) } diff --git a/crates/nargo/src/ops/verify.rs b/crates/nargo/src/ops/verify.rs index 9bb06a2f317..cd76fbd430e 100644 --- a/crates/nargo/src/ops/verify.rs +++ b/crates/nargo/src/ops/verify.rs @@ -2,12 +2,12 @@ use acvm::acir::circuit::Circuit; use acvm::ProofSystemCompiler; use noirc_abi::WitnessMap; -pub fn verify_proof( - backend: &Backend, +pub fn verify_proof( + backend: &B, circuit: &Circuit, proof: &[u8], public_inputs: WitnessMap, verification_key: &[u8], -) -> Result { +) -> Result { backend.verify_with_vk(proof, public_inputs, circuit, verification_key) } diff --git a/crates/nargo_cli/src/cli/check_cmd.rs b/crates/nargo_cli/src/cli/check_cmd.rs index 1297742c450..916d21ce333 100644 --- a/crates/nargo_cli/src/cli/check_cmd.rs +++ b/crates/nargo_cli/src/cli/check_cmd.rs @@ -17,21 +17,21 @@ pub(crate) struct CheckCommand { compile_options: CompileOptions, } -pub(crate) fn run( - backend: &ConcreteBackend, +pub(crate) fn run( + backend: &B, args: CheckCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { check_from_path(backend, config.program_dir, &args.compile_options)?; println!("Constraint system successfully built!"); Ok(()) } -fn check_from_path>( - backend: &ConcreteBackend, +fn check_from_path>( + backend: &B, p: P, compile_options: &CompileOptions, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let mut driver = Resolver::resolve_root_manifest(p.as_ref(), backend.np_language())?; driver.check_crate(compile_options).map_err(|_| CliError::CompilationError)?; @@ -154,7 +154,7 @@ d2 = ["", "", ""] let pass_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("{TEST_DATA_DIR}/pass")); - let backend = crate::backends::ConcreteBackend::default(); + let backend = crate::backends::B::default(); let config = CompileOptions::default(); let paths = std::fs::read_dir(pass_dir).unwrap(); for path in paths.flatten() { @@ -173,7 +173,7 @@ d2 = ["", "", ""] let fail_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("{TEST_DATA_DIR}/fail")); - let backend = crate::backends::ConcreteBackend::default(); + let backend = crate::backends::B::default(); let config = CompileOptions::default(); let paths = std::fs::read_dir(fail_dir).unwrap(); for path in paths.flatten() { @@ -191,7 +191,7 @@ d2 = ["", "", ""] let pass_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join(format!("{TEST_DATA_DIR}/pass_dev_mode")); - let backend = crate::backends::ConcreteBackend::default(); + let backend = crate::backends::B::default(); let config = CompileOptions { allow_warnings: true, ..Default::default() }; let paths = std::fs::read_dir(pass_dir).unwrap(); diff --git a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs index 658d18b669d..d38433e2d1c 100644 --- a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -19,11 +19,11 @@ pub(crate) struct CodegenVerifierCommand { compile_options: CompileOptions, } -pub(crate) fn run( - backend: &ConcreteBackend, +pub(crate) fn run( + backend: &B, args: CodegenVerifierCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { // TODO(#1201): Should this be a utility function? let circuit_build_path = args .circuit_name diff --git a/crates/nargo_cli/src/cli/compile_cmd.rs b/crates/nargo_cli/src/cli/compile_cmd.rs index f9bc3d5cd11..f6794e68bd8 100644 --- a/crates/nargo_cli/src/cli/compile_cmd.rs +++ b/crates/nargo_cli/src/cli/compile_cmd.rs @@ -26,11 +26,11 @@ pub(crate) struct CompileCommand { compile_options: CompileOptions, } -pub(crate) fn run( - backend: &ConcreteBackend, +pub(crate) fn run( + backend: &B, args: CompileCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let circuit_dir = config.program_dir.join(TARGET_DIR); // If contracts is set we're compiling every function in a 'contract' rather than just 'main'. @@ -61,18 +61,18 @@ pub(crate) fn run( Ok(()) } -fn setup_driver( - backend: &ConcreteBackend, +fn setup_driver( + backend: &B, program_dir: &Path, ) -> Result { Resolver::resolve_root_manifest(program_dir, backend.np_language()) } -pub(crate) fn compile_circuit( - backend: &ConcreteBackend, +pub(crate) fn compile_circuit( + backend: &B, program_dir: &Path, compile_options: &CompileOptions, -) -> Result> { +) -> Result> { let mut driver = setup_driver(backend, program_dir)?; driver.compile_main(compile_options).map_err(|_| CliError::CompilationError) } diff --git a/crates/nargo_cli/src/cli/execute_cmd.rs b/crates/nargo_cli/src/cli/execute_cmd.rs index 52ce468b174..855fea04cb3 100644 --- a/crates/nargo_cli/src/cli/execute_cmd.rs +++ b/crates/nargo_cli/src/cli/execute_cmd.rs @@ -25,11 +25,11 @@ pub(crate) struct ExecuteCommand { compile_options: CompileOptions, } -pub(crate) fn run( - backend: &ConcreteBackend, +pub(crate) fn run( + backend: &B, args: ExecuteCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let (return_value, solved_witness) = execute_with_path(backend, &config.program_dir, &args.compile_options)?; @@ -47,11 +47,11 @@ pub(crate) fn run( Ok(()) } -fn execute_with_path( - backend: &ConcreteBackend, +fn execute_with_path( + backend: &B, program_dir: &Path, compile_options: &CompileOptions, -) -> Result<(Option, WitnessMap), CliError> { +) -> Result<(Option, WitnessMap), CliError> { let CompiledProgram { abi, circuit } = compile_circuit(backend, program_dir, compile_options)?; // Parse the initial witness values from Prover.toml @@ -66,12 +66,12 @@ fn execute_with_path( Ok((return_value, solved_witness)) } -pub(crate) fn execute_program( - backend: &ConcreteBackend, +pub(crate) fn execute_program( + backend: &B, circuit: Circuit, abi: &Abi, inputs_map: &InputMap, -) -> Result> { +) -> Result> { let initial_witness = abi.encode(inputs_map, None)?; let solved_witness = nargo::ops::execute_circuit(backend, circuit, initial_witness)?; diff --git a/crates/nargo_cli/src/cli/gates_cmd.rs b/crates/nargo_cli/src/cli/gates_cmd.rs index 8c57858d347..88e11c683eb 100644 --- a/crates/nargo_cli/src/cli/gates_cmd.rs +++ b/crates/nargo_cli/src/cli/gates_cmd.rs @@ -15,19 +15,19 @@ pub(crate) struct GatesCommand { compile_options: CompileOptions, } -pub(crate) fn run( - backend: &ConcreteBackend, +pub(crate) fn run( + backend: &B, args: GatesCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { count_gates_with_path(backend, config.program_dir, &args.compile_options) } -fn count_gates_with_path>( - backend: &ConcreteBackend, +fn count_gates_with_path>( + backend: &B, program_dir: P, compile_options: &CompileOptions, -) -> Result<(), CliError> { +) -> Result<(), CliError> { 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/new_cmd.rs b/crates/nargo_cli/src/cli/new_cmd.rs index bef6f088264..5868c1e820e 100644 --- a/crates/nargo_cli/src/cli/new_cmd.rs +++ b/crates/nargo_cli/src/cli/new_cmd.rs @@ -40,12 +40,12 @@ fn test_main() { } "#; -pub(crate) fn run( +pub(crate) fn run( // Backend is currently unused, but we might want to use it to inform the "new" template in the future - _backend: &ConcreteBackend, + _backend: &B, args: NewCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let package_dir = config.program_dir.join(args.package_name); if package_dir.exists() { diff --git a/crates/nargo_cli/src/cli/print_acir_cmd.rs b/crates/nargo_cli/src/cli/print_acir_cmd.rs index 2f8e64ccdd8..420c57c6a08 100644 --- a/crates/nargo_cli/src/cli/print_acir_cmd.rs +++ b/crates/nargo_cli/src/cli/print_acir_cmd.rs @@ -15,19 +15,19 @@ pub(crate) struct PrintAcirCommand { compile_options: CompileOptions, } -pub(crate) fn run( - backend: &ConcreteBackend, +pub(crate) fn run( + backend: &B, args: PrintAcirCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { print_acir_with_path(backend, config.program_dir, &args.compile_options) } -fn print_acir_with_path>( - backend: &ConcreteBackend, +fn print_acir_with_path>( + backend: &B, program_dir: P, compile_options: &CompileOptions, -) -> Result<(), CliError> { +) -> Result<(), CliError> { 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 8a7c2c9882c..d2adc8d4af1 100644 --- a/crates/nargo_cli/src/cli/prove_cmd.rs +++ b/crates/nargo_cli/src/cli/prove_cmd.rs @@ -39,11 +39,11 @@ pub(crate) struct ProveCommand { compile_options: CompileOptions, } -pub(crate) fn run( - backend: &ConcreteBackend, +pub(crate) fn run( + backend: &B, args: ProveCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let proof_dir = config.program_dir.join(PROOFS_DIR); let circuit_build_path = args @@ -63,15 +63,15 @@ pub(crate) fn run( Ok(()) } -pub(crate) fn prove_with_path>( - backend: &ConcreteBackend, +pub(crate) fn prove_with_path>( + backend: &B, proof_name: Option, program_dir: P, proof_dir: P, circuit_build_path: Option, check_proof: bool, compile_options: &CompileOptions, -) -> Result, CliError> { +) -> Result, CliError> { let preprocessed_program = match circuit_build_path { Some(circuit_build_path) => read_program_from_file(circuit_build_path)?, None => { diff --git a/crates/nargo_cli/src/cli/test_cmd.rs b/crates/nargo_cli/src/cli/test_cmd.rs index ad0a0b005bc..139d33b6c3d 100644 --- a/crates/nargo_cli/src/cli/test_cmd.rs +++ b/crates/nargo_cli/src/cli/test_cmd.rs @@ -21,22 +21,22 @@ pub(crate) struct TestCommand { compile_options: CompileOptions, } -pub(crate) fn run( - backend: &ConcreteBackend, +pub(crate) fn run( + backend: &B, args: TestCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let test_name: String = args.test_name.unwrap_or_else(|| "".to_owned()); run_tests(backend, &config.program_dir, &test_name, &args.compile_options) } -fn run_tests( - backend: &ConcreteBackend, +fn run_tests( + backend: &B, program_dir: &Path, test_name: &str, compile_options: &CompileOptions, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let mut driver = Resolver::resolve_root_manifest(program_dir, backend.np_language())?; driver.check_crate(compile_options).map_err(|_| CliError::CompilationError)?; @@ -76,13 +76,13 @@ fn run_tests( Ok(()) } -fn run_test( - backend: &ConcreteBackend, +fn run_test( + backend: &B, test_name: &str, main: FuncId, driver: &Driver, config: &CompileOptions, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let program = driver .compile_no_check(config, main) .map_err(|_| CliError::Generic(format!("Test '{test_name}' failed to compile")))?; diff --git a/crates/nargo_cli/src/cli/verify_cmd.rs b/crates/nargo_cli/src/cli/verify_cmd.rs index 82580fc55a4..07ba12d3899 100644 --- a/crates/nargo_cli/src/cli/verify_cmd.rs +++ b/crates/nargo_cli/src/cli/verify_cmd.rs @@ -27,11 +27,11 @@ pub(crate) struct VerifyCommand { compile_options: CompileOptions, } -pub(crate) fn run( - backend: &ConcreteBackend, +pub(crate) fn run( + backend: &B, args: VerifyCommand, config: NargoConfig, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let proof_path = config.program_dir.join(PROOFS_DIR).join(&args.proof).with_extension(PROOF_EXT); @@ -48,13 +48,13 @@ pub(crate) fn run( ) } -fn verify_with_path>( - backend: &ConcreteBackend, +fn verify_with_path>( + backend: &B, program_dir: P, proof_path: PathBuf, circuit_build_path: Option

, compile_options: CompileOptions, -) -> Result<(), CliError> { +) -> Result<(), CliError> { let preprocessed_program = match circuit_build_path { Some(circuit_build_path) => read_program_from_file(circuit_build_path)?, None => { From 866f8299e9bc6fb1f608613d9703868e9492f1c9 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 9 May 2023 15:29:12 -0700 Subject: [PATCH 06/12] fix grep problems --- crates/nargo/src/ops/codegen_verifier.rs | 2 +- crates/nargo_cli/src/cli/check_cmd.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/nargo/src/ops/codegen_verifier.rs b/crates/nargo/src/ops/codegen_verifier.rs index 125f22a1d33..2a0b54df865 100644 --- a/crates/nargo/src/ops/codegen_verifier.rs +++ b/crates/nargo/src/ops/codegen_verifier.rs @@ -1,7 +1,7 @@ use acvm::SmartContract; pub fn codegen_verifier( - backend: B, + backend: &B, verification_key: &[u8], ) -> Result { backend.eth_contract_from_vk(verification_key) diff --git a/crates/nargo_cli/src/cli/check_cmd.rs b/crates/nargo_cli/src/cli/check_cmd.rs index 916d21ce333..9664930466b 100644 --- a/crates/nargo_cli/src/cli/check_cmd.rs +++ b/crates/nargo_cli/src/cli/check_cmd.rs @@ -154,7 +154,7 @@ d2 = ["", "", ""] let pass_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("{TEST_DATA_DIR}/pass")); - let backend = crate::backends::B::default(); + let backend = crate::backends::ConcreteBackend::default(); let config = CompileOptions::default(); let paths = std::fs::read_dir(pass_dir).unwrap(); for path in paths.flatten() { @@ -173,7 +173,7 @@ d2 = ["", "", ""] let fail_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(format!("{TEST_DATA_DIR}/fail")); - let backend = crate::backends::B::default(); + let backend = crate::backends::ConcreteBackend::default(); let config = CompileOptions::default(); let paths = std::fs::read_dir(fail_dir).unwrap(); for path in paths.flatten() { @@ -191,7 +191,7 @@ d2 = ["", "", ""] let pass_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join(format!("{TEST_DATA_DIR}/pass_dev_mode")); - let backend = crate::backends::B::default(); + let backend = crate::backends::ConcreteBackend::default(); let config = CompileOptions { allow_warnings: true, ..Default::default() }; let paths = std::fs::read_dir(pass_dir).unwrap(); From 31c6eb0a7d0a0c432529ada27e6efe44ac0916d2 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 9 May 2023 15:47:07 -0700 Subject: [PATCH 07/12] remove unneeded import --- crates/nargo_cli/src/errors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nargo_cli/src/errors.rs b/crates/nargo_cli/src/errors.rs index 69752d2c245..15d1917a5d6 100644 --- a/crates/nargo_cli/src/errors.rs +++ b/crates/nargo_cli/src/errors.rs @@ -2,7 +2,7 @@ use acvm::{Backend, ProofSystemCompiler, SmartContract}; use hex::FromHexError; use nargo::NargoError; use noirc_abi::errors::{AbiError, InputParserError}; -use std::{fmt::Debug, path::PathBuf}; +use std::path::PathBuf; use thiserror::Error; use crate::resolver::DependencyResolutionError; From 98ac822bda7208070499bbc161881612d45dd84c Mon Sep 17 00:00:00 2001 From: sirasistant Date: Wed, 10 May 2023 12:01:39 +0000 Subject: [PATCH 08/12] feat: adapted to heterogeneous bb calls --- crates/nargo/src/ops/execute.rs | 5 +- crates/noirc_evaluator/src/lib.rs | 4 +- .../src/ssa/acir_gen/constraints.rs | 24 ++- .../src/ssa/acir_gen/operations/bitwise.rs | 28 ++-- .../src/ssa/acir_gen/operations/intrinsics.rs | 128 +++++++++----- .../src/ssa/acir_gen/operations/sort.rs | 158 +++++++++--------- crates/noirc_frontend/src/node_interner.rs | 11 +- 7 files changed, 202 insertions(+), 156 deletions(-) diff --git a/crates/nargo/src/ops/execute.rs b/crates/nargo/src/ops/execute.rs index e4c8a5afbb5..04f3501d211 100644 --- a/crates/nargo/src/ops/execute.rs +++ b/crates/nargo/src/ops/execute.rs @@ -1,5 +1,6 @@ +use acvm::pwg::{solve, PartialWitnessGeneratorStatus}; +use acvm::PartialWitnessGenerator; use acvm::{acir::circuit::Circuit, pwg::block::Blocks}; -use acvm::{PartialWitnessGenerator, PartialWitnessGeneratorStatus}; use noirc_abi::WitnessMap; use crate::NargoError; @@ -10,7 +11,7 @@ pub fn execute_circuit( mut initial_witness: WitnessMap, ) -> Result { let mut blocks = Blocks::default(); - let solver_status = backend.solve(&mut initial_witness, &mut blocks, circuit.opcodes)?; + let solver_status = solve(backend, &mut initial_witness, &mut blocks, circuit.opcodes)?; if matches!(solver_status, PartialWitnessGeneratorStatus::RequiresOracleData { .. }) { todo!("Add oracle support to nargo execute") } diff --git a/crates/noirc_evaluator/src/lib.rs b/crates/noirc_evaluator/src/lib.rs index 533adce4325..4c70e15bcb4 100644 --- a/crates/noirc_evaluator/src/lib.rs +++ b/crates/noirc_evaluator/src/lib.rs @@ -13,7 +13,7 @@ pub mod ssa_refactor; use acvm::{ acir::circuit::{opcodes::Opcode as AcirOpcode, Circuit, PublicInputs}, acir::native_types::{Expression, Witness}, - compiler::transformers::IsOpcodeSupported, + compiler::{optimizers::simplify::CircuitSimplifier, transformers::IsOpcodeSupported}, Language, }; use errors::{RuntimeError, RuntimeErrorKind}; @@ -83,6 +83,7 @@ pub fn create_circuit( opcodes, .. } = evaluator; + let simplifier = CircuitSimplifier::new(current_witness_index); let optimized_circuit = acvm::compiler::compile( Circuit { current_witness_index, @@ -92,6 +93,7 @@ pub fn create_circuit( }, np_language, is_opcode_supported, + &simplifier, ) .map_err(|_| RuntimeErrorKind::Spanless(String::from("produced an acvm compile error")))?; diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs b/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs index 11371dc54a6..2d0378c3390 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/constraints.rs @@ -6,7 +6,7 @@ use crate::{ use acvm::{ acir::{ circuit::{ - directives::Directive, + directives::{Directive, QuotientDirective}, opcodes::{BlackBoxFuncCall, FunctionInput, Opcode as AcirOpcode}, }, native_types::{Expression, Witness}, @@ -265,13 +265,13 @@ pub(crate) fn range_constraint( let b_witness = evaluator.add_witness_to_cs(); let exp_big = BigUint::from(2_u128).pow(num_bits - 1); let exp = FieldElement::from_be_bytes_reduce(&exp_big.to_bytes_be()); - evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient { + evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient(QuotientDirective { a: Expression::from(witness), b: Expression::from_field(exp), q: b_witness, r: r_witness, predicate: None, - })); + }))); try_range_constraint(r_witness, num_bits - 1, evaluator); try_range_constraint(b_witness, 1, evaluator); @@ -283,10 +283,8 @@ pub(crate) fn range_constraint( let my_constraint = add(&res, -FieldElement::one(), &witness.into()); evaluator.push_opcode(AcirOpcode::Arithmetic(my_constraint)); } else { - let gate = AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall { - name: acvm::acir::BlackBoxFunc::RANGE, - inputs: vec![FunctionInput { witness, num_bits }], - outputs: vec![], + let gate = AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall::RANGE { + input: FunctionInput { witness, num_bits }, }); evaluator.push_opcode(gate); } @@ -311,13 +309,13 @@ pub(crate) fn bound_check( //2^s+a-b=q*2^s +r let expr = add(&r_witness.into(), two_s, &q_witness.into()); evaluator.push_opcode(AcirOpcode::Arithmetic(subtract(&sub, FieldElement::one(), &expr))); - evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient { + evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient(QuotientDirective { a: sub, b: Expression::from_field(two_s), q: q_witness, r: r_witness, predicate: None, - })); + }))); try_range_constraint(r_witness, max_bits, evaluator); evaluator.push_opcode(AcirOpcode::Arithmetic(boolean(q_witness))); q_witness @@ -504,13 +502,13 @@ pub(crate) fn evaluate_truncate( //1. Generate witnesses a,b,c let b_witness = evaluator.add_witness_to_cs(); let c_witness = evaluator.add_witness_to_cs(); - evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient { + evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient(QuotientDirective { a: lhs.clone(), b: Expression::from_field(exp), q: c_witness, r: b_witness, predicate: None, - })); + }))); try_range_constraint(b_witness, rhs, evaluator); //TODO propagate the error using ? try_range_constraint(c_witness, max_bits - rhs, evaluator); @@ -537,13 +535,13 @@ pub(crate) fn evaluate_udiv( let q_witness = evaluator.add_witness_to_cs(); let r_witness = evaluator.add_witness_to_cs(); let pa = mul_with_witness(evaluator, lhs, predicate); - evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient { + evaluator.push_opcode(AcirOpcode::Directive(Directive::Quotient(QuotientDirective { a: lhs.clone(), b: rhs.clone(), q: q_witness, r: r_witness, predicate: Some(predicate.clone()), - })); + }))); //r acvm::acir::BlackBoxFunc::AND, - BinaryOp::Xor => acvm::acir::BlackBoxFunc::XOR, + let gate = match opcode { + BinaryOp::And => AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall::AND { + lhs: FunctionInput { witness: a_witness, num_bits: bit_size }, + rhs: FunctionInput { witness: b_witness, num_bits: bit_size }, + output: result, + }), + BinaryOp::Xor => AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall::XOR { + lhs: FunctionInput { witness: a_witness, num_bits: bit_size }, + rhs: FunctionInput { witness: b_witness, num_bits: bit_size }, + output: result, + }), BinaryOp::Or => { a_witness = evaluator.create_intermediate_variable(constraints::subtract( &Expression::from_field(max), @@ -136,19 +144,15 @@ pub(super) fn evaluate_bitwise( &Expression::from(b_witness), )); // We do not have an OR gate yet, so we use the AND gate - acvm::acir::BlackBoxFunc::AND + AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall::AND { + lhs: FunctionInput { witness: a_witness, num_bits: bit_size }, + rhs: FunctionInput { witness: b_witness, num_bits: bit_size }, + output: result, + }) } _ => unreachable!("ICE: expected a bitwise operation"), }; - let gate = AcirOpcode::BlackBoxFuncCall(BlackBoxFuncCall { - name: bit_gate, - inputs: vec![ - FunctionInput { witness: a_witness, num_bits: bit_size }, - FunctionInput { witness: b_witness, num_bits: bit_size }, - ], - outputs: vec![result], - }); evaluator.opcodes.push(gate); if opcode == BinaryOp::Or { diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs index ea7d3d9c6c0..86b916d8ce3 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs @@ -7,7 +7,7 @@ use crate::{ }, builtin, context::SsaContext, - mem::{ArrayId, Memory}, + mem::Memory, node::{self, Instruction, Node, NodeId, ObjectType}, }, Evaluator, @@ -19,6 +19,7 @@ use acvm::{ opcodes::{BlackBoxFuncCall, FunctionInput, Opcode as AcirOpcode}, }, native_types::{Expression, Witness}, + BlackBoxFunc, }, FieldElement, }; @@ -79,15 +80,70 @@ pub(crate) fn evaluate( } } Opcode::LowLevel(op) => { - let inputs = prepare_inputs(acir_gen, args, ctx, evaluator); - let output_count = op.definition().output_size.0 as u32; - outputs = - prepare_outputs(&mut acir_gen.memory, instruction_id, output_count, ctx, evaluator); - - let func_call = BlackBoxFuncCall { - name: op, - inputs, //witness + bit size - outputs: outputs.clone(), //witness + outputs = match op { + BlackBoxFunc::SHA256 | BlackBoxFunc::Blake2s => { + prepare_outputs(&mut acir_gen.memory, instruction_id, 32, ctx, evaluator) + } + BlackBoxFunc::Keccak256 => { + prepare_outputs(&mut acir_gen.memory, instruction_id, 32, ctx, evaluator) + } + BlackBoxFunc::Pedersen | BlackBoxFunc::FixedBaseScalarMul => { + prepare_outputs(&mut acir_gen.memory, instruction_id, 2, ctx, evaluator) + } + BlackBoxFunc::SchnorrVerify + | BlackBoxFunc::EcdsaSecp256k1 + | BlackBoxFunc::ComputeMerkleRoot + | BlackBoxFunc::HashToField128Security => { + prepare_outputs(&mut acir_gen.memory, instruction_id, 1, ctx, evaluator) + } + _ => panic!("Unsupported low level function {:?}", op), + }; + let func_call = match op { + BlackBoxFunc::SHA256 => BlackBoxFuncCall::SHA256 { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::Blake2s => BlackBoxFuncCall::Blake2s { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::Keccak256 => BlackBoxFuncCall::Keccak256 { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::Pedersen => BlackBoxFuncCall::Pedersen { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::FixedBaseScalarMul => BlackBoxFuncCall::FixedBaseScalarMul { + input: resolve_variable(&args[0], acir_gen, ctx, evaluator).unwrap(), + outputs: outputs.to_vec(), + }, + BlackBoxFunc::SchnorrVerify => BlackBoxFuncCall::SchnorrVerify { + public_key_x: resolve_variable(&args[0], acir_gen, ctx, evaluator).unwrap(), + public_key_y: resolve_variable(&args[1], acir_gen, ctx, evaluator).unwrap(), + signature: resolve_array(&args[2], acir_gen, ctx, evaluator), + message: resolve_array(&args[3], acir_gen, ctx, evaluator), + output: outputs[0], + }, + BlackBoxFunc::EcdsaSecp256k1 => BlackBoxFuncCall::EcdsaSecp256k1 { + public_key_x: resolve_array(&args[0], acir_gen, ctx, evaluator), + public_key_y: resolve_array(&args[1], acir_gen, ctx, evaluator), + signature: resolve_array(&args[2], acir_gen, ctx, evaluator), + hashed_message: resolve_array(&args[3], acir_gen, ctx, evaluator), + output: outputs[0], + }, + BlackBoxFunc::ComputeMerkleRoot => BlackBoxFuncCall::ComputeMerkleRoot { + leaf: resolve_variable(&args[0], acir_gen, ctx, evaluator).unwrap(), + index: resolve_variable(&args[1], acir_gen, ctx, evaluator).unwrap(), + hash_path: resolve_array(&args[2], acir_gen, ctx, evaluator), + output: outputs[0], + }, + BlackBoxFunc::HashToField128Security => BlackBoxFuncCall::HashToField128Security { + inputs: resolve_array(&args[0], acir_gen, ctx, evaluator), + output: outputs[0], + }, + _ => panic!("Unsupported low level function {:?}", op), }; evaluator.opcodes.push(AcirOpcode::BlackBoxFuncCall(func_call)); } @@ -139,27 +195,12 @@ pub(crate) fn evaluate( (outputs.len() == 1).then(|| InternalVar::from(outputs[0])) } -// Transform the arguments of intrinsic functions into witnesses -fn prepare_inputs( - acir_gen: &mut Acir, - arguments: &[NodeId], - cfg: &SsaContext, - evaluator: &mut Evaluator, -) -> Vec { - let mut inputs: Vec = Vec::new(); - - for argument in arguments { - inputs.extend(resolve_node_id(argument, acir_gen, cfg, evaluator)); - } - inputs -} - -fn resolve_node_id( +fn resolve_variable( node_id: &NodeId, acir_gen: &mut Acir, cfg: &SsaContext, evaluator: &mut Evaluator, -) -> Vec { +) -> Option { let node_object = cfg.try_get_node(*node_id).expect("could not find node for {node_id}"); match node_object { node::NodeObject::Variable(v) => { @@ -167,14 +208,12 @@ fn resolve_node_id( match node_obj_type { // If the `Variable` represents a Pointer // Then we know that it is an `Array` - node::ObjectType::ArrayPointer(a) => resolve_array(a, acir_gen, cfg, evaluator), + node::ObjectType::ArrayPointer(_) => None, // If it is not a pointer, we attempt to fetch the witness associated with it - _ => match v.witness { - Some(w) => { - vec![FunctionInput { witness: w, num_bits: v.size_in_bits() }] - } - None => todo!("generate a witness"), - }, + _ => { + let witness = v.witness?; + Some(FunctionInput { witness, num_bits: v.size_in_bits() }) + } } } _ => { @@ -182,21 +221,30 @@ fn resolve_node_id( // we attempt to fetch an associated `InternalVar`. // Otherwise, this is a internal compiler error. let internal_var = acir_gen.var_cache.get(node_id).expect("invalid input").clone(); - let witness = acir_gen - .var_cache - .get_or_compute_witness(internal_var, evaluator) - .expect("unexpected constant expression"); - vec![FunctionInput { witness, num_bits: node_object.size_in_bits() }] + let witness = acir_gen.var_cache.get_or_compute_witness(internal_var, evaluator)?; + Some(FunctionInput { witness, num_bits: node_object.size_in_bits() }) } } } fn resolve_array( - array_id: ArrayId, + node_id: &NodeId, acir_gen: &mut Acir, cfg: &SsaContext, evaluator: &mut Evaluator, ) -> Vec { + let node_object = cfg.try_get_node(*node_id).expect("could not find node for {node_id}"); + let array_id = match node_object { + node::NodeObject::Variable(_) => { + let node_obj_type = node_object.get_type(); + match node_obj_type { + node::ObjectType::ArrayPointer(a) => a, + _ => unreachable!(), + } + } + _ => todo!("generate a witness"), + }; + let mut inputs = Vec::new(); let array = &cfg.mem[array_id]; diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index 9566252b2be..02870bf1ef9 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -111,88 +111,88 @@ fn permutation_layer( (conf, out_expr) } -#[cfg(test)] -mod test { - use std::collections::BTreeMap; +// #[cfg(test)] +// mod test { +// use std::collections::BTreeMap; - use acvm::{ - acir::{circuit::opcodes::BlackBoxFuncCall, native_types::Witness}, - pwg::block::Blocks, - FieldElement, OpcodeResolution, OpcodeResolutionError, PartialWitnessGenerator, - PartialWitnessGeneratorStatus, - }; +// use acvm::{ +// acir::{circuit::opcodes::BlackBoxFuncCall, native_types::Witness}, +// pwg::block::Blocks, +// FieldElement, OpcodeResolution, OpcodeResolutionError, PartialWitnessGenerator, +// PartialWitnessGeneratorStatus, +// }; - use crate::{ - ssa::acir_gen::operations::sort::{evaluate_permutation, permutation_layer}, - Evaluator, - }; - use rand::prelude::*; +// use crate::{ +// ssa::acir_gen::operations::sort::{evaluate_permutation, permutation_layer}, +// Evaluator, +// }; +// use rand::prelude::*; - struct MockBackend {} - impl PartialWitnessGenerator for MockBackend { - fn solve_black_box_function_call( - &self, - _initial_witness: &mut BTreeMap, - _func_call: &BlackBoxFuncCall, - ) -> Result { - unreachable!(); - } - } +// struct MockBackend {} +// impl PartialWitnessGenerator for MockBackend { +// fn solve_black_box_function_call( +// &self, +// _initial_witness: &mut BTreeMap, +// _func_call: &BlackBoxFuncCall, +// ) -> Result { +// unreachable!(); +// } +// } - // Check that a random network constrains its output to be a permutation of any random input - #[test] - fn test_permutation() { - let mut rng = rand::thread_rng(); - for n in 2..50 { - let mut eval = Evaluator::default(); +// // Check that a random network constrains its output to be a permutation of any random input +// #[test] +// fn test_permutation() { +// let mut rng = rand::thread_rng(); +// for n in 2..50 { +// let mut eval = Evaluator::default(); - //we generate random inputs - let mut input = Vec::new(); - let mut a_val = Vec::new(); - let mut b_wit = Vec::new(); - let mut solved_witness: BTreeMap = BTreeMap::new(); - for i in 0..n { - let w = eval.add_witness_to_cs(); - input.push(w.into()); - a_val.push(FieldElement::from(rng.next_u32() as i128)); - solved_witness.insert(w, a_val[i]); - } +// //we generate random inputs +// let mut input = Vec::new(); +// let mut a_val = Vec::new(); +// let mut b_wit = Vec::new(); +// let mut solved_witness: BTreeMap = BTreeMap::new(); +// for i in 0..n { +// let w = eval.add_witness_to_cs(); +// input.push(w.into()); +// a_val.push(FieldElement::from(rng.next_u32() as i128)); +// solved_witness.insert(w, a_val[i]); +// } - let mut output = Vec::new(); - for _i in 0..n { - let w = eval.add_witness_to_cs(); - b_wit.push(w); - output.push(w.into()); - } - //generate constraints for the inputs - let w = evaluate_permutation(&input, &output, &mut eval); - //checks that it generate the same witness - let (w1, _) = permutation_layer(&input, &w, false, &mut eval); - assert_eq!(w, w1); - //we generate random network - let mut c = Vec::new(); - for _i in 0..w.len() { - c.push(rng.next_u32() % 2 != 0); - } - // initialize bits - for i in 0..w.len() { - solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); - } - // compute the network output by solving the constraints - let backend = MockBackend {}; - let mut blocks = Blocks::default(); - let solver_status = backend - .solve(&mut solved_witness, &mut blocks, eval.opcodes.clone()) - .expect("Could not solve permutation constraints"); - assert_eq!(solver_status, PartialWitnessGeneratorStatus::Solved, "Incomplete solution"); - let mut b_val = Vec::new(); - for i in 0..output.len() { - b_val.push(solved_witness[&b_wit[i]]); - } - // ensure the outputs are a permutation of the inputs - a_val.sort(); - b_val.sort(); - assert_eq!(a_val, b_val); - } - } -} +// let mut output = Vec::new(); +// for _i in 0..n { +// let w = eval.add_witness_to_cs(); +// b_wit.push(w); +// output.push(w.into()); +// } +// //generate constraints for the inputs +// let w = evaluate_permutation(&input, &output, &mut eval); +// //checks that it generate the same witness +// let (w1, _) = permutation_layer(&input, &w, false, &mut eval); +// assert_eq!(w, w1); +// //we generate random network +// let mut c = Vec::new(); +// for _i in 0..w.len() { +// c.push(rng.next_u32() % 2 != 0); +// } +// // initialize bits +// for i in 0..w.len() { +// solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); +// } +// // compute the network output by solving the constraints +// let backend = MockBackend {}; +// let mut blocks = Blocks::default(); +// let solver_status = backend +// .solve(&mut solved_witness, &mut blocks, eval.opcodes.clone()) +// .expect("Could not solve permutation constraints"); +// assert_eq!(solver_status, PartialWitnessGeneratorStatus::Solved, "Incomplete solution"); +// let mut b_val = Vec::new(); +// for i in 0..output.len() { +// b_val.push(solved_witness[&b_wit[i]]); +// } +// // ensure the outputs are a permutation of the inputs +// a_val.sort(); +// b_val.sort(); +// assert_eq!(a_val, b_val); +// } +// } +// } diff --git a/crates/noirc_frontend/src/node_interner.rs b/crates/noirc_frontend/src/node_interner.rs index d8ea11ae89c..f43071c30b5 100644 --- a/crates/noirc_frontend/src/node_interner.rs +++ b/crates/noirc_frontend/src/node_interner.rs @@ -1,7 +1,5 @@ use std::collections::{BTreeMap, HashMap}; -use acvm::acir::circuit::opcodes::BlackBoxFuncCall; -use acvm::acir::circuit::Opcode; use acvm::Language; use arena::{Arena, Index}; use fm::FileId; @@ -583,18 +581,13 @@ impl NodeInterner { self.language = language.clone(); } - #[allow(deprecated)] pub fn foreign(&self, opcode: &str) -> bool { - let is_supported = acvm::default_is_opcode_supported(self.language.clone()); + let is_supported = acvm::default_is_bb_supported(self.language.clone()); let black_box_func = match acvm::acir::BlackBoxFunc::lookup(opcode) { Some(black_box_func) => black_box_func, None => return false, }; - is_supported(&Opcode::BlackBoxFuncCall(BlackBoxFuncCall { - name: black_box_func, - inputs: Vec::new(), - outputs: Vec::new(), - })) + is_supported(black_box_func) } pub fn push_delayed_type_check(&mut self, f: TypeCheckFn) { From 48c9bda69c35d6f04e7852383115a725a682e621 Mon Sep 17 00:00:00 2001 From: sirasistant Date: Wed, 10 May 2023 12:23:20 +0000 Subject: [PATCH 09/12] chore: update cargo tomls --- Cargo.lock | 715 +++++++++++++++++++++--------------- Cargo.toml | 3 +- crates/nargo_cli/Cargo.toml | 4 +- 3 files changed, 431 insertions(+), 291 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e83eaddf54..4ee77a6220e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,8 +5,7 @@ version = 3 [[package]] name = "acir" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084577e67b44c72d1cdfabe286d48adac6f5e0ad441ef134c5c467f4b6eee291" +source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" dependencies = [ "acir_field", "flate2", @@ -17,8 +16,7 @@ dependencies = [ [[package]] name = "acir_field" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a267ef529f4b132293199ecdf8c232ade817f01d916039f2d34562cab39e75e9" +source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" dependencies = [ "ark-bn254", "ark-ff", @@ -31,8 +29,7 @@ dependencies = [ [[package]] name = "acvm" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1d6795105b50b13fa0dd1779b5191c4d8e9cd98b357b0b9a0b04a847baacf0" +source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" dependencies = [ "acir", "acvm_stdlib", @@ -42,7 +39,7 @@ dependencies = [ "k256", "num-bigint", "num-traits", - "sha2 0.9.9", + "sha2 0.10.6", "sha3", "thiserror", ] @@ -50,11 +47,10 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.0.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=0aa72dec1367b4f546ba96a83894b8ae062240f4#0aa72dec1367b4f546ba96a83894b8ae062240f4" +source = "git+https://github.com/noir-lang/aztec_backend?rev=08c3ca9dab72204f241a79f93ceb0696ad0fafea#08c3ca9dab72204f241a79f93ceb0696ad0fafea" dependencies = [ "acvm", "barretenberg-sys", - "blake2", "dirs 3.0.2", "futures-util", "getrandom", @@ -70,8 +66,7 @@ dependencies = [ [[package]] name = "acvm_stdlib" version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3131af53d17ac12340c0ff50f8555d8e040321f8078b8ee3cd8846560b6a44a9" +source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" dependencies = [ "acir", ] @@ -122,6 +117,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -131,11 +135,54 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + [[package]] name = "anstyle" -version = "0.3.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] [[package]] name = "arena" @@ -157,9 +204,9 @@ dependencies = [ [[package]] name = "ark-ec" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c60370a92f8e1a5f053cad73a862e1b99bc642333cd676fa11c0c39f80f4ac2" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" dependencies = [ "ark-ff", "ark-poly", @@ -174,9 +221,9 @@ dependencies = [ [[package]] name = "ark-ff" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2d42532524bee1da5a4f6f733eb4907301baa480829557adcff5dfaeee1d9a" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" dependencies = [ "ark-ff-asm", "ark-ff-macros", @@ -194,32 +241,32 @@ dependencies = [ [[package]] name = "ark-ff-asm" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6873aaba7959593d89babed381d33e2329453368f1bf3c67e07686a1c1056f" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "ark-ff-macros" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c2e7d0f2d67cc7fc925355c74d36e7eda19073639be4a0a233d4611b8c959d" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint", "num-traits", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "ark-poly" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6ec811462cabe265cfe1b102fcfe3df79d7d2929c2425673648ee9abfd0272" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" dependencies = [ "ark-ff", "ark-serialize", @@ -230,9 +277,9 @@ dependencies = [ [[package]] name = "ark-serialize" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e735959bc173ea4baf13327b19c22d452b8e9e8e8f7b7fc34e6bf0e316c33e" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-serialize-derive", "ark-std", @@ -242,13 +289,13 @@ dependencies = [ [[package]] name = "ark-serialize-derive" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd34f0920d995d2c932f38861c416f70de89a6de9875876b012557079603e6cc" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -263,14 +310,14 @@ dependencies = [ [[package]] name = "assert_cmd" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0b2340f55d9661d76793b2bfc2eb0e62689bd79d067a95707ea762afd5e9dd" +checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" dependencies = [ "anstyle", "bstr", "doc-comment", - "predicates 3.0.2", + "predicates 3.0.3", "predicates-core", "predicates-tree", "wait-timeout", @@ -278,14 +325,14 @@ dependencies = [ [[package]] name = "assert_fs" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d5bf7e5441c6393b5a9670a5036abe6b4847612f594b870f7332dbf10cf6fa" +checksum = "f070617a68e5c2ed5d06ee8dd620ee18fb72b99f6c094bed34cf8ab07c875b48" dependencies = [ "anstyle", "doc-comment", "globwalk", - "predicates 3.0.2", + "predicates 3.0.3", "predicates-core", "predicates-tree", "tempfile", @@ -307,16 +354,16 @@ dependencies = [ "cc", "cfg-if 1.0.0", "libc", - "miniz_oxide", + "miniz_oxide 0.6.2", "object 0.30.3", "rustc-demangle", ] [[package]] name = "barretenberg-sys" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bc96e40cc45e7d5622cbc57a140aee926a7fb6e4f7d07dda758daa9256f3317" +checksum = "8083873c06ad0d80fa3a3fe72e465da0d89cd5ed92c8a0e75d765dc5eeafe8e0" dependencies = [ "bindgen", "cc", @@ -350,7 +397,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn", + "syn 1.0.109", "which", ] @@ -373,13 +420,11 @@ dependencies = [ [[package]] name = "blake2" -version = "0.9.2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "crypto-mac 0.8.0", - "digest 0.9.0", - "opaque-debug", + "digest 0.10.6", ] [[package]] @@ -388,7 +433,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding", "generic-array", ] @@ -401,12 +445,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "bstr" version = "1.4.0" @@ -421,9 +459,9 @@ dependencies = [ [[package]] name = "build-data" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a94f9f7aab679acac7ce29ba5581c00d3971a861c3b501c5bb74c3ba0026d90" +checksum = "4ac83c47416b2db78a5a8a45d7d229a730b62806fa41ac6b4dbde6d016798776" dependencies = [ "chrono", "safe-lock", @@ -432,9 +470,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" [[package]] name = "bytecheck" @@ -455,7 +493,7 @@ checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -523,9 +561,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", @@ -534,40 +572,45 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.8" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ - "bitflags", + "clap_builder", "clap_derive", - "clap_lex", - "is-terminal", "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex", "strsim", - "termcolor", ] [[package]] name = "clap_derive" -version = "4.1.8" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bec8e5c9d09e439c4335b1af0abaab56dcf3b94999a936e1bb47b9134288f0" +checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "clap_lex" -version = "0.3.2" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" -dependencies = [ - "os_str_bytes", -] +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" [[package]] name = "codespan" @@ -625,6 +668,12 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "console" version = "0.15.5" @@ -676,9 +725,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "corosensei" @@ -695,9 +744,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -772,9 +821,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -823,16 +872,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "crypto-mac" version = "0.10.1" @@ -845,9 +884,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" dependencies = [ "cc", "cxxbridge-flags", @@ -857,9 +896,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" dependencies = [ "cc", "codespan-reporting 0.11.1", @@ -867,31 +906,31 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 2.0.15", ] [[package]] name = "cxxbridge-flags" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.92" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "darling" -version = "0.14.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" dependencies = [ "darling_core", "darling_macro", @@ -899,26 +938,26 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "darling_macro" -version = "0.14.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -938,7 +977,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -964,6 +1003,7 @@ checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer 0.10.4", "crypto-common", + "subtle", ] [[package]] @@ -1068,39 +1108,39 @@ checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "enumset" -version = "1.0.12" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753" +checksum = "e875f1719c16de097dee81ed675e2d9bb63096823ed3f0ca827b7dea3028bbbb" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" +checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "errno" -version = "0.2.8" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -1151,12 +1191,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.7.1", ] [[package]] @@ -1208,53 +1248,53 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures-channel" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-io" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "futures-sink" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-core", "futures-io", @@ -1278,9 +1318,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -1288,9 +1328,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if 1.0.0", "libc", @@ -1326,7 +1366,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.20", "bstr", "fnv", "log", @@ -1447,7 +1487,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ - "crypto-mac 0.10.1", + "crypto-mac", "digest 0.9.0", ] @@ -1487,9 +1527,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.25" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -1524,16 +1564,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] @@ -1587,9 +1627,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -1604,7 +1644,7 @@ checksum = "cef509aa9bc73864d6756f0d34d35504af3cf0844373afe9b8669a5b8005a729" dependencies = [ "console", "number_prefix", - "portable-atomic", + "portable-atomic 0.3.20", "unicode-width", ] @@ -1619,30 +1659,31 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.6" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "ipnet" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", "rustix", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -1666,9 +1707,9 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5" dependencies = [ "wasm-bindgen", ] @@ -1714,9 +1755,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.140" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libloading" @@ -1739,9 +1780,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" [[package]] name = "log" @@ -1770,7 +1811,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1817,9 +1858,9 @@ dependencies = [ [[package]] name = "mime" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minimal-lexical" @@ -1836,6 +1877,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.6" @@ -2083,12 +2133,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "os_str_bytes" -version = "6.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" - [[package]] name = "owo-colors" version = "3.5.0" @@ -2136,15 +2180,24 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "portable-atomic" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b" +checksum = "e30165d31df606f5726b090ec7592c308a0eaf61721ff64c9a3018e344a8753e" +dependencies = [ + "portable-atomic 1.3.2", +] + +[[package]] +name = "portable-atomic" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc59d1bcc64fc5d021d67521f818db868368028108d37f0e98d74e33f68297b5" [[package]] name = "ppv-lite86" @@ -2168,9 +2221,9 @@ dependencies = [ [[package]] name = "predicates" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c575290b64d24745b6c57a12a31465f0a66f3a4799686a6921526a33b0797965" +checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" dependencies = [ "anstyle", "difflib", @@ -2203,7 +2256,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -2220,9 +2273,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -2253,14 +2306,14 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "quote" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -2375,6 +2428,15 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + [[package]] name = "redox_users" version = "0.4.3" @@ -2382,7 +2444,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", - "redox_syscall", + "redox_syscall 0.2.16", "thiserror", ] @@ -2399,11 +2461,11 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ - "aho-corasick", + "aho-corasick 1.0.1", "memchr", "regex-syntax", ] @@ -2416,9 +2478,9 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "region" @@ -2452,9 +2514,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.16" +version = "0.11.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" +checksum = "13293b639a097af28fc8a90f22add145a9c954e49d77da06263d58cf44d5fb91" dependencies = [ "base64", "bytes", @@ -2508,9 +2570,9 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.40" +version = "0.7.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c30f1d45d9aa61cbc8cd1eb87705470892289bb2d01943e7803b873a57404dc3" +checksum = "21499ed91807f07ae081880aabb2ccc0235e9d88011867d984525e9a4c3cfa3e" dependencies = [ "bytecheck", "hashbrown 0.12.3", @@ -2522,13 +2584,13 @@ dependencies = [ [[package]] name = "rkyv_derive" -version = "0.7.40" +version = "0.7.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff26ed6c7c4dfc2aa9480b86a60e3c7233543a270a680e10758a507c5a4ce476" +checksum = "ac1c672430eb41556291981f45ca900a0239ad007242d1cb4b4167af842db666" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2555,9 +2617,9 @@ dependencies = [ [[package]] name = "rust-embed" -version = "6.6.0" +version = "6.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb133b9a38b5543fad3807fb2028ea47c5f2b566f4f5e28a11902f1a358348b6" +checksum = "1b68543d5527e158213414a92832d2aab11a84d2571a5eb021ebe22c43aab066" dependencies = [ "rust-embed-impl", "rust-embed-utils", @@ -2574,7 +2636,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn", + "syn 1.0.109", "walkdir", ] @@ -2591,9 +2653,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -2612,16 +2674,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.9" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", "errno", "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -2755,9 +2817,9 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.155" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71f2b4817415c6d4210bfe1c7bfcf4801b2d904cb4d0e1a8fdb651013c9e86b8" +checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" dependencies = [ "serde_derive", ] @@ -2773,20 +2835,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.155" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d071a94a3fac4aff69d023a7f411e33f40f3483f8c5190b1953822b6b76d7630" +checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "serde_json" -version = "1.0.94" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -2840,14 +2902,12 @@ dependencies = [ [[package]] name = "sha3" -version = "0.9.1" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", + "digest 0.10.6", "keccak", - "opaque-debug", ] [[package]] @@ -2980,7 +3040,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.109", ] [[package]] @@ -3001,22 +3061,21 @@ dependencies = [ ] [[package]] -name = "synstructure" -version = "0.12.6" +name = "syn" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", - "syn", - "unicode-xid", + "unicode-ident", ] [[package]] name = "target-lexicon" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempdir" @@ -3030,15 +3089,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if 1.0.0", "fastrand", - "redox_syscall", + "redox_syscall 0.3.5", "rustix", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -3058,22 +3117,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -3114,18 +3173,17 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.26.0" +version = "1.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +checksum = "0aa32867d44e6f2ce3385e89dceb990188b8bb0fb25b0cf576647a6f98ac5105" dependencies = [ "autocfg", "bytes", "libc", - "memchr", "mio", "pin-project-lite", "socket2", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -3141,9 +3199,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -3176,9 +3234,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.6" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08de71aa0d6e348f070457f85af8bd566e2bc452156a423ddf22861b3a953fae" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", "serde", @@ -3208,13 +3266,13 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -3239,9 +3297,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" dependencies = [ "sharded-slab", "thread_local", @@ -3262,9 +3320,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-bidi" -version = "0.3.11" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" @@ -3310,6 +3368,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "valuable" version = "0.1.0" @@ -3333,12 +3397,11 @@ dependencies = [ [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -3366,9 +3429,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4" dependencies = [ "cfg-if 1.0.0", "serde", @@ -3378,24 +3441,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.15", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +checksum = "083abe15c5d88556b77bdf7aef403625be9e327ad37c62c4e4129af740168163" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3405,9 +3468,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3415,28 +3478,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb" [[package]] name = "wasm-encoder" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" +checksum = "d05d0b6fcd0aeb98adf16e7975331b3c17222aa815148f5b976370ce589d80ef" dependencies = [ "leb128", ] @@ -3552,7 +3615,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3704,9 +3767,9 @@ checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" [[package]] name = "wast" -version = "55.0.0" +version = "57.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4984d3e1406571f4930ba5cf79bd70f75f41d0e87e17506e0bd19b0e5d085f05" +checksum = "6eb0f5ed17ac4421193c7477da05892c2edafd67f9639e3c11a82086416662dc" dependencies = [ "leb128", "memchr", @@ -3716,18 +3779,18 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af2b53f4da14db05d32e70e9c617abdf6620c575bd5dd972b7400037b4df2091" +checksum = "ab9ab0d87337c3be2bb6fc5cd331c4ba9fd6bcb4ee85048a0dd59ed9ecf92e53" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721" dependencies = [ "js-sys", "wasm-bindgen", @@ -3794,6 +3857,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.33.0" @@ -3813,12 +3885,12 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.42.2", "windows_aarch64_msvc 0.42.2", "windows_i686_gnu 0.42.2", "windows_i686_msvc 0.42.2", "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.42.2", "windows_x86_64_msvc 0.42.2", ] @@ -3828,7 +3900,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", ] [[package]] @@ -3837,21 +3918,42 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.42.2", "windows_aarch64_msvc 0.42.2", "windows_i686_gnu 0.42.2", "windows_i686_msvc 0.42.2", "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.42.2", "windows_x86_64_msvc 0.42.2", ] +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.33.0" @@ -3864,6 +3966,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.33.0" @@ -3876,6 +3984,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.33.0" @@ -3888,6 +4002,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.33.0" @@ -3900,12 +4020,24 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.33.0" @@ -3918,11 +4050,17 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "winnow" -version = "0.3.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee7b2c67f962bf5042bfd8b6a916178df33a26eec343ae064cb8e069f638fa6f" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" dependencies = [ "memchr", ] @@ -3944,21 +4082,20 @@ checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" [[package]] name = "zeroize" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn", - "synstructure", + "syn 2.0.15", ] diff --git a/Cargo.toml b/Cargo.toml index 4169aa9b6eb..447958b3268 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,8 @@ edition = "2021" rust-version = "1.66" [workspace.dependencies] -acvm = "0.11.0" +#acvm = "0.11.0" +acvm = { git = "https://github.com/noir-lang/acvm", rev = "045e18ae13f2228171ce9e37da6e3e9691da2876" } arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 179076c22c1..68f4a967892 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -37,7 +37,9 @@ termcolor = "1.1.2" color-eyre = "0.6.2" # Backends -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "0aa72dec1367b4f546ba96a83894b8ae062240f4", default-features = false } +#acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "0aa72dec1367b4f546ba96a83894b8ae062240f4", default-features = false } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "08c3ca9dab72204f241a79f93ceb0696ad0fafea", default-features = false } + [dev-dependencies] tempdir = "0.3.7" From eebe4266744464ee352f7c3b41e5d7361a4b2ae5 Mon Sep 17 00:00:00 2001 From: sirasistant Date: Wed, 10 May 2023 12:29:42 +0000 Subject: [PATCH 10/12] test: re enabled sort test --- .../src/ssa/acir_gen/operations/sort.rs | 263 ++++++++++++------ 1 file changed, 184 insertions(+), 79 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs index 02870bf1ef9..d85182f1387 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -111,88 +111,193 @@ fn permutation_layer( (conf, out_expr) } -// #[cfg(test)] -// mod test { -// use std::collections::BTreeMap; +#[cfg(test)] +mod test { + use std::collections::BTreeMap; -// use acvm::{ -// acir::{circuit::opcodes::BlackBoxFuncCall, native_types::Witness}, -// pwg::block::Blocks, -// FieldElement, OpcodeResolution, OpcodeResolutionError, PartialWitnessGenerator, -// PartialWitnessGeneratorStatus, -// }; + use acvm::{ + acir::{circuit::opcodes::FunctionInput, native_types::Witness}, + pwg::{block::Blocks, solve, OpcodeResolution, PartialWitnessGeneratorStatus}, + FieldElement, OpcodeResolutionError, PartialWitnessGenerator, + }; -// use crate::{ -// ssa::acir_gen::operations::sort::{evaluate_permutation, permutation_layer}, -// Evaluator, -// }; -// use rand::prelude::*; + use crate::{ + ssa::acir_gen::operations::sort::{evaluate_permutation, permutation_layer}, + Evaluator, + }; + use rand::prelude::*; -// struct MockBackend {} -// impl PartialWitnessGenerator for MockBackend { -// fn solve_black_box_function_call( -// &self, -// _initial_witness: &mut BTreeMap, -// _func_call: &BlackBoxFuncCall, -// ) -> Result { -// unreachable!(); -// } -// } + struct MockBackend {} + impl PartialWitnessGenerator for MockBackend { + fn aes( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn and( + &self, + _initial_witness: &mut BTreeMap, + _lhs: &FunctionInput, + _rhs: &FunctionInput, + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn xor( + &self, + _initial_witness: &mut BTreeMap, + _lhs: &FunctionInput, + _rhs: &FunctionInput, + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn range( + &self, + _initial_witness: &mut BTreeMap, + _input: &FunctionInput, + ) -> Result { + panic!("Path not trodden by this test") + } + fn sha256( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn blake2s( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn compute_merkle_root( + &self, + _initial_witness: &mut BTreeMap, + _leaf: &FunctionInput, + _index: &FunctionInput, + _hash_path: &[FunctionInput], + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn schnorr_verify( + &self, + _initial_witness: &mut BTreeMap, + _public_key_x: &FunctionInput, + _public_key_y: &FunctionInput, + _signature: &[FunctionInput], + _message: &[FunctionInput], + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn pedersen( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn hash_to_field_128_security( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn ecdsa_secp256k1( + &self, + _initial_witness: &mut BTreeMap, + _public_key_x: &[FunctionInput], + _public_key_y: &[FunctionInput], + _signature: &[FunctionInput], + _message: &[FunctionInput], + _output: &Witness, + ) -> Result { + panic!("Path not trodden by this test") + } + fn fixed_base_scalar_mul( + &self, + _initial_witness: &mut BTreeMap, + _input: &FunctionInput, + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + fn keccak256( + &self, + _initial_witness: &mut BTreeMap, + _inputs: &[FunctionInput], + _outputs: &[Witness], + ) -> Result { + panic!("Path not trodden by this test") + } + } -// // Check that a random network constrains its output to be a permutation of any random input -// #[test] -// fn test_permutation() { -// let mut rng = rand::thread_rng(); -// for n in 2..50 { -// let mut eval = Evaluator::default(); + // Check that a random network constrains its output to be a permutation of any random input + #[test] + fn test_permutation() { + let mut rng = rand::thread_rng(); + for n in 2..50 { + let mut eval = Evaluator::default(); -// //we generate random inputs -// let mut input = Vec::new(); -// let mut a_val = Vec::new(); -// let mut b_wit = Vec::new(); -// let mut solved_witness: BTreeMap = BTreeMap::new(); -// for i in 0..n { -// let w = eval.add_witness_to_cs(); -// input.push(w.into()); -// a_val.push(FieldElement::from(rng.next_u32() as i128)); -// solved_witness.insert(w, a_val[i]); -// } + //we generate random inputs + let mut input = Vec::new(); + let mut a_val = Vec::new(); + let mut b_wit = Vec::new(); + let mut solved_witness: BTreeMap = BTreeMap::new(); + for i in 0..n { + let w = eval.add_witness_to_cs(); + input.push(w.into()); + a_val.push(FieldElement::from(rng.next_u32() as i128)); + solved_witness.insert(w, a_val[i]); + } -// let mut output = Vec::new(); -// for _i in 0..n { -// let w = eval.add_witness_to_cs(); -// b_wit.push(w); -// output.push(w.into()); -// } -// //generate constraints for the inputs -// let w = evaluate_permutation(&input, &output, &mut eval); -// //checks that it generate the same witness -// let (w1, _) = permutation_layer(&input, &w, false, &mut eval); -// assert_eq!(w, w1); -// //we generate random network -// let mut c = Vec::new(); -// for _i in 0..w.len() { -// c.push(rng.next_u32() % 2 != 0); -// } -// // initialize bits -// for i in 0..w.len() { -// solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); -// } -// // compute the network output by solving the constraints -// let backend = MockBackend {}; -// let mut blocks = Blocks::default(); -// let solver_status = backend -// .solve(&mut solved_witness, &mut blocks, eval.opcodes.clone()) -// .expect("Could not solve permutation constraints"); -// assert_eq!(solver_status, PartialWitnessGeneratorStatus::Solved, "Incomplete solution"); -// let mut b_val = Vec::new(); -// for i in 0..output.len() { -// b_val.push(solved_witness[&b_wit[i]]); -// } -// // ensure the outputs are a permutation of the inputs -// a_val.sort(); -// b_val.sort(); -// assert_eq!(a_val, b_val); -// } -// } -// } + let mut output = Vec::new(); + for _i in 0..n { + let w = eval.add_witness_to_cs(); + b_wit.push(w); + output.push(w.into()); + } + //generate constraints for the inputs + let w = evaluate_permutation(&input, &output, &mut eval); + //checks that it generate the same witness + let (w1, _) = permutation_layer(&input, &w, false, &mut eval); + assert_eq!(w, w1); + //we generate random network + let mut c = Vec::new(); + for _i in 0..w.len() { + c.push(rng.next_u32() % 2 != 0); + } + // initialize bits + for i in 0..w.len() { + solved_witness.insert(w[i], FieldElement::from(c[i] as i128)); + } + // compute the network output by solving the constraints + let backend = MockBackend {}; + let mut blocks = Blocks::default(); + let solver_status = + solve(&backend, &mut solved_witness, &mut blocks, eval.opcodes.clone()) + .expect("Could not solve permutation constraints"); + assert_eq!(solver_status, PartialWitnessGeneratorStatus::Solved, "Incomplete solution"); + let mut b_val = Vec::new(); + for i in 0..output.len() { + b_val.push(solved_witness[&b_wit[i]]); + } + // ensure the outputs are a permutation of the inputs + a_val.sort(); + b_val.sort(); + assert_eq!(a_val, b_val); + } + } +} From 693d53d8b746b446f1265c074cda1a878388578c Mon Sep 17 00:00:00 2001 From: sirasistant Date: Wed, 10 May 2023 13:31:24 +0000 Subject: [PATCH 11/12] fix: improve variable resolution --- .../src/ssa/acir_gen/operations/intrinsics.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs index 86b916d8ce3..01d5fecc897 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/intrinsics.rs @@ -204,17 +204,7 @@ fn resolve_variable( let node_object = cfg.try_get_node(*node_id).expect("could not find node for {node_id}"); match node_object { node::NodeObject::Variable(v) => { - let node_obj_type = node_object.get_type(); - match node_obj_type { - // If the `Variable` represents a Pointer - // Then we know that it is an `Array` - node::ObjectType::ArrayPointer(_) => None, - // If it is not a pointer, we attempt to fetch the witness associated with it - _ => { - let witness = v.witness?; - Some(FunctionInput { witness, num_bits: v.size_in_bits() }) - } - } + Some(FunctionInput { witness: v.witness?, num_bits: v.size_in_bits() }) } _ => { // Upon the case that the `NodeObject` is not a `Variable`, @@ -244,7 +234,6 @@ fn resolve_array( } _ => todo!("generate a witness"), }; - let mut inputs = Vec::new(); let array = &cfg.mem[array_id]; From 9de3f2b31917c9f56d56902c699c9d53d6a00e55 Mon Sep 17 00:00:00 2001 From: sirasistant Date: Thu, 11 May 2023 08:52:21 +0000 Subject: [PATCH 12/12] feat: use dummy constructor for bb call --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- crates/nargo_cli/Cargo.toml | 2 +- crates/noirc_frontend/src/node_interner.rs | 11 +++++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ee77a6220e..48b1003fc21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ version = 3 [[package]] name = "acir" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" dependencies = [ "acir_field", "flate2", @@ -16,7 +16,7 @@ dependencies = [ [[package]] name = "acir_field" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" dependencies = [ "ark-bn254", "ark-ff", @@ -29,7 +29,7 @@ dependencies = [ [[package]] name = "acvm" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" dependencies = [ "acir", "acvm_stdlib", @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "acvm-backend-barretenberg" version = "0.0.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=08c3ca9dab72204f241a79f93ceb0696ad0fafea#08c3ca9dab72204f241a79f93ceb0696ad0fafea" +source = "git+https://github.com/noir-lang/aztec_backend?rev=51457b47adf8f5b8c97d935ebe7176f3c8620e16#51457b47adf8f5b8c97d935ebe7176f3c8620e16" dependencies = [ "acvm", "barretenberg-sys", @@ -66,7 +66,7 @@ dependencies = [ [[package]] name = "acvm_stdlib" version = "0.11.0" -source = "git+https://github.com/noir-lang/acvm?rev=045e18ae13f2228171ce9e37da6e3e9691da2876#045e18ae13f2228171ce9e37da6e3e9691da2876" +source = "git+https://github.com/noir-lang/acvm?rev=018d6865e03ddd09ed409b383f38971ec9ec3310#018d6865e03ddd09ed409b383f38971ec9ec3310" dependencies = [ "acir", ] diff --git a/Cargo.toml b/Cargo.toml index 447958b3268..62841cd8484 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ rust-version = "1.66" [workspace.dependencies] #acvm = "0.11.0" -acvm = { git = "https://github.com/noir-lang/acvm", rev = "045e18ae13f2228171ce9e37da6e3e9691da2876" } +acvm = { git = "https://github.com/noir-lang/acvm", rev = "018d6865e03ddd09ed409b383f38971ec9ec3310" } arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 68f4a967892..c57a3b027a7 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -38,7 +38,7 @@ color-eyre = "0.6.2" # Backends #acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "0aa72dec1367b4f546ba96a83894b8ae062240f4", default-features = false } -acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "08c3ca9dab72204f241a79f93ceb0696ad0fafea", default-features = false } +acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "51457b47adf8f5b8c97d935ebe7176f3c8620e16", default-features = false } [dev-dependencies] diff --git a/crates/noirc_frontend/src/node_interner.rs b/crates/noirc_frontend/src/node_interner.rs index f43071c30b5..f3cb00ae9ca 100644 --- a/crates/noirc_frontend/src/node_interner.rs +++ b/crates/noirc_frontend/src/node_interner.rs @@ -1,5 +1,7 @@ use std::collections::{BTreeMap, HashMap}; +use acvm::acir::circuit::opcodes::BlackBoxFuncCall; +use acvm::acir::circuit::Opcode; use acvm::Language; use arena::{Arena, Index}; use fm::FileId; @@ -581,13 +583,14 @@ impl NodeInterner { self.language = language.clone(); } + #[allow(deprecated)] pub fn foreign(&self, opcode: &str) -> bool { - let is_supported = acvm::default_is_bb_supported(self.language.clone()); - let black_box_func = match acvm::acir::BlackBoxFunc::lookup(opcode) { - Some(black_box_func) => black_box_func, + let is_supported = acvm::default_is_opcode_supported(self.language.clone()); + let black_box_func_call = match acvm::acir::BlackBoxFunc::lookup(opcode) { + Some(black_box_func) => BlackBoxFuncCall::dummy(black_box_func), None => return false, }; - is_supported(black_box_func) + is_supported(&Opcode::BlackBoxFuncCall(black_box_func_call)) } pub fn push_delayed_type_check(&mut self, f: TypeCheckFn) {