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(avm): avm keccak permutation #6596

Merged
merged 1 commit into from
May 30, 2024

Conversation

IlyasRidhuan
Copy link
Contributor

Please read contributing guidelines and remove this line.

Copy link
Contributor Author

IlyasRidhuan commented May 22, 2024

@IlyasRidhuan IlyasRidhuan force-pushed the 05-16-feat_avm_poseidon2_gadget branch from bef8263 to c1806ec Compare May 22, 2024 13:39
Copy link
Contributor

Changes to circuit sizes

Generated at commit: a721034770781c7507376f2b6fb646ebbfe4d71d, compared to commit: 4935971da700f4e5340a2218cdbfa72c59c3e78c

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail_to_public_simulated 0 ➖ 0.00% +93 ❌ +2.66%
public_kernel_app_logic_simulated 0 ➖ 0.00% +93 ❌ +2.66%
public_kernel_setup_simulated 0 ➖ 0.00% +93 ❌ +2.66%
public_kernel_teardown_simulated 0 ➖ 0.00% +93 ❌ +2.66%
rollup_base_simulated 0 ➖ 0.00% +1 ❌ +2.17%
private_kernel_reset +7,558 ❌ +3.02% +41,874 ❌ +1.68%
private_kernel_init_simulated 0 ➖ 0.00% +40 ❌ +1.54%
private_kernel_inner_simulated 0 ➖ 0.00% +40 ❌ +1.54%
private_kernel_reset_simulated 0 ➖ 0.00% +40 ❌ +1.54%
private_kernel_tail_to_public +9,967 ❌ +1.63% +27,686 ❌ +1.31%
private_kernel_inner +3,143 ❌ +1.21% +21,918 ❌ +1.30%
private_kernel_init +2,695 ❌ +1.20% +8,589 ❌ +1.04%
public_kernel_setup +3,258 ❌ +1.48% +6,580 ❌ +1.00%
public_kernel_teardown +3,250 ❌ +1.48% +6,572 ❌ +0.99%
public_kernel_app_logic +4,250 ❌ +1.72% +7,592 ❌ +0.96%
private_kernel_tail +621 ❌ +0.32% +7,628 ❌ +0.58%
private_kernel_tail_simulated 0 ➖ 0.00% +1 ❌ +0.38%
public_kernel_tail_simulated 0 ➖ 0.00% +1 ❌ +0.38%
rollup_base +100 ❌ +0.06% +4,412 ❌ +0.25%
rollup_root +2 ❌ +0.14% +314 ❌ +0.11%
public_kernel_tail +239 ❌ +0.02% +240 ❌ +0.01%
rollup_merge +2 ❌ +0.66% 0 ➖ 0.00%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail_to_public_simulated 1 (0) 0.00% 3,588 (+93) +2.66%
public_kernel_app_logic_simulated 1 (0) 0.00% 3,588 (+93) +2.66%
public_kernel_setup_simulated 1 (0) 0.00% 3,588 (+93) +2.66%
public_kernel_teardown_simulated 1 (0) 0.00% 3,588 (+93) +2.66%
rollup_base_simulated 1 (0) 0.00% 47 (+1) +2.17%
private_kernel_reset 257,443 (+7,558) +3.02% 2,528,135 (+41,874) +1.68%
private_kernel_init_simulated 1 (0) 0.00% 2,643 (+40) +1.54%
private_kernel_inner_simulated 1 (0) 0.00% 2,643 (+40) +1.54%
private_kernel_reset_simulated 1 (0) 0.00% 2,643 (+40) +1.54%
private_kernel_tail_to_public 621,556 (+9,967) +1.63% 2,147,294 (+27,686) +1.31%
private_kernel_inner 262,668 (+3,143) +1.21% 1,712,375 (+21,918) +1.30%
private_kernel_init 228,119 (+2,695) +1.20% 835,753 (+8,589) +1.04%
public_kernel_setup 223,317 (+3,258) +1.48% 667,588 (+6,580) +1.00%
public_kernel_teardown 223,523 (+3,250) +1.48% 667,881 (+6,572) +0.99%
public_kernel_app_logic 251,897 (+4,250) +1.72% 796,956 (+7,592) +0.96%
private_kernel_tail 195,033 (+621) +0.32% 1,316,889 (+7,628) +0.58%
private_kernel_tail_simulated 1 (0) 0.00% 267 (+1) +0.38%
public_kernel_tail_simulated 1 (0) 0.00% 267 (+1) +0.38%
rollup_base 181,127 (+100) +0.06% 1,776,900 (+4,412) +0.25%
rollup_root 1,407 (+2) +0.14% 296,070 (+314) +0.11%
public_kernel_tail 1,029,431 (+239) +0.02% 3,709,841 (+240) +0.01%
rollup_merge 304 (+2) +0.66% 45,980 (0) 0.00%

