AztecProtocol / aztec-packages

Apache License 2.0
155 stars 156 forks source link

feat: example of private token transfer event #7242

Closed LHerskind closed 2 days ago

LHerskind commented 2 days ago

A small extension on some of the work @sklppy88 have been doing lately to satisfy @rahul-kothari and have an example where you end up with your "transfer history".

The events currently only have neat macros autogenerated for when we are using a struct of fields only, but works just fine for us here.

LHerskind commented 2 days 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 2 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/7242.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,482 (+1%) | 3,102 (+1%) | 1,496 (-11%) | 1,613 (+1%) | 1,466 (-2%) | proof_construction_time_sha256_100_ms | 44,173 (+1%) | 11,971 (+2%) | 5,686 (+4%) | 5,568 (+3%) | 5,527 (+3%) | proof_construction_time_poseidon_hash_ms | 78.0 | 34.0 | 35.0 (+3%) | 58.0 (-2%) | 89.0 | proof_construction_time_poseidon_hash_30_ms | 1,517 | 415 | 200 | 226 (-2%) | 267 | proof_construction_time_poseidon_hash_100_ms | 5,772 | 1,571 (+1%) | 731 (+2%) | 767 (+3%) | 795 | ### 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,476 | 9,470 | 9,476 | l1_rollup_execution_gas | 610,297 | 610,291 | 610,297 | l2_block_processing_time_in_ms | 754 (-2%) | 1,407 | 2,683 (-2%) | l2_block_building_time_in_ms | 25,715 | 51,246 | 101,047 (+1%) | l2_block_rollup_simulation_time_in_ms | 25,715 | 51,246 | 101,047 (+1%) | l2_block_public_tx_process_time_in_ms | 22,052 | 47,427 | 97,285 (+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,011 | 9,847 | node_database_size_in_bytes | 12,161,104 | 16,011,344 (-1%) | 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 | 122 (+1%) | 491 (-3%) | 12,402 (-2%) | 20,634 | 67,190 | 92,352 | 2,819 | 524,288 | private-kernel-inner | 385 (+1%) | 1,007 (-5%) | 44,808 (-10%) | 94,902 | 67,190 | 92,352 | 2,819 | 2,097,152 | private-kernel-tail | 312 | 1,812 (+3%) | 45,793 (-8%) | 99,121 | 71,733 | 14,912 | 399 | 2,097,152 | base-parity | 6.22 (+1%) | 1,965 | 2,572 (-6%) | 128 | 64.0 | 2,208 | 2.00 | 131,072 | root-parity | 49.8 (+1%) | 68.8 (-8%) | :warning: 33,718 (**-20%**) | 27,100 | 64.0 | 2,720 | 18.0 | 2,097,152 | base-rollup | 8,004 | 5,054 (+1%) | 72,233 (-14%) | 170,330 | 756 | 3,648 | 47.0 | 4,194,304 | root-rollup | 112 (+2%) | 71.9 (-23%) | 20,350 (-10%) | 25,309 | 620 | 3,456 | 41.0 | 1,048,576 | public-kernel-setup | 733 (+3%) | 3,730 (-1%) | 38,729 (-13%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | public-kernel-app-logic | 636 | 4,914 (+4%) | 40,028 (-15%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | public-kernel-tail | 1,413 (+1%) | 37,823 (+1%) | 167,239 (-14%) | 511,910 | 10,014 | 14,912 | 399 | 8,388,608 | private-kernel-reset-small | 560 | 2,174 (+8%) | 41,499 (-11%) | 123,313 | 67,190 | 92,352 | 2,819 | 2,097,152 | public-kernel-teardown | 643 (+2%) | 4,904 (+4%) | 40,134 (-12%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | merge-rollup | 29.3 (+1%) | N/A | N/A | 16,542 | 756 | N/A | N/A | N/A | private-kernel-tail-to-public | N/A | 7,129 (-1%) | 85,343 (-12%) | 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 | 425 | N/A | N/A | N/A | N/A | ContractInstanceDeployer:deploy | 1,408 | 9,944 | 40.7 (+2%) | N/A | N/A | N/A | N/A | MultiCallEntrypoint:entrypoint | 1,920 | 9,944 | 1,816 (+2%) | N/A | N/A | N/A | N/A | GasToken:deploy | 1,376 | 9,944 | 1,013 (+4%) | N/A | N/A | N/A | N/A | SchnorrAccount:constructor | 1,312 | 9,944 | 1,452 (+3%) | N/A | N/A | N/A | N/A | SchnorrAccount:entrypoint | 2,304 | 9,944 | 2,842 (+1%) | 16,768 | 50,932 (-11%) | 2,097,152 | 457 | Token:privately_mint_private_note | 1,280 | 9,944 | 1,706 (+5%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_public | 1,344 | 9,944 | 379 (+6%) | 16,768 | 10,529 (-13%) | 524,288 | 457 | Token:transfer | 1,312 | 9,944 | 4,594 (+3%) | 16,768 | 41,601 (-9%) | 2,097,152 | 457 | AuthRegistry:set_authorized (avm) | 20,996 | N/A | N/A | 87,552 | :warning: 1,592 (**+18%**) | N/A | N/A | FPC:prepare_fee (avm) | 28,495 | N/A | N/A | 88,448 | :warning: 4,755 (**-19%**) | N/A | N/A | Token:transfer_public (avm) | 44,705 | N/A | N/A | 88,170 | 3,519 (-10%) | N/A | N/A | AuthRegistry:consume (avm) | 34,874 | N/A | N/A | 87,968 | 2,750 (-4%) | N/A | N/A | FPC:pay_refund (avm) | 41,394 | N/A | N/A | 89,248 | :warning: 17,071 (**-32%**) | N/A | N/A | Benchmarking:create_note | 1,344 | 9,944 | 1,393 (-1%) | N/A | N/A | N/A | N/A | SchnorrAccount:verify_private_authwit | 1,280 | 9,944 | 73.3 | N/A | N/A | N/A | N/A | Token:unshield | 1,376 | 9,944 | 3,758 (+2%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_private | 1,376 | 9,944 | 4,742 (+3%) | 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 | 71.6 (+7%) | 13,800 | GasToken:set_portal | 17.3 (+1%) | 3,315 | Token:constructor | 93.5 (+1%) | 23,719 | FPC:constructor | 64.7 (+2%) | 13,653 | GasToken:mint_public | 54.0 (+2%) | 10,168 | Token:mint_public | :warning: 633 (**+872%**) | 19,010 | Token:assert_minter_and_mint | :warning: 84.1 (**-61%**) | 12,901 | AuthRegistry:set_authorized | 31.1 (-3%) | 7,822 | FPC:prepare_fee | 147 (-2%) | 15,129 | Token:transfer_public | :warning: 34.2 (**-34%**) | 31,245 | FPC:pay_refund | 191 (-9%) | 28,061 | Benchmarking:increment_balance | 2,711 | 15,300 | Token:_increase_public_balance | 61.5 (+9%) | 14,982 | FPC:pay_refund_with_shielded_rebate | 154 (-24%) | 29,148 | ### Public DB Access Time to access various public DBs. | Function | time_ms | | - | - | get-nullifier-index | 0.157 (+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 (+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.605 (+1%) | 0.518 (+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.4 | 75.7 | 131 (-1%) | 244 | 468 (-1%) | 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.495 | 0.465 | 0.449 (-1%) | 0.443 | 0.437 | batch_insert_into_indexed_tree_20_depth_ms | N/A | N/A | 59.8 | 112 (-1%) | 182 (-3%) | 353 | 692 (-2%) | 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.506 | 0.501 (-1%) | 0.482 (-3%) | 0.478 | 0.474 (-2%) | batch_insert_into_indexed_tree_40_depth_ms | N/A | N/A | 73.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 | 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,707 | 670,983 | Transaction size based on fee payment method | Metric | | | - | |