diff --git a/.aztec-sync-commit b/.aztec-sync-commit index fdbc14d511e..0bdea76121d 100644 --- a/.aztec-sync-commit +++ b/.aztec-sync-commit @@ -1 +1 @@ -1d785fd1087d7387fc29213ca3be50b2fc9c4725 +86a33140f9a65e518003b3f4c60f97d132f85b89 diff --git a/acvm-repo/acvm_js/build.sh b/acvm-repo/acvm_js/build.sh index ee93413ab85..16fb26e55db 100755 --- a/acvm-repo/acvm_js/build.sh +++ b/acvm-repo/acvm_js/build.sh @@ -25,7 +25,7 @@ function run_if_available { require_command jq require_command cargo require_command wasm-bindgen -# require_command wasm-opt +require_command wasm-opt self_path=$(dirname "$(readlink -f "$0")") pname=$(cargo read-manifest | jq -r '.name') diff --git a/aztec_macros/src/transforms/functions.rs b/aztec_macros/src/transforms/functions.rs index 0fb13975fec..4d8b6ef7cdf 100644 --- a/aztec_macros/src/transforms/functions.rs +++ b/aztec_macros/src/transforms/functions.rs @@ -216,12 +216,30 @@ pub fn export_fn_abi( /// /// Inserts the following code at the beginning of an unconstrained function /// ```noir -/// let storage = Storage::init(Context::none()); +/// let context = UnconstrainedContext::new(); +/// let storage = Storage::init(context); /// ``` /// /// This will allow developers to access their contract' storage struct in unconstrained functions pub fn transform_unconstrained(func: &mut NoirFunction, storage_struct_name: String) { + // let context = UnconstrainedContext::new(); + let let_context = assignment( + "context", // Assigned to + call( + variable_path(chained_dep!( + "aztec", + "context", + "unconstrained_context", + "UnconstrainedContext", + "new" + )), + vec![], + ), + ); + + // We inject the statements at the beginning, in reverse order. func.def.body.statements.insert(0, abstract_storage(storage_struct_name, true)); + func.def.body.statements.insert(0, let_context); } /// Helper function that returns what the private context would look like in the ast @@ -597,7 +615,7 @@ fn abstract_return_values(func: &NoirFunction) -> Result>, /// ```noir /// #[aztec(private)] /// fn lol() { -/// let storage = Storage::init(context); +/// let storage = Storage::init(&mut context); /// } /// ``` /// @@ -605,22 +623,18 @@ fn abstract_return_values(func: &NoirFunction) -> Result>, /// ```noir /// #[aztec(public)] /// fn lol() { -/// let storage = Storage::init(context); +/// let storage = Storage::init(&mut context); /// } /// ``` /// /// For unconstrained functions: /// ```noir /// unconstrained fn lol() { -/// let storage = Storage::init(()); +/// let storage = Storage::init(context); /// } fn abstract_storage(storage_struct_name: String, unconstrained: bool) -> Statement { - let context_expr = if unconstrained { - // Note that the literal unit type (i.e. '()') is not the same as a tuple with zero elements - expression(ExpressionKind::Literal(Literal::Unit)) - } else { - mutable_reference("context") - }; + let context_expr = + if unconstrained { variable("context") } else { mutable_reference("context") }; assignment( "storage", // Assigned to diff --git a/compiler/integration-tests/test/node/prove_and_verify.test.ts b/compiler/integration-tests/test/node/prove_and_verify.test.ts index 1cfe36f31e9..15d39436a3b 100644 --- a/compiler/integration-tests/test/node/prove_and_verify.test.ts +++ b/compiler/integration-tests/test/node/prove_and_verify.test.ts @@ -42,10 +42,10 @@ it('end-to-end proof creation and verification (outer) -- Verifier API', async ( const { witness } = await program.execute(inputs); // Generate proof - const backend = new Backend(assert_lt_program); - const proof = await backend.generateProof(witness); + const prover = new Backend(assert_lt_program); + const proof = await prover.generateProof(witness); - const verificationKey = await backend.getVerificationKey(); + const verificationKey = await prover.getVerificationKey(); // Proof verification const verifier = new Verifier(); @@ -147,10 +147,10 @@ it('end-to-end proof creation and verification for multiple ACIR circuits (inner // bb.js part // // Proof creation - const backend = new Backend(fold_fibonacci_program); - const proof = await backend.generateProof(witness); + const prover = new Backend(fold_fibonacci_program); + const proof = await prover.generateProof(witness); // Proof verification - const isValid = await backend.verifyProof(proof); + const isValid = await prover.verifyProof(proof); expect(isValid).to.be.true; }); diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index 4030d017f2b..f8043a60f8c 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -102,6 +102,10 @@ pub struct CompileOptions { /// Enable the experimental elaborator pass #[arg(long, hide = true)] pub use_elaborator: bool, + + /// Outputs the paths to any modified artifacts + #[arg(long, hide = true)] + pub show_artifact_paths: bool, } fn parse_expression_width(input: &str) -> Result { diff --git a/examples/recursion/.gitignore b/examples/recursion/.gitignore new file mode 100644 index 00000000000..12587094b0f --- /dev/null +++ b/examples/recursion/.gitignore @@ -0,0 +1,2 @@ +recurse_leaf/Prover.toml +recurse_node/Prover.toml \ No newline at end of file diff --git a/examples/recursion/Nargo.toml b/examples/recursion/Nargo.toml new file mode 100644 index 00000000000..7c7a8b1926f --- /dev/null +++ b/examples/recursion/Nargo.toml @@ -0,0 +1,2 @@ +[workspace] +members = ["recurse_leaf", "recurse_node", "sum"] diff --git a/examples/recursion/generate_recursive_proof.sh b/examples/recursion/generate_recursive_proof.sh new file mode 100755 index 00000000000..362512529d4 --- /dev/null +++ b/examples/recursion/generate_recursive_proof.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -eu + +BACKEND=${BACKEND:-bb} + +nargo execute sum_witness --package sum +$BACKEND prove -b ./target/sum.json -w ./target/sum_witness.gz -o ./target/sum_proof + +# Once we have generated our inner proof, we must use this to generate inputs to `recurse_leaf`` + +$BACKEND write_vk -b ./target/sum.json -o ./target/sum_key +$BACKEND vk_as_fields -k ./target/sum_key -o ./target/sum_vk_as_fields +VK_HASH=$(jq -r '.[0]' ./target/sum_vk_as_fields) +VK_AS_FIELDS=$(jq -r '.[1:]' ./target/sum_vk_as_fields) + +FULL_PROOF_AS_FIELDS="$($BACKEND proof_as_fields -p ./target/sum_proof -k ./target/sum_key -o -)" +# sum has 3 public inputs +PUBLIC_INPUTS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[:3]') +PROOF_AS_FIELDS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[3:]') + +RECURSE_LEAF_PROVER_TOML=./recurse_leaf/Prover.toml +echo "num = 2" > $RECURSE_LEAF_PROVER_TOML +echo "key_hash = \"$VK_HASH\"" >> $RECURSE_LEAF_PROVER_TOML +echo "verification_key = $VK_AS_FIELDS" >> $RECURSE_LEAF_PROVER_TOML +echo "proof = $PROOF_AS_FIELDS" >> $RECURSE_LEAF_PROVER_TOML +echo "public_inputs = $PUBLIC_INPUTS" >> $RECURSE_LEAF_PROVER_TOML + +# We can now execute and prove `recurse_leaf` + +nargo execute recurse_leaf_witness --package recurse_leaf +$BACKEND prove -b ./target/recurse_leaf.json -w ./target/recurse_leaf_witness.gz -o ./target/recurse_leaf_proof + +# Let's do a sanity check that the proof we've generated so far is valid. +$BACKEND write_vk -b ./target/recurse_leaf.json -o ./target/recurse_leaf_key +$BACKEND verify -p ./target/recurse_leaf_proof -k ./target/recurse_leaf_key + +# Now we generate the final `recurse_node` proof similarly to how we did for `recurse_leaf`. + +$BACKEND vk_as_fields -k ./target/recurse_leaf_key -o ./target/recurse_leaf_vk_as_fields +VK_HASH=$(jq -r '.[0]' ./target/recurse_leaf_vk_as_fields) +VK_AS_FIELDS=$(jq -r '.[1:]' ./target/recurse_leaf_vk_as_fields) + +FULL_PROOF_AS_FIELDS="$($BACKEND proof_as_fields -p ./target/recurse_leaf_proof -k ./target/recurse_leaf_key -o -)" +# recurse_leaf has 4 public inputs (excluding aggregation object) +PUBLIC_INPUTS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[:4]') +PROOF_AS_FIELDS=$(echo $FULL_PROOF_AS_FIELDS | jq -r '.[4:]') + +RECURSE_NODE_PROVER_TOML=./recurse_node/Prover.toml +echo "key_hash = \"$VK_HASH\"" > $RECURSE_NODE_PROVER_TOML +echo "verification_key = $VK_AS_FIELDS" >> $RECURSE_NODE_PROVER_TOML +echo "proof = $PROOF_AS_FIELDS" >> $RECURSE_NODE_PROVER_TOML +echo "public_inputs = $PUBLIC_INPUTS" >> $RECURSE_NODE_PROVER_TOML + +# We can now execute and prove `recurse_node` + +nargo execute recurse_node_witness --package recurse_node +$BACKEND prove -b ./target/recurse_node.json -w ./target/recurse_node_witness.gz -o ./target/recurse_node_proof + +# We finally verify that the generated recursive proof is valid. +$BACKEND write_vk -b ./target/recurse_node.json -o ./target/recurse_node_key +$BACKEND verify -p ./target/recurse_node_proof -k ./target/recurse_node_key diff --git a/examples/recursion/recurse_leaf/Nargo.toml b/examples/recursion/recurse_leaf/Nargo.toml new file mode 100644 index 00000000000..7af9cd74940 --- /dev/null +++ b/examples/recursion/recurse_leaf/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "recurse_leaf" +type = "bin" +authors = [""] +compiler_version = ">=0.26.0" + +[dependencies] \ No newline at end of file diff --git a/examples/recursion/recurse_leaf/src/main.nr b/examples/recursion/recurse_leaf/src/main.nr new file mode 100644 index 00000000000..b6a2b49b219 --- /dev/null +++ b/examples/recursion/recurse_leaf/src/main.nr @@ -0,0 +1,20 @@ +use dep::std; + +#[recursive] +fn main( + verification_key: [Field; 114], + public_inputs: pub [Field; 3], + key_hash: Field, + proof: [Field; 93], + num: u64 +) -> pub u64 { + // verify sum so far was computed correctly + std::verify_proof( + verification_key.as_slice(), + proof.as_slice(), + public_inputs.as_slice(), + key_hash + ); + // Take output of previous proof and add another number to it. + public_inputs[2] as u64 + num +} \ No newline at end of file diff --git a/examples/recursion/recurse_node/Nargo.toml b/examples/recursion/recurse_node/Nargo.toml new file mode 100644 index 00000000000..db4b3b77693 --- /dev/null +++ b/examples/recursion/recurse_node/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "recurse_node" +type = "bin" +authors = [""] +compiler_version = ">=0.26.0" + +[dependencies] \ No newline at end of file diff --git a/examples/recursion/recurse_node/src/main.nr b/examples/recursion/recurse_node/src/main.nr new file mode 100644 index 00000000000..7c983dcf050 --- /dev/null +++ b/examples/recursion/recurse_node/src/main.nr @@ -0,0 +1,17 @@ +use dep::std; + +fn main( + verification_key: [Field; 114], + public_inputs: pub [Field; 4], + key_hash: Field, + proof: [Field; 109] +) -> pub u64 { + // verify sum was computed correctly + std::verify_proof( + verification_key.as_slice(), + proof.as_slice(), + public_inputs.as_slice(), + key_hash + ); + public_inputs[3] as u64 +} \ No newline at end of file diff --git a/examples/recursion/sum/Nargo.toml b/examples/recursion/sum/Nargo.toml new file mode 100644 index 00000000000..7a5f1498c3e --- /dev/null +++ b/examples/recursion/sum/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "sum" +type = "bin" +authors = [""] +compiler_version = ">=0.26.0" + +[dependencies] \ No newline at end of file diff --git a/examples/recursion/sum/Prover.toml b/examples/recursion/sum/Prover.toml new file mode 100644 index 00000000000..eae66cb8593 --- /dev/null +++ b/examples/recursion/sum/Prover.toml @@ -0,0 +1,2 @@ +a = 1 +b = 2 \ No newline at end of file diff --git a/examples/recursion/sum/src/main.nr b/examples/recursion/sum/src/main.nr new file mode 100644 index 00000000000..722d941d57d --- /dev/null +++ b/examples/recursion/sum/src/main.nr @@ -0,0 +1,4 @@ +#[recursive] +fn main(a: pub u64, b: pub u64) -> pub u64 { + a + b +} \ No newline at end of file diff --git a/examples/recursion/test.sh b/examples/recursion/test.sh new file mode 100755 index 00000000000..1e9eca35cab --- /dev/null +++ b/examples/recursion/test.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -eu + +# This file is used for Noir CI and is not required. + +BACKEND=${BACKEND:-bb} + +./generate_recursive_proof.sh \ No newline at end of file diff --git a/test_programs/benchmarks/bench_eddsa_poseidon/Nargo.toml b/test_programs/benchmarks/bench_eddsa_poseidon/Nargo.toml new file mode 100644 index 00000000000..bc2a779f7b2 --- /dev/null +++ b/test_programs/benchmarks/bench_eddsa_poseidon/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bench_eddsa_poseidon" +version = "0.1.0" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/benchmarks/bench_eddsa_poseidon/Prover.toml b/test_programs/benchmarks/bench_eddsa_poseidon/Prover.toml new file mode 100644 index 00000000000..8cfb63cd80e --- /dev/null +++ b/test_programs/benchmarks/bench_eddsa_poseidon/Prover.toml @@ -0,0 +1,6 @@ +msg = 789 +pub_key_x = "0x16b051f37589e0dcf4ad3c415c090798c10d3095bedeedabfcc709ad787f3507" +pub_key_y = "0x062800ac9e60839fab9218e5ed9d541f4586e41275f4071816a975895d349a5e" +r8_x = "0x163814666f04c4d2969059a6b63ee26a0f9f0f81bd5957b0796e2e8f4a8a2f06" +r8_y = "0x1255b17d9e4bfb81831625b788f8a1665128079ac4b6c8c3cd1b857666a05a54" +s = "1230930278088778318663840827871215383007447616379808164955640681455510074924" \ No newline at end of file diff --git a/test_programs/benchmarks/bench_eddsa_poseidon/src/main.nr b/test_programs/benchmarks/bench_eddsa_poseidon/src/main.nr new file mode 100644 index 00000000000..31c2f1f2d13 --- /dev/null +++ b/test_programs/benchmarks/bench_eddsa_poseidon/src/main.nr @@ -0,0 +1,12 @@ +use dep::std::eddsa::{eddsa_poseidon_verify}; + +fn main( + msg: pub Field, + pub_key_x: Field, + pub_key_y: Field, + r8_x: Field, + r8_y: Field, + s: Field +) -> pub bool { + eddsa_poseidon_verify(pub_key_x, pub_key_y, s, r8_x, r8_y, msg) +} \ No newline at end of file diff --git a/test_programs/benchmarks/bench_poseidon_hash/Nargo.toml b/test_programs/benchmarks/bench_poseidon_hash/Nargo.toml new file mode 100644 index 00000000000..9024d9a7301 --- /dev/null +++ b/test_programs/benchmarks/bench_poseidon_hash/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bench_poseidon_hash" +version = "0.1.0" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/benchmarks/bench_poseidon_hash/Prover.toml b/test_programs/benchmarks/bench_poseidon_hash/Prover.toml new file mode 100644 index 00000000000..66779dea9d7 --- /dev/null +++ b/test_programs/benchmarks/bench_poseidon_hash/Prover.toml @@ -0,0 +1 @@ +input = [1,2] diff --git a/test_programs/benchmarks/bench_poseidon_hash/src/main.nr b/test_programs/benchmarks/bench_poseidon_hash/src/main.nr new file mode 100644 index 00000000000..38adeef6ec7 --- /dev/null +++ b/test_programs/benchmarks/bench_poseidon_hash/src/main.nr @@ -0,0 +1,5 @@ +use dep::std::hash::poseidon; + +fn main(input: [Field; 2]) -> pub Field { + poseidon::bn254::hash_2(input) +} diff --git a/test_programs/benchmarks/bench_poseidon_hash_100/Nargo.toml b/test_programs/benchmarks/bench_poseidon_hash_100/Nargo.toml new file mode 100644 index 00000000000..b23716b2a20 --- /dev/null +++ b/test_programs/benchmarks/bench_poseidon_hash_100/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bench_poseidon_hash_100" +version = "0.1.0" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/benchmarks/bench_poseidon_hash_100/Prover.toml b/test_programs/benchmarks/bench_poseidon_hash_100/Prover.toml new file mode 100644 index 00000000000..542b4a08dd6 --- /dev/null +++ b/test_programs/benchmarks/bench_poseidon_hash_100/Prover.toml @@ -0,0 +1,102 @@ +input = [ + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], +] \ No newline at end of file diff --git a/test_programs/benchmarks/bench_poseidon_hash_100/src/main.nr b/test_programs/benchmarks/bench_poseidon_hash_100/src/main.nr new file mode 100644 index 00000000000..fc9a5b7a970 --- /dev/null +++ b/test_programs/benchmarks/bench_poseidon_hash_100/src/main.nr @@ -0,0 +1,12 @@ +use dep::std::hash; + +global SIZE = 100; + +fn main(input: [[Field; 2]; SIZE]) -> pub [Field; SIZE] { + let mut results: [Field; SIZE] = [0; SIZE]; + for i in 0..SIZE { + results[i] = hash::poseidon::bn254::hash_2(input[i]); + } + + results +} \ No newline at end of file diff --git a/test_programs/benchmarks/bench_poseidon_hash_30/Nargo.toml b/test_programs/benchmarks/bench_poseidon_hash_30/Nargo.toml new file mode 100644 index 00000000000..dbcbc07b1ba --- /dev/null +++ b/test_programs/benchmarks/bench_poseidon_hash_30/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bench_poseidon_hash_30" +version = "0.1.0" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/benchmarks/bench_poseidon_hash_30/Prover.toml b/test_programs/benchmarks/bench_poseidon_hash_30/Prover.toml new file mode 100644 index 00000000000..7792a9ab8e3 --- /dev/null +++ b/test_programs/benchmarks/bench_poseidon_hash_30/Prover.toml @@ -0,0 +1,32 @@ +input = [ + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], +] \ No newline at end of file diff --git a/test_programs/benchmarks/bench_poseidon_hash_30/src/main.nr b/test_programs/benchmarks/bench_poseidon_hash_30/src/main.nr new file mode 100644 index 00000000000..4d2d94e4946 --- /dev/null +++ b/test_programs/benchmarks/bench_poseidon_hash_30/src/main.nr @@ -0,0 +1,12 @@ +use dep::std::hash; + +global SIZE = 30; + +fn main(input: [[Field; 2]; SIZE]) -> pub [Field; SIZE] { + let mut results: [Field; SIZE] = [0; SIZE]; + for i in 0..SIZE { + results[i] = hash::poseidon::bn254::hash_2(input[i]); + } + + results +} \ No newline at end of file diff --git a/test_programs/benchmarks/bench_sha256/Nargo.toml b/test_programs/benchmarks/bench_sha256/Nargo.toml new file mode 100644 index 00000000000..488b94ca858 --- /dev/null +++ b/test_programs/benchmarks/bench_sha256/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bench_sha256" +version = "0.1.0" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/benchmarks/bench_sha256/Prover.toml b/test_programs/benchmarks/bench_sha256/Prover.toml new file mode 100644 index 00000000000..66779dea9d7 --- /dev/null +++ b/test_programs/benchmarks/bench_sha256/Prover.toml @@ -0,0 +1 @@ +input = [1,2] diff --git a/test_programs/benchmarks/bench_sha256/src/main.nr b/test_programs/benchmarks/bench_sha256/src/main.nr new file mode 100644 index 00000000000..fc873fb4afb --- /dev/null +++ b/test_programs/benchmarks/bench_sha256/src/main.nr @@ -0,0 +1,5 @@ +use dep::std; + +fn main(input: [u8; 2]) -> pub [u8; 32] { + std::hash::sha256(input) +} \ No newline at end of file diff --git a/test_programs/benchmarks/bench_sha256_100/Nargo.toml b/test_programs/benchmarks/bench_sha256_100/Nargo.toml new file mode 100644 index 00000000000..d0c90d75088 --- /dev/null +++ b/test_programs/benchmarks/bench_sha256_100/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bench_sha256_100" +version = "0.1.0" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/benchmarks/bench_sha256_100/Prover.toml b/test_programs/benchmarks/bench_sha256_100/Prover.toml new file mode 100644 index 00000000000..542b4a08dd6 --- /dev/null +++ b/test_programs/benchmarks/bench_sha256_100/Prover.toml @@ -0,0 +1,102 @@ +input = [ + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], +] \ No newline at end of file diff --git a/test_programs/benchmarks/bench_sha256_100/src/main.nr b/test_programs/benchmarks/bench_sha256_100/src/main.nr new file mode 100644 index 00000000000..d78ca8002d2 --- /dev/null +++ b/test_programs/benchmarks/bench_sha256_100/src/main.nr @@ -0,0 +1,12 @@ +use dep::std; + +global SIZE = 100; + +fn main(input: [[u8; 2]; SIZE]) -> pub [[u8; 32]; SIZE] { + let mut results: [[u8; 32]; SIZE] = [[0; 32]; SIZE]; + for i in 0..SIZE { + results[i] = std::hash::sha256(input[i]); + } + + results +} \ No newline at end of file diff --git a/test_programs/benchmarks/bench_sha256_30/Nargo.toml b/test_programs/benchmarks/bench_sha256_30/Nargo.toml new file mode 100644 index 00000000000..c1dc76df394 --- /dev/null +++ b/test_programs/benchmarks/bench_sha256_30/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "bench_sha256_30" +version = "0.1.0" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/benchmarks/bench_sha256_30/Prover.toml b/test_programs/benchmarks/bench_sha256_30/Prover.toml new file mode 100644 index 00000000000..7792a9ab8e3 --- /dev/null +++ b/test_programs/benchmarks/bench_sha256_30/Prover.toml @@ -0,0 +1,32 @@ +input = [ + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], + [1,2], +] \ No newline at end of file diff --git a/test_programs/benchmarks/bench_sha256_30/src/main.nr b/test_programs/benchmarks/bench_sha256_30/src/main.nr new file mode 100644 index 00000000000..fa66d626586 --- /dev/null +++ b/test_programs/benchmarks/bench_sha256_30/src/main.nr @@ -0,0 +1,12 @@ +use dep::std; + +global SIZE = 30; + +fn main(input: [[u8; 2]; SIZE]) -> pub [[u8; 32]; SIZE] { + let mut results: [[u8; 32]; SIZE] = [[0; 32]; SIZE]; + for i in 0..SIZE { + results[i] = std::hash::sha256(input[i]); + } + + results +} \ No newline at end of file diff --git a/test_programs/rebuild.sh b/test_programs/rebuild.sh index cfc6479febf..2d4147cb08c 100755 --- a/test_programs/rebuild.sh +++ b/test_programs/rebuild.sh @@ -55,6 +55,13 @@ for dir in $base_path/*; do dirs_to_process+=("$dir") done +for dir in $current_dir/benchmarks/*; do + if [[ ! -d $dir ]]; then + continue + fi + dirs_to_process+=("$dir") +done + # Process each directory in parallel pids=() if [ -z $NO_PARALLEL ]; then diff --git a/tooling/debugger/src/context.rs b/tooling/debugger/src/context.rs index 5d0916b4863..4436ce0ec3d 100644 --- a/tooling/debugger/src/context.rs +++ b/tooling/debugger/src/context.rs @@ -296,7 +296,7 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { self.handle_foreign_call(foreign_call) } Err(err) => DebugCommandResult::Error(NargoError::ExecutionError( - // TODO: debugger does not not handle multiple acir calls + // TODO: debugger does not handle multiple acir calls ExecutionError::SolvingError(err, None), )), } @@ -340,7 +340,7 @@ impl<'a, B: BlackBoxFunctionSolver> DebugContext<'a, B> { } } ACVMStatus::Failure(error) => DebugCommandResult::Error(NargoError::ExecutionError( - // TODO: debugger does not not handle multiple acir calls + // TODO: debugger does not handle multiple acir calls ExecutionError::SolvingError(error, None), )), ACVMStatus::RequiresForeignCall(_) => { diff --git a/tooling/nargo_cli/src/cli/compile_cmd.rs b/tooling/nargo_cli/src/cli/compile_cmd.rs index ecf2e2e9f53..bd76cf24805 100644 --- a/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -142,7 +142,7 @@ pub(super) fn compile_workspace_full( let circuit_dir = workspace.target_directory_path(); for (package, contract) in contract_packages.into_iter().zip(compiled_contracts) { let contract = nargo::ops::transform_contract(contract, compile_options.expression_width); - save_contract(contract, &package, &circuit_dir); + save_contract(contract, &package, &circuit_dir, compile_options.show_artifact_paths); } Ok(()) @@ -200,11 +200,19 @@ pub(super) fn save_program(program: CompiledProgram, package: &Package, circuit_ save_program_to_file(&program_artifact, &package.name, circuit_dir); } -fn save_contract(contract: CompiledContract, package: &Package, circuit_dir: &Path) { +fn save_contract( + contract: CompiledContract, + package: &Package, + circuit_dir: &Path, + show_artifact_paths: bool, +) { let contract_name = contract.name.clone(); - save_contract_to_file( + let artifact_path = save_contract_to_file( &contract.into(), &format!("{}-{}", package.name, contract_name), circuit_dir, ); + if show_artifact_paths { + println!("Saved contract artifact to: {}", artifact_path.display()); + } }