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): poseidon2 gadget #6504

Merged
merged 1 commit into from
May 29, 2024
Merged

Conversation

IlyasRidhuan
Copy link
Contributor

Please read contributing guidelines and remove this line.

Copy link
Contributor Author

IlyasRidhuan commented May 17, 2024

@AztecBot
Copy link
Collaborator

AztecBot commented May 17, 2024

Benchmark results

Metrics with a significant change:

  • protocol_circuit_witness_generation_time_in_ms (root-parity): 58.6 (-41%)
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,709 1,544 692 (-2%) 759 (+4%) 772
proof_construction_time_sha256_30_ms 11,732 (+3%) 3,143 (+2%) 1,411 (+3%) 1,439 (+2%) 1,465 (+2%)
proof_construction_time_sha256_100_ms 43,906 11,737 5,447 (+1%) 5,817 (-4%) 5,366
proof_construction_time_poseidon_hash_ms 236 79.0 58.0 93.0 (+4%) 149 (+1%)
proof_construction_time_poseidon_hash_30_ms 5,750 1,576 (+1%) 730 (+2%) 785 (+3%) 797 (+1%)
proof_construction_time_poseidon_hash_100_ms 11,394 3,062 1,375 (+1%) 1,422 (+1%) 1,441

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,440 9,476 9,452
l1_rollup_execution_gas 616,081 616,117 616,093
l2_block_processing_time_in_ms 1,303 (+2%) 4,840 (+1%) 9,631 (+1%)
l2_block_building_time_in_ms 45,620 180,383 360,881 (-1%)
l2_block_rollup_simulation_time_in_ms 45,442 179,732 359,597 (-1%)
l2_block_public_tx_process_time_in_ms 24,556 102,276 209,537

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,519 (+1%) 14,449
node_database_size_in_bytes 14,495,824 21,340,240
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 135 (-1%) 487 14,035 (-2%) 20,630 64,614 89,536 2,731 524,288
private-kernel-inner 404 950 (+4%) 47,302 (+1%) 92,318 64,614 89,536 2,731 2,097,152
private-kernel-tail 579 (-1%) 2,721 (+4%) 45,587 (+1%) 96,541 77,732 11,648 297 2,097,152
base-parity 6.54 (+2%) 1,250 (+10%) 2,749 (-1%) 128 64.0 2,208 2.00 131,072
root-parity 49.2 (+1%) ⚠️ 58.6 (-41%) 51,956 (+2%) 27,084 64.0 2,720 18.0 2,097,152
base-rollup 730 2,420 88,145 (+4%) 119,734 756 3,648 47.0 4,194,304
root-rollup 109 75.1 (-5%) 23,541 (+3%) 25,297 620 3,456 41.0 1,048,576
public-kernel-app-logic 531 (-1%) 3,216 (+4%) 51,842 (+1%) 105,253 86,550 116,768 3,582 2,097,152
public-kernel-tail 1,111 (-1%) 25,413 (+7%) 180,387 (+2%) 401,002 7,646 11,648 297 8,388,608
private-kernel-reset-small 584 (-1%) 2,092 49,899 (+1%) 120,733 64,614 89,536 2,731 2,097,152
merge-rollup 28.7 N/A N/A 16,534 756 N/A N/A N/A
public-kernel-setup 636 (-1%) N/A N/A 105,253 86,550 N/A N/A N/A
public-kernel-teardown 553 (+1%) N/A N/A 105,253 86,550 N/A N/A N/A
private-kernel-tail-to-public N/A 8,280 (-2%) 106,925 (+1%) 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 470 (+2%) N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 41.1 (-1%) N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,682 (+1%) N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,428 N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,595 16,768 53,795 (+1%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,556 (+1%) N/A N/A N/A N/A
Token:transfer 1,376 9,944 4,922 (+1%) 16,768 57,796 (+1%) 2,097,152 457
Benchmarking:create_note 1,344 9,944 1,394 (-1%) N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 226 N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 77.0 N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,721 N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,576 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.4 17.0 (+1%) 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.605 0.519 (+1%) 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.5 (+1%) 76.8 (+1%) 249 (+1%) 475 931 1,861 (+1%) 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.496 0.473 (+1%) 0.451 0.443 0.441 0.443 (+1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.2 (+1%) 113 360 (+2%) 699 1,392 2,788 (+1%) 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 0.506 0.487 (+2%) 0.480 0.481 0.483 (+1%) 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.555

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-16-feat_avm_poseidon2_gadget branch from 4935971 to 8a98e76 Compare May 19, 2024 16:55
@IlyasRidhuan IlyasRidhuan force-pushed the 05-14-feat_avm_sha256_compression branch from 4e10cfd to 56a59d1 Compare May 22, 2024 11:51
@IlyasRidhuan IlyasRidhuan force-pushed the 05-16-feat_avm_poseidon2_gadget branch from 8a98e76 to bef8263 Compare May 22, 2024 13:23
@IlyasRidhuan IlyasRidhuan force-pushed the 05-16-feat_avm_poseidon2_gadget branch from bef8263 to c1806ec Compare May 22, 2024 13:39
@IlyasRidhuan IlyasRidhuan marked this pull request as ready for review May 22, 2024 16:02
@IlyasRidhuan IlyasRidhuan force-pushed the 05-14-feat_avm_sha256_compression branch from 56a59d1 to 7be5bda Compare May 22, 2024 16:21
@IlyasRidhuan IlyasRidhuan force-pushed the 05-16-feat_avm_poseidon2_gadget branch from c1806ec to b79a9b7 Compare May 22, 2024 16:22
Copy link
Contributor

Changes to circuit sizes

Generated at commit: 97a91782d39ce5d50eaef78f284432a8bfef8547, compared to commit: 56a59d196ab887d66784204aa4ac85aceaef6205

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_reset_big +15,596 ❌ +9.00% +131,418 ❌ +8.49%
private_kernel_reset_medium +6,684 ❌ +4.51% +56,322 ❌ +4.70%
private_kernel_reset_small +3,342 ❌ +2.49% +28,187 ❌ +2.78%
rollup_base +9,914 ❌ +5.47% +29,611 ❌ +1.67%
private_kernel_tail -2 ✅ -0.00% -4 ✅ -0.00%
private_kernel_tail_to_public -4 ✅ -0.00% -8 ✅ -0.00%
public_kernel_teardown -160 ✅ -0.07% -300 ✅ -0.04%
public_kernel_setup -160 ✅ -0.07% -300 ✅ -0.04%
public_kernel_app_logic -200 ✅ -0.08% -360 ✅ -0.05%
private_kernel_tail_to_public_simulated 0 ➖ 0.00% -4 ✅ -0.11%
public_kernel_app_logic_simulated 0 ➖ 0.00% -4 ✅ -0.11%
public_kernel_setup_simulated 0 ➖ 0.00% -4 ✅ -0.11%
public_kernel_teardown_simulated 0 ➖ 0.00% -4 ✅ -0.11%
public_kernel_tail -2,126 ✅ -0.21% -4,928 ✅ -0.13%
private_kernel_tail_simulated 0 ➖ 0.00% -2 ✅ -0.75%
public_kernel_tail_simulated 0 ➖ 0.00% -2 ✅ -0.75%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_reset_big 188,976 (+15,596) +9.00% 1,678,516 (+131,418) +8.49%
private_kernel_reset_medium 154,744 (+6,684) +4.51% 1,253,708 (+56,322) +4.70%
private_kernel_reset_small 137,627 (+3,342) +2.49% 1,041,303 (+28,187) +2.78%
rollup_base 191,041 (+9,914) +5.47% 1,806,511 (+29,611) +1.67%
private_kernel_tail 195,031 (-2) -0.00% 1,316,885 (-4) -0.00%
private_kernel_tail_to_public 621,552 (-4) -0.00% 2,147,286 (-8) -0.00%
public_kernel_teardown 223,363 (-160) -0.07% 667,581 (-300) -0.04%
public_kernel_setup 223,157 (-160) -0.07% 667,288 (-300) -0.04%
public_kernel_app_logic 251,697 (-200) -0.08% 796,596 (-360) -0.05%
private_kernel_tail_to_public_simulated 1 (0) 0.00% 3,584 (-4) -0.11%
public_kernel_app_logic_simulated 1 (0) 0.00% 3,584 (-4) -0.11%
public_kernel_setup_simulated 1 (0) 0.00% 3,584 (-4) -0.11%
public_kernel_teardown_simulated 1 (0) 0.00% 3,584 (-4) -0.11%
public_kernel_tail 1,027,305 (-2,126) -0.21% 3,704,913 (-4,928) -0.13%
private_kernel_tail_simulated 1 (0) 0.00% 265 (-2) -0.75%
public_kernel_tail_simulated 1 (0) 0.00% 265 (-2) -0.75%

@IlyasRidhuan IlyasRidhuan force-pushed the 05-14-feat_avm_sha256_compression branch 2 times, most recently from dc2aac0 to 59d97c1 Compare May 28, 2024 08:53
@IlyasRidhuan IlyasRidhuan force-pushed the 05-16-feat_avm_poseidon2_gadget branch from b79a9b7 to 15f4013 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-14-feat_avm_sha256_compression branch from 59d97c1 to 2fcf252 Compare May 29, 2024 14:10
Base automatically changed from 05-14-feat_avm_sha256_compression to master May 29, 2024 14:54
@IlyasRidhuan IlyasRidhuan force-pushed the 05-16-feat_avm_poseidon2_gadget branch from 15f4013 to bdabf50 Compare May 29, 2024 15:10
@IlyasRidhuan IlyasRidhuan merged commit 9e8cba1 into master May 29, 2024
87 of 89 checks passed
@IlyasRidhuan IlyasRidhuan deleted the 05-16-feat_avm_poseidon2_gadget branch May 29, 2024 16:25
TomAFrench added a commit that referenced this pull request May 29, 2024
* master:
  chore: add linting to avm-transpiler CI (#6732)
  feat(avm): poseidon2 gadget (#6504)
  chore(ci): try a different ubuntu runner (#6740)
  feat(nargo): hidden option to show contract artifact paths written by `nargo compile` (#6131)
  feat(avm): sha256_compression (#6452)
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