AztecProtocol / aztec-packages

Apache License 2.0
181 stars 184 forks source link

feat: Shplonk revival in ECCVM #7164

Closed maramihali closed 3 months ago

maramihali commented 3 months ago

Refactor Shplonk to have better encapsulated functionality on proving side and integrate it in ECCVM. Until now, we performed two IPA rounds in ECCVM, the second one necessary to ensure the consistency of transcript polynomials. We introduce Shplonk to batch the two opening claims and perform one round of IPA which reduces the number of constraints by ~5 million constraints in the ClientIVCRecursiveVerifier. The branch also includes small refactorings in ECCVM prover and verifier.

Before: 17956264
After: 12495384

(number of gates produced by running the prove_tube flow in branch and master)

AztecBot commented 3 months ago

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](https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/benchmarks-v1/pulls/7164.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,726 (-1%) | 3,161 (-3%) | 1,499 (-13%) | 1,443 (-8%) | 1,462 (-1%) | proof_construction_time_sha256_100_ms | 44,828 (-1%) | 11,768 | 5,447 | 5,392 (-1%) | 5,353 | proof_construction_time_poseidon_hash_ms | 78.0 | 34.0 | 34.0 | 58.0 (-2%) | 88.0 | proof_construction_time_poseidon_hash_30_ms | 1,515 (-1%) | 415 (-1%) | 199 (-1%) | 223 (-1%) | 269 (+1%) | proof_construction_time_poseidon_hash_100_ms | 5,735 (-1%) | 1,576 (-1%) | 723 (-1%) | 768 (-2%) | 792 | ### 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,466 | 9,464 | l1_rollup_execution_gas | 610,285 | 610,287 | 610,285 | l2_block_processing_time_in_ms | 755 | 1,413 | 2,713 (+1%) | l2_block_building_time_in_ms | 25,800 (+2%) | 51,275 | 100,930 (+1%) | l2_block_rollup_simulation_time_in_ms | 25,701 (+2%) | 50,966 | 100,576 (+1%) | l2_block_public_tx_process_time_in_ms | 22,093 (+2%) | 47,180 | 96,852 (+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,021 (+1%) | 9,895 (+1%) | node_database_size_in_bytes | 12,181,584 | 16,130,128 | 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 | 129 (-1%) | 473 (+3%) | 12,914 (+2%) | 20,634 | 67,190 | 92,352 | 2,819 | 524,288 | private-kernel-inner | 392 | 1,136 (-1%) | 48,429 (-1%) | 94,902 | 67,190 | 92,352 | 2,819 | 2,097,152 | private-kernel-tail | 370 | 1,807 (+1%) | 52,000 (+3%) | 99,121 | 71,733 | 14,912 | 399 | 2,097,152 | base-parity | 6.19 (+1%) | 1,901 (+2%) | 2,714 (-2%) | 128 | 64.0 | 2,208 | 2.00 | 131,072 | root-parity | 48.6 | 75.6 | 41,542 (+2%) | 27,100 | 64.0 | 2,720 | 18.0 | 2,097,152 | base-rollup | 7,930 (+1%) | 4,861 (-2%) | 83,320 (-3%) | 170,330 | 756 | 3,648 | 47.0 | 4,194,304 | root-rollup | 109 (-1%) | 94.6 (+11%) | 23,892 (+3%) | 25,309 | 620 | 3,456 | 41.0 | 1,048,576 | public-kernel-setup | 712 (-1%) | 3,694 (-2%) | 44,587 (+2%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | public-kernel-app-logic | 616 (+1%) | 4,678 (-1%) | 45,714 | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | public-kernel-tail | 1,415 | 33,678 (-6%) | 192,707 (-7%) | 511,910 | 10,014 | 14,912 | 399 | 8,388,608 | private-kernel-reset-small | 594 | 2,031 (-12%) | 45,319 (-1%) | 123,313 | 67,190 | 92,352 | 2,819 | 2,097,152 | public-kernel-teardown | 612 (-1%) | 4,664 (-3%) | 47,698 (+2%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | merge-rollup | 28.6 | N/A | N/A | 16,542 | 756 | N/A | N/A | N/A | private-kernel-tail-to-public | N/A | 6,900 (+2%) | 100,624 (+3%) | N/A | N/A | 125,344 | 3,850 | 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 | 426 (+2%) | N/A | N/A | N/A | N/A | ContractInstanceDeployer:deploy | 1,408 | 9,944 | 39.4 | N/A | N/A | N/A | N/A | MultiCallEntrypoint:entrypoint | 1,920 | 9,944 | 1,775 | N/A | N/A | N/A | N/A | GasToken:deploy | 1,376 | 9,944 | 974 (+1%) | N/A | N/A | N/A | N/A | SchnorrAccount:constructor | 1,312 | 9,944 | 1,399 | N/A | N/A | N/A | N/A | SchnorrAccount:entrypoint | 2,304 | 9,944 | 2,836 (+1%) | 16,768 | 54,088 (-2%) | 2,097,152 | 457 | Token:privately_mint_private_note | 1,280 | 9,944 | 1,723 (+7%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_public | 1,344 | 9,944 | 367 (+7%) | 16,768 | 11,207 (-1%) | 524,288 | 457 | Token:transfer | 1,312 | 9,944 | 4,636 (+4%) | 16,768 | 46,251 (+3%) | 2,097,152 | 457 | AuthRegistry:set_authorized (avm) | 21,043 | N/A | N/A | 87,200 | 1,357 (-1%) | N/A | N/A | FPC:prepare_fee (avm) | 28,841 | N/A | N/A | 88,032 | 5,676 | N/A | N/A | Token:transfer_public (avm) | 44,971 | N/A | N/A | 87,865 | 4,745 (-1%) | N/A | N/A | AuthRegistry:consume (avm) | 34,973 | N/A | N/A | 87,616 | 2,958 (-6%) | N/A | N/A | FPC:pay_refund (avm) | 33,573 | N/A | N/A | 88,448 | 11,084 | N/A | N/A | Benchmarking:create_note | 1,344 | 9,944 | 1,400 | N/A | N/A | N/A | N/A | SchnorrAccount:verify_private_authwit | 1,280 | 9,944 | 83.3 (+14%) | N/A | N/A | N/A | N/A | Token:unshield | 1,376 | 9,944 | 3,719 | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_private | 1,376 | 9,944 | 4,668 | 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 | 65.2 (-8%) | 13,873 | GasToken:set_portal | 17.0 (+2%) | 3,495 | Token:constructor | 93.6 (+3%) | 24,207 | FPC:constructor | 62.6 (+2%) | 13,893 | GasToken:mint_public | 50.7 (-3%) | 10,241 | Token:mint_public | 60.6 (+1%) | 19,216 | Token:assert_minter_and_mint | 228 (+5%) | 13,034 | AuthRegistry:set_authorized | 33.3 (-9%) | 7,869 | FPC:prepare_fee | 155 (-18%) | 15,187 | Token:transfer_public | 50.9 (+11%) | 31,425 | FPC:pay_refund | 122 (+5%) | 20,080 | Benchmarking:increment_balance | 2,692 | 15,465 | Token:_increase_public_balance | 56.6 (+2%) | 15,089 | FPC:pay_refund_with_shielded_rebate | 144 | 21,167 | ### Public DB Access Time to access various public DBs. | Function | time_ms | | - | - | get-nullifier-index | 0.163 (+6%) | ### 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 (+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 (+1%) | 0.515 (+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.7 (+1%) | 76.9 (+1%) | 131 | 246 | 470 | 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.497 (+1%) | 0.472 (+1%) | 0.452 | 0.446 (+1%) | 0.439 | batch_insert_into_indexed_tree_20_depth_ms | N/A | N/A | 59.5 (+1%) | 113 (+1%) | 182 | 354 (+1%) | 694 | 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.506 (+1%) | 0.483 | 0.479 | 0.477 | 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.519 | 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 | 85,672 | 670,983 | Transaction size based on fee payment method | Metric | | | - | |