@AztecBot
Copy link
Collaborator

AztecBot commented May 22, 2024

Benchmark results

No metrics with a significant change found.

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,731 1,548 707 (+1%) 748 (-2%) 767 (-2%)
proof_construction_time_sha256_30_ms 11,840 3,135 (-2%) 1,406 (-2%) 1,427 (-2%) 1,459 (-1%)
proof_construction_time_sha256_100_ms 44,914 (+2%) 12,055 (+2%) 5,681 (+2%) 5,608 (+2%) 5,474
proof_construction_time_poseidon_hash_ms 79.0 (+1%) 34.0 34.0 58.0 88.0
proof_construction_time_poseidon_hash_30_ms 1,520 418 202 226 266 (-4%)
proof_construction_time_poseidon_hash_100_ms 5,752 1,564 725 778 795

L2 block published to L1

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

Metric 8 txs 32 txs 64 txs
l1_rollup_calldata_size_in_bytes 1,412 1,412 1,412
l1_rollup_calldata_gas 9,452 9,452 9,464
l1_rollup_execution_gas 616,093 616,093 616,105
l2_block_processing_time_in_ms 1,284 4,804 9,558
l2_block_building_time_in_ms 46,829 (+2%) 182,894 365,939
l2_block_rollup_simulation_time_in_ms 46,647 (+2%) 182,223 364,605
l2_block_public_tx_process_time_in_ms 24,919 (+1%) 104,960 (+1%) 212,523 (+1%)

