Skip to content

Commit

Permalink
Merge pull request #9 from Savio-Sou/main
Browse files Browse the repository at this point in the history
Upgrade to support Noir >=v0.19.0
  • Loading branch information
ax0 authored Jan 4, 2024
2 parents ee20882 + 31ff5b0 commit 4f7aba6
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 83 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Noir
proofs/
target/
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,45 @@ To run the integration tests, you can execute against various projects in `tests
- `nargo execute --package depth_8_storage_proof`
- `nargo execute --package one_level`
- `nargo execute --package rlp_decode`

## Benchmarks

### depth_8_storage_proof

As of Noir v0.21.0 paired with the default proving backend, circuit size of the depth_8_storage_proof test program is:

```
+-----------------------+------------------------+--------------+----------------------+
| Package | Language | ACIR Opcodes | Backend Circuit Size |
+-----------------------+------------------------+--------------+----------------------+
| depth_8_storage_proof | PLONKCSat { width: 3 } | 51563 | 1687738 |
+-----------------------+------------------------+--------------+----------------------+
```

#### CLI

On M2 Macbook Air, using Nargo v0.21.0 paired with the default proving backend:

Compiling takes approximately 2 seconds:

```
% time nargo compile --package depth_8_storage_proof
nargo compile --package depth_8_storage_proof 1.84s user 0.07s system 99% cpu 1.925 total
```

Executing for witness takes approximately 1 second:

```
% time nargo execute --package depth_8_storage_proof
[depth_8_storage_proof] Circuit witness successfully solved
nargo execute --package depth_8_storage_proof 1.40s user 0.05s system 140% cpu 1.028 total
```

Executing + proving (as `nargo prove` always re-executes for witness) takes approximately 1.5 mins:

```
% time nargo prove --package depth_8_storage_proof
nargo prove --package depth_8_storage_proof 408.52s user 18.15s system 548% cpu 1:17.81 total
```

NOTE: Running `nargo prove` the first time / before `nargo compile` would automatically include program compilation. Subsequent runs without program modifications would make use of the cached artifacts and provide more representative benchmarking results.
2 changes: 1 addition & 1 deletion lib/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
name = "noir_trie_proofs"
type = "lib"
authors = [""]
compiler_version = "0.10.0"
compiler_version = ">=0.19.0"

[dependencies]
2 changes: 1 addition & 1 deletion lib/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ pub fn compact_decode<MAX_ENC_LEN, NIB_LEN>(input: [u8; MAX_ENC_LEN], length: Fi
/// * `key` - Array containing the nibbles to be resolved
/// * `key_ptr` - Pointer to the nibbles in `key` to be resolved
/// * `node` - RLP-encoded byte array of branch or extension node
fn resolve_nibble32<N>(
pub fn resolve_nibble32<N>(
key: [u4; NIBBLE_LENGTH],
mut key_ptr: Field,
node: [u8; N]) ->
Expand Down
146 changes: 75 additions & 71 deletions lib/src/rlp.nr

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/depth_8_state_proof/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "depth_8_state_proof"
type = "bin"
authors = [""]
compiler_version = "0.10.0"
compiler_version = ">=0.19.0"

[dependencies]
trie = { path = "../../lib" }
5 changes: 4 additions & 1 deletion tests/depth_8_state_proof/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use dep::std::hash::keccak256;

global DEPTH8_MAX: Field = 4256;

fn main(state_root: pub [u8; 32], state_proof: trie::TrieProof<20, DEPTH8_MAX, trie::MAX_ACCOUNT_STATE_LENGTH>) {
fn main(
state_root: pub [u8; 32],
state_proof: trie::TrieProof<20, DEPTH8_MAX, trie::MAX_ACCOUNT_STATE_LENGTH>
) {
assert(state_proof.verify_state_root(state_root));
}
2 changes: 1 addition & 1 deletion tests/depth_8_storage_proof/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "depth_8_storage_proof"
type = "bin"
authors = [""]
compiler_version = "0.10.0"
compiler_version = ">=0.19.0"

[dependencies]
trie = { path = "../../lib" }
2 changes: 1 addition & 1 deletion tests/depth_8_storage_proof/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ use dep::trie;
global DEPTH8_MAX: Field = 4256;

fn main(storage_root: pub [u8; 32], storage_proof: trie::StorageProof<DEPTH8_MAX>) {
assert(storage_proof.verify_storage_root(storage_root));
assert(storage_proof.verify_storage_root(storage_root));
}
2 changes: 1 addition & 1 deletion tests/one_level/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "one_level"
type = "bin"
authors = [""]
compiler_version = "0.10.0"
compiler_version = ">=0.19.0"

[dependencies]
trie = { path = "../../lib" }
3 changes: 1 addition & 2 deletions tests/one_level/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use dep::trie;

fn main(node: [u8; trie::MAX_TRIE_NODE_LENGTH], key: [u8; trie::KEY_LENGTH], key_offset: Field)
{
fn main(node: [u8; trie::MAX_TRIE_NODE_LENGTH], key: [u8; trie::KEY_LENGTH], key_offset: Field) {
let _lookup: ([u8; trie::KEY_LENGTH], Field) = trie::resolve_nibble32(trie::key_as_nibbles(key), key_offset, node);
}
2 changes: 1 addition & 1 deletion tests/rlp_decode/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "rlp_decode"
type = "bin"
authors = [""]
compiler_version = "0.10.0"
compiler_version = ">=0.19.0"

[dependencies]
trie = { path = "../../lib" }
3 changes: 1 addition & 2 deletions tests/rlp_decode/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use dep::trie;
use dep::trie::rlp;

fn main(input: [u8; 532])
{
fn main(input: [u8; 532]) {
let rlp_list: rlp::RLP_List<trie::MAX_NUM_FIELDS> = rlp::decode1_small_lis(input);
assert(rlp_list.num_fields == 17);
}

0 comments on commit 4f7aba6

Please sign in to comment.