Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove ram tables in note_getter #7434

Merged
merged 2 commits into from
Jul 11, 2024
Merged

Conversation

nventuro
Copy link
Contributor

@nventuro nventuro commented Jul 10, 2024

With the work from #7050, we can now use the collapse function introduced in #7016 to make note_getter use rom tables instead of ram, resulting in smaller circuits (see #7016 for details re. why this is the case). Nothing changed in terms of functionality, except that we no longer require the oracle to produce fewer notes than the limit (assuming the filter removes some).

This does require however that most notes implement the Eq trait, which collapse requires in order to verify the hint. I don't imagine this would be an issue, since Eq implementations should be trivial, and automatically implemented once we have metaprogramming.

Copy link
Contributor

@sklppy88 sklppy88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@AztecBot
Copy link
Collaborator

AztecBot commented Jul 10, 2024

Benchmark results

Metrics with a significant change:

  • proof_construction_time_sha256_100_ms (16): 6,509 (+20%)
  • avm_simulation_time_ms (Token:mint_public): 376 (+497%)
  • avm_simulation_time_ms (Token:assert_minter_and_mint): 51.6 (-50%)
  • avm_simulation_time_ms (Token:_increase_public_balance): 83.7 (+461%)
  • protocol_circuit_witness_generation_time_in_ms (public-kernel-tail): 24,020 (+17%)
  • protocol_circuit_proving_time_in_ms (base-parity): 1,915 (+43%)
Detailed results

All benchmarks are run on txs on the Benchmarking contract on the repository. Each tx consists of a batch call to create_note and increment_balance, which guarantees that each tx has a private call, a nested private call, a public call, and a nested public call, as well as an emitted private note, an unencrypted log, and public storage read and write.

This benchmark source data is available in JSON format on S3 here.

Proof generation

Each column represents the number of threads used in proof generation.

Metric 1 threads 4 threads 16 threads 32 threads 64 threads
proof_construction_time_sha256_ms 5,713 (-1%) 1,541 (-1%) 702 (-1%) 765 (+1%) 766 (-2%)
proof_construction_time_sha256_30_ms 11,707 (-1%) 3,129 (-2%) 1,403 1,422 (-2%) 1,459 (-1%)
proof_construction_time_sha256_100_ms 43,692 (-1%) 11,720 (-1%) ⚠️ 6,509 (+20%) 5,383 (-1%) 5,346
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 58.0 88.0 (+1%)
proof_construction_time_poseidon_hash_30_ms 1,515 (-1%) 414 (-1%) 199 (-1%) 222 278 (+3%)
proof_construction_time_poseidon_hash_100_ms 5,605 (-1%) 1,511 (-1%) 695 (+3%) 713 (-2%) 742 (-1%)

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 4 txs 8 txs 16 txs
l1_rollup_calldata_size_in_bytes 708 708 708
l1_rollup_calldata_gas 6,588 6,590 6,588
l1_rollup_execution_gas 583,050 583,203 583,352
l2_block_processing_time_in_ms 762 1,420 2,699 (-1%)
l2_block_building_time_in_ms 13,175 25,869 (-1%) 50,902
l2_block_rollup_simulation_time_in_ms 13,175 25,869 (-1%) 50,902
l2_block_public_tx_process_time_in_ms 11,075 23,534 (-1%) 48,510

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 8 txs.

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 7,059 9,858
node_database_size_in_bytes 12,398,672 16,179,280
pxe_database_size_in_bytes 16,254 26,813

Circuits stats

Stats on running time and I/O sizes collected for every kernel circuit run across all benchmarks.