L2 chain processing

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

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 9,428 14,325 (-1%)
node_database_size_in_bytes 14,475,344 21,356,624
pxe_database_size_in_bytes 18,071 29,868

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 proving_time_in_ms input_size_in_bytes output_size_in_bytes proof_size_in_bytes num_public_inputs size_in_gates
private-kernel-init 134 (+1%) 496 (-1%) 12,236 (-9%) 20,634 64,614 89,536 2,731 524,288
private-kernel-inner 409 1,022 (+2%) 37,867 (-12%) 92,326 64,614 89,536 2,731 2,097,152
private-kernel-tail 589 2,975 (+6%) 38,624 (+7%) 96,545 77,732 11,648 297 2,097,152
base-parity 6.54 (-4%) 1,297 (+10%) 2,894 (-1%) 128 64.0 2,208 2.00 131,072
root-parity 50.9 (+1%) 48.7 (-6%) 44,347 27,100 64.0 2,720 18.0 2,097,152
base-rollup 747 (-2%) 2,318 (+1%) 74,787 119,738 756 3,648 47.0 4,194,304
root-rollup 112 (-1%) 64.6 (+1%) 19,668 (+1%) 25,309 620 3,456 41.0 1,048,576
public-kernel-app-logic 548 3,573 48,727 106,345 86,550 116,768 3,582 2,097,152
public-kernel-tail 1,123 21,645 (-8%) 154,492 (-1%) 401,006 7,646 11,648 297 8,388,608
private-kernel-reset-small 594 (+1%) 2,051 (-5%) 45,705 (+1%) 120,737 64,614 89,536 2,731 2,097,152
merge-rollup 29.6 (+3%) N/A N/A 16,542 756 N/A N/A N/A
public-kernel-setup 654 (-2%) N/A N/A 106,345 86,550 N/A N/A N/A
public-kernel-teardown 561 (-2%) N/A N/A 106,345 86,550 N/A N/A N/A
private-kernel-tail-to-public N/A 8,553 (-1%) 96,061 (+4%) N/A N/A 116,768 3,582 4,194,304

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 size_in_gates num_public_inputs
ContractClassRegisterer:register 1,344 9,944 468 N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 42.3 N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,745 (-1%) N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,471 N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,649 16,768 49,475 (+1%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,644 N/A N/A N/A N/A
Token:transfer 1,376 9,944 5,036 (-1%) 16,768 47,413 (-12%) 2,097,152 457
Benchmarking:create_note 1,344 9,944 1,392 (-1%) N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 239 N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 77.3 (-8%) N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,777 (-1%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,655 (-1%) N/A N/A N/A N/A

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 512 leaves 1024 leaves 2048 leaves 4096 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.5 (+1%) 17.0 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.7 31.8 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.611 (+1%) 0.520 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 48.6 75.9 248 (+1%) 474 927 1,846 N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 543 1,055 2,079 4,127 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.497 0.468 0.450 (+1%) 0.443 0.440 0.440 N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.2 (-1%) 113 (+1%) 355 696 1,382 2,765 N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 106 208 692 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.504 (-1%) 0.505 (+1%) 0.481 0.478 0.479 0.479 N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A N/A 62.7
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A N/A 107
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A N/A 0.556

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 84,050 665,267

Transaction size based on fee payment method

| Metric | |
| - | |

@IlyasRidhuan IlyasRidhuan force-pushed the 05-17-feat_avm_avm_keccak_permutation branch from 1cc6b93 to 7ba1cc9 Compare May 22, 2024 15:58
@IlyasRidhuan IlyasRidhuan marked this pull request as ready for review May 22, 2024 16:02
@IlyasRidhuan IlyasRidhuan force-pushed the 05-16-feat_avm_poseidon2_gadget branch from c1806ec to b79a9b7 Compare May 22, 2024 16:22
@IlyasRidhuan IlyasRidhuan force-pushed the 05-17-feat_avm_avm_keccak_permutation branch from 7ba1cc9 to 5445448 Compare May 22, 2024 16:22
@IlyasRidhuan IlyasRidhuan force-pushed the 05-16-feat_avm_poseidon2_gadget branch from b79a9b7 to 15f4013 Compare May 28, 2024 08:54
@IlyasRidhuan IlyasRidhuan force-pushed the 05-17-feat_avm_avm_keccak_permutation branch from 5445448 to 1d469dd Compare May 28, 2024 08:54
Copy link
Contributor

@jeanmon jeanmon left a comment

Choose a reason for hiding this comment

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

LGTM! See comments.

@IlyasRidhuan IlyasRidhuan force-pushed the 05-16-feat_avm_poseidon2_gadget branch from 15f4013 to bdabf50 Compare May 29, 2024 15:10
Base automatically changed from 05-16-feat_avm_poseidon2_gadget to master May 29, 2024 16:25
@IlyasRidhuan IlyasRidhuan force-pushed the 05-17-feat_avm_avm_keccak_permutation branch 2 times, most recently from 0633e92 to 442b868 Compare May 29, 2024 16:44
@IlyasRidhuan IlyasRidhuan force-pushed the 05-17-feat_avm_avm_keccak_permutation branch from 442b868 to dafcfbf Compare May 30, 2024 08:35
@IlyasRidhuan IlyasRidhuan merged commit c0917e4 into master May 30, 2024
90 of 122 checks passed
@IlyasRidhuan IlyasRidhuan deleted the 05-17-feat_avm_avm_keccak_permutation branch May 30, 2024 09:27
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.

3 participants