AztecProtocol / aztec-packages

Apache License 2.0
155 stars 157 forks source link

feat: WIP - balanced outbox tree #7287

Open MirandaWood opened 3 days ago

MirandaWood commented 3 days ago

Quick POC for removing out hash from the circuits. Instead we:

The rollup circuits no longer need to deal with the out hash and we can remove it from the content commitment. EDIT: Gas cost increase - unsure if acceptable. Note that we could use regular sha (not shaToField) here, which would bring down the costs as well.

Sol Test Gas Before Gas After Change
Decode Blocks 2,715,860 2,912,727 +196,867
C. Empty Blocks 2,325,504 2,337,322 +11,818
C. Mixed Blocks 6,986,350 7,223,404 +237,054
Empty Block 1,191,048 1,207,958 +16,910
Mixed Block 3,385,143 3,503,670 +118,527
github-actions[bot] commented 3 days ago

Changes to circuit sizes

Generated at commit: cdc85f6e3081b83c69bb458b2c284387a4287475, compared to commit: b12c6cb54ec6b39baed6e6bb06ecf4ace3eeede5

๐Ÿงพ Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_reset +106,707 โŒ +78.98% +847,413 โŒ +49.94%
private_kernel_init_simulated 0 โž– 0.00% +576 โŒ +25.81%
private_kernel_inner_simulated 0 โž– 0.00% +576 โŒ +25.81%
private_kernel_reset_simulated 0 โž– 0.00% +576 โŒ +25.81%
private_kernel_reset_simulated_big 0 โž– 0.00% +576 โŒ +25.81%
private_kernel_reset_simulated_medium 0 โž– 0.00% +576 โŒ +25.81%
private_kernel_reset_simulated_small 0 โž– 0.00% +576 โŒ +25.81%
public_kernel_tail +246,491 โŒ +25.38% +1,020,150 โŒ +23.15%
public_kernel_setup +97,600 โŒ +53.23% +336,012 โŒ +22.91%
public_kernel_app_logic +97,840 โŒ +40.32% +362,976 โŒ +21.82%
public_kernel_teardown +97,840 โŒ +40.28% +362,975 โŒ +21.82%
private_kernel_tail_to_public_simulated 0 โž– 0.00% +576 โŒ +17.65%
public_kernel_app_logic_simulated 0 โž– 0.00% +576 โŒ +17.65%
public_kernel_setup_simulated 0 โž– 0.00% +576 โŒ +17.65%
public_kernel_teardown_simulated 0 โž– 0.00% +576 โŒ +17.65%
private_kernel_reset_small +61,184 โŒ +87.34% +155,730 โŒ +17.01%
private_kernel_reset_medium +61,184 โŒ +71.27% +155,730 โŒ +13.83%
private_kernel_inner +9,376 โŒ +21.24% +132,822 โŒ +11.45%
private_kernel_reset_big +61,184 โŒ +52.10% +155,730 โŒ +10.07%
private_kernel_tail +192 โŒ +0.90% +92,017 โŒ +7.40%
private_kernel_tail_to_public +960 โŒ +0.22% +93,504 โŒ +5.58%
private_kernel_init +5,440 โŒ +21.55% +16,839 โŒ +4.50%
rollup_root -114 โœ… -5.26% -6,906 โœ… -0.76%
rollup_merge -113 โœ… -8.44% -6,905 โœ… -1.15%
rollup_base -1,695 โœ… -0.50% -49,411 โœ… -1.61%