Circuit simulation_time_in_ms witness_generation_time_in_ms input_size_in_bytes output_size_in_bytes proving_time_in_ms proof_size_in_bytes num_public_inputs size_in_gates
private-kernel-init 115 414 (-1%) 21,737 54,085 N/A N/A N/A N/A
private-kernel-inner 245 742 (-1%) 81,199 54,264 N/A N/A N/A N/A
private-kernel-tail 1,116 2,618 (+3%) 61,808 61,554 N/A N/A N/A N/A
base-parity 6.57 839 (+2%) 160 96.0 ⚠️ 1,915 (+43%) 12,676 3.00 131,072
root-parity 108 (-1%) 107 (-4%) 64,860 96.0 44,292 12,676 3.00 4,194,304
base-rollup 4,214 5,039 180,315 632 44,471 13,476 28.0 4,194,304
root-rollup 154 (-1%) 107 (-3%) 51,261 652 37,497 13,412 26.0 4,194,304
public-kernel-setup 197 (+1%) 2,378 (+1%) 112,536 80,310 19,923 118,916 3,323 2,097,152
public-kernel-app-logic 150 3,314 (+2%) 112,536 80,310 8,787 (-2%) 118,916 3,323 1,048,576
public-kernel-tail 895 ⚠️ 24,020 (+17%) 409,413 10,046 66,076 24,868 384 8,388,608
private-kernel-reset-small 330 1,111 (-1%) 85,493 53,954 N/A N/A N/A N/A
private-kernel-tail-to-public 5,833 (+2%) 3,053 (-1%) 868,634 1,632 N/A N/A N/A N/A
public-kernel-teardown 139 3,333 (+1%) 112,536 80,310 20,355 (-1%) 118,916 3,323 2,097,152
merge-rollup 57.6 N/A 33,566 632 N/A N/A N/A N/A
undefined N/A N/A N/A N/A 163,816 (+2%) N/A N/A N/A

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms proof_size_in_bytes proving_time_in_ms
ContractClassRegisterer:register 1,312 9,344 397 (+1%) N/A N/A
ContractInstanceDeployer:deploy 1,376 9,344 25.4 N/A N/A
MultiCallEntrypoint:entrypoint 1,888 9,344 629 N/A N/A
GasToken:deploy 1,344 9,344 569 (-1%) N/A N/A
SchnorrAccount:constructor 1,280 9,344 435 N/A N/A
SchnorrAccount:entrypoint 2,272 9,344 766 (-1%) N/A N/A
Token:privately_mint_private_note 1,248 9,344 519 (-1%) N/A N/A
FPC:fee_entrypoint_public 1,312 9,344 106 N/A N/A
Token:transfer 1,280 9,344 1,484 (-7%) N/A N/A
AuthRegistry:set_authorized (avm) 19,222 N/A N/A 95,392 2,445 (+6%)
FPC:prepare_fee (avm) 26,664 N/A N/A 95,456 3,093 (+1%)
Token:transfer_public (avm) 42,914 N/A N/A 95,456 3,431 (+2%)
AuthRegistry:consume (avm) 33,100 N/A N/A 95,424 3,061 (+3%)
FPC:pay_refund (avm) 36,829 N/A N/A 95,424 10,192
Benchmarking:create_note 1,312 9,344 432 (+2%) N/A N/A
SchnorrAccount:verify_private_authwit 1,248 9,344 41.5 N/A N/A
Token:unshield 1,344 9,344 1,185 (-9%) N/A N/A
FPC:fee_entrypoint_private 1,344 9,344 1,548 (-7%) N/A N/A

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
GasToken:_increase_public_balance 98.0 (-2%) 13,790
GasToken:set_portal 13.0 (+7%) 3,339
Token:constructor 123 (+1%) 23,692
FPC:constructor 92.8 13,592
GasToken:mint_public 81.3 (-1%) 10,158
Token:mint_public ⚠️ 376 (+497%) 19,034
Token:assert_minter_and_mint ⚠️ 51.6 (-50%) 12,925
AuthRegistry:set_authorized 45.5 (+1%) 7,812
FPC:prepare_fee 124 (+11%) 15,062
Token:transfer_public 38.6 (+3%) 31,218
FPC:pay_refund 127 (-5%) 25,260
Benchmarking:increment_balance 1,338 (-1%) 15,267
Token:_increase_public_balance ⚠️ 83.7 (+461%) 15,006
FPC:pay_refund_with_shielded_rebate 181 (+1%) 26,347

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.152 (-1%)

Tree insertion stats

The duration to insert a fixed batch of leaves into each tree type.

