AztecProtocol / aztec-packages

Apache License 2.0
184 stars 184 forks source link

refactor: ARGS_HASH constants 64 -> 16 #7284

Closed LHerskind closed 3 months ago

LHerskind commented 3 months ago

Fixes #7272.

Reduces the number of elements that make its way into the argshash. If you really wanna bloat the number of inputs, go visit capsules, we don't really want to pay for the option all the time when most simple will not use it. Reducing both the args hash constants to 16 instead of 64, allowing 256 instead of 4096 elements as inputs, should suffice most cases still.


Tests passed in CI earlier, but I updated a big stack that seemed to kill it as it could not run 4 branches in CI for me at the same time :)

LHerskind commented 3 months ago

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @LHerskind and the rest of your teammates on Graphite Graphite

AztecBot commented 3 months 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/7284.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_ms | 5,717 | 1,548 | 706 | 767 (+1%) | 774 (-1%) | proof_construction_time_sha256_30_ms | 11,774 | 3,162 | 1,418 | 1,429 | 1,462 | proof_construction_time_sha256_100_ms | 43,912 | 11,799 | 5,452 | 5,393 (-1%) | 5,383 | proof_construction_time_poseidon_hash_ms | 78.0 | 34.0 | 34.0 | 59.0 | 87.0 (-2%) | proof_construction_time_poseidon_hash_30_ms | 1,515 | 415 | 200 | 230 (+2%) | 267 (+1%) | proof_construction_time_poseidon_hash_100_ms | 5,739 | 1,558 (-1%) | 728 | 773 (-2%) | 793 | ### 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,464 | 9,460 | 9,452 | l1_rollup_execution_gas | 611,203 | 611,350 | 611,493 | l2_block_processing_time_in_ms | 765 | 1,423 | 2,735 (+1%) | l2_block_building_time_in_ms | 20,799 (-1%) | 41,553 | 81,223 (-1%) | l2_block_rollup_simulation_time_in_ms | 20,799 (-1%) | 41,553 | 81,223 (-1%) | l2_block_public_tx_process_time_in_ms | 17,786 (-1%) | 38,351 | 78,068 (-1%) | ### 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,049 (+1%) | 9,876 | node_database_size_in_bytes | 12,259,408 | 16,109,648 | 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 | 103 | 390 (+3%) | 13,011 (+7%) | 19,482 | 54,134 | 73,920 | 2,243 | 524,288 | private-kernel-inner | 307 | 770 (+1%) | 50,861 (+1%) | 80,694 | 54,134 | 73,920 | 2,243 | 2,097,152 | private-kernel-tail | 1,078 (-1%) | 2,543 (+1%) | 49,477 (-2%) | 61,457 | 62,057 | 14,912 | 399 | 2,097,152 | base-parity | 6.16 (-1%) | 1,513 (-2%) | 2,635 (+1%) | 128 | 64.0 | 2,208 | 2.00 | 131,072 | root-parity | 48.9 (+1%) | 72.1 (+13%) | 40,416 (-3%) | 27,100 | 64.0 | 2,720 | 18.0 | 2,097,152 | base-rollup | 6,534 (-1%) | 4,811 (-2%) | 90,637 (+1%) | 170,330 | 728 | 3,648 | 47.0 | 4,194,304 | root-rollup | 110 | 81.5 (+2%) | 21,789 (-10%) | 25,253 | 620 | 3,456 | 41.0 | 1,048,576 | public-kernel-setup | 537 | 2,386 (+1%) | 42,800 (-2%) | 102,121 | 80,278 | 106,912 | 3,274 | 2,097,152 | public-kernel-app-logic | 500 | 3,304 (-1%) | 44,923 (+6%) | 102,121 | 80,278 | 106,912 | 3,274 | 2,097,152 | public-kernel-tail | 1,143 | 25,167 (-5%) | 177,529 (+1%) | 399,014 | 10,014 | 14,912 | 399 | 8,388,608 | private-kernel-reset-small | 466 | 1,092 (-1%) | 30,213 | 109,233 | 54,134 | 73,920 | 2,243 | 1,048,576 | public-kernel-teardown | 487 (-8%) | 3,283 | 44,435 | 102,121 | 80,278 | 106,912 | 3,274 | 2,097,152 | merge-rollup | 29.5 (+1%) | N/A | N/A | 16,486 | 728 | N/A | N/A | N/A | private-kernel-tail-to-public | N/A | 8,677 (-1%) | 52,385 | N/A | N/A | 106,912 | 3,274 | 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 | 8,792 | 396 (-1%) | N/A | N/A | N/A | N/A | ContractInstanceDeployer:deploy | 1,408 | 8,792 | :warning: 24.2 (**-37%**) | N/A | N/A | N/A | N/A | MultiCallEntrypoint:entrypoint | 1,920 | 8,792 | 1,159 (-2%) | N/A | N/A | N/A | N/A | GasToken:deploy | 1,376 | 8,792 | 815 (-7%) | N/A | N/A | N/A | N/A | SchnorrAccount:constructor | 1,312 | 8,792 | 476 (-3%) | N/A | N/A | N/A | N/A | SchnorrAccount:entrypoint | 2,304 | 8,792 | 1,599 (-1%) | 14,720 | 54,775 (+2%) | 2,097,152 | 393 | Token:privately_mint_private_note | 1,280 | 8,792 | 610 (-1%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_public | 1,344 | 8,792 | 231 (-14%) | 14,720 | 11,714 (-1%) | 524,288 | 393 | Token:transfer | 1,312 | 8,792 | 1,777 (+1%) | 14,720 | 13,213 (-1%) | 524,288 | 393 | AuthRegistry:set_authorized (avm) | 19,226 | N/A | N/A | 91,264 | 1,334 (+7%) | N/A | N/A | FPC:prepare_fee (avm) | 26,668 | N/A | N/A | 91,328 | 2,902 (+7%) | N/A | N/A | Token:transfer_public (avm) | 42,918 | N/A | N/A | 91,328 | 3,765 (-2%) | N/A | N/A | AuthRegistry:consume (avm) | 33,104 | N/A | N/A | 91,264 | 2,764 (+2%) | N/A | N/A | FPC:pay_refund (avm) | 36,833 | N/A | N/A | 91,296 | 23,152 | N/A | N/A | Benchmarking:create_note | 1,344 | 8,792 | 465 (-3%) | N/A | N/A | N/A | N/A | SchnorrAccount:verify_private_authwit | 1,280 | 8,792 | :warning: 40.4 (**-49%**) | N/A | N/A | N/A | N/A | Token:unshield | 1,376 | 8,792 | 1,449 (-6%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_private | 1,376 | 8,792 | 1,975 (-7%) | 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 | 64.5 (-4%) | 13,790 | GasToken:set_portal | 13.9 (-21%) | 3,339 | Token:constructor | 93.6 (+3%) | 23,692 | FPC:constructor | 60.7 (-4%) | 13,592 | GasToken:mint_public | 49.9 (-1%) | 10,158 | Token:mint_public | 62.7 (-8%) | 19,034 | Token:assert_minter_and_mint | 174 (-5%) | 12,925 | AuthRegistry:set_authorized | 29.8 (-5%) | 7,812 | FPC:prepare_fee | 106 (-2%) | 15,062 | Token:transfer_public | 49.0 (+19%) | 31,218 | FPC:pay_refund | 131 (-11%) | 25,260 | Benchmarking:increment_balance | 2,183 (-1%) | 15,267 | Token:_increase_public_balance | 53.6 (-4%) | 15,006 | FPC:pay_refund_with_shielded_rebate | 113 (-3%) | 26,347 | ### Public DB Access Time to access various public DBs. | Function | time_ms | | - | - | get-nullifier-index | 0.165 (+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.8 (+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.600 | 0.516 (+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.2 (+1%) | 76.0 | 132 | 245 | 474 | 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.492 (+1%) | 0.467 | 0.452 | 0.445 (+1%) | 0.442 | batch_insert_into_indexed_tree_20_depth_ms | N/A | N/A | 59.6 (+1%) | 112 | 184 | 355 (+1%) | 698 | 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.503 (+1%) | 0.502 | 0.485 | 0.480 (+1%) | 0.478 | batch_insert_into_indexed_tree_40_depth_ms | N/A | N/A | 73.0 (+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.519 (+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 | 74,057 | 667,850 | Transaction size based on fee payment method | Metric | | | - | |