AztecProtocol / aztec-packages

Apache License 2.0
180 stars 184 forks source link

feat!: constant inputs for blackbox #7222

Closed guipublic closed 2 months ago

guipublic commented 3 months ago

This PR allows to use constant values for blackbox inputs. Only MultiScalarMul is currently handling constant input, so it will fail if constant inputs are used for any other blackboxes. Noir does ensure that other blackboxes functions do not use constant inputs in this PR. I will make a follow-up PR once this one is merged to have more blackbox functions using constant inputs.

TomAFrench commented 3 months ago

I've pushed a commit which removes the trait bounds being applied to the various struct definitions as it's generally good practice to avoid these unless absolutely necessary and apply the bounds to impls instead.

github-actions[bot] commented 3 months ago

Changes to circuit sizes

Generated at commit: b3e5b31980592c1331fbdede08cb19f53eaf7744, compared to commit: 819f37002a253cdba8c46daac5d68f64fa11f19c

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

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_reset_small -1 โœ… -0.00% -152 โœ… -0.02%
private_kernel_reset_medium -1 โœ… -0.00% -304 โœ… -0.03%
private_kernel_reset_big -1 โœ… -0.00% -608 โœ… -0.05%
private_kernel_reset -1 โœ… -0.00% -1,216 โœ… -0.07%

Full diff report ๐Ÿ‘‡
| Program | ACIR opcodes (+/-) | % | Circuit size (+/-) | % | |:-|-:|-:|-:|-:| | **private_kernel_reset_small** | 62,366 (-1) | **-0.00%** | 828,341 (-152) | **-0.02%** | | **private_kernel_reset_medium** | 72,361 (-1) | **-0.00%** | 952,008 (-304) | **-0.03%** | | **private_kernel_reset_big** | 92,350 (-1) | **-0.00%** | 1,199,421 (-608) | **-0.05%** | | **private_kernel_reset** | 132,326 (-1) | **-0.00%** | 1,694,245 (-1,216) | **-0.07%** |
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/7222.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,708 (+3%) | 1,541 (+4%) | 705 (+4%) | 739 (+2%) | 765 (+4%) | proof_construction_time_sha256_30_ms | 11,690 (+3%) | 3,134 (+3%) | 1,400 (+4%) | 1,414 (+2%) | 1,462 (+4%) | proof_construction_time_sha256_100_ms | 43,702 (+3%) | 11,753 (+3%) | 5,435 (-4%) | 5,428 (+4%) | 5,347 (+3%) | proof_construction_time_poseidon_hash_ms | 78.0 (+3%) | 34.0 (+3%) | 34.0 (+3%) | 57.0 (+4%) | 89.0 (+3%) | proof_construction_time_poseidon_hash_30_ms | 1,516 (+3%) | 415 (+3%) | 200 (+4%) | 224 (+4%) | 270 (+3%) | proof_construction_time_poseidon_hash_100_ms | 5,607 (+1%) | 1,514 | 676 (-3%) | 705 (-6%) | 739 (-4%) | ### 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,472 | 9,476 | l1_rollup_execution_gas | 613,492 | 613,651 | 613,806 | l2_block_processing_time_in_ms | 751 (-1%) | 1,421 | 2,700 | l2_block_building_time_in_ms | 12,941 | 25,671 (+1%) | 49,705 | l2_block_rollup_simulation_time_in_ms | 12,941 | 25,671 (+1%) | 49,705 | l2_block_public_tx_process_time_in_ms | 10,879 (-1%) | 23,424 (+1%) | 47,483 | ### 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,031 | 9,985 (+1%) | node_database_size_in_bytes | 12,439,632 | 16,207,952 | 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 | 108 (+1%) | 396 (+2%) | 14,620 | 20,002 | 55,022 | 74,208 | 2,252 | 524,288 | private-kernel-inner | 222 (+1%) | 710 (+3%) | 29,671 (+2%) | 82,134 | 55,022 | 74,208 | 2,252 | 1,048,576 | private-kernel-tail | 1,063 (+1%) | 2,482 (+2%) | 52,899 (-3%) | 62,409 | 62,089 | 14,944 | 400 | 2,097,152 | base-parity | 6.30 (-9%) | 895 (-1%) | 2,641 | 160 | 96.0 | 2,240 | 3.00 | 131,072 | root-parity | 69.6 (+1%) | 71.2 (-8%) | 40,754 (-6%) | 27,868 | 96.0 | 2,752 | 19.0 | 2,097,152 | base-rollup | 4,145 | 4,837 (+1%) | 93,347 (+3%) | 172,028 | 632 | 3,552 | 44.0 | 4,194,304 | root-rollup | 126 | 88.5 (-2%) | 22,307 (-7%) | 25,053 | 652 | 3,488 | 42.0 | 1,048,576 | public-kernel-setup | 189 (+1%) | 2,371 | 42,925 (+4%) | 103,911 | 80,310 | 106,944 | 3,275 | 2,097,152 | public-kernel-app-logic | 146 (+1%) | 3,293 (+1%) | 43,291 (+4%) | 103,911 | 80,310 | 106,944 | 3,275 | 2,097,152 | public-kernel-tail | 892 | 23,159 (-5%) | 180,938 (+1%) | 400,808 | 10,046 | 14,944 | 400 | 8,388,608 | private-kernel-reset-small | 292 (+1%) | 1,300 (+1%) | 27,316 (+1%) | 79,273 | 55,022 | 74,208 | 2,252 | 1,048,576 | public-kernel-teardown | 133 | 3,307 (+1%) | 44,620 (+3%) | 103,911 | 80,310 | 106,944 | 3,275 | 2,097,152 | merge-rollup | 40.8 | N/A | N/A | 16,094 | 632 | N/A | N/A | N/A | private-kernel-tail-to-public | N/A | 8,490 (+1%) | 58,203 (-1%) | N/A | N/A | 106,944 | 3,275 | 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,312 | 9,344 | 393 (+1%) | N/A | N/A | N/A | N/A | ContractInstanceDeployer:deploy | 1,376 | 9,344 | 24.6 (+1%) | N/A | N/A | N/A | N/A | MultiCallEntrypoint:entrypoint | 1,888 | 9,344 | 640 | N/A | N/A | N/A | N/A | GasToken:deploy | 1,344 | 9,344 | 553 (+2%) | N/A | N/A | N/A | N/A | SchnorrAccount:constructor | 1,280 | 9,344 | 474 | N/A | N/A | N/A | N/A | SchnorrAccount:entrypoint | 2,272 | 9,344 | 821 (+1%) | 15,840 | 4,807 (+2%) | 131,072 | 428 | Token:privately_mint_private_note | 1,248 | 9,344 | 539 (+1%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_public | 1,312 | 9,344 | 103 (+4%) | 15,840 | 1,705 (+1%) | 65,536 | 428 | Token:transfer | 1,280 | 9,344 | 1,626 (+1%) | 15,840 | 11,749 (+3%) | 524,288 | 428 | AuthRegistry:set_authorized (avm) | 19,222 | N/A | N/A | 91,232 | 1,266 (+1%) | N/A | N/A | FPC:prepare_fee (avm) | 26,664 | N/A | N/A | 91,296 | 2,706 (+2%) | N/A | N/A | Token:transfer_public (avm) | 42,914 | N/A | N/A | 91,296 | 3,874 (-1%) | N/A | N/A | AuthRegistry:consume (avm) | 33,100 | N/A | N/A | 91,232 | 2,875 (+9%) | N/A | N/A | FPC:pay_refund (avm) | 36,829 | N/A | N/A | 91,264 | 25,251 (+8%) | N/A | N/A | Benchmarking:create_note | 1,312 | 9,344 | 471 (+2%) | N/A | N/A | N/A | N/A | SchnorrAccount:verify_private_authwit | 1,248 | 9,344 | 41.4 (+1%) | N/A | N/A | N/A | N/A | Token:unshield | 1,344 | 9,344 | 1,347 (+1%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_private | 1,344 | 9,344 | 1,744 (+1%) | 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 | 78.8 (+4%) | 13,790 | GasToken:set_portal | 16.4 (+13%) | 3,339 | Token:constructor | 101 | 23,692 | FPC:constructor | 71.2 (-2%) | 13,592 | GasToken:mint_public | 60.0 (-4%) | 10,158 | Token:mint_public | :warning: 335 (**+581%**) | 19,034 | Token:assert_minter_and_mint | :warning: 38.7 (**-41%**) | 12,925 | AuthRegistry:set_authorized | 32.7 (-2%) | 7,812 | FPC:prepare_fee | 100 (-2%) | 15,062 | Token:transfer_public | 47.5 (+29%) | 31,218 | FPC:pay_refund | 125 (-5%) | 25,260 | Benchmarking:increment_balance | 1,322 | 15,267 | Token:_increase_public_balance | :warning: 65.6 (**-52%**) | 15,006 | FPC:pay_refund_with_shielded_rebate | 115 | 26,347 | ### Public DB Access Time to access various public DBs. | Function | time_ms | | - | - | get-nullifier-index | 0.155 (-4%) | ### 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.7 | 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.599 (-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.0 (-1%) | 75.4 | 131 | 245 | 469 | 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.490 (-1%) | 0.464 | 0.450 | 0.444 | 0.439 | batch_insert_into_indexed_tree_20_depth_ms | N/A | N/A | 59.2 | 111 | 183 | 353 | 692 | 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.500 | 0.500 | 0.484 | 0.479 | 0.475 | batch_insert_into_indexed_tree_40_depth_ms | N/A | N/A | 72.6 | 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.517 | 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,082 | 667,868 | Transaction size based on fee payment method | Metric | | | - | |
TomAFrench commented 2 months ago

Looks good, shall we merge this on monday so it can be included in the Tuesday release? We'll be able to immediately sync out to Noir then.

TomAFrench commented 2 months ago

We've got a release tomorrow so merging this now.