Metric 1 leaves 16 leaves 64 leaves 128 leaves 256 leaves 512 leaves 1024 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.4 16.9 (+1%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.7 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.601 0.520 (+1%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 48.4 75.4 (-1%) 131 (-1%) 244 (-1%) 469 (-1%)
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 287 543 1,055
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.494 0.464 (-1%) 0.449 (-1%) 0.443 (-1%) 0.439 (-1%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 59.8 111 (-1%) 183 (-1%) 351 (-1%) 693
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 109 207 355 691 1,363
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.505 0.499 0.484 0.476 (-1%) 0.475 (-1%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 72.8 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A 133 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A 0.518 N/A N/A N/A N/A

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes 1 registered classes
tx_size_in_bytes 76,837 667,838

Transaction size based on fee payment method

| Metric | |
| - | |

Copy link
Contributor

@benesjan benesjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nice, very smart, much brain

@nventuro I plan on doing changes to the notes today so I enabled auto-merge to avoid unnecessary conflicts.

@benesjan benesjan enabled auto-merge (squash) July 11, 2024 07:55
@benesjan benesjan merged commit fd67da3 into master Jul 11, 2024
89 checks passed
@benesjan benesjan deleted the nv/note-getter-collapse branch July 11, 2024 08:23
rahul-kothari pushed a commit that referenced this pull request Jul 11, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.46.3</summary>

##
[0.46.3](aztec-package-v0.46.2...aztec-package-v0.46.3)
(2024-07-11)


### Miscellaneous

* **aztec-package:** Synchronize aztec-packages versions
</details>

<details><summary>barretenberg.js: 0.46.3</summary>

##
[0.46.3](barretenberg.js-v0.46.2...barretenberg.js-v0.46.3)
(2024-07-11)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

<details><summary>aztec-packages: 0.46.3</summary>

##
[0.46.3](aztec-packages-v0.46.2...aztec-packages-v0.46.3)
(2024-07-11)


### Features

* Add CLI argument for debugging comptime blocks
(noir-lang/noir#5192)
([97ecff5](97ecff5))
* Add reset tiny and optimize tail
([#7422](#7422))
([399917b](399917b))
* **avm:** Calldatacopy and return gadget
([#7415](#7415))
([ec39e4e](ec39e4e)),
closes
[#7381](#7381)
[#7211](#7211)
* **avm:** Make ProverPolynomials::get_row return references
([#7419](#7419))
([108fc5f](108fc5f))
* Integrate new proving systems in e2e
([#6971](#6971))
([723a0c1](723a0c1))
* Lsp rename/find-all-references for struct members
(noir-lang/noir#5443)
([97ecff5](97ecff5))
* MSM sorting
([#7351](#7351))
([5cbdc54](5cbdc54))
* **optimization:** Deduplicate more instructions
(noir-lang/noir#5457)
([97ecff5](97ecff5))
* Prefix operator overload trait dispatch
(noir-lang/noir#5423)
([97ecff5](97ecff5))
* Remove proof from L1 Rollup process
([#7347](#7347))
([2645eab](2645eab)),
closes
[#7346](#7346)
* Remove ram tables in note_getter
([#7434](#7434))
([fd67da3](fd67da3))
* Sync from aztec-packages (noir-lang/noir#5467)
([97ecff5](97ecff5))
* Typing return values of embedded_curve_ops
([#7413](#7413))
([db96077](db96077))


### Bug Fixes

* **avm:** Fixes AVM full tests and decrease timeout to 35 minutes
([#7438](#7438))
([2a7494b](2a7494b))
* Memory init with no other ops gate counting
([#7427](#7427))
([e7177ba](e7177ba))
* Pass secrets to ci-arm.yml
([#7436](#7436))
([619501d](619501d))
* Remove compile-time error for invalid indices
(noir-lang/noir#5466)
([97ecff5](97ecff5))
* Using different generators in private refund
([#7414](#7414))
([59b92ca](59b92ca)),
closes
[#7320](#7320)


### Miscellaneous

* **bb:** Fix double increment
([#7428](#7428))
([7870a58](7870a58))
* **boxes:** Adding an init command for an empty project
([#7398](#7398))
([a6a605d](a6a605d))
* Bump bb to 0.45.1 (noir-lang/noir#5469)
([97ecff5](97ecff5))
* Disable flaky cheat code test
([7b8c2ba](7b8c2ba))
* Document EmbeddedCurvePoint
(noir-lang/noir#5468)
([97ecff5](97ecff5))
* Minimize usage of get_row in inverse computation
([#7431](#7431))
([f177887](f177887))
* Private refund cleanup
([#7403](#7403))
([ebec8ff](ebec8ff))
* Replace relative paths to noir-protocol-circuits
([842f6d1](842f6d1))
* Unbundle `check_array_is_initialized`
(noir-lang/noir#5451)
([97ecff5](97ecff5))
</details>

<details><summary>barretenberg: 0.46.3</summary>

##
[0.46.3](barretenberg-v0.46.2...barretenberg-v0.46.3)
(2024-07-11)


### Features

* **avm:** Calldatacopy and return gadget
([#7415](#7415))
([ec39e4e](ec39e4e)),
closes
[#7381](#7381)
[#7211](#7211)
* **avm:** Make ProverPolynomials::get_row return references
([#7419](#7419))
([108fc5f](108fc5f))
* Integrate new proving systems in e2e
([#6971](#6971))
([723a0c1](723a0c1))
* MSM sorting
([#7351](#7351))
([5cbdc54](5cbdc54))


### Bug Fixes

* **avm:** Fixes AVM full tests and decrease timeout to 35 minutes
([#7438](#7438))
([2a7494b](2a7494b))
* Memory init with no other ops gate counting
([#7427](#7427))
([e7177ba](e7177ba))


### Miscellaneous

* **bb:** Fix double increment
([#7428](#7428))
([7870a58](7870a58))
* Minimize usage of get_row in inverse computation
([#7431](#7431))
([f177887](f177887))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
AztecBot added a commit to AztecProtocol/barretenberg that referenced this pull request Jul 12, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-package: 0.46.3</summary>

##
[0.46.3](AztecProtocol/aztec-packages@aztec-package-v0.46.2...aztec-package-v0.46.3)
(2024-07-11)


### Miscellaneous

* **aztec-package:** Synchronize aztec-packages versions
</details>

<details><summary>barretenberg.js: 0.46.3</summary>

##
[0.46.3](AztecProtocol/aztec-packages@barretenberg.js-v0.46.2...barretenberg.js-v0.46.3)
(2024-07-11)


### Miscellaneous

* **barretenberg.js:** Synchronize aztec-packages versions
</details>

<details><summary>aztec-packages: 0.46.3</summary>

##
[0.46.3](AztecProtocol/aztec-packages@aztec-packages-v0.46.2...aztec-packages-v0.46.3)
(2024-07-11)


### Features

* Add CLI argument for debugging comptime blocks
(noir-lang/noir#5192)
([97ecff5](AztecProtocol/aztec-packages@97ecff5))
* Add reset tiny and optimize tail
([#7422](AztecProtocol/aztec-packages#7422))
([399917b](AztecProtocol/aztec-packages@399917b))
* **avm:** Calldatacopy and return gadget
([#7415](AztecProtocol/aztec-packages#7415))
([ec39e4e](AztecProtocol/aztec-packages@ec39e4e)),
closes
[#7381](AztecProtocol/aztec-packages#7381)
[#7211](AztecProtocol/aztec-packages#7211)
* **avm:** Make ProverPolynomials::get_row return references
([#7419](AztecProtocol/aztec-packages#7419))
([108fc5f](AztecProtocol/aztec-packages@108fc5f))
* Integrate new proving systems in e2e
([#6971](AztecProtocol/aztec-packages#6971))
([723a0c1](AztecProtocol/aztec-packages@723a0c1))
* Lsp rename/find-all-references for struct members
(noir-lang/noir#5443)
([97ecff5](AztecProtocol/aztec-packages@97ecff5))
* MSM sorting
([#7351](AztecProtocol/aztec-packages#7351))
([5cbdc54](AztecProtocol/aztec-packages@5cbdc54))
* **optimization:** Deduplicate more instructions
(noir-lang/noir#5457)
([97ecff5](AztecProtocol/aztec-packages@97ecff5))
* Prefix operator overload trait dispatch
(noir-lang/noir#5423)
([97ecff5](AztecProtocol/aztec-packages@97ecff5))
* Remove proof from L1 Rollup process
([#7347](AztecProtocol/aztec-packages#7347))
([2645eab](AztecProtocol/aztec-packages@2645eab)),
closes
[#7346](AztecProtocol/aztec-packages#7346)
* Remove ram tables in note_getter
([#7434](AztecProtocol/aztec-packages#7434))
([fd67da3](AztecProtocol/aztec-packages@fd67da3))
* Sync from aztec-packages (noir-lang/noir#5467)
([97ecff5](AztecProtocol/aztec-packages@97ecff5))
* Typing return values of embedded_curve_ops
([#7413](AztecProtocol/aztec-packages#7413))
([db96077](AztecProtocol/aztec-packages@db96077))


### Bug Fixes

* **avm:** Fixes AVM full tests and decrease timeout to 35 minutes
([#7438](AztecProtocol/aztec-packages#7438))
([2a7494b](AztecProtocol/aztec-packages@2a7494b))
* Memory init with no other ops gate counting
([#7427](AztecProtocol/aztec-packages#7427))
([e7177ba](AztecProtocol/aztec-packages@e7177ba))
* Pass secrets to ci-arm.yml
([#7436](AztecProtocol/aztec-packages#7436))
([619501d](AztecProtocol/aztec-packages@619501d))
* Remove compile-time error for invalid indices
(noir-lang/noir#5466)
([97ecff5](AztecProtocol/aztec-packages@97ecff5))
* Using different generators in private refund
([#7414](AztecProtocol/aztec-packages#7414))
([59b92ca](AztecProtocol/aztec-packages@59b92ca)),
closes
[#7320](AztecProtocol/aztec-packages#7320)


### Miscellaneous

* **bb:** Fix double increment
([#7428](AztecProtocol/aztec-packages#7428))
([7870a58](AztecProtocol/aztec-packages@7870a58))
* **boxes:** Adding an init command for an empty project
([#7398](AztecProtocol/aztec-packages#7398))
([a6a605d](AztecProtocol/aztec-packages@a6a605d))
* Bump bb to 0.45.1 (noir-lang/noir#5469)
([97ecff5](AztecProtocol/aztec-packages@97ecff5))
* Disable flaky cheat code test
([7b8c2ba](AztecProtocol/aztec-packages@7b8c2ba))
* Document EmbeddedCurvePoint
(noir-lang/noir#5468)
([97ecff5](AztecProtocol/aztec-packages@97ecff5))
* Minimize usage of get_row in inverse computation
([#7431](AztecProtocol/aztec-packages#7431))
([f177887](AztecProtocol/aztec-packages@f177887))
* Private refund cleanup
([#7403](AztecProtocol/aztec-packages#7403))
([ebec8ff](AztecProtocol/aztec-packages@ebec8ff))
* Replace relative paths to noir-protocol-circuits
([842f6d1](AztecProtocol/aztec-packages@842f6d1))
* Unbundle `check_array_is_initialized`
(noir-lang/noir#5451)
([97ecff5](AztecProtocol/aztec-packages@97ecff5))
</details>

<details><summary>barretenberg: 0.46.3</summary>

##
[0.46.3](AztecProtocol/aztec-packages@barretenberg-v0.46.2...barretenberg-v0.46.3)
(2024-07-11)


### Features

* **avm:** Calldatacopy and return gadget
([#7415](AztecProtocol/aztec-packages#7415))
([ec39e4e](AztecProtocol/aztec-packages@ec39e4e)),
closes
[#7381](AztecProtocol/aztec-packages#7381)
[#7211](AztecProtocol/aztec-packages#7211)
* **avm:** Make ProverPolynomials::get_row return references
([#7419](AztecProtocol/aztec-packages#7419))
([108fc5f](AztecProtocol/aztec-packages@108fc5f))
* Integrate new proving systems in e2e
([#6971](AztecProtocol/aztec-packages#6971))
([723a0c1](AztecProtocol/aztec-packages@723a0c1))
* MSM sorting
([#7351](AztecProtocol/aztec-packages#7351))
([5cbdc54](AztecProtocol/aztec-packages@5cbdc54))


### Bug Fixes

* **avm:** Fixes AVM full tests and decrease timeout to 35 minutes
([#7438](AztecProtocol/aztec-packages#7438))
([2a7494b](AztecProtocol/aztec-packages@2a7494b))
* Memory init with no other ops gate counting
([#7427](AztecProtocol/aztec-packages#7427))
([e7177ba](AztecProtocol/aztec-packages@e7177ba))


### Miscellaneous

* **bb:** Fix double increment
([#7428](AztecProtocol/aztec-packages#7428))
([7870a58](AztecProtocol/aztec-packages@7870a58))
* Minimize usage of get_row in inverse computation
([#7431](AztecProtocol/aztec-packages#7431))
([f177887](AztecProtocol/aztec-packages@f177887))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants