From 7168aec8633df76238afd786e8ab5b52504812ad Mon Sep 17 00:00:00 2001 From: Koby Date: Wed, 22 Feb 2023 08:46:25 +0100 Subject: [PATCH 01/54] feat(build): Nix flake to build with --- crates/nargo/Cargo.toml | 1 - flake.lock | 184 ++++++++++++++++++++++++++++++++++++++++ flake.nix | 171 +++++++++++++++++++++++++++++++++++++ 3 files changed, 355 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/crates/nargo/Cargo.toml b/crates/nargo/Cargo.toml index d24d238ea3..317ae1e706 100644 --- a/crates/nargo/Cargo.toml +++ b/crates/nargo/Cargo.toml @@ -14,4 +14,3 @@ rustc_version = "0.4.0" toml.workspace = true serde.workspace = true thiserror.workspace = true - diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..124c843061 --- /dev/null +++ b/flake.lock @@ -0,0 +1,184 @@ +{ + "nodes": { + "barretenberg": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1678819958, + "narHash": "sha256-ResINN3e6J91RlGlu9BVucxIbIRRbWMKL6HcyCNt9ZY=", + "ref": "refs/heads/master", + "rev": "f2f8d1f7a24ca73e30c981fd245c86f7f964abb7", + "revCount": 931, + "type": "git", + "url": "https://github.com/AztecProtocol/barretenberg" + }, + "original": { + "type": "git", + "url": "https://github.com/AztecProtocol/barretenberg" + } + }, + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1678152261, + "narHash": "sha256-cPRDxwygVMleiSEGELrvAiq9vYAN4c3KK/K4UEO13vU=", + "owner": "ipetkov", + "repo": "crane", + "rev": "5291dd0aa7a52d607fc952763ef60714e4c881d4", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678875422, + "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "barretenberg": "barretenberg", + "crane": "crane", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay_2" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "crane", + "flake-utils" + ], + "nixpkgs": [ + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677812689, + "narHash": "sha256-EakqhgRnjVeYJv5+BJx/NZ7/eFTMBxc4AhICUNquhUg=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "e53e8853aa7b0688bc270e9e6a681d22e01cf299", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "rust-overlay_2": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1678933473, + "narHash": "sha256-UY19R278O9bwneLWC7ady8VMoQ+UlAWy8SkUsfDZvQs=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "5c1af9b9d618e02a87cdd30a3022aec0b78cd9aa", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..089f721f00 --- /dev/null +++ b/flake.nix @@ -0,0 +1,171 @@ +{ + description = "Nargo"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + crane = { + url = "github:ipetkov/crane"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + flake-utils.url = "github:numtide/flake-utils"; + + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + + barretenberg = { + url = "git+https://github.com/AztecProtocol/barretenberg"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { self, nixpkgs, crane, flake-utils, rust-overlay, barretenberg, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ + rust-overlay.overlays.default + barretenberg.overlays.default + ]; + }; + + rustToolchain = pkgs.rust-bin.stable."1.66.0".default; + + craneLibScope = (crane.mkLib pkgs).overrideScope' (final: prev: { + # As per https://discourse.nixos.org/t/gcc11stdenv-and-clang/17734/7 + stdenv = with pkgs; + if (stdenv.targetPlatform.isGnu && stdenv.targetPlatform.isAarch64) then + overrideCC llvmPackages.stdenv (llvmPackages.clang.override { gccForLibs = gcc11.cc; }) + else + llvmPackages.stdenv; + }); + + craneLib = craneLibScope.overrideToolchain rustToolchain; + + environment = { + # rust-bindgen needs to know the location of libclang + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + + # We set the environment variable because requiring 2 versions of bb collide when pkg-config searches for it + BARRETENBERG_BIN_DIR = "${pkgs.pkgsCross.wasi32.barretenberg}/bin"; + + # We fetch the transcript as a dependency and provide it to the build. + # This is necessary because the Nix sandbox is read-only and downloading during tests would fail + BARRETENBERG_TRANSCRIPT = pkgs.fetchurl { + url = "http://aztec-ignition.s3.amazonaws.com/MAIN%20IGNITION/sealed/transcript00.dat"; + sha256 = "sha256-ryR/d+vpOCxa3gM0lze2UVUKNUinj0nN3ScCfysN84k="; + }; + }; + + COMMIT_HASH = if builtins.pathExists ./revision.checksum + then builtins.readFile ./revision.checksum + else "unknown"; + # COMMIT_HASH = builtins.tryEval (builtins.readFile "revision.checksum" {}) ? ""; + # This is a problem for now + GIT_COMMIT = if (self ? rev) then self.rev else COMMIT_HASH; + GIT_DIRTY = "false"; + + commonArgs = { + pname = "nargo"; + src = ./.; + + nativeBuildInputs = [ + # This provides the pkg-config tool to find barretenberg & other native libraries + pkgs.pkg-config + # This provides the `lld` linker to cargo + pkgs.llvmPackages.bintools + ]; + + buildInputs = [ + pkgs.llvmPackages.openmp + pkgs.barretenberg + ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ + # Need libiconv and apple Security on Darwin. See https://github.com/ipetkov/crane/issues/156 + pkgs.libiconv + pkgs.darwin.apple_sdk.frameworks.Security + ]; + + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + + inherit GIT_COMMIT; + inherit GIT_DIRTY; + + } // environment; + + src = pkgs.copyPathToStore ./.; + + + nargo = craneLib.buildPackage ({ + + doCheck = true; + + cargoBuildCommand = "cargo build --release"; + + } // commonArgs); + + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + in rec { + checks = { + cargo-check = craneLib.buildPackage (commonArgs // { + inherit cargoArtifacts; + + doCheck = true; + }); + + cargo-clippy = craneLib.cargoClippy (commonArgs // { + inherit cargoArtifacts; + + cargoClippyExtraArgs = "--all-targets --workspace -- -D warnings"; + + doCheck = true; + }); + + cargo-test = craneLib.cargoTest (commonArgs // { + inherit cargoArtifacts; + + cargoTestArgs = "--workspace -- --test-threads=1"; + + doCheck = true; + }); + }; + + packages.default = nargo; + + apps.default = flake-utils.lib.mkApp { drv = nargo; }; + + devShells.default = pkgs.mkShell.override { stdenv = pkgs.llvmPackages.stdenv; } { + inputsFrom = builtins.attrValues self.checks; + + buildInputs = packages.default.buildInputs ; + + inherit COMMIT_HASH; + + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + # Uncertain if below line is needed. dev Shell is not yet fully working + # BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.barretenberg}/include -isystem ${pkgs.llvmPackages.libcxx.dev}/include"; + + TERM = "xterm-256color"; + + nativeBuildInputs = with pkgs; packages.default.buildInputs ++ [ + which + starship + git + cargo + rustc + ]; + + shellHook = '' + eval "$(starship init bash)" + ''; + + }; + }); +} From 4d962ffe4fb59fe29b34c6d8b10c776b17bb5559 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Tue, 28 Mar 2023 11:37:43 +0100 Subject: [PATCH 02/54] use debug ultra branch for backend, and temporary simple XOR/AND test added to nargo test_data --- .../nargo/tests/test_data/testing/Nargo.toml | 5 ++++ .../nargo/tests/test_data/testing/Prover.toml | 2 ++ .../nargo/tests/test_data/testing/src/main.nr | 5 ++++ .../tests/test_data/8_integration/src/main.nr | 24 ++++++++++++------- 4 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 crates/nargo/tests/test_data/testing/Nargo.toml create mode 100644 crates/nargo/tests/test_data/testing/Prover.toml create mode 100644 crates/nargo/tests/test_data/testing/src/main.nr diff --git a/crates/nargo/tests/test_data/testing/Nargo.toml b/crates/nargo/tests/test_data/testing/Nargo.toml new file mode 100644 index 0000000000..e0b467ce5d --- /dev/null +++ b/crates/nargo/tests/test_data/testing/Nargo.toml @@ -0,0 +1,5 @@ +[package] +authors = [""] +compiler_version = "0.1" + +[dependencies] \ No newline at end of file diff --git a/crates/nargo/tests/test_data/testing/Prover.toml b/crates/nargo/tests/test_data/testing/Prover.toml new file mode 100644 index 0000000000..f28f2f8cc4 --- /dev/null +++ b/crates/nargo/tests/test_data/testing/Prover.toml @@ -0,0 +1,2 @@ +x = "5" +y = "10" diff --git a/crates/nargo/tests/test_data/testing/src/main.nr b/crates/nargo/tests/test_data/testing/src/main.nr new file mode 100644 index 0000000000..cc7caf17fa --- /dev/null +++ b/crates/nargo/tests/test_data/testing/src/main.nr @@ -0,0 +1,5 @@ +fn main(x : u32, y : pub u32) { + let m = x ^ y; + + constrain m != 10; +} \ No newline at end of file diff --git a/crates/nargo_cli/tests/test_data/8_integration/src/main.nr b/crates/nargo_cli/tests/test_data/8_integration/src/main.nr index 57dca4e2ac..eb285de5ce 100644 --- a/crates/nargo_cli/tests/test_data/8_integration/src/main.nr +++ b/crates/nargo_cli/tests/test_data/8_integration/src/main.nr @@ -1,3 +1,5 @@ +use dep::std; + fn matrix_mul_2(a: [u32; 4], b: [u32; 4]) ->[u32; 4] { let mut c = [0 as u32; 4]; for i in 0..2 { @@ -142,14 +144,14 @@ fn too(x: u32) -> u32 { (x + 17 as u32) * (x + 3 as u32) } -fn test6(x: [u8; 32]) -> [u32; 8] { +fn test6(x: [u32; 32]) -> [u32; 8] { let mut sha_m = [0 as u32; 64]; let mut sha_hash = [ 1 as u32, 2, 3, 4, 5, 6, 7, 8 ]; - let mut buffer = [0 as u8; 64]; + let mut buffer = [0 as u32; 64]; for i in 0..32 { buffer[i] = x[i]; } @@ -159,14 +161,14 @@ fn test6(x: [u8; 32]) -> [u32; 8] { sha_hash } -fn iterate6_1(mut sha_m: [u32; 64], next_chunk: [u8; 64]) -> [u32; 64] { +fn iterate6_1(mut sha_m: [u32; 64], next_chunk: [u32; 64]) -> [u32; 64] { let mut j = 0; for i in 0..16 { j = (i ) * 4; - sha_m[i] = ((next_chunk[j] as u32) << 24 as u32) - | ((next_chunk[j + 1] as u32) << 16 as u32) - | ((next_chunk[j + 2] as u32) << 8 as u32) - | (next_chunk[j + 3] as u32); + sha_m[i] = ((next_chunk[j]) << 24 as u32) + | ((next_chunk[j + 1]) << 16) + | ((next_chunk[j + 2]) << 8) + | (next_chunk[j + 3]); } for i in 16..64 { sha_m[i] = sig1(sha_m[i - 2])+(sha_m[i - 7])+(sig0(sha_m[i - 15]))+(sha_m[i - 16]); @@ -242,7 +244,13 @@ fn sig1(x: u32) -> u32 { } -fn main(a: [u32; 100], b: [u32; 100], c: [u32; 4], mut d: [u32; 4], m: [u8; 32]) { +fn main(a: [u32; 100], b: [u32; 100], c: [u32; 4], mut d: [u32; 4], m: [u32; 32]) { + + // let sha_m = (m[0] << 24 as u32) + // | (m[1] << 16 as u32); + + // constrain sha_m != 10; + let e = matrix_mul_10(a,b); constrain e[6] == 1866842232; let f = matrix_mul_2(c,d); From df4d386163a2b331df20e02d57a25f828c590f54 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:13:20 -0700 Subject: [PATCH 03/54] ignore result --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 10988465b2..84d2972035 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ examples/9 .vscode node_modules pkg/ +result # Nargo output *.proof @@ -13,4 +14,4 @@ pkg/ *.tr *.pk *.vk -**/Verifier.toml \ No newline at end of file +**/Verifier.toml From 3ad9134ae99334c3908689ca9da24d8f6074453c Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:14:24 -0700 Subject: [PATCH 04/54] Update deps --- Cargo.lock | 155 ++++++++++-------------------------- crates/nargo_cli/Cargo.toml | 4 +- 2 files changed, 46 insertions(+), 113 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b311bc608c..8e09f9bb27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -512,17 +512,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -545,32 +534,37 @@ dependencies = [ ] [[package]] -name = "barretenberg_static_lib" +name = "barretenberg-sys" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=26178359a2251e885f15f0a4d1a686afda04aec9#26178359a2251e885f15f0a4d1a686afda04aec9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a7cbc8eeb6dbbea6d4d3f3db55b786d5c52ad6c88e999a328e1ce6aedd605e" dependencies = [ - "barretenberg_wrapper", - "common", + "bindgen", + "cc", + "color-eyre", + "link-cplusplus", + "pkg-config", + "thiserror", ] [[package]] -name = "barretenberg_wasm" +name = "barretenberg_static_lib" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=26178359a2251e885f15f0a4d1a686afda04aec9#26178359a2251e885f15f0a4d1a686afda04aec9" +source = "git+https://github.com/noir-lang/aztec_backend?rev=880bcc8657b63205573655c175fad596bf277c36#880bcc8657b63205573655c175fad596bf277c36" dependencies = [ + "barretenberg-sys", "common", - "wasmer", ] [[package]] -name = "barretenberg_wrapper" +name = "barretenberg_wasm" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec-connect?branch=kw/noir-dsl#dbd544318819cf710dede8ffb7b7eafa112f5aed" +source = "git+https://github.com/noir-lang/aztec_backend?rev=880bcc8657b63205573655c175fad596bf277c36#880bcc8657b63205573655c175fad596bf277c36" dependencies = [ - "bindgen", - "cmake", - "hex", - "num_cpus 0.2.13", + "common", + "pkg-config", + "rust-embed", + "wasmer", ] [[package]] @@ -581,15 +575,13 @@ checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] name = "bindgen" -version = "0.60.1" +version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ "bitflags", "cexpr", "clang-sys", - "clap 3.2.23", - "env_logger", "lazy_static", "lazycell", "log", @@ -599,6 +591,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", + "syn", "which", ] @@ -773,21 +766,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "clap" -version = "3.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" -dependencies = [ - "atty", - "bitflags", - "clap_lex 0.2.4", - "indexmap", - "strsim", - "termcolor", - "textwrap", -] - [[package]] name = "clap" version = "4.1.8" @@ -796,7 +774,7 @@ checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" dependencies = [ "bitflags", "clap_derive", - "clap_lex 0.3.2", + "clap_lex", "is-terminal", "once_cell", "strsim", @@ -816,15 +794,6 @@ dependencies = [ "syn", ] -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "clap_lex" version = "0.3.2" @@ -834,15 +803,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "cmake" -version = "0.1.49" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db34956e100b30725f2eb215f90d4871051239535632f84fea3bc92722c66b7c" -dependencies = [ - "cc", -] - [[package]] name = "codespan" version = "0.9.5" @@ -902,14 +862,13 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=26178359a2251e885f15f0a4d1a686afda04aec9#26178359a2251e885f15f0a4d1a686afda04aec9" +source = "git+https://github.com/noir-lang/aztec_backend?rev=880bcc8657b63205573655c175fad596bf277c36#880bcc8657b63205573655c175fad596bf277c36" dependencies = [ "acvm 0.8.0", "blake2", "dirs 3.0.2", "downloader", "indicatif", - "regex", "sled", ] @@ -1393,19 +1352,6 @@ dependencies = [ "syn", ] -[[package]] -name = "env_logger" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - [[package]] name = "errno" version = "0.2.8" @@ -1781,15 +1727,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.2.6" @@ -1855,12 +1792,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.25" @@ -2261,7 +2192,7 @@ dependencies = [ "barretenberg_wasm", "build-data", "cfg-if 1.0.0", - "clap 4.1.8", + "clap", "color-eyre", "const_format", "dirs 4.0.0", @@ -2316,7 +2247,7 @@ name = "noirc_driver" version = "0.3.2" dependencies = [ "acvm 0.8.0", - "clap 4.1.8", + "clap", "fm", "iter-extended", "noirc_abi", @@ -2418,15 +2349,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee7e88156f3f9e19bdd598f8d6c9db7bf4078f99f8381f43a55b09648d1a6e3" -dependencies = [ - "libc", -] - [[package]] name = "num_cpus" version = "1.15.0" @@ -2562,6 +2484,12 @@ dependencies = [ "der", ] +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2770,7 +2698,7 @@ dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus 1.15.0", + "num_cpus", ] [[package]] @@ -2987,6 +2915,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", + "shellexpand", "syn", "walkdir", ] @@ -2997,6 +2926,7 @@ version = "7.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512b0ab6853f7e14e3c8754acb43d6f748bb9ced66aa5915a6553ac8213f7731" dependencies = [ + "globset", "sha2 0.10.6", "walkdir", ] @@ -3286,6 +3216,15 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shellexpand" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4" +dependencies = [ + "dirs 4.0.0", +] + [[package]] name = "shlex" version = "1.1.0" @@ -3481,12 +3420,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "textwrap" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" - [[package]] name = "thiserror" version = "1.0.39" @@ -3554,7 +3487,7 @@ dependencies = [ "libc", "memchr", "mio", - "num_cpus 1.15.0", + "num_cpus", "pin-project-lite", "socket2", "windows-sys 0.45.0", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 8d96eba810..8d7ddc8d1f 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -38,8 +38,8 @@ tempdir = "0.3.7" color-eyre = "0.6.2" # Backends -aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "26178359a2251e885f15f0a4d1a686afda04aec9" } -aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "26178359a2251e885f15f0a4d1a686afda04aec9" } +aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "880bcc8657b63205573655c175fad596bf277c36" } +aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "880bcc8657b63205573655c175fad596bf277c36" } marlin_arkworks_backend = { optional = true, git = "https://github.com/noir-lang/marlin_arkworks_backend", rev = "144378edad821bfaa52bf2cacca8ecc87514a4fc" } [dev-dependencies] From 22cf6776ae02e535e18dbda1c0ccc0859897d028 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:14:51 -0700 Subject: [PATCH 05/54] Avoid reading build data if we already have it --- crates/nargo_cli/build.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/nargo_cli/build.rs b/crates/nargo_cli/build.rs index 0745d31840..8f3b00d765 100644 --- a/crates/nargo_cli/build.rs +++ b/crates/nargo_cli/build.rs @@ -7,10 +7,16 @@ fn check_rustc_version() { ); } +const GIT_COMMIT: &&str = &"GIT_COMMIT"; + fn main() { check_rustc_version(); - build_data::set_GIT_COMMIT(); - build_data::set_GIT_DIRTY(); - build_data::no_debug_rebuilds(); + // Only use build_data if the environment variable isn't set + // The environment variable is always set when working via Nix + if let Err(_) = std::env::var(GIT_COMMIT) { + build_data::set_GIT_COMMIT(); + build_data::set_GIT_DIRTY(); + build_data::no_debug_rebuilds(); + } } From c2561c1269f9df677c72e6fe73c6f007a620c91f Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:15:04 -0700 Subject: [PATCH 06/54] Update values for UP --- crates/nargo_cli/tests/test_data/pedersen_check/Prover.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/nargo_cli/tests/test_data/pedersen_check/Prover.toml b/crates/nargo_cli/tests/test_data/pedersen_check/Prover.toml index c5eaec281c..4459711e6e 100644 --- a/crates/nargo_cli/tests/test_data/pedersen_check/Prover.toml +++ b/crates/nargo_cli/tests/test_data/pedersen_check/Prover.toml @@ -2,5 +2,5 @@ x = "0" y = "1" salt = "42" -out_x = "0x229fb88be21cec523e9223a21324f2e305aea8bff9cdbcb3d0c6bba384666ea1" -out_y = "0x296b4b4605e586a91caa3202baad557628a8c56d0a1d6dff1a7ca35aed3029d5" +out_x = "0x11831f49876c313f2a9ec6d8d521c7ce0b6311c852117e340bfe27fd1ac096ef" +out_y = "0x0ecf9d98be4597a88c46a7e0fa8836b57a7dcb41ee30f8d8787b11cc259c83fa" From ebebb2ef4322b5533b95159add16d2ad17b67c5d Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:15:28 -0700 Subject: [PATCH 07/54] Align flake with aztec_backend --- flake.nix | 219 +++++++++++++++++++++++++++--------------------------- 1 file changed, 108 insertions(+), 111 deletions(-) diff --git a/flake.nix b/flake.nix index 089f721f00..b02877d4ca 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,8 @@ { - description = "Nargo"; + description = "Build the Noir programming language"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; crane = { url = "github:ipetkov/crane"; @@ -20,152 +20,149 @@ }; barretenberg = { - url = "git+https://github.com/AztecProtocol/barretenberg"; - inputs.nixpkgs.follows = "nixpkgs"; + url = "github:AztecProtocol/barretenberg"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; }; }; outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, barretenberg, ... }: flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = [ - rust-overlay.overlays.default - barretenberg.overlays.default - ]; - }; - - rustToolchain = pkgs.rust-bin.stable."1.66.0".default; - - craneLibScope = (crane.mkLib pkgs).overrideScope' (final: prev: { - # As per https://discourse.nixos.org/t/gcc11stdenv-and-clang/17734/7 - stdenv = with pkgs; - if (stdenv.targetPlatform.isGnu && stdenv.targetPlatform.isAarch64) then - overrideCC llvmPackages.stdenv (llvmPackages.clang.override { gccForLibs = gcc11.cc; }) - else - llvmPackages.stdenv; - }); - - craneLib = craneLibScope.overrideToolchain rustToolchain; + let + pkgs = import nixpkgs { + inherit system; + overlays = [ + rust-overlay.overlays.default + barretenberg.overlays.default + ]; + }; - environment = { - # rust-bindgen needs to know the location of libclang - LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + rustToolchain = pkgs.rust-bin.stable."1.66.0".default; - # We set the environment variable because requiring 2 versions of bb collide when pkg-config searches for it - BARRETENBERG_BIN_DIR = "${pkgs.pkgsCross.wasi32.barretenberg}/bin"; + craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; - # We fetch the transcript as a dependency and provide it to the build. - # This is necessary because the Nix sandbox is read-only and downloading during tests would fail - BARRETENBERG_TRANSCRIPT = pkgs.fetchurl { - url = "http://aztec-ignition.s3.amazonaws.com/MAIN%20IGNITION/sealed/transcript00.dat"; - sha256 = "sha256-ryR/d+vpOCxa3gM0lze2UVUKNUinj0nN3ScCfysN84k="; - }; - }; + environment = { + # rust-bindgen needs to know the location of libclang + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; - COMMIT_HASH = if builtins.pathExists ./revision.checksum - then builtins.readFile ./revision.checksum - else "unknown"; - # COMMIT_HASH = builtins.tryEval (builtins.readFile "revision.checksum" {}) ? ""; - # This is a problem for now - GIT_COMMIT = if (self ? rev) then self.rev else COMMIT_HASH; - GIT_DIRTY = "false"; + # We set the environment variable because barretenberg must be compiled in a special way for wasm + BARRETENBERG_BIN_DIR = "${pkgs.barretenberg-wasm}/bin"; - commonArgs = { - pname = "nargo"; - src = ./.; + # We provide `barretenberg-transcript00` from the overlay to the build. + # This is necessary because the Nix sandbox is read-only and downloading during tests would fail + BARRETENBERG_TRANSCRIPT = pkgs.barretenberg-transcript00; + }; - nativeBuildInputs = [ - # This provides the pkg-config tool to find barretenberg & other native libraries - pkgs.pkg-config - # This provides the `lld` linker to cargo - pkgs.llvmPackages.bintools - ]; + # if file exists in git tree, commit hash wil bea read from it + # or unknown value will be assigned + COMMIT_HASH = + if builtins.pathExists ./.commit + then builtins.readFile ./.commit + else "unknown"; - buildInputs = [ - pkgs.llvmPackages.openmp - pkgs.barretenberg - ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ - # Need libiconv and apple Security on Darwin. See https://github.com/ipetkov/crane/issues/156 - pkgs.libiconv - pkgs.darwin.apple_sdk.frameworks.Security - ]; + # rev attribute meta is only available when nix build https://github.com/noir-lang/noir + # is issued therefore reading this info from file is a hack for CI + GIT_COMMIT = if (self ? rev) then self.rev else COMMIT_HASH; + GIT_DIRTY = if (self ? rev) then "false" else "true"; - LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + commonArgs = { + pname = "noir"; + version = "0.3.2"; - inherit GIT_COMMIT; - inherit GIT_DIRTY; + # As per https://discourse.nixos.org/t/gcc11stdenv-and-clang/17734/7 since it seems that aarch64-linux uses + # gcc9 instead of gcc11 for the C++ stdlib, while all other targets we support provide the correct libstdc++ + stdenv = with pkgs; + if (stdenv.targetPlatform.isGnu && stdenv.targetPlatform.isAarch64) then + overrideCC llvmPackages.stdenv (llvmPackages.clang.override { gccForLibs = gcc11.cc; }) + else + llvmPackages.stdenv; - } // environment; + src = ./.; - src = pkgs.copyPathToStore ./.; + doCheck = false; + nativeBuildInputs = [ + # This provides the pkg-config tool to find barretenberg & other native libraries + pkgs.pkg-config + # This provides the `lld` linker to cargo + pkgs.llvmPackages.bintools + ]; - nargo = craneLib.buildPackage ({ + buildInputs = [ + pkgs.llvmPackages.openmp + pkgs.barretenberg + ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ + # Need libiconv and apple Security on Darwin. See https://github.com/ipetkov/crane/issues/156 + pkgs.libiconv + pkgs.darwin.apple_sdk.frameworks.Security + ]; - doCheck = true; - - cargoBuildCommand = "cargo build --release"; + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; - } // commonArgs); + inherit GIT_COMMIT; + inherit GIT_DIRTY; - cargoArtifacts = craneLib.buildDepsOnly commonArgs; - in rec { - checks = { - cargo-check = craneLib.buildPackage (commonArgs // { - inherit cargoArtifacts; + } // environment; - doCheck = true; - }); + # Build *just* the cargo dependencies, so we can reuse all of that work between runs + cargoArtifacts = craneLib.buildDepsOnly commonArgs; - cargo-clippy = craneLib.cargoClippy (commonArgs // { - inherit cargoArtifacts; + noir = craneLib.buildPackage (commonArgs // { + inherit cargoArtifacts; + }); + in + rec { + checks = { + cargo-check = craneLib.buildPackage (commonArgs // { + inherit cargoArtifacts; - cargoClippyExtraArgs = "--all-targets --workspace -- -D warnings"; + doCheck = true; + }); - doCheck = true; - }); + cargo-clippy = craneLib.cargoClippy (commonArgs // { + inherit cargoArtifacts; - cargo-test = craneLib.cargoTest (commonArgs // { - inherit cargoArtifacts; + cargoClippyExtraArgs = "--all-targets --workspace -- -D warnings"; - cargoTestArgs = "--workspace -- --test-threads=1"; + doCheck = true; + }); - doCheck = true; - }); - }; + cargo-test = craneLib.cargoTest (commonArgs // { + inherit cargoArtifacts; - packages.default = nargo; + cargoTestArgs = "--workspace -- --test-threads=1"; - apps.default = flake-utils.lib.mkApp { drv = nargo; }; + doCheck = true; + }); + }; - devShells.default = pkgs.mkShell.override { stdenv = pkgs.llvmPackages.stdenv; } { - inputsFrom = builtins.attrValues self.checks; + packages.default = noir; - buildInputs = packages.default.buildInputs ; + # apps.default = flake-utils.lib.mkApp { drv = nargo; }; - inherit COMMIT_HASH; + devShells.default = pkgs.mkShell.override { stdenv = pkgs.llvmPackages.stdenv; } { + inputsFrom = builtins.attrValues self.checks; - LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; - # Uncertain if below line is needed. dev Shell is not yet fully working - # BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.barretenberg}/include -isystem ${pkgs.llvmPackages.libcxx.dev}/include"; + buildInputs = packages.default.buildInputs; - TERM = "xterm-256color"; + inherit COMMIT_HASH; - nativeBuildInputs = with pkgs; packages.default.buildInputs ++ [ - which - starship - git - cargo - rustc - ]; + LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; - shellHook = '' - eval "$(starship init bash)" - ''; + nativeBuildInputs = with pkgs; [ + which + starship + git + cargo + rustc + ]; - }; - }); + shellHook = '' + eval "$(starship init bash)" + ''; + }; + }); } From b6d300c813ef10e0bc6e82720494dbd4c810da42 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:16:23 -0700 Subject: [PATCH 08/54] update lockfile --- flake.lock | 79 +++++++++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 46 deletions(-) diff --git a/flake.lock b/flake.lock index 124c843061..c340a5e3e4 100644 --- a/flake.lock +++ b/flake.lock @@ -2,40 +2,42 @@ "nodes": { "barretenberg": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": [ + "flake-utils" + ], "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1678819958, - "narHash": "sha256-ResINN3e6J91RlGlu9BVucxIbIRRbWMKL6HcyCNt9ZY=", - "ref": "refs/heads/master", - "rev": "f2f8d1f7a24ca73e30c981fd245c86f7f964abb7", - "revCount": 931, - "type": "git", - "url": "https://github.com/AztecProtocol/barretenberg" + "lastModified": 1680810781, + "narHash": "sha256-2ctkV3EyHtog3caxbckTDUtJbMk/USdmF179Jvr0w40=", + "owner": "AztecProtocol", + "repo": "barretenberg", + "rev": "3bc724d2163d29041bfa29a1e49625bab77289a2", + "type": "github" }, "original": { - "type": "git", - "url": "https://github.com/AztecProtocol/barretenberg" + "owner": "AztecProtocol", + "repo": "barretenberg", + "type": "github" } }, "crane": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ], "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1678152261, - "narHash": "sha256-cPRDxwygVMleiSEGELrvAiq9vYAN4c3KK/K4UEO13vU=", + "lastModified": 1680584903, + "narHash": "sha256-uraq+D3jcLzw/UVk0xMHcnfILfIMa0DLrtAEq2nNlxU=", "owner": "ipetkov", "repo": "crane", - "rev": "5291dd0aa7a52d607fc952763ef60714e4c881d4", + "rev": "65d3f6a3970cd46bef5eedfd458300f72c56b3c5", "type": "github" }, "original": { @@ -62,11 +64,11 @@ }, "flake-utils": { "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", "owner": "numtide", "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", "type": "github" }, "original": { @@ -77,26 +79,11 @@ }, "flake-utils_2": { "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_3": { - "locked": { - "lastModified": 1678901627, - "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "lastModified": 1680776469, + "narHash": "sha256-3CXUDK/3q/kieWtdsYpDOBJw3Gw4Af6x+2EiSnIkNQw=", "owner": "numtide", "repo": "flake-utils", - "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "rev": "411e8764155aa9354dbcd6d5faaeb97e9e3dce24", "type": "github" }, "original": { @@ -107,16 +94,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1678875422, - "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", + "lastModified": 1680665430, + "narHash": "sha256-MTVhTukwza1Jlq2gECITZPFnhROmylP2uv3O3cSqQCE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", + "rev": "5233fd2ba76a3accb5aaa999c00509a11fd0793c", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-22.11", "repo": "nixpkgs", "type": "github" } @@ -125,7 +112,7 @@ "inputs": { "barretenberg": "barretenberg", "crane": "crane", - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay_2" } @@ -142,11 +129,11 @@ ] }, "locked": { - "lastModified": 1677812689, - "narHash": "sha256-EakqhgRnjVeYJv5+BJx/NZ7/eFTMBxc4AhICUNquhUg=", + "lastModified": 1680488274, + "narHash": "sha256-0vYMrZDdokVmPQQXtFpnqA2wEgCCUXf5a3dDuDVshn0=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "e53e8853aa7b0688bc270e9e6a681d22e01cf299", + "rev": "7ec2ff598a172c6e8584457167575b3a1a5d80d8", "type": "github" }, "original": { @@ -165,11 +152,11 @@ ] }, "locked": { - "lastModified": 1678933473, - "narHash": "sha256-UY19R278O9bwneLWC7ady8VMoQ+UlAWy8SkUsfDZvQs=", + "lastModified": 1680747499, + "narHash": "sha256-E9rcxSTsqRqNd4SD+D/4aqm3qfFyVw0S9YseCks7h+c=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "5c1af9b9d618e02a87cdd30a3022aec0b78cd9aa", + "rev": "8ad3b5ee01a2074b54274216ff2cf0ab844a7426", "type": "github" }, "original": { From d650a9f50a82a90ce8fb9acffdd3af5c7a92a4cc Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:30:27 -0700 Subject: [PATCH 09/54] skip simple_shield until it is updated --- crates/nargo_cli/tests/test_data/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nargo_cli/tests/test_data/config.toml b/crates/nargo_cli/tests/test_data/config.toml index 1c7536af5a..2565c345b8 100644 --- a/crates/nargo_cli/tests/test_data/config.toml +++ b/crates/nargo_cli/tests/test_data/config.toml @@ -2,7 +2,7 @@ # "1_mul", "2_div","3_add","4_sub","5_over", "6","6_array", "7_function","7","8_integration", "9_conditional", "10_slices", "assign_ex", "bool_not", "bool_or", "pedersen_check", "poseidonperm_x5_254", "poseidonsponge_x5_254", "pred_eq", "schnorr", "sha256", "tuples", # "array_len", "array_neq", "bit_and", "cast_bool", "comptime_array_access", "generics", "global_comptime", "main_bool_arg", "main_return", "merkle_insert", "modules", "modules_more", "scalar_mul", "simple_shield", "struct", "submodules", # Exclude "poseidonsponge_x5_254" and "sha2_byte" due to relatively long computation time and "sha2_blocks" due to very long computation time. -exclude = ["comptime_fail", "poseidonsponge_x5_254", "sha2_blocks", "sha2_byte"] +exclude = ["comptime_fail", "poseidonsponge_x5_254", "sha2_blocks", "sha2_byte", "simple_shield"] # List of tests (as their directory name in test_data) expecting to fail: if the test pass, we report an error. From 4bfd4d18aa89464f6ef38684090cce1a4d8d36b4 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:42:12 -0700 Subject: [PATCH 10/54] Update nix version with our workflow --- .github/workflows/release.yml | 1 + flake.nix | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee67f48605..d606b65682 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,7 @@ jobs: pull-request-title-pattern: "chore(noir): Release ${version}" extra-files: | Cargo.toml + flake.nix update-lockfile: name: Update lockfile diff --git a/flake.nix b/flake.nix index b02877d4ca..5a034a7e00 100644 --- a/flake.nix +++ b/flake.nix @@ -70,7 +70,9 @@ commonArgs = { pname = "noir"; + # x-release-please-start-version version = "0.3.2"; + # x-release-please-end # As per https://discourse.nixos.org/t/gcc11stdenv-and-clang/17734/7 since it seems that aarch64-linux uses # gcc9 instead of gcc11 for the C++ stdlib, while all other targets we support provide the correct libstdc++ From 30afaf527b3a47d56fc9382b15cfa3ac660db754 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:42:22 -0700 Subject: [PATCH 11/54] Build with Nix in CI --- .github/workflows/rust.yml | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8363858fa8..510d601dde 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -8,14 +8,32 @@ concurrency: cancel-in-progress: true jobs: - test: - name: Cargo test - uses: noir-lang/.github/.github/workflows/rust-test.yml@main + nix: + name: Nix build & test - ${{ matrix.os }} + runs-on: ${{ matrix.os }} - clippy: - name: Cargo clippy - uses: noir-lang/.github/.github/workflows/rust-clippy.yml@main + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + target: x86_64-linux + - os: macos-latest + target: x86_64-darwin - format: - name: Cargo fmt - uses: noir-lang/.github/.github/workflows/rust-format.yml@main \ No newline at end of file + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v20 + with: + nix_path: nixpkgs=channel:nixos-22.11 + github_access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cargo clippy + run: | + nix build -L .#checks.${{ matrix.target }}.cargo-clippy + + - name: Cargo test + run: | + nix build -L .#checks.${{ matrix.target }}.cargo-test From 3dc730b4202e563216eadab8779048a2dbde910e Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:59:38 -0700 Subject: [PATCH 12/54] Update backend deps --- Cargo.lock | 7 ++++--- crates/nargo_cli/Cargo.toml | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e09f9bb27..6026be34b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -550,7 +550,7 @@ dependencies = [ [[package]] name = "barretenberg_static_lib" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=880bcc8657b63205573655c175fad596bf277c36#880bcc8657b63205573655c175fad596bf277c36" +source = "git+https://github.com/noir-lang/aztec_backend?rev=c6b50231da065e7550bfe8bddf8e46f4cd8002d7#c6b50231da065e7550bfe8bddf8e46f4cd8002d7" dependencies = [ "barretenberg-sys", "common", @@ -559,9 +559,10 @@ dependencies = [ [[package]] name = "barretenberg_wasm" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=880bcc8657b63205573655c175fad596bf277c36#880bcc8657b63205573655c175fad596bf277c36" +source = "git+https://github.com/noir-lang/aztec_backend?rev=c6b50231da065e7550bfe8bddf8e46f4cd8002d7#c6b50231da065e7550bfe8bddf8e46f4cd8002d7" dependencies = [ "common", + "getrandom", "pkg-config", "rust-embed", "wasmer", @@ -862,7 +863,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=880bcc8657b63205573655c175fad596bf277c36#880bcc8657b63205573655c175fad596bf277c36" +source = "git+https://github.com/noir-lang/aztec_backend?rev=c6b50231da065e7550bfe8bddf8e46f4cd8002d7#c6b50231da065e7550bfe8bddf8e46f4cd8002d7" dependencies = [ "acvm 0.8.0", "blake2", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 8d7ddc8d1f..9557644ce7 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -38,8 +38,8 @@ tempdir = "0.3.7" color-eyre = "0.6.2" # Backends -aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "880bcc8657b63205573655c175fad596bf277c36" } -aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "880bcc8657b63205573655c175fad596bf277c36" } +aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "c6b50231da065e7550bfe8bddf8e46f4cd8002d7" } +aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "c6b50231da065e7550bfe8bddf8e46f4cd8002d7" } marlin_arkworks_backend = { optional = true, git = "https://github.com/noir-lang/marlin_arkworks_backend", rev = "144378edad821bfaa52bf2cacca8ecc87514a4fc" } [dev-dependencies] From b03c7591f4857a443d8d3ae8a8bf011d47feaab2 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 6 Apr 2023 15:59:50 -0700 Subject: [PATCH 13/54] Simplify the nix file --- flake.nix | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/flake.nix b/flake.nix index 5a034a7e00..a70cdbe6fd 100644 --- a/flake.nix +++ b/flake.nix @@ -56,16 +56,8 @@ BARRETENBERG_TRANSCRIPT = pkgs.barretenberg-transcript00; }; - # if file exists in git tree, commit hash wil bea read from it - # or unknown value will be assigned - COMMIT_HASH = - if builtins.pathExists ./.commit - then builtins.readFile ./.commit - else "unknown"; - - # rev attribute meta is only available when nix build https://github.com/noir-lang/noir - # is issued therefore reading this info from file is a hack for CI - GIT_COMMIT = if (self ? rev) then self.rev else COMMIT_HASH; + # The `self.rev` property is only available when the working tree is not dirty + GIT_COMMIT = if (self ? rev) then self.rev else "unknown"; GIT_DIRTY = if (self ? rev) then "false" else "true"; commonArgs = { @@ -143,6 +135,7 @@ packages.default = noir; + # TODO: Look into installable apps with Nix flakes # apps.default = flake-utils.lib.mkApp { drv = nargo; }; devShells.default = pkgs.mkShell.override { stdenv = pkgs.llvmPackages.stdenv; } { @@ -150,8 +143,6 @@ buildInputs = packages.default.buildInputs; - inherit COMMIT_HASH; - LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; nativeBuildInputs = with pkgs; [ From 02d5c07a2e3cf20f2d85f048624d56785d6e77ba Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 08:30:29 -0700 Subject: [PATCH 14/54] chore(nargo)!: Update the codegen command to use vk, which requires circuit_name arg --- .../nargo_cli/src/cli/codegen_verifier_cmd.rs | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs index b05626e439..6b10cf55b0 100644 --- a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -1,23 +1,52 @@ -use super::fs::{create_named_dir, write_to_file}; +use super::fs::{ + create_named_dir, keys::fetch_pk_and_vk, program::read_program_from_file, write_to_file, +}; use super::NargoConfig; -use crate::{cli::compile_cmd::compile_circuit, constants::CONTRACT_DIR, errors::CliError}; -use acvm::SmartContract; +use crate::{ + cli::compile_cmd::compile_circuit, constants::CONTRACT_DIR, constants::TARGET_DIR, + errors::CliError, +}; +use acvm::{ProofSystemCompiler, SmartContract}; use clap::Args; use noirc_driver::CompileOptions; /// Generates a Solidity verifier smart contract for the program #[derive(Debug, Clone, Args)] pub(crate) struct CodegenVerifierCommand { + /// The name of the circuit build files (ACIR, proving and verification keys) + circuit_name: Option, + #[clap(flatten)] compile_options: CompileOptions, } pub(crate) fn run(args: CodegenVerifierCommand, config: NargoConfig) -> Result<(), CliError> { - let compiled_program = compile_circuit(&config.program_dir, &args.compile_options)?; - let backend = crate::backends::ConcreteBackend; - #[allow(deprecated)] - let smart_contract_string = backend.eth_contract_from_cs(compiled_program.circuit); + + // Based on code in verify_cmd.rs + // TODO(blaine): Should this be a utility function? + let circuit_build_path = args + .circuit_name + .map(|circuit_name| config.program_dir.join(TARGET_DIR).join(circuit_name)); + + let verification_key = match circuit_build_path { + Some(circuit_build_path) => { + let compiled_program = read_program_from_file(&circuit_build_path)?; + + let (_, verification_key) = + fetch_pk_and_vk(&compiled_program.circuit, circuit_build_path, false, true)?; + verification_key + } + None => { + let compiled_program = + compile_circuit(config.program_dir.as_ref(), &args.compile_options)?; + + let (_, verification_key) = backend.preprocess(&compiled_program.circuit); + verification_key + } + }; + + let smart_contract_string = backend.eth_contract_from_vk(&verification_key); let contract_dir = config.program_dir.join(CONTRACT_DIR); create_named_dir(&contract_dir, "contract"); From b049ab56457fc747bf73b3fcf270336c2cc958ab Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Mon, 10 Apr 2023 21:00:14 +0100 Subject: [PATCH 15/54] chore!: Update Prover.toml for merkle_insert and simple_shield with UP (#1123) --- .../tests/test_data/merkle_insert/Prover.toml | 14 +++++++------- .../tests/test_data/simple_shield/Prover.toml | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/nargo_cli/tests/test_data/merkle_insert/Prover.toml b/crates/nargo_cli/tests/test_data/merkle_insert/Prover.toml index 909fc1bbf6..691ea27abd 100644 --- a/crates/nargo_cli/tests/test_data/merkle_insert/Prover.toml +++ b/crates/nargo_cli/tests/test_data/merkle_insert/Prover.toml @@ -1,11 +1,11 @@ -old_root = "0x083b35b32ba24436c1614e4262cb4ad8f98f99cdb5fb0da8932ab2a290034867" -old_leaf = "0x0b81829b478114d28b964bd382ebff8be0216741aa72ff2896909110aef1704a" +old_root = "0x04ccfbbb859b8605546e03dcaf41393476642859ff7f99446c054b841f0e05c8" +old_leaf = "0x1cdcf02431ba623767fe389337d011df1048dcc24b98ed81cec97627bab454a0" old_hash_path = [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0e4223f3925f98934393c74975142bd73079ab0621f4ee133cee050a3c194f1a", - "0x2fd7bb412155bf8693a3bd2a3e7581a679c95c68a052f835dddca85fa1569a40" + "0x1cdcf02431ba623767fe389337d011df1048dcc24b98ed81cec97627bab454a0", + "0x0b5e9666e7323ce925c28201a97ddf4144ac9d148448ed6f49f9008719c1b85b", + "0x22ec636f8ad30ef78c42b7fe2be4a4cacf5a445cfb5948224539f59a11d70775", ] -new_root = "0x256c13d7694e2f900f55756246aa1104169efd9fb9e7c6be54c15794795d476f" -leaf = "0x2e5ba44f3c5329aeb915c703e39b33c5872f1542500cbb22f12b71640aba502f" +new_root = "0x293ee9de893904164a8f8b248b6941217d16a4c9042ec54b71896dddbbce7a3b" +leaf = "0x085ca53be9c9d95b57e6e5fc91c5d531ad9e63e85dd71af7e35562991774b435" index = "0" mimc_input = [12,45,78,41] diff --git a/crates/nargo_cli/tests/test_data/simple_shield/Prover.toml b/crates/nargo_cli/tests/test_data/simple_shield/Prover.toml index 67e825f633..554ae9900a 100644 --- a/crates/nargo_cli/tests/test_data/simple_shield/Prover.toml +++ b/crates/nargo_cli/tests/test_data/simple_shield/Prover.toml @@ -1,11 +1,11 @@ # Random test key priv_key = "0x000000000000000000000000000000000000000000000000000000616c696365" -note_root = "0x165cdc3cbcf4a6bf7b69514807409a3ed2e701556821f396ca04781a6434d96a" +note_root = "0x293ee9de893904164a8f8b248b6941217d16a4c9042ec54b71896dddbbce7a3b" index = "0" note_hash_path = [ - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0e4223f3925f98934393c74975142bd73079ab0621f4ee133cee050a3c194f1a", - "0x2fd7bb412155bf8693a3bd2a3e7581a679c95c68a052f835dddca85fa1569a40", + "0x1cdcf02431ba623767fe389337d011df1048dcc24b98ed81cec97627bab454a0", + "0x0b5e9666e7323ce925c28201a97ddf4144ac9d148448ed6f49f9008719c1b85b", + "0x22ec636f8ad30ef78c42b7fe2be4a4cacf5a445cfb5948224539f59a11d70775", ] to_pubkey_x = "0x0000000000000000000000000000000000000000000000000000000000000001" to_pubkey_y = "0x0000000000000002cf135e7506a45d632d270d45f1181294833fc48d823f272c" From eb6b2ee87e61a840d3554fd4ffdb8406dc1e9d60 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 13:00:54 -0700 Subject: [PATCH 16/54] re-enable simple_shield --- crates/nargo_cli/tests/test_data/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nargo_cli/tests/test_data/config.toml b/crates/nargo_cli/tests/test_data/config.toml index 2565c345b8..1c7536af5a 100644 --- a/crates/nargo_cli/tests/test_data/config.toml +++ b/crates/nargo_cli/tests/test_data/config.toml @@ -2,7 +2,7 @@ # "1_mul", "2_div","3_add","4_sub","5_over", "6","6_array", "7_function","7","8_integration", "9_conditional", "10_slices", "assign_ex", "bool_not", "bool_or", "pedersen_check", "poseidonperm_x5_254", "poseidonsponge_x5_254", "pred_eq", "schnorr", "sha256", "tuples", # "array_len", "array_neq", "bit_and", "cast_bool", "comptime_array_access", "generics", "global_comptime", "main_bool_arg", "main_return", "merkle_insert", "modules", "modules_more", "scalar_mul", "simple_shield", "struct", "submodules", # Exclude "poseidonsponge_x5_254" and "sha2_byte" due to relatively long computation time and "sha2_blocks" due to very long computation time. -exclude = ["comptime_fail", "poseidonsponge_x5_254", "sha2_blocks", "sha2_byte", "simple_shield"] +exclude = ["comptime_fail", "poseidonsponge_x5_254", "sha2_blocks", "sha2_byte"] # List of tests (as their directory name in test_data) expecting to fail: if the test pass, we report an error. From 13a652a1337bdd41ffd5a6aab86d5f7c305a41e1 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 14:20:21 -0700 Subject: [PATCH 17/54] use CARGO_MANIFEST_DIR to locate data for integration testing --- crates/nargo_cli/tests/prove_and_verify.rs | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/crates/nargo_cli/tests/prove_and_verify.rs b/crates/nargo_cli/tests/prove_and_verify.rs index 0006dd1b98..97edef02d3 100644 --- a/crates/nargo_cli/tests/prove_and_verify.rs +++ b/crates/nargo_cli/tests/prove_and_verify.rs @@ -1,11 +1,9 @@ use std::collections::BTreeMap; use std::fs; -const TEST_DIR: &str = "tests"; -const TEST_DATA_DIR: &str = "test_data"; -const CONFIG_FILE: &str = "config.toml"; - mod tests { + use std::path::PathBuf; + use super::*; fn load_conf(conf_path: &str) -> BTreeMap> { @@ -28,22 +26,25 @@ mod tests { #[test] fn noir_integration() { - let mut current_dir = std::env::current_dir().unwrap(); - current_dir.push(TEST_DIR); - current_dir.push(TEST_DATA_DIR); + // Try to find the directory that Cargo sets when it is running; otherwise fallback to assuming the CWD + // is the root of the repository and append the crate path + let manifest_dir = match std::env::var("CARGO_MANIFEST_DIR") { + Ok(dir) => PathBuf::from(dir), + Err(_) => { + PathBuf::from(std::env::current_dir().unwrap()).join("crates").join("nargo_cli") + } + }; + let test_data_dir = manifest_dir.join("tests").join("test_data"); + let config_path = test_data_dir.join("config.toml"); //load config.tml file from test_data directory - current_dir.push(CONFIG_FILE); - let config_path = std::fs::read_to_string(current_dir).unwrap(); + let config_path = std::fs::read_to_string(config_path).unwrap(); let config_data: BTreeMap> = load_conf(&config_path); - let mut current_dir = std::env::current_dir().unwrap(); - current_dir.push(TEST_DIR); - current_dir.push(TEST_DATA_DIR); - for c in fs::read_dir(current_dir.as_path()).unwrap().flatten() { + for c in fs::read_dir(test_data_dir).unwrap().flatten() { if let Ok(test_name) = c.file_name().into_string() { - println!("Running test {test_name:?}"); if c.path().is_dir() && !config_data["exclude"].contains(&test_name) { + println!("Running test {test_name:?}"); let verified = std::panic::catch_unwind(|| { nargo_cli::cli::prove_and_verify("pp", &c.path(), false) }); @@ -60,6 +61,8 @@ mod tests { } else { assert!(r, "verification fail for {:?}", c.file_name()); } + } else { + println!("Ignoring test {test_name:?}"); } } } From a4e11d29f330cd55cb75097d67a3f699972d43a6 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 14:59:19 -0700 Subject: [PATCH 18/54] clippy --- crates/nargo_cli/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nargo_cli/build.rs b/crates/nargo_cli/build.rs index 8f3b00d765..8e8ff02b90 100644 --- a/crates/nargo_cli/build.rs +++ b/crates/nargo_cli/build.rs @@ -14,7 +14,7 @@ fn main() { // Only use build_data if the environment variable isn't set // The environment variable is always set when working via Nix - if let Err(_) = std::env::var(GIT_COMMIT) { + if std::env::var(GIT_COMMIT).is_err() { build_data::set_GIT_COMMIT(); build_data::set_GIT_DIRTY(); build_data::no_debug_rebuilds(); From d3f4a548fb593855e34d458bc2b2b4459fc69382 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 14:59:37 -0700 Subject: [PATCH 19/54] patch for bb-sys --- Cargo.lock | 3 +-- Cargo.toml | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6026be34b1..f098cb71ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -536,8 +536,7 @@ dependencies = [ [[package]] name = "barretenberg-sys" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a7cbc8eeb6dbbea6d4d3f3db55b786d5c52ad6c88e999a328e1ce6aedd605e" +source = "git+https://github.com/noir-lang/barretenberg-sys.git?branch=phated/pedersen-commitment-header#7aa8cfd47f581f26236dca2de6e19a9df859711b" dependencies = [ "bindgen", "cc", diff --git a/Cargo.toml b/Cargo.toml index 29ac590f6f..4f172765eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,3 +50,6 @@ toml = "0.7.2" url = "2.2.0" wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" + +[patch.crates-io] +barretenberg-sys = { git = "https://github.com/noir-lang/barretenberg-sys.git", branch = "phated/pedersen-commitment-header" } From ff82cda1908447f23e6cb8cd6a18beb07460c6b7 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 14:59:55 -0700 Subject: [PATCH 20/54] patch for bb --- flake.lock | 43 +++++++++++++++++++++++++++++++------------ flake.nix | 2 +- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index c340a5e3e4..116f4615e4 100644 --- a/flake.lock +++ b/flake.lock @@ -10,15 +10,16 @@ ] }, "locked": { - "lastModified": 1680810781, - "narHash": "sha256-2ctkV3EyHtog3caxbckTDUtJbMk/USdmF179Jvr0w40=", + "lastModified": 1681153256, + "narHash": "sha256-0rHyY0vDbCfziBwFcrVZS9GDjLbjSQyCvTZhdmVhzk0=", "owner": "AztecProtocol", "repo": "barretenberg", - "rev": "3bc724d2163d29041bfa29a1e49625bab77289a2", + "rev": "ac2db15e26e4403df4154d6f3d4765060f456bf2", "type": "github" }, "original": { "owner": "AztecProtocol", + "ref": "phated/generator-memory-oob", "repo": "barretenberg", "type": "github" } @@ -78,12 +79,15 @@ } }, "flake-utils_2": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1680776469, - "narHash": "sha256-3CXUDK/3q/kieWtdsYpDOBJw3Gw4Af6x+2EiSnIkNQw=", + "lastModified": 1681037374, + "narHash": "sha256-XL6X3VGbEFJZDUouv2xpKg2Aljzu/etPLv5e1FPt1q0=", "owner": "numtide", "repo": "flake-utils", - "rev": "411e8764155aa9354dbcd6d5faaeb97e9e3dce24", + "rev": "033b9f258ca96a10e543d4442071f614dc3f8412", "type": "github" }, "original": { @@ -94,11 +98,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1680665430, - "narHash": "sha256-MTVhTukwza1Jlq2gECITZPFnhROmylP2uv3O3cSqQCE=", + "lastModified": 1681091990, + "narHash": "sha256-ifIzhksUBZKp5WgCuoVhDY32qaEplXp7khzrB6zkaFc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5233fd2ba76a3accb5aaa999c00509a11fd0793c", + "rev": "ea96b4af6148114421fda90df33cf236ff5ecf1d", "type": "github" }, "original": { @@ -152,11 +156,11 @@ ] }, "locked": { - "lastModified": 1680747499, - "narHash": "sha256-E9rcxSTsqRqNd4SD+D/4aqm3qfFyVw0S9YseCks7h+c=", + "lastModified": 1681093076, + "narHash": "sha256-6uLZNeuP5jDDGlFkXgcoAxsJhTKy8yUTw25zdLHzdxE=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "8ad3b5ee01a2074b54274216ff2cf0ab844a7426", + "rev": "45c2ed9dd1397526dad35fc867c43955d87f9f3f", "type": "github" }, "original": { @@ -164,6 +168,21 @@ "repo": "rust-overlay", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index a70cdbe6fd..70bcb0568d 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,7 @@ }; barretenberg = { - url = "github:AztecProtocol/barretenberg"; + url = "github:AztecProtocol/barretenberg/phated/generator-memory-oob"; inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; From 2505346be496947a2c7082b87c10f41900974a04 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 15:04:18 -0700 Subject: [PATCH 21/54] Add build workaround to wasm crate --- crates/wasm/build.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/wasm/build.rs b/crates/wasm/build.rs index 9c91effe74..3b96be74ef 100644 --- a/crates/wasm/build.rs +++ b/crates/wasm/build.rs @@ -1,6 +1,14 @@ +const GIT_COMMIT: &&str = &"GIT_COMMIT"; + fn main() { - build_data::set_GIT_COMMIT(); - build_data::set_GIT_DIRTY(); + // Only use build_data if the environment variable isn't set + // The environment variable is always set when working via Nix + if std::env::var(GIT_COMMIT).is_err() { + build_data::set_GIT_COMMIT(); + build_data::set_GIT_DIRTY(); + build_data::no_debug_rebuilds(); + } + build_data::set_SOURCE_TIMESTAMP(); build_data::no_debug_rebuilds(); } From 0c38f6c1fbf561e2d25e2fd36a6901fac6d6a780 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 15:09:06 -0700 Subject: [PATCH 22/54] clippy --- crates/nargo_cli/tests/prove_and_verify.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/nargo_cli/tests/prove_and_verify.rs b/crates/nargo_cli/tests/prove_and_verify.rs index 97edef02d3..88ed2d56d3 100644 --- a/crates/nargo_cli/tests/prove_and_verify.rs +++ b/crates/nargo_cli/tests/prove_and_verify.rs @@ -30,9 +30,7 @@ mod tests { // is the root of the repository and append the crate path let manifest_dir = match std::env::var("CARGO_MANIFEST_DIR") { Ok(dir) => PathBuf::from(dir), - Err(_) => { - PathBuf::from(std::env::current_dir().unwrap()).join("crates").join("nargo_cli") - } + Err(_) => std::env::current_dir().unwrap().join("crates").join("nargo_cli"), }; let test_data_dir = manifest_dir.join("tests").join("test_data"); let config_path = test_data_dir.join("config.toml"); From 95808b40e8e12efc67f6cec2999701585fc25fb8 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 15:36:37 -0700 Subject: [PATCH 23/54] Remove buggy clippy lint --- crates/nargo_cli/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nargo_cli/src/lib.rs b/crates/nargo_cli/src/lib.rs index 08e8513d45..cc25a09f80 100644 --- a/crates/nargo_cli/src/lib.rs +++ b/crates/nargo_cli/src/lib.rs @@ -1,5 +1,5 @@ #![forbid(unsafe_code)] -#![warn(unused_crate_dependencies, unused_extern_crates)] +#![warn(unused_extern_crates)] #![warn(unreachable_pub)] //! Nargo is the package manager for Noir From 6f02d9255e3ee9c47bcf4c3bf5350db0d9b32fc2 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 15:48:43 -0700 Subject: [PATCH 24/54] cleanup flake --- flake.nix | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 70bcb0568d..418b973ec0 100644 --- a/flake.nix +++ b/flake.nix @@ -110,12 +110,6 @@ in rec { checks = { - cargo-check = craneLib.buildPackage (commonArgs // { - inherit cargoArtifacts; - - doCheck = true; - }); - cargo-clippy = craneLib.cargoClippy (commonArgs // { inherit cargoArtifacts; @@ -127,7 +121,7 @@ cargo-test = craneLib.cargoTest (commonArgs // { inherit cargoArtifacts; - cargoTestArgs = "--workspace -- --test-threads=1"; + cargoTestExtraArgs = "--workspace -- --test-threads=1"; doCheck = true; }); From 5fcdb49ef1ce7b0f9ffb45921be2bde01a8dcdd7 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Mon, 10 Apr 2023 16:22:09 -0700 Subject: [PATCH 25/54] Rough guidelines for working on Noir with nix --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index bef2e9a0a8..929f53c399 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,21 @@ Concretely the following items are on the road map: This crate's minimum supported rustc version is 1.66.0. +## Working on Noir / Building from source + +Building Noir requires a variety of native dependencies, but we've bundled up everything you need with [Nix](https://nixos.org/). + +To work on Noir, you'll want to: +1. Install Nix following [their guide](https://nixos.org/download.html) for your operating system +2. Create the file `~/.config/nix/nix.conf` with the contents: +``` +experimental-features = nix-command +extra-experimental-features = flakes +``` +3. Clone the project with `git clone git@github.com:noir-lang/noir` +4. Run `nix build . -L` in the `noir` directory +5. Run `nix flake check -L` to run clippy and the tests + ## License Noir is free and open source. It is distributed under a dual license. (MIT/APACHE) From 5e50ddedb8b300609907af7e807ee6ff368ea546 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Tue, 11 Apr 2023 02:55:58 +0100 Subject: [PATCH 26/54] chore: Cleanup UltraPlonk Debugging (#1130) cleanup debugging code from UP --- .../tests/test_data/8_integration/src/main.nr | 22 ++++++------------- .../tests/test_data/xor}/Nargo.toml | 0 .../tests/test_data/xor}/Prover.toml | 0 .../tests/test_data/xor}/src/main.nr | 0 4 files changed, 7 insertions(+), 15 deletions(-) rename crates/{nargo/tests/test_data/testing => nargo_cli/tests/test_data/xor}/Nargo.toml (100%) rename crates/{nargo/tests/test_data/testing => nargo_cli/tests/test_data/xor}/Prover.toml (100%) rename crates/{nargo/tests/test_data/testing => nargo_cli/tests/test_data/xor}/src/main.nr (100%) diff --git a/crates/nargo_cli/tests/test_data/8_integration/src/main.nr b/crates/nargo_cli/tests/test_data/8_integration/src/main.nr index eb285de5ce..2650eea3d7 100644 --- a/crates/nargo_cli/tests/test_data/8_integration/src/main.nr +++ b/crates/nargo_cli/tests/test_data/8_integration/src/main.nr @@ -1,5 +1,3 @@ -use dep::std; - fn matrix_mul_2(a: [u32; 4], b: [u32; 4]) ->[u32; 4] { let mut c = [0 as u32; 4]; for i in 0..2 { @@ -144,14 +142,14 @@ fn too(x: u32) -> u32 { (x + 17 as u32) * (x + 3 as u32) } -fn test6(x: [u32; 32]) -> [u32; 8] { +fn test6(x: [u8; 32]) -> [u32; 8] { let mut sha_m = [0 as u32; 64]; let mut sha_hash = [ 1 as u32, 2, 3, 4, 5, 6, 7, 8 ]; - let mut buffer = [0 as u32; 64]; + let mut buffer = [0 as u8; 64]; for i in 0..32 { buffer[i] = x[i]; } @@ -161,14 +159,14 @@ fn test6(x: [u32; 32]) -> [u32; 8] { sha_hash } -fn iterate6_1(mut sha_m: [u32; 64], next_chunk: [u32; 64]) -> [u32; 64] { +fn iterate6_1(mut sha_m: [u32; 64], next_chunk: [u8; 64]) -> [u32; 64] { let mut j = 0; for i in 0..16 { j = (i ) * 4; - sha_m[i] = ((next_chunk[j]) << 24 as u32) - | ((next_chunk[j + 1]) << 16) - | ((next_chunk[j + 2]) << 8) - | (next_chunk[j + 3]); + sha_m[i] = ((next_chunk[j] as u32) << 24 as u32) + | ((next_chunk[j + 1] as u32) << 16 as u32) + | ((next_chunk[j + 2] as u32) << 8 as u32) + | (next_chunk[j + 3] as u32); } for i in 16..64 { sha_m[i] = sig1(sha_m[i - 2])+(sha_m[i - 7])+(sig0(sha_m[i - 15]))+(sha_m[i - 16]); @@ -245,12 +243,6 @@ fn sig1(x: u32) -> u32 { fn main(a: [u32; 100], b: [u32; 100], c: [u32; 4], mut d: [u32; 4], m: [u32; 32]) { - - // let sha_m = (m[0] << 24 as u32) - // | (m[1] << 16 as u32); - - // constrain sha_m != 10; - let e = matrix_mul_10(a,b); constrain e[6] == 1866842232; let f = matrix_mul_2(c,d); diff --git a/crates/nargo/tests/test_data/testing/Nargo.toml b/crates/nargo_cli/tests/test_data/xor/Nargo.toml similarity index 100% rename from crates/nargo/tests/test_data/testing/Nargo.toml rename to crates/nargo_cli/tests/test_data/xor/Nargo.toml diff --git a/crates/nargo/tests/test_data/testing/Prover.toml b/crates/nargo_cli/tests/test_data/xor/Prover.toml similarity index 100% rename from crates/nargo/tests/test_data/testing/Prover.toml rename to crates/nargo_cli/tests/test_data/xor/Prover.toml diff --git a/crates/nargo/tests/test_data/testing/src/main.nr b/crates/nargo_cli/tests/test_data/xor/src/main.nr similarity index 100% rename from crates/nargo/tests/test_data/testing/src/main.nr rename to crates/nargo_cli/tests/test_data/xor/src/main.nr From 4b6a544c20dda056881a068a25d44c758cfb51b5 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Mon, 10 Apr 2023 22:00:12 -0400 Subject: [PATCH 27/54] update 8_integration main func --- crates/nargo_cli/tests/test_data/8_integration/src/main.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nargo_cli/tests/test_data/8_integration/src/main.nr b/crates/nargo_cli/tests/test_data/8_integration/src/main.nr index 2650eea3d7..57dca4e2ac 100644 --- a/crates/nargo_cli/tests/test_data/8_integration/src/main.nr +++ b/crates/nargo_cli/tests/test_data/8_integration/src/main.nr @@ -242,7 +242,7 @@ fn sig1(x: u32) -> u32 { } -fn main(a: [u32; 100], b: [u32; 100], c: [u32; 4], mut d: [u32; 4], m: [u32; 32]) { +fn main(a: [u32; 100], b: [u32; 100], c: [u32; 4], mut d: [u32; 4], m: [u8; 32]) { let e = matrix_mul_10(a,b); constrain e[6] == 1866842232; let f = matrix_mul_2(c,d); From 506bfb55d673e8a420974dcded6c335f5f20fc03 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 12 Apr 2023 11:33:13 -0700 Subject: [PATCH 28/54] update to newer bb --- Cargo.lock | 5 +++-- Cargo.toml | 3 --- flake.lock | 31 +++++++++++++++---------------- flake.nix | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f098cb71ca..7bc1248a56 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -535,8 +535,9 @@ dependencies = [ [[package]] name = "barretenberg-sys" -version = "0.1.0" -source = "git+https://github.com/noir-lang/barretenberg-sys.git?branch=phated/pedersen-commitment-header#7aa8cfd47f581f26236dca2de6e19a9df859711b" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "550a86403cc44a6ddca26c74ffecf5c0f6aa64f7de9952654b7c6ed062184c3e" dependencies = [ "bindgen", "cc", diff --git a/Cargo.toml b/Cargo.toml index 4f172765eb..29ac590f6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,6 +50,3 @@ toml = "0.7.2" url = "2.2.0" wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = "0.3.33" - -[patch.crates-io] -barretenberg-sys = { git = "https://github.com/noir-lang/barretenberg-sys.git", branch = "phated/pedersen-commitment-header" } diff --git a/flake.lock b/flake.lock index 116f4615e4..a3aca5d919 100644 --- a/flake.lock +++ b/flake.lock @@ -10,16 +10,15 @@ ] }, "locked": { - "lastModified": 1681153256, - "narHash": "sha256-0rHyY0vDbCfziBwFcrVZS9GDjLbjSQyCvTZhdmVhzk0=", + "lastModified": 1681312149, + "narHash": "sha256-+W+atUPf5OXPt/HX12+JL5N9AiutjL3HeWVVNxWHpQg=", "owner": "AztecProtocol", "repo": "barretenberg", - "rev": "ac2db15e26e4403df4154d6f3d4765060f456bf2", + "rev": "500daf1ceb03771d2c01eaf1a86139a7ac1d814f", "type": "github" }, "original": { "owner": "AztecProtocol", - "ref": "phated/generator-memory-oob", "repo": "barretenberg", "type": "github" } @@ -34,11 +33,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1680584903, - "narHash": "sha256-uraq+D3jcLzw/UVk0xMHcnfILfIMa0DLrtAEq2nNlxU=", + "lastModified": 1681177078, + "narHash": "sha256-ZNIjBDou2GOabcpctiQykEQVkI8BDwk7TyvlWlI4myE=", "owner": "ipetkov", "repo": "crane", - "rev": "65d3f6a3970cd46bef5eedfd458300f72c56b3c5", + "rev": "0c9f468ff00576577d83f5019a66c557ede5acf6", "type": "github" }, "original": { @@ -83,11 +82,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1681037374, - "narHash": "sha256-XL6X3VGbEFJZDUouv2xpKg2Aljzu/etPLv5e1FPt1q0=", + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", "owner": "numtide", "repo": "flake-utils", - "rev": "033b9f258ca96a10e543d4442071f614dc3f8412", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", "type": "github" }, "original": { @@ -98,11 +97,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1681091990, - "narHash": "sha256-ifIzhksUBZKp5WgCuoVhDY32qaEplXp7khzrB6zkaFc=", + "lastModified": 1681154110, + "narHash": "sha256-OQwWzlzAY1dCqgSsgZzsPIOGmX4pBGaoXOy0rSl4b5Y=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "ea96b4af6148114421fda90df33cf236ff5ecf1d", + "rev": "115a96e2ac1e92937cd47c30e073e16dcaaf6247", "type": "github" }, "original": { @@ -156,11 +155,11 @@ ] }, "locked": { - "lastModified": 1681093076, - "narHash": "sha256-6uLZNeuP5jDDGlFkXgcoAxsJhTKy8yUTw25zdLHzdxE=", + "lastModified": 1681265948, + "narHash": "sha256-wYS5dR1fRoU6VtoKScz1OUS/dmart7hfI0G71qkJcwc=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "45c2ed9dd1397526dad35fc867c43955d87f9f3f", + "rev": "b10a42fe6bb0b6d1b335c1f137419ebf754b2b59", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 418b973ec0..0cd04d4cde 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,7 @@ }; barretenberg = { - url = "github:AztecProtocol/barretenberg/phated/generator-memory-oob"; + url = "github:AztecProtocol/barretenberg"; inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; From 44a0d7435757fe9c4f51a204d4092758502b7dd2 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 12 Apr 2023 13:57:07 -0700 Subject: [PATCH 29/54] update aztec_backend --- Cargo.lock | 61 ++++++++++++++++++++++++++++++++++--- crates/nargo_cli/Cargo.toml | 4 +-- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7bc1248a56..a76105bd29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,6 +26,18 @@ dependencies = [ "serde", ] +[[package]] +name = "acir" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "018148d69bf14422b1c1d62909a241af2a7f51fec064feb2b01de88fb02b11b8" +dependencies = [ + "acir_field 0.9.0", + "flate2", + "rmp-serde", + "serde", +] + [[package]] name = "acir_field" version = "0.3.1" @@ -57,6 +69,20 @@ dependencies = [ "serde", ] +[[package]] +name = "acir_field" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d40dac25cf6be6335dd86286caeac859afd0dc74a4a75c64eed041b0f00a278" +dependencies = [ + "ark-bn254 0.4.0", + "ark-ff 0.4.1", + "cfg-if 1.0.0", + "hex", + "num-bigint", + "serde", +] + [[package]] name = "acvm" version = "0.3.1" @@ -94,6 +120,24 @@ dependencies = [ "thiserror", ] +[[package]] +name = "acvm" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17b7bc8f2b2215075b8e080ba3a0b8b7d759f04bc44b27e5bb8d845f4c77f20" +dependencies = [ + "acir 0.9.0", + "acvm_stdlib 0.9.0", + "blake2", + "crc32fast", + "indexmap", + "k256", + "num-bigint", + "num-traits", + "sha2 0.9.9", + "thiserror", +] + [[package]] name = "acvm_stdlib" version = "0.3.1" @@ -113,6 +157,15 @@ dependencies = [ "acir 0.8.0", ] +[[package]] +name = "acvm_stdlib" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ce2d19a9d1e7ff1bf415ed909b43031e33ef6df21be70e470bb1817b3e6989" +dependencies = [ + "acir 0.9.0", +] + [[package]] name = "addr2line" version = "0.19.0" @@ -550,7 +603,7 @@ dependencies = [ [[package]] name = "barretenberg_static_lib" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=c6b50231da065e7550bfe8bddf8e46f4cd8002d7#c6b50231da065e7550bfe8bddf8e46f4cd8002d7" +source = "git+https://github.com/noir-lang/aztec_backend?rev=00bb15779dfb64539eeb3f3bb4c4deeba106f2fe#00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" dependencies = [ "barretenberg-sys", "common", @@ -559,7 +612,7 @@ dependencies = [ [[package]] name = "barretenberg_wasm" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=c6b50231da065e7550bfe8bddf8e46f4cd8002d7#c6b50231da065e7550bfe8bddf8e46f4cd8002d7" +source = "git+https://github.com/noir-lang/aztec_backend?rev=00bb15779dfb64539eeb3f3bb4c4deeba106f2fe#00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" dependencies = [ "common", "getrandom", @@ -863,9 +916,9 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=c6b50231da065e7550bfe8bddf8e46f4cd8002d7#c6b50231da065e7550bfe8bddf8e46f4cd8002d7" +source = "git+https://github.com/noir-lang/aztec_backend?rev=00bb15779dfb64539eeb3f3bb4c4deeba106f2fe#00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" dependencies = [ - "acvm 0.8.0", + "acvm 0.9.0", "blake2", "dirs 3.0.2", "downloader", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 9557644ce7..3ef91475b8 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -38,8 +38,8 @@ tempdir = "0.3.7" color-eyre = "0.6.2" # Backends -aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "c6b50231da065e7550bfe8bddf8e46f4cd8002d7" } -aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "c6b50231da065e7550bfe8bddf8e46f4cd8002d7" } +aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" } +aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" } marlin_arkworks_backend = { optional = true, git = "https://github.com/noir-lang/marlin_arkworks_backend", rev = "144378edad821bfaa52bf2cacca8ecc87514a4fc" } [dev-dependencies] From 818d1f90eaec1b28469fc134a5278892f98b953b Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 12 Apr 2023 13:57:56 -0700 Subject: [PATCH 30/54] update acvm to 0.9.0 --- Cargo.lock | 65 +++++------------------------------------------------- Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a76105bd29..40d1487d88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,18 +14,6 @@ dependencies = [ "serde", ] -[[package]] -name = "acir" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f764b474e341efc3e8ee3d5054840b2fd2ac002f764fc2f4cd3569ce76badd1" -dependencies = [ - "acir_field 0.8.0", - "flate2", - "rmp-serde", - "serde", -] - [[package]] name = "acir" version = "0.9.0" @@ -55,20 +43,6 @@ dependencies = [ "serde", ] -[[package]] -name = "acir_field" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbca7df5192c7823d4108d2c34cadcfd30dca94506b9e9861f85f0ea747ddedc" -dependencies = [ - "ark-bn254 0.4.0", - "ark-ff 0.4.1", - "cfg-if 1.0.0", - "hex", - "num-bigint", - "serde", -] - [[package]] name = "acir_field" version = "0.9.0" @@ -102,24 +76,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "acvm" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d5df175b6923bf9bb05ba973b017b0fa1356066be8f0ebadd3d2dbbc48bd5b" -dependencies = [ - "acir 0.8.0", - "acvm_stdlib 0.8.0", - "blake2", - "crc32fast", - "indexmap", - "k256", - "num-bigint", - "num-traits", - "sha2 0.9.9", - "thiserror", -] - [[package]] name = "acvm" version = "0.9.0" @@ -148,15 +104,6 @@ dependencies = [ "acir_field 0.3.1", ] -[[package]] -name = "acvm_stdlib" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2bbc18fe9732ca3d93a2bf8f1a1ad99a003b565e7bc1ad5c67f69867449e8f" -dependencies = [ - "acir 0.8.0", -] - [[package]] name = "acvm_stdlib" version = "0.9.0" @@ -2239,7 +2186,7 @@ dependencies = [ name = "nargo_cli" version = "0.3.2" dependencies = [ - "acvm 0.8.0", + "acvm 0.9.0", "assert_cmd", "assert_fs", "barretenberg_static_lib", @@ -2272,7 +2219,7 @@ dependencies = [ name = "noir_wasm" version = "0.3.2" dependencies = [ - "acvm 0.8.0", + "acvm 0.9.0", "build-data", "console_error_panic_hook", "gloo-utils", @@ -2288,7 +2235,7 @@ dependencies = [ name = "noirc_abi" version = "0.3.2" dependencies = [ - "acvm 0.8.0", + "acvm 0.9.0", "iter-extended", "serde", "serde_json", @@ -2300,7 +2247,7 @@ dependencies = [ name = "noirc_driver" version = "0.3.2" dependencies = [ - "acvm 0.8.0", + "acvm 0.9.0", "clap", "fm", "iter-extended", @@ -2326,7 +2273,7 @@ dependencies = [ name = "noirc_evaluator" version = "0.3.2" dependencies = [ - "acvm 0.8.0", + "acvm 0.9.0", "arena", "iter-extended", "noirc_abi", @@ -2342,7 +2289,7 @@ dependencies = [ name = "noirc_frontend" version = "0.3.2" dependencies = [ - "acvm 0.8.0", + "acvm 0.9.0", "arena", "chumsky", "fm", diff --git a/Cargo.toml b/Cargo.toml index 29ac590f6f..953470e856 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2021" rust-version = "1.66" [workspace.dependencies] -acvm = "0.8.0" +acvm = "0.9.0" arena = { path = "crates/arena" } fm = { path = "crates/fm" } iter-extended = { path = "crates/iter-extended" } From e3745dc71bf65587bd5576d884d49983630ea9b7 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 12 Apr 2023 15:02:22 -0700 Subject: [PATCH 31/54] Reference temp commit on aztec_backend --- Cargo.lock | 6 +++--- crates/nargo_cli/Cargo.toml | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40d1487d88..9992c601bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -550,7 +550,7 @@ dependencies = [ [[package]] name = "barretenberg_static_lib" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=00bb15779dfb64539eeb3f3bb4c4deeba106f2fe#00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" +source = "git+https://github.com/noir-lang/aztec_backend?rev=3bf8443d087373c808a154bc4b674f2fb42a2895#3bf8443d087373c808a154bc4b674f2fb42a2895" dependencies = [ "barretenberg-sys", "common", @@ -559,7 +559,7 @@ dependencies = [ [[package]] name = "barretenberg_wasm" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=00bb15779dfb64539eeb3f3bb4c4deeba106f2fe#00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" +source = "git+https://github.com/noir-lang/aztec_backend?rev=3bf8443d087373c808a154bc4b674f2fb42a2895#3bf8443d087373c808a154bc4b674f2fb42a2895" dependencies = [ "common", "getrandom", @@ -863,7 +863,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=00bb15779dfb64539eeb3f3bb4c4deeba106f2fe#00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" +source = "git+https://github.com/noir-lang/aztec_backend?rev=3bf8443d087373c808a154bc4b674f2fb42a2895#3bf8443d087373c808a154bc4b674f2fb42a2895" dependencies = [ "acvm 0.9.0", "blake2", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 3ef91475b8..5815813bfe 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -38,8 +38,9 @@ tempdir = "0.3.7" color-eyre = "0.6.2" # Backends -aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" } -aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "00bb15779dfb64539eeb3f3bb4c4deeba106f2fe" } +# TODO(blaine): Update to upstream commit +aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "3bf8443d087373c808a154bc4b674f2fb42a2895" } +aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "3bf8443d087373c808a154bc4b674f2fb42a2895" } marlin_arkworks_backend = { optional = true, git = "https://github.com/noir-lang/marlin_arkworks_backend", rev = "144378edad821bfaa52bf2cacca8ecc87514a4fc" } [dev-dependencies] From 4c626b30319b7a8ec04fdf51386e1028f98931c8 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 12 Apr 2023 15:02:39 -0700 Subject: [PATCH 32/54] fix some issues with the acvm 0.9 upgrade --- .../src/ssa/acir_gen/operations/sort.rs | 1 + crates/wasm/src/circuit.rs | 23 ------------------- crates/wasm/src/lib.rs | 3 +-- 3 files changed, 2 insertions(+), 25 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 fe7c39de7c..04524959fb 100644 --- a/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs +++ b/crates/noirc_evaluator/src/ssa/acir_gen/operations/sort.rs @@ -130,6 +130,7 @@ mod test { struct MockBackend {} impl PartialWitnessGenerator for MockBackend { fn solve_black_box_function_call( + &self, _initial_witness: &mut BTreeMap, _func_call: &BlackBoxFuncCall, ) -> Result { diff --git a/crates/wasm/src/circuit.rs b/crates/wasm/src/circuit.rs index 6168fe77bb..97f9ef9cf1 100644 --- a/crates/wasm/src/circuit.rs +++ b/crates/wasm/src/circuit.rs @@ -2,29 +2,6 @@ use acvm::acir::circuit::Circuit; use gloo_utils::format::JsValueSerdeExt; use wasm_bindgen::prelude::*; -// Deserializes bytes into ACIR structure -#[deprecated( - note = "we have moved away from this serialization strategy. Call `acir_read_bytes` instead" -)] -#[allow(deprecated)] -#[wasm_bindgen] -pub fn acir_from_bytes(bytes: Vec) -> JsValue { - console_error_panic_hook::set_once(); - let circuit = Circuit::from_bytes(&bytes); - ::from_serde(&circuit).unwrap() -} - -#[deprecated( - note = "we have moved away from this serialization strategy. Call `acir_write_bytes` instead" -)] -#[allow(deprecated)] -#[wasm_bindgen] -pub fn acir_to_bytes(acir: JsValue) -> Vec { - console_error_panic_hook::set_once(); - let circuit: Circuit = JsValueSerdeExt::into_serde(&acir).unwrap(); - circuit.to_bytes() -} - // Deserializes bytes into ACIR structure #[wasm_bindgen] pub fn acir_read_bytes(bytes: Vec) -> JsValue { diff --git a/crates/wasm/src/lib.rs b/crates/wasm/src/lib.rs index 90a9bf0f17..3deee5624d 100644 --- a/crates/wasm/src/lib.rs +++ b/crates/wasm/src/lib.rs @@ -10,8 +10,7 @@ use wasm_bindgen::prelude::*; mod circuit; mod compile; -#[allow(deprecated)] -pub use circuit::{acir_from_bytes, acir_read_bytes, acir_to_bytes, acir_write_bytes}; +pub use circuit::{acir_read_bytes, acir_write_bytes}; pub use compile::{compile, WASMCompileOptions}; #[derive(Serialize, Deserialize)] From a5ad5756f6f97580b47920292e56c3aa7f4232d4 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 12 Apr 2023 15:02:58 -0700 Subject: [PATCH 33/54] temp lock to cody bb branch --- flake.lock | 7 ++++--- flake.nix | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index a3aca5d919..4886edb046 100644 --- a/flake.lock +++ b/flake.lock @@ -10,15 +10,16 @@ ] }, "locked": { - "lastModified": 1681312149, - "narHash": "sha256-+W+atUPf5OXPt/HX12+JL5N9AiutjL3HeWVVNxWHpQg=", + "lastModified": 1681328994, + "narHash": "sha256-SJDiQZ656UnjvQEysZ6c7QPAZzPQj6xCoB/Q6+93pzQ=", "owner": "AztecProtocol", "repo": "barretenberg", - "rev": "500daf1ceb03771d2c01eaf1a86139a7ac1d814f", + "rev": "9b1d132477e61b3521071c126ab6c3b99590abac", "type": "github" }, "original": { "owner": "AztecProtocol", + "ref": "cg/ultra-with-keccak-32B", "repo": "barretenberg", "type": "github" } diff --git a/flake.nix b/flake.nix index 0cd04d4cde..fb8b3d2207 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,7 @@ }; barretenberg = { - url = "github:AztecProtocol/barretenberg"; + url = "github:AztecProtocol/barretenberg/cg/ultra-with-keccak-32B"; inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; From 5ce8a05ec1ca3ab00b84ee2274a7f9154aedc3fc Mon Sep 17 00:00:00 2001 From: Tom French Date: Thu, 13 Apr 2023 14:55:00 +0100 Subject: [PATCH 34/54] chore: fix up merge issues --- crates/nargo_cli/src/cli/codegen_verifier_cmd.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs index 6b4d5ee680..442f24c4b3 100644 --- a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -1,12 +1,9 @@ -use super::fs::{ - create_named_dir, keys::fetch_pk_and_vk, program::read_program_from_file, write_to_file, -}; +use super::fs::{create_named_dir, program::read_program_from_file, write_to_file}; use super::NargoConfig; use crate::{ cli::compile_cmd::compile_circuit, constants::CONTRACT_DIR, constants::TARGET_DIR, errors::CliError, }; -use acvm::{ProofSystemCompiler, SmartContract}; use clap::Args; use nargo::ops::{codegen_verifier, preprocess_program}; use noirc_driver::CompileOptions; @@ -33,7 +30,7 @@ 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, program_dir.as_ref(), &compile_options)?; + compile_circuit(&backend, config.program_dir.as_ref(), &args.compile_options)?; preprocess_program(&backend, compiled_program)? } }; From 50b5050678feafa68f876a9263ac477ceb36b438 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 13 Apr 2023 07:52:02 -0700 Subject: [PATCH 35/54] update for contract changes --- Cargo.lock | 6 +++--- crates/nargo_cli/Cargo.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e782e7a6ec..04c4c14280 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -550,7 +550,7 @@ dependencies = [ [[package]] name = "barretenberg_static_lib" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=3bf8443d087373c808a154bc4b674f2fb42a2895#3bf8443d087373c808a154bc4b674f2fb42a2895" +source = "git+https://github.com/noir-lang/aztec_backend?rev=8086db1548764d1419c6919ba5104fe5461aa507#8086db1548764d1419c6919ba5104fe5461aa507" dependencies = [ "barretenberg-sys", "common", @@ -559,7 +559,7 @@ dependencies = [ [[package]] name = "barretenberg_wasm" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=3bf8443d087373c808a154bc4b674f2fb42a2895#3bf8443d087373c808a154bc4b674f2fb42a2895" +source = "git+https://github.com/noir-lang/aztec_backend?rev=8086db1548764d1419c6919ba5104fe5461aa507#8086db1548764d1419c6919ba5104fe5461aa507" dependencies = [ "common", "getrandom", @@ -863,7 +863,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=3bf8443d087373c808a154bc4b674f2fb42a2895#3bf8443d087373c808a154bc4b674f2fb42a2895" +source = "git+https://github.com/noir-lang/aztec_backend?rev=8086db1548764d1419c6919ba5104fe5461aa507#8086db1548764d1419c6919ba5104fe5461aa507" dependencies = [ "acvm 0.9.0", "blake2", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 5815813bfe..ba8bd6ea14 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -39,8 +39,8 @@ color-eyre = "0.6.2" # Backends # TODO(blaine): Update to upstream commit -aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "3bf8443d087373c808a154bc4b674f2fb42a2895" } -aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "3bf8443d087373c808a154bc4b674f2fb42a2895" } +aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "8086db1548764d1419c6919ba5104fe5461aa507" } +aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "8086db1548764d1419c6919ba5104fe5461aa507" } marlin_arkworks_backend = { optional = true, git = "https://github.com/noir-lang/marlin_arkworks_backend", rev = "144378edad821bfaa52bf2cacca8ecc87514a4fc" } [dev-dependencies] From bdf50a609c50049382858154620f9996cf54744c Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 13 Apr 2023 11:00:41 -0700 Subject: [PATCH 36/54] update to appropriate refs --- Cargo.lock | 6 +++--- crates/nargo_cli/Cargo.toml | 5 ++--- flake.lock | 19 +++++++++---------- flake.nix | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04c4c14280..f269940eac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -550,7 +550,7 @@ dependencies = [ [[package]] name = "barretenberg_static_lib" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=8086db1548764d1419c6919ba5104fe5461aa507#8086db1548764d1419c6919ba5104fe5461aa507" +source = "git+https://github.com/noir-lang/aztec_backend?rev=7ec5693f194a79c379ae2952bc17a31ee63a42b9#7ec5693f194a79c379ae2952bc17a31ee63a42b9" dependencies = [ "barretenberg-sys", "common", @@ -559,7 +559,7 @@ dependencies = [ [[package]] name = "barretenberg_wasm" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=8086db1548764d1419c6919ba5104fe5461aa507#8086db1548764d1419c6919ba5104fe5461aa507" +source = "git+https://github.com/noir-lang/aztec_backend?rev=7ec5693f194a79c379ae2952bc17a31ee63a42b9#7ec5693f194a79c379ae2952bc17a31ee63a42b9" dependencies = [ "common", "getrandom", @@ -863,7 +863,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=8086db1548764d1419c6919ba5104fe5461aa507#8086db1548764d1419c6919ba5104fe5461aa507" +source = "git+https://github.com/noir-lang/aztec_backend?rev=7ec5693f194a79c379ae2952bc17a31ee63a42b9#7ec5693f194a79c379ae2952bc17a31ee63a42b9" dependencies = [ "acvm 0.9.0", "blake2", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index ba8bd6ea14..5684648237 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -38,9 +38,8 @@ tempdir = "0.3.7" color-eyre = "0.6.2" # Backends -# TODO(blaine): Update to upstream commit -aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "8086db1548764d1419c6919ba5104fe5461aa507" } -aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "8086db1548764d1419c6919ba5104fe5461aa507" } +aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "7ec5693f194a79c379ae2952bc17a31ee63a42b9" } +aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "7ec5693f194a79c379ae2952bc17a31ee63a42b9" } marlin_arkworks_backend = { optional = true, git = "https://github.com/noir-lang/marlin_arkworks_backend", rev = "144378edad821bfaa52bf2cacca8ecc87514a4fc" } [dev-dependencies] diff --git a/flake.lock b/flake.lock index 4886edb046..85df45a80b 100644 --- a/flake.lock +++ b/flake.lock @@ -10,16 +10,15 @@ ] }, "locked": { - "lastModified": 1681328994, - "narHash": "sha256-SJDiQZ656UnjvQEysZ6c7QPAZzPQj6xCoB/Q6+93pzQ=", + "lastModified": 1681402584, + "narHash": "sha256-AAfe7VTfHCRqBmxTW2dhHl58tZbJRa4zjU2X7kuKnzQ=", "owner": "AztecProtocol", "repo": "barretenberg", - "rev": "9b1d132477e61b3521071c126ab6c3b99590abac", + "rev": "d104756225a72c047a6b54d453cea2d3fb0110bb", "type": "github" }, "original": { "owner": "AztecProtocol", - "ref": "cg/ultra-with-keccak-32B", "repo": "barretenberg", "type": "github" } @@ -98,11 +97,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1681154110, - "narHash": "sha256-OQwWzlzAY1dCqgSsgZzsPIOGmX4pBGaoXOy0rSl4b5Y=", + "lastModified": 1681269223, + "narHash": "sha256-i6OeI2f7qGvmLfD07l1Az5iBL+bFeP0RHixisWtpUGo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "115a96e2ac1e92937cd47c30e073e16dcaaf6247", + "rev": "87edbd74246ccdfa64503f334ed86fa04010bab9", "type": "github" }, "original": { @@ -156,11 +155,11 @@ ] }, "locked": { - "lastModified": 1681265948, - "narHash": "sha256-wYS5dR1fRoU6VtoKScz1OUS/dmart7hfI0G71qkJcwc=", + "lastModified": 1681408438, + "narHash": "sha256-EpTkdgZDGjZSHzzA5Di5kBcrAkEDpoYng+Dm4+cVfMo=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b10a42fe6bb0b6d1b335c1f137419ebf754b2b59", + "rev": "c949d341f2b507857d589c48d1bd719896a2a224", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index fb8b3d2207..0cd04d4cde 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,7 @@ }; barretenberg = { - url = "github:AztecProtocol/barretenberg/cg/ultra-with-keccak-32B"; + url = "github:AztecProtocol/barretenberg"; inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; From 6fe4ad78d79a2b27e487d5ebd57cbe6832642394 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Fri, 14 Apr 2023 08:35:42 -0700 Subject: [PATCH 37/54] working on direnv --- .envrc | 2 +- .gitignore | 3 +++ flake.nix | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.envrc b/.envrc index 1d953f4bd7..3550a30f2d 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use nix +use flake diff --git a/.gitignore b/.gitignore index 84d2972035..71fff59d75 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,10 @@ examples/9 .vscode node_modules pkg/ + +# Nix stuff result +.direnv/ # Nargo output *.proof diff --git a/flake.nix b/flake.nix index 0cd04d4cde..79e4fad0c3 100644 --- a/flake.nix +++ b/flake.nix @@ -40,7 +40,9 @@ ]; }; - rustToolchain = pkgs.rust-bin.stable."1.66.0".default; + rustToolchain = pkgs.rust-bin.stable."1.66.0".default.override { + extensions = [ "rust-src" ]; + }; craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; @@ -133,9 +135,9 @@ # apps.default = flake-utils.lib.mkApp { drv = nargo; }; devShells.default = pkgs.mkShell.override { stdenv = pkgs.llvmPackages.stdenv; } { - inputsFrom = builtins.attrValues self.checks; + inputsFrom = builtins.attrValues checks; - buildInputs = packages.default.buildInputs; + # buildInputs = packages.default.buildInputs; LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; @@ -143,8 +145,6 @@ which starship git - cargo - rustc ]; shellHook = '' From 8ada5fe67f2c62bd48521028e9302fedff0390cc Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 19 Apr 2023 15:28:11 -0700 Subject: [PATCH 38/54] Update nix and direnv stuff --- .envrc | 21 ++++++++++++- .gitignore | 1 + default.nix | 24 ++++++++------- flake.lock | 57 ++++++++--------------------------- flake.nix | 86 +++++++++++++++++++++++++++++++++++++---------------- shell.nix | 13 ++++++++ 6 files changed, 120 insertions(+), 82 deletions(-) create mode 100644 shell.nix diff --git a/.envrc b/.envrc index 3550a30f2d..b2f868b189 100644 --- a/.envrc +++ b/.envrc @@ -1 +1,20 @@ -use flake +# Based on https://github.com/direnv/direnv-vscode/blob/158e8302c2594cc0eaa5f8b4f0cafedd4e1c0315/.envrc + +# You can define your system-specific logic (like Git settings or GH tokens) in .envrc.local +# If that logic is usable by other people and might improve development environment, consider +# contributing it to this file! + +source_env_if_exists .envrc.local + +if [[ -z "${SKIP_NIX:-}" ]] && has nix; then + + if nix flake metadata &>/dev/null && has use_flake; then + # use flakes if possible + use flake + + else + # Otherwise fall back to pure nix + use nix + fi + +fi diff --git a/.gitignore b/.gitignore index 71fff59d75..423805bdcb 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ pkg/ # Nix stuff result +.envrc.local .direnv/ # Nargo output diff --git a/default.nix b/default.nix index 0bb5c39e06..9e230590a6 100644 --- a/default.nix +++ b/default.nix @@ -1,11 +1,13 @@ -{ pkgs ? import {} }: - -pkgs.mkShell { - buildInputs = [ - pkgs.openssl - pkgs.pkg-config - pkgs.cmake - pkgs.llvmPackages.openmp - pkgs.rustup - ]; -} \ No newline at end of file +let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + flakeCompatRev = lock.nodes.flake-compat.locked.rev; + flakeCompatHash = lock.nodes.flake-compat.locked.narHash; + flakeCompat = fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${flakeCompatRev}.tar.gz"; + sha256 = flakeCompatHash; + }; + compat = import flakeCompat { + src = ./.; + }; +in +compat.defaultNix diff --git a/flake.lock b/flake.lock index 85df45a80b..c8a1c66eee 100644 --- a/flake.lock +++ b/flake.lock @@ -25,12 +25,18 @@ }, "crane": { "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", + "flake-compat": [ + "flake-compat" + ], + "flake-utils": [ + "flake-utils" + ], "nixpkgs": [ "nixpkgs" ], - "rust-overlay": "rust-overlay" + "rust-overlay": [ + "rust-overlay" + ] }, "locked": { "lastModified": 1681177078, @@ -63,21 +69,6 @@ } }, "flake-utils": { - "locked": { - "lastModified": 1678901627, - "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { "inputs": { "systems": "systems" }, @@ -115,37 +106,13 @@ "inputs": { "barretenberg": "barretenberg", "crane": "crane", - "flake-utils": "flake-utils_2", + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay_2" + "rust-overlay": "rust-overlay" } }, "rust-overlay": { - "inputs": { - "flake-utils": [ - "crane", - "flake-utils" - ], - "nixpkgs": [ - "crane", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1680488274, - "narHash": "sha256-0vYMrZDdokVmPQQXtFpnqA2wEgCCUXf5a3dDuDVshn0=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "7ec2ff598a172c6e8584457167575b3a1a5d80d8", - "type": "github" - }, - "original": { - "owner": "oxalica", - "repo": "rust-overlay", - "type": "github" - } - }, - "rust-overlay_2": { "inputs": { "flake-utils": [ "flake-utils" diff --git a/flake.nix b/flake.nix index 79e4fad0c3..3b1f0281ee 100644 --- a/flake.nix +++ b/flake.nix @@ -2,25 +2,45 @@ description = "Build the Noir programming language"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; + nixpkgs = { + url = "github:NixOS/nixpkgs/nixos-22.11"; + }; - crane = { - url = "github:ipetkov/crane"; - inputs.nixpkgs.follows = "nixpkgs"; + flake-utils = { + url = "github:numtide/flake-utils"; }; - flake-utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; rust-overlay = { url = "github:oxalica/rust-overlay"; + # All of these inputs (a.k.a. dependencies) need to align with inputs we + # use so they use the `inputs.*.follows` syntax to reference our inputs + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + + crane = { + url = "github:ipetkov/crane"; + # All of these inputs (a.k.a. dependencies) need to align with inputs we + # use so they use the `inputs.*.follows` syntax to reference our inputs inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; + flake-compat.follows = "flake-compat"; + rust-overlay.follows = "rust-overlay"; }; }; barretenberg = { url = "github:AztecProtocol/barretenberg"; + # All of these inputs (a.k.a. dependencies) need to align with inputs we + # use so they use the `inputs.*.follows` syntax to reference our inputs inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; @@ -41,6 +61,8 @@ }; rustToolchain = pkgs.rust-bin.stable."1.66.0".default.override { + # We include rust-src to ensure rust-analyzer works. + # See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/4 extensions = [ "rust-src" ]; }; @@ -50,6 +72,13 @@ # rust-bindgen needs to know the location of libclang LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; + # Barretenberg fails if tests are run on multiple threads, so we set the test thread + # count to 1 throughout the entire project + # + # Note: Setting this allows for consistent behavior across build and shells, but is mostly + # hidden from the developer - i.e. when they see the command being run via `nix flake check` + RUST_TEST_THREADS = "1"; + # We set the environment variable because barretenberg must be compiled in a special way for wasm BARRETENBERG_BIN_DIR = "${pkgs.barretenberg-wasm}/bin"; @@ -62,22 +91,28 @@ GIT_COMMIT = if (self ? rev) then self.rev else "unknown"; GIT_DIRTY = if (self ? rev) then "false" else "true"; - commonArgs = { + # As per https://discourse.nixos.org/t/gcc11stdenv-and-clang/17734/7 since it seems that aarch64-linux uses + # gcc9 instead of gcc11 for the C++ stdlib, while all other targets we support provide the correct libstdc++ + stdenv = + if (pkgs.stdenv.targetPlatform.isGnu && pkgs.stdenv.targetPlatform.isAarch64) then + pkgs.overrideCC pkgs.llvmPackages.stdenv (pkgs.llvmPackages.clang.override { gccForLibs = pkgs.gcc11.cc; }) + else + pkgs.llvmPackages.stdenv; + + # Combine the environment and other configuration needed for crane to build our Rust packages + commonArgs = environment // { pname = "noir"; # x-release-please-start-version version = "0.3.2"; # x-release-please-end - # As per https://discourse.nixos.org/t/gcc11stdenv-and-clang/17734/7 since it seems that aarch64-linux uses - # gcc9 instead of gcc11 for the C++ stdlib, while all other targets we support provide the correct libstdc++ - stdenv = with pkgs; - if (stdenv.targetPlatform.isGnu && stdenv.targetPlatform.isAarch64) then - overrideCC llvmPackages.stdenv (llvmPackages.clang.override { gccForLibs = gcc11.cc; }) - else - llvmPackages.stdenv; + # Use our custom stdenv to build and test our Rust project + inherit stdenv; src = ./.; + # Running checks don't do much more than compiling itself and increase + # the build time by a lot, so we disable them throughout all our flakes doCheck = false; nativeBuildInputs = [ @@ -96,12 +131,9 @@ pkgs.darwin.apple_sdk.frameworks.Security ]; - LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; - inherit GIT_COMMIT; inherit GIT_DIRTY; - - } // environment; + }; # Build *just* the cargo dependencies, so we can reuse all of that work between runs cargoArtifacts = craneLib.buildDepsOnly commonArgs; @@ -115,7 +147,8 @@ cargo-clippy = craneLib.cargoClippy (commonArgs // { inherit cargoArtifacts; - cargoClippyExtraArgs = "--all-targets --workspace -- -D warnings"; + # TODO(blaine): It'd be nice to include these flags when running `cargo clippy` in a devShell. + cargoClippyExtraArgs = "--all-targets -- -D warnings"; doCheck = true; }); @@ -123,7 +156,8 @@ cargo-test = craneLib.cargoTest (commonArgs // { inherit cargoArtifacts; - cargoTestExtraArgs = "--workspace -- --test-threads=1"; + # TODO(blaine): It'd be nice to include this flag when running `cargo test` in a devShell. + cargoTestExtraArgs = "--workspace"; doCheck = true; }); @@ -134,22 +168,24 @@ # TODO: Look into installable apps with Nix flakes # apps.default = flake-utils.lib.mkApp { drv = nargo; }; - devShells.default = pkgs.mkShell.override { stdenv = pkgs.llvmPackages.stdenv; } { + # Setup the environment to match the stdenv from `nix build` & `nix flake check`, and + # combine it with the environment settings, the inputs from our checks derivations, + # and extra tooling via `nativeBuildInputs` + devShells.default = pkgs.mkShell.override { inherit stdenv; } (environment // { inputsFrom = builtins.attrValues checks; - # buildInputs = packages.default.buildInputs; - - LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; - nativeBuildInputs = with pkgs; [ which starship git + nil + nixpkgs-fmt + llvmPackages.lldb # This ensures the right lldb is in the environment for running rust-lldb ]; shellHook = '' eval "$(starship init bash)" ''; - }; + }); }); } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000000..b72d4a4697 --- /dev/null +++ b/shell.nix @@ -0,0 +1,13 @@ +let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + flakeCompatRev = lock.nodes.flake-compat.locked.rev; + flakeCompatHash = lock.nodes.flake-compat.locked.narHash; + flakeCompat = fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${flakeCompatRev}.tar.gz"; + sha256 = flakeCompatHash; + }; + compat = import flakeCompat { + src = ./.; + }; +in +compat.shellNix From c98cacc57625ae5fbb9968564e52e7cc20f416db Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 19 Apr 2023 15:29:03 -0700 Subject: [PATCH 39/54] Update building documentation --- README.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 929f53c399..2b2397d508 100644 --- a/README.md +++ b/README.md @@ -65,20 +65,84 @@ Concretely the following items are on the road map: This crate's minimum supported rustc version is 1.66.0. -## Working on Noir / Building from source +## Working on this project -Building Noir requires a variety of native dependencies, but we've bundled up everything you need with [Nix](https://nixos.org/). +Due to the large number of native dependencies, this project uses [Nix](https://nixos.org/) and [direnv](https://direnv.net/) to streamline the development experience. -To work on Noir, you'll want to: +### Setting up your environment + +For the best experience, please follow these instructions to setup your environment: 1. Install Nix following [their guide](https://nixos.org/download.html) for your operating system 2. Create the file `~/.config/nix/nix.conf` with the contents: -``` +```ini experimental-features = nix-command extra-experimental-features = flakes ``` -3. Clone the project with `git clone git@github.com:noir-lang/noir` -4. Run `nix build . -L` in the `noir` directory -5. Run `nix flake check -L` to run clippy and the tests +3. Install direnv into your Nix profile by running: +```sh +nix profile install nixpkgs#direnv +``` +4. Add direnv to your shell following [their guide](https://direnv.net/docs/hook.html) +5. Restart your shell + +### Shell & editor experience + +Now that your environment is set up, you can get to work on the project. + +1. Clone the repository, such as: +```sh +git clone git@github.com:noir-lang/barretenberg-sys +``` +2. Navigate to the directory: +```sh +cd barretenberg-sys +``` +3. You should see a __direnv error__ because projects aren't allowed by default. Make sure you trust our `.envrc` file, then you need to run: +```sh +direnv allow +``` +4. Now, wait awhile for all the native dependencies to be built. This will take some time and direnv will warn you that it is taking a long time, but we just need to let it run. +5. Once you are presented with your prompt again, you can start your editor within the project directory (we recommend [VSCode](https://code.visualstudio.com/)): +```sh +code . +``` +6. (Recommended) When launching VSCode for the first time, you should be prompted to install our recommended plugins. We highly recommend installing these for the best development experience. + +### Building and testing + +Assuming you are using `direnv` to populate your environment, building and testing the project can be done +with the typical `cargo build`, `cargo test`, and `cargo clippy` commands. You'll notice that the `cargo` version matches the version we specify in [flake.nix](./flake.nix), which is 1.66.0 at the time of this writing. + +If you want to build the entire project in an isolated sandbox, you can use Nix commands: +1. `nix build .` (or `nix build . -L` for verbose output) to build the project in a Nix sandbox +2. `nix flake check` (or `nix flake check -L` for verbose output) to run clippy and tests in a Nix sandbox + +### Building against a different local/remote version of Barretenberg + +If you are working on this crate, it is likely that you want to incorporate changes from some other version of Barretenberg +instead of the version this project is pinned against. + +To reference a different version of Barretenberg, you want to replace the lockfile version with your version. This can be done +by running: + +```sh +nix flake lock --override-input barretenberg /absolute/path/to/your/barretenberg +``` + +You can also point at a fork and/or branch on GitHub using: + +```sh +nix flake lock --override-input barretenberg github:phated/barretenberg/mybranch +``` + +__Note:__ You don't want to commit the updated lockfile, as it will fail in CI! + +### Without direnv + +If you have hesitations with using `direnv`, you can launch a subshell with `nix develop` and then launch your editor +from within the subshell. However, if VSCode was already launched in the project directory, the environment won't be updated. + +__Advanced:__ If you aren't using `direnv` nor launching your editor within the subshell, you can try to install barretenberg and other global dependencies the package needs. This is an advanced workflow and likely won't receive support! ## License From 3a47d2d266b57a3ee43aae2ea2e0f47e0f8b01f4 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 19 Apr 2023 15:29:26 -0700 Subject: [PATCH 40/54] Stop ignoring vscode dir and recommend extensions and settings --- .gitignore | 1 - .vscode/extensions.json | 13 +++++++++++++ .vscode/settings.json | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 423805bdcb..351f5e16a7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .DS_Store examples/**/target/ examples/9 -.vscode node_modules pkg/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000..64ae238015 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,13 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "mkhl.direnv", + "jnoortheen.nix-ide", + "rust-lang.rust-analyzer", + "redhat.vscode-yaml" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..78bfd88c35 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "direnv.restart.automatic": true, + "redhat.telemetry.enabled": false, + "yaml.recommendations.show": false, + "nix.serverPath": "nil", + "nix.enableLanguageServer": true, + "nix.serverSettings": { + "nil": { + "formatting": { + "command": [ + "nixpkgs-fmt" + ] + } + } + }, +} From 6d4649e92d369fe17356a28f469f1bdbc1cf57bb Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Wed, 19 Apr 2023 15:34:31 -0700 Subject: [PATCH 41/54] cspell --- cspell.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cspell.json b/cspell.json index 37667e96ba..586ef4a337 100644 --- a/cspell.json +++ b/cspell.json @@ -52,6 +52,12 @@ "uninstantiated", "urem", "vecmap", + "direnv", + "nixpkgs", + "envrc", + "phated", + "mybranch", + "subshell", // Dependencies // "acir", From 957fb8544a797a731ae402574341fe88e183116c Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 20 Apr 2023 12:44:20 -0700 Subject: [PATCH 42/54] aztec_backend refs --- Cargo.lock | 6 +++--- crates/nargo_cli/Cargo.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ec186aed1..427589f19d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -308,7 +308,7 @@ dependencies = [ [[package]] name = "barretenberg_static_lib" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=8ed67d68c71d655e1a6a5c38fa9ea1c3566f771d#8ed67d68c71d655e1a6a5c38fa9ea1c3566f771d" +source = "git+https://github.com/noir-lang/aztec_backend?rev=680457cf59ccd3f0b6db6fc545c606294964c72d#680457cf59ccd3f0b6db6fc545c606294964c72d" dependencies = [ "barretenberg-sys", "common", @@ -317,7 +317,7 @@ dependencies = [ [[package]] name = "barretenberg_wasm" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=8ed67d68c71d655e1a6a5c38fa9ea1c3566f771d#8ed67d68c71d655e1a6a5c38fa9ea1c3566f771d" +source = "git+https://github.com/noir-lang/aztec_backend?rev=680457cf59ccd3f0b6db6fc545c606294964c72d#680457cf59ccd3f0b6db6fc545c606294964c72d" dependencies = [ "common", "getrandom", @@ -621,7 +621,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=8ed67d68c71d655e1a6a5c38fa9ea1c3566f771d#8ed67d68c71d655e1a6a5c38fa9ea1c3566f771d" +source = "git+https://github.com/noir-lang/aztec_backend?rev=680457cf59ccd3f0b6db6fc545c606294964c72d#680457cf59ccd3f0b6db6fc545c606294964c72d" dependencies = [ "acvm", "blake2", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index afe2a69f4f..134f800883 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -38,8 +38,8 @@ tempdir = "0.3.7" color-eyre = "0.6.2" # Backends -aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "8ed67d68c71d655e1a6a5c38fa9ea1c3566f771d" } -aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "8ed67d68c71d655e1a6a5c38fa9ea1c3566f771d" } +aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "680457cf59ccd3f0b6db6fc545c606294964c72d" } +aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "680457cf59ccd3f0b6db6fc545c606294964c72d" } [dev-dependencies] assert_cmd = "2.0.8" From d662842e1aaa36846052089fde606b22d20e68fa Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 20 Apr 2023 12:44:48 -0700 Subject: [PATCH 43/54] nix lockfile --- flake.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/flake.lock b/flake.lock index c8a1c66eee..04dbc188a5 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1681402584, - "narHash": "sha256-AAfe7VTfHCRqBmxTW2dhHl58tZbJRa4zjU2X7kuKnzQ=", + "lastModified": 1682019675, + "narHash": "sha256-KZ/VL/u81z2sFTdwfxvUFR+ftqf3+2AA0gR9kkgKxe4=", "owner": "AztecProtocol", "repo": "barretenberg", - "rev": "d104756225a72c047a6b54d453cea2d3fb0110bb", + "rev": "a38e3611590e085e5f25c322757871fb048aa3d7", "type": "github" }, "original": { @@ -39,11 +39,11 @@ ] }, "locked": { - "lastModified": 1681177078, - "narHash": "sha256-ZNIjBDou2GOabcpctiQykEQVkI8BDwk7TyvlWlI4myE=", + "lastModified": 1681680516, + "narHash": "sha256-EB8Adaeg4zgcYDJn9sR6UMjN/OHdIiMMK19+3LmmXQY=", "owner": "ipetkov", "repo": "crane", - "rev": "0c9f468ff00576577d83f5019a66c557ede5acf6", + "rev": "54b63c8eae4c50172cb50b612946ff1d2bc1c75c", "type": "github" }, "original": { @@ -88,11 +88,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1681269223, - "narHash": "sha256-i6OeI2f7qGvmLfD07l1Az5iBL+bFeP0RHixisWtpUGo=", + "lastModified": 1681932375, + "narHash": "sha256-tSXbYmpnKSSWpzOrs27ie8X3I0yqKA6AuCzCYNtwbCU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "87edbd74246ccdfa64503f334ed86fa04010bab9", + "rev": "3d302c67ab8647327dba84fbdb443cdbf0e82744", "type": "github" }, "original": { @@ -122,11 +122,11 @@ ] }, "locked": { - "lastModified": 1681408438, - "narHash": "sha256-EpTkdgZDGjZSHzzA5Di5kBcrAkEDpoYng+Dm4+cVfMo=", + "lastModified": 1681957132, + "narHash": "sha256-52GaHyeLyyiT0u4OL3uGbo0vsUMKm33Z3zLkPyK/ZRY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "c949d341f2b507857d589c48d1bd719896a2a224", + "rev": "4771640d46c214d702512a8ece591f582ae507fa", "type": "github" }, "original": { From 3e3c3e7d7bd2627cdf560e3f6e45afee8be7868f Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 20 Apr 2023 13:06:05 -0700 Subject: [PATCH 44/54] Simplify and rename workflow --- .github/workflows/{rust.yml => test.yml} | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) rename .github/workflows/{rust.yml => test.yml} (72%) diff --git a/.github/workflows/rust.yml b/.github/workflows/test.yml similarity index 72% rename from .github/workflows/rust.yml rename to .github/workflows/test.yml index 510d601dde..220985d800 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Rust +name: Test on: [push, pull_request] @@ -8,8 +8,8 @@ concurrency: cancel-in-progress: true jobs: - nix: - name: Nix build & test - ${{ matrix.os }} + test: + name: Test on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: @@ -30,10 +30,6 @@ jobs: nix_path: nixpkgs=channel:nixos-22.11 github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Cargo clippy + - name: Run `nix flake check` run: | - nix build -L .#checks.${{ matrix.target }}.cargo-clippy - - - name: Cargo test - run: | - nix build -L .#checks.${{ matrix.target }}.cargo-test + nix flake check From a64d04f1999999bcfd347504de0d734c1daaeffe Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 20 Apr 2023 13:10:37 -0700 Subject: [PATCH 45/54] docs cleanup --- README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2b2397d508..287846d547 100644 --- a/README.md +++ b/README.md @@ -91,13 +91,13 @@ Now that your environment is set up, you can get to work on the project. 1. Clone the repository, such as: ```sh -git clone git@github.com:noir-lang/barretenberg-sys +git clone git@github.com:noir-lang/noir ``` 2. Navigate to the directory: ```sh -cd barretenberg-sys +cd noir ``` -3. You should see a __direnv error__ because projects aren't allowed by default. Make sure you trust our `.envrc` file, then you need to run: +3. You should see a __direnv error__ because projects aren't allowed by default. Make sure you've reviewed and trust our `.envrc` file, then you need to run: ```sh direnv allow ``` @@ -119,11 +119,7 @@ If you want to build the entire project in an isolated sandbox, you can use Nix ### Building against a different local/remote version of Barretenberg -If you are working on this crate, it is likely that you want to incorporate changes from some other version of Barretenberg -instead of the version this project is pinned against. - -To reference a different version of Barretenberg, you want to replace the lockfile version with your version. This can be done -by running: +If you are working on this project and want a different version of Barretenberg (instead of the version this project is pinned against), you'll want to replace the lockfile version with your version. This can be done by running: ```sh nix flake lock --override-input barretenberg /absolute/path/to/your/barretenberg @@ -142,7 +138,7 @@ __Note:__ You don't want to commit the updated lockfile, as it will fail in CI! If you have hesitations with using `direnv`, you can launch a subshell with `nix develop` and then launch your editor from within the subshell. However, if VSCode was already launched in the project directory, the environment won't be updated. -__Advanced:__ If you aren't using `direnv` nor launching your editor within the subshell, you can try to install barretenberg and other global dependencies the package needs. This is an advanced workflow and likely won't receive support! +__Advanced:__ If you aren't using `direnv` nor launching your editor within the subshell, you can try to install Barretenberg and other global dependencies the package needs. This is an advanced workflow and likely won't receive support! ## License From 6a79a0e94260a78d5ccd5c25b24c657b4ebac7f2 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 20 Apr 2023 14:03:32 -0700 Subject: [PATCH 46/54] code review --- crates/nargo_cli/src/cli/codegen_verifier_cmd.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs index 90a4053527..442f24c4b3 100644 --- a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -4,9 +4,8 @@ use crate::{ cli::compile_cmd::compile_circuit, constants::CONTRACT_DIR, constants::TARGET_DIR, errors::CliError, }; -use acvm::SmartContract; use clap::Args; -use nargo::ops::preprocess_program; +use nargo::ops::{codegen_verifier, preprocess_program}; use noirc_driver::CompileOptions; /// Generates a Solidity verifier smart contract for the program @@ -36,8 +35,7 @@ pub(crate) fn run(args: CodegenVerifierCommand, config: NargoConfig) -> Result<( } }; - let smart_contract_string = - backend.eth_contract_from_vk(&preprocessed_program.verification_key); + let smart_contract_string = codegen_verifier(&backend, &preprocessed_program.verification_key)?; let contract_dir = config.program_dir.join(CONTRACT_DIR); create_named_dir(&contract_dir, "contract"); From 855cbd334d60607e47a224bba1b9aa8f7c79795b Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 21 Apr 2023 11:40:02 +0100 Subject: [PATCH 47/54] Update crates/nargo_cli/tests/prove_and_verify.rs --- crates/nargo_cli/tests/prove_and_verify.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nargo_cli/tests/prove_and_verify.rs b/crates/nargo_cli/tests/prove_and_verify.rs index 98b2812237..1f533ad6ec 100644 --- a/crates/nargo_cli/tests/prove_and_verify.rs +++ b/crates/nargo_cli/tests/prove_and_verify.rs @@ -57,7 +57,7 @@ mod tests { let test_data_dir = manifest_dir.join("tests").join("test_data"); let config_path = test_data_dir.join("config.toml"); - //load config.tml file from test_data directory + // Load config.toml file from `test_data` directory let config_data: BTreeMap> = load_conf(&config_path); // Copy all the test cases into a temp dir so we don't leave artifacts around. From 652b7fa34be171fd6f7362862b72dcd808557b9c Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Fri, 21 Apr 2023 11:43:09 +0100 Subject: [PATCH 48/54] Update crates/nargo_cli/tests/prove_and_verify.rs Co-authored-by: kevaundray --- crates/nargo_cli/tests/prove_and_verify.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/nargo_cli/tests/prove_and_verify.rs b/crates/nargo_cli/tests/prove_and_verify.rs index 1f533ad6ec..070db6d8ce 100644 --- a/crates/nargo_cli/tests/prove_and_verify.rs +++ b/crates/nargo_cli/tests/prove_and_verify.rs @@ -4,8 +4,7 @@ use std::collections::BTreeMap; use std::fs; mod tests { - use std::path::Path; - use std::path::PathBuf; + use std::path::{Path, PathBuf}; use super::*; From 9d904a5f020d8fda1fa9bbd090a1f734221d15aa Mon Sep 17 00:00:00 2001 From: kevaundray Date: Fri, 21 Apr 2023 12:00:17 +0100 Subject: [PATCH 49/54] Update cspell.json --- cspell.json | 1 - 1 file changed, 1 deletion(-) diff --git a/cspell.json b/cspell.json index 586ef4a337..5649cb46f1 100644 --- a/cspell.json +++ b/cspell.json @@ -55,7 +55,6 @@ "direnv", "nixpkgs", "envrc", - "phated", "mybranch", "subshell", // Dependencies From ce9d46a65cfcacf35c03965e0894f9d045701bd6 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Fri, 21 Apr 2023 12:05:57 +0100 Subject: [PATCH 50/54] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 287846d547..1830e43016 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ nix flake lock --override-input barretenberg /absolute/path/to/your/barretenberg You can also point at a fork and/or branch on GitHub using: ```sh -nix flake lock --override-input barretenberg github:phated/barretenberg/mybranch +nix flake lock --override-input barretenberg github:username/barretenberg/branch_name ``` __Note:__ You don't want to commit the updated lockfile, as it will fail in CI! From ef2ca289068d12e00840b706888a8195607f9097 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Fri, 21 Apr 2023 12:07:33 +0100 Subject: [PATCH 51/54] Update cspell.json --- cspell.json | 1 - 1 file changed, 1 deletion(-) diff --git a/cspell.json b/cspell.json index 5649cb46f1..f0031d724b 100644 --- a/cspell.json +++ b/cspell.json @@ -55,7 +55,6 @@ "direnv", "nixpkgs", "envrc", - "mybranch", "subshell", // Dependencies // From f821ec18c5a9ecca39d07fadd8fa541b4ad9643e Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Fri, 21 Apr 2023 10:52:47 -0700 Subject: [PATCH 52/54] update bb-sys for linux env fixes --- Cargo.lock | 10 +++++----- crates/nargo_cli/Cargo.toml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1661785516..85b5c12aa4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -293,9 +293,9 @@ dependencies = [ [[package]] name = "barretenberg-sys" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "550a86403cc44a6ddca26c74ffecf5c0f6aa64f7de9952654b7c6ed062184c3e" +checksum = "6bc96e40cc45e7d5622cbc57a140aee926a7fb6e4f7d07dda758daa9256f3317" dependencies = [ "bindgen", "cc", @@ -308,7 +308,7 @@ dependencies = [ [[package]] name = "barretenberg_static_lib" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=680457cf59ccd3f0b6db6fc545c606294964c72d#680457cf59ccd3f0b6db6fc545c606294964c72d" +source = "git+https://github.com/noir-lang/aztec_backend?rev=e3d4504f15e1295e637c4da80b1d08c87c267c45#e3d4504f15e1295e637c4da80b1d08c87c267c45" dependencies = [ "barretenberg-sys", "common", @@ -317,7 +317,7 @@ dependencies = [ [[package]] name = "barretenberg_wasm" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=680457cf59ccd3f0b6db6fc545c606294964c72d#680457cf59ccd3f0b6db6fc545c606294964c72d" +source = "git+https://github.com/noir-lang/aztec_backend?rev=e3d4504f15e1295e637c4da80b1d08c87c267c45#e3d4504f15e1295e637c4da80b1d08c87c267c45" dependencies = [ "common", "getrandom", @@ -621,7 +621,7 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=680457cf59ccd3f0b6db6fc545c606294964c72d#680457cf59ccd3f0b6db6fc545c606294964c72d" +source = "git+https://github.com/noir-lang/aztec_backend?rev=e3d4504f15e1295e637c4da80b1d08c87c267c45#e3d4504f15e1295e637c4da80b1d08c87c267c45" dependencies = [ "acvm", "blake2", diff --git a/crates/nargo_cli/Cargo.toml b/crates/nargo_cli/Cargo.toml index 7e7bcd87d3..40ab4b9245 100644 --- a/crates/nargo_cli/Cargo.toml +++ b/crates/nargo_cli/Cargo.toml @@ -37,8 +37,8 @@ termcolor = "1.1.2" color-eyre = "0.6.2" # Backends -aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "680457cf59ccd3f0b6db6fc545c606294964c72d" } -aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "680457cf59ccd3f0b6db6fc545c606294964c72d" } +aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "e3d4504f15e1295e637c4da80b1d08c87c267c45" } +aztec_wasm_backend = { optional = true, package = "barretenberg_wasm", git = "https://github.com/noir-lang/aztec_backend", rev = "e3d4504f15e1295e637c4da80b1d08c87c267c45" } [dev-dependencies] tempdir = "0.3.7" From 8d1eaceb30391fa479bdbd521897dce11cbc3f00 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Fri, 21 Apr 2023 10:58:57 -0700 Subject: [PATCH 53/54] add issue numbers to TODOs --- crates/nargo_cli/src/cli/codegen_verifier_cmd.rs | 2 +- flake.nix | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs index 442f24c4b3..319a572270 100644 --- a/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/crates/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -21,7 +21,7 @@ pub(crate) struct CodegenVerifierCommand { pub(crate) fn run(args: CodegenVerifierCommand, config: NargoConfig) -> Result<(), CliError> { let backend = crate::backends::ConcreteBackend; - // TODO(blaine): Should this be a utility function? + // TODO(#1201): Should this be a utility function? let circuit_build_path = args .circuit_name .map(|circuit_name| config.program_dir.join(TARGET_DIR).join(circuit_name)); diff --git a/flake.nix b/flake.nix index 3b1f0281ee..ac1728b1d2 100644 --- a/flake.nix +++ b/flake.nix @@ -147,7 +147,7 @@ cargo-clippy = craneLib.cargoClippy (commonArgs // { inherit cargoArtifacts; - # TODO(blaine): It'd be nice to include these flags when running `cargo clippy` in a devShell. + # TODO(#1198): It'd be nice to include these flags when running `cargo clippy` in a devShell. cargoClippyExtraArgs = "--all-targets -- -D warnings"; doCheck = true; @@ -156,7 +156,7 @@ cargo-test = craneLib.cargoTest (commonArgs // { inherit cargoArtifacts; - # TODO(blaine): It'd be nice to include this flag when running `cargo test` in a devShell. + # TODO(#1198): It'd be nice to include this flag when running `cargo test` in a devShell. cargoTestExtraArgs = "--workspace"; doCheck = true; @@ -165,7 +165,7 @@ packages.default = noir; - # TODO: Look into installable apps with Nix flakes + # TODO(#1197): Look into installable apps with Nix flakes # apps.default = flake-utils.lib.mkApp { drv = nargo; }; # Setup the environment to match the stdenv from `nix build` & `nix flake check`, and From ab9e8c39f6b64ce2cd7106694d42c84ec5bb27f3 Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Fri, 21 Apr 2023 10:59:36 -0700 Subject: [PATCH 54/54] Update transcript comment --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ac1728b1d2..ab5012160d 100644 --- a/flake.nix +++ b/flake.nix @@ -83,7 +83,7 @@ BARRETENBERG_BIN_DIR = "${pkgs.barretenberg-wasm}/bin"; # We provide `barretenberg-transcript00` from the overlay to the build. - # This is necessary because the Nix sandbox is read-only and downloading during tests would fail + # This is necessary because the Nix sandbox disables the $HOME so downloading during tests would fail BARRETENBERG_TRANSCRIPT = pkgs.barretenberg-transcript00; };