Full diff report ๐Ÿ‘‡
| Program | ACIR opcodes (+/-) | % | Circuit size (+/-) | % | |:-|-:|-:|-:|-:| | **private_kernel_reset** | 241,816 (+106,707) | **+78.98%** | 2,544,408 (+847,413) | **+49.94%** | | **private_kernel_init_simulated** | 1 (0) | **0.00%** | 2,808 (+576) | **+25.81%** | | **private_kernel_inner_simulated** | 1 (0) | **0.00%** | 2,808 (+576) | **+25.81%** | | **private_kernel_reset_simulated** | 1 (0) | **0.00%** | 2,808 (+576) | **+25.81%** | | **private_kernel_reset_simulated_big** | 1 (0) | **0.00%** | 2,808 (+576) | **+25.81%** | | **private_kernel_reset_simulated_medium** | 1 (0) | **0.00%** | 2,808 (+576) | **+25.81%** | | **private_kernel_reset_simulated_small** | 1 (0) | **0.00%** | 2,808 (+576) | **+25.81%** | | **public_kernel_tail** | 1,217,548 (+246,491) | **+25.38%** | 5,427,671 (+1,020,150) | **+23.15%** | | **public_kernel_setup** | 280,955 (+97,600) | **+53.23%** | 1,802,693 (+336,012) | **+22.91%** | | **public_kernel_app_logic** | 340,521 (+97,840) | **+40.32%** | 2,026,181 (+362,976) | **+21.82%** | | **public_kernel_teardown** | 340,719 (+97,840) | **+40.28%** | 2,026,420 (+362,975) | **+21.82%** | | **private_kernel_tail_to_public_simulated** | 1 (0) | **0.00%** | 3,839 (+576) | **+17.65%** | | **public_kernel_app_logic_simulated** | 1 (0) | **0.00%** | 3,839 (+576) | **+17.65%** | | **public_kernel_setup_simulated** | 1 (0) | **0.00%** | 3,839 (+576) | **+17.65%** | | **public_kernel_teardown_simulated** | 1 (0) | **0.00%** | 3,839 (+576) | **+17.65%** | | **private_kernel_reset_small** | 131,240 (+61,184) | **+87.34%** | 1,071,366 (+155,730) | **+17.01%** | | **private_kernel_reset_medium** | 147,037 (+61,184) | **+71.27%** | 1,281,801 (+155,730) | **+13.83%** | | **private_kernel_inner** | 53,510 (+9,376) | **+21.24%** | 1,292,648 (+132,822) | **+11.45%** | | **private_kernel_reset_big** | 178,629 (+61,184) | **+52.10%** | 1,702,669 (+155,730) | **+10.07%** | | **private_kernel_tail** | 21,436 (+192) | **+0.90%** | 1,335,543 (+92,017) | **+7.40%** | | **private_kernel_tail_to_public** | 445,438 (+960) | **+0.22%** | 1,770,506 (+93,504) | **+5.58%** | | **private_kernel_init** | 30,687 (+5,440) | **+21.55%** | 390,775 (+16,839) | **+4.50%** | | **rollup_root** | 2,054 (-114) | **-5.26%** | 904,280 (-6,906) | **-0.76%** | | **rollup_merge** | 1,226 (-113) | **-8.44%** | 595,162 (-6,905) | **-1.15%** | | **rollup_base** | 337,533 (-1,695) | **-0.50%** | 3,014,739 (-49,411) | **-1.61%** |
AztecBot commented 3 days ago

Benchmark results

Metrics with a significant change:

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](https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/benchmarks-v1/pulls/7287.json). ### 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_30_ms | 11,704 (-2%) | 3,130 (-1%) | :warning: 1,683 (**+19%**) | 1,527 (+7%) | 1,561 (+6%) | proof_construction_time_sha256_100_ms | 43,594 | 11,714 (-1%) | 5,419 (-1%) | 5,413 | 5,339 (-1%) | proof_construction_time_poseidon_hash_ms | 79.0 | 34.0 | 34.0 | 57.0 (-2%) | 88.0 (-1%) | proof_construction_time_poseidon_hash_30_ms | 1,515 | 419 (+1%) | 200 | 229 (+2%) | 269 (-1%) | proof_construction_time_poseidon_hash_100_ms | 5,732 | 1,557 (-1%) | 722 (-1%) | 780 (+1%) | 798 (+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 | 1,412 | 1,412 | 1,412 | l1_rollup_calldata_gas | 9,056 (-4%) | 9,094 (-4%) | 9,080 (-4%) | l1_rollup_execution_gas | 613,314 | 613,469 | 613,572 | l2_block_processing_time_in_ms | 749 (-1%) | 1,421 | 2,700 | l2_block_building_time_in_ms | :warning: 24,767 (**+19%**) | :warning: 51,490 (**+24%**) | :warning: 97,110 (**+19%**) | l2_block_rollup_simulation_time_in_ms | :warning: 24,767 (**+19%**) | :warning: 51,489 (**+24%**) | :warning: 97,109 (**+19%**) | l2_block_public_tx_process_time_in_ms | :warning: 21,283 (**+19%**) | :warning: 47,685 (**+24%**) | :warning: 93,479 (**+19%**) | ### 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,113 (+1%) | 9,964 | node_database_size_in_bytes | 12,263,504 | 16,142,416 | 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 | 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 | 118 (+16%) | :warning: 471 (**+19%**) | 13,240 (+5%) | 20,634 (+6%) | :warning: 67,190 (**+24%**) | :warning: 92,352 (**+25%**) | :warning: 2,819 (**+26%**) | 524,288 | private-kernel-inner | :warning: 363 (**+18%**) | :warning: 926 (**+18%**) | 49,971 (+1%) | :warning: 94,902 (**+18%**) | :warning: 67,190 (**+24%**) | :warning: 92,352 (**+25%**) | :warning: 2,819 (**+26%**) | 2,097,152 | private-kernel-tail | 1,137 (+6%) | 2,588 (+2%) | 51,549 (+11%) | :warning: 74,513 (**+21%**) | :warning: 71,733 (**+16%**) | 14,912 | 399 | 2,097,152 | base-parity | 6.32 (+4%) | 1,797 (+15%) | 2,750 (+5%) | 128 | 64.0 | 2,208 | 2.00 | 131,072 | root-parity | 49.4 | 78.3 (+21%) | 40,415 (-1%) | 27,100 | 64.0 | 2,720 | 18.0 | 2,097,152 | base-rollup | :warning: 7,937 (**+21%**) | 4,920 (+2%) | 90,764 (+1%) | 170,330 | 728 | 3,648 | 47.0 | 4,194,304 | root-rollup | 108 (-1%) | 89.6 (+14%) | 24,233 (+5%) | 25,253 | 620 | 3,456 | 41.0 | 1,048,576 | public-kernel-setup | :warning: 641 (**+20%**) | :warning: 3,834 (**+60%**) | 45,071 (+7%) | 116,905 (+14%) | :warning: 93,334 (**+16%**) | :warning: 125,344 (**+17%**) | :warning: 3,850 (**+18%**) | 2,097,152 | public-kernel-app-logic | :warning: 591 (**+19%**) | :warning: 4,788 (**+44%**) | 46,914 (+9%) | 116,905 (+14%) | :warning: 93,334 (**+16%**) | :warning: 125,344 (**+17%**) | :warning: 3,850 (**+18%**) | 2,097,152 | public-kernel-tail | :warning: 1,452 (**+27%**) | :warning: 39,584 (**+45%**) | 195,272 (+7%) | :warning: 511,910 (**+28%**) | 10,014 | 14,912 | 399 | 8,388,608 | private-kernel-reset-small | :warning: 560 (**+21%**) | :warning: 2,098 (**+94%**) | :warning: 46,966 (**+76%**) | 123,313 (+13%) | :warning: 67,190 (**+24%**) | :warning: 92,352 (**+25%**) | :warning: 2,819 (**+26%**) | :warning: 2,097,152 (**+100%**) | public-kernel-teardown | 579 (+15%) | :warning: 4,866 (**+46%**) | 48,724 (+10%) | 116,905 (+14%) | :warning: 93,334 (**+16%**) | :warning: 125,344 (**+17%**) | :warning: 3,850 (**+18%**) | 2,097,152 | merge-rollup | 28.0 (-4%) | N/A | N/A | 16,486 | 728 | N/A | N/A | N/A | private-kernel-tail-to-public | N/A | 8,661 (+5%) | 52,632 (+6%) | N/A | N/A | :warning: 125,344 (**+17%**) | :warning: 3,850 (**+18%**) | 2,097,152 | 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 (+13%) | 413 (+2%) | N/A | N/A | N/A | N/A | ContractInstanceDeployer:deploy | 1,408 | 9,944 (+13%) | 39.8 (+4%) | N/A | N/A | N/A | N/A | MultiCallEntrypoint:entrypoint | 1,920 | 9,944 (+13%) | 1,304 (+10%) | N/A | N/A | N/A | N/A | GasToken:deploy | 1,376 | 9,944 (+13%) | 965 (+8%) | N/A | N/A | N/A | N/A | SchnorrAccount:constructor | 1,312 | 9,944 (+13%) | 491 (+1%) | N/A | N/A | N/A | N/A | SchnorrAccount:entrypoint | 2,304 | 9,944 (+13%) | :warning: 1,880 (**+16%**) | 16,768 (+14%) | 54,483 (+1%) | 2,097,152 | :warning: 457 (**+16%**) | Token:privately_mint_private_note | 1,280 | 9,944 (+13%) | 657 (+5%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_public | 1,344 | 9,944 (+13%) | 306 (+13%) | 16,768 (+14%) | 11,797 (+3%) | 524,288 | :warning: 457 (**+16%**) | Token:transfer | 1,312 | 9,944 (+13%) | :warning: 2,907 (**+64%**) | 16,768 (+14%) | :warning: 23,695 (**+95%**) | :warning: 1,048,576 (**+100%**) | :warning: 457 (**+16%**) | AuthRegistry:set_authorized (avm) | 20,954 (+9%) | N/A | N/A | 94,336 (+3%) | 1,358 (+10%) | N/A | N/A | FPC:prepare_fee (avm) | 28,396 (+6%) | N/A | N/A | 94,400 (+3%) | 3,192 (+12%) | N/A | N/A | Token:transfer_public (avm) | 44,612 (+4%) | N/A | N/A | 94,400 (+3%) | 4,144 (+7%) | N/A | N/A | AuthRegistry:consume (avm) | 34,832 (+5%) | N/A | N/A | 94,336 (+3%) | 3,034 (+6%) | N/A | N/A | FPC:pay_refund (avm) | 38,561 (+5%) | N/A | N/A | 94,368 (+3%) | 23,506 (+3%) | N/A | N/A | Benchmarking:create_note | 1,344 | 9,944 (+13%) | 484 (+1%) | N/A | N/A | N/A | N/A | SchnorrAccount:verify_private_authwit | 1,280 | 9,944 (+13%) | 72.7 (+2%) | N/A | N/A | N/A | N/A | Token:unshield | 1,376 | 9,944 (+13%) | :warning: 2,711 (**+78%**) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_private | 1,376 | 9,944 (+13%) | :warning: 3,486 (**+65%**) | N/A | N/A | 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 | 67.3 (+1%) | 13,790 | GasToken:set_portal | 15.9 (-4%) | 3,305 (-1%) | Token:constructor | 97.6 (-2%) | 23,658 | FPC:constructor | 60.8 | 13,592 | GasToken:mint_public | 52.2 (+1%) | 10,158 | Token:mint_public | :warning: 598 (**+858%**) | 19,000 | Token:assert_minter_and_mint | :warning: 79.4 (**-54%**) | 12,891 | AuthRegistry:set_authorized | 32.2 (+1%) | 7,812 | FPC:prepare_fee | 131 (+15%) | 15,062 | Token:transfer_public | :warning: 29.4 (**-41%**) | 31,184 | FPC:pay_refund | 154 (+19%) | 25,260 | Benchmarking:increment_balance | :warning: 2,693 (**+23%**) | 15,233 | Token:_increase_public_balance | 57.7 (+5%) | 14,972 | FPC:pay_refund_with_shielded_rebate | 133 (+10%) | 26,347 | ### Public DB Access Time to access various public DBs. | Function | time_ms | | - | - | get-nullifier-index | 0.159 (+2%) | ### 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 (+1%) | 16.8 | 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 (+1%) | 0.515 | N/A | N/A | N/A | N/A | N/A | batch_insert_into_append_only_tree_32_depth_ms | N/A | N/A | 48.3 (+1%) | 76.4 (+1%) | 132 (+1%) | 246 (+1%) | 472 | 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.493 (+1%) | 0.469 (+1%) | 0.452 (+1%) | 0.445 (+1%) | 0.440 | batch_insert_into_indexed_tree_20_depth_ms | N/A | N/A | 59.8 (+1%) | 113 (+1%) | 182 (-1%) | 355 (+1%) | 695 (+1%) | 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.504 (+1%) | 0.504 (+1%) | 0.483 | 0.480 (+1%) | 0.477 | batch_insert_into_indexed_tree_40_depth_ms | N/A | N/A | 73.1 (+1%) | 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.520 (+1%) | 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 | :warning: 85,707 (**+16%**) | 670,983 | Transaction size based on fee payment method | Metric | | | - | |