AztecProtocol / aztec-packages

Apache License 2.0
155 stars 156 forks source link

chore(docs): Update token tutorial #7241

Open critesjosh opened 2 days ago

critesjosh commented 2 days ago

Updates the token tutorial with the missing transfer_from and cancel_authwit functions. Also adds a view function section.

closes: https://github.com/AztecProtocol/dev-rel/issues/304

AztecBot commented 2 days ago

Docs Preview

Hey there! 👋 You can check your preview at https://667f12b82d3c7375087b651e--aztec-docs-dev.netlify.app

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/7241.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,421 | 3,070 | 1,590 (-5%) | 1,531 (-4%) | 1,554 (+3%) | proof_construction_time_sha256_100_ms | 44,666 (+2%) | 11,878 (+1%) | 5,462 | 5,428 | 5,392 (+1%) | proof_construction_time_poseidon_hash_ms | 78.0 | 34.0 | 34.0 | 57.0 (-3%) | 87.0 (-2%) | proof_construction_time_poseidon_hash_30_ms | 1,520 | 415 | 200 | 222 (-3%) | 267 | proof_construction_time_poseidon_hash_100_ms | 5,755 | 1,565 (+1%) | 726 (+1%) | 770 (+3%) | 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,452 | 9,468 | 9,464 | l1_rollup_execution_gas | 610,273 | 610,289 | 610,285 | l2_block_processing_time_in_ms | 749 (-3%) | 1,409 | 2,688 (-2%) | l2_block_building_time_in_ms | 25,706 | 51,267 | 100,415 | l2_block_rollup_simulation_time_in_ms | 25,706 | 51,266 | 100,415 | l2_block_public_tx_process_time_in_ms | 22,107 | 47,468 | 96,670 | ### 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,045 (+1%) | 9,867 | node_database_size_in_bytes | 12,157,008 | 16,035,920 | 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 | 121 | 467 (-8%) | 13,126 (+4%) | 20,634 | 67,190 | 92,352 | 2,819 | 524,288 | private-kernel-inner | 382 | 960 (-9%) | 51,520 (+4%) | 94,902 | 67,190 | 92,352 | 2,819 | 2,097,152 | private-kernel-tail | 311 | 1,785 (+1%) | 51,388 (+4%) | 99,121 | 71,733 | 14,912 | 399 | 2,097,152 | base-parity | 6.22 (+1%) | 1,937 (-2%) | 2,725 (-1%) | 128 | 64.0 | 2,208 | 2.00 | 131,072 | root-parity | 50.0 (+2%) | 76.1 (+2%) | 40,527 (-4%) | 27,100 | 64.0 | 2,720 | 18.0 | 2,097,152 | base-rollup | 7,982 | 5,054 (+1%) | 88,579 (+6%) | 170,330 | 756 | 3,648 | 47.0 | 4,194,304 | root-rollup | 110 | 88.2 (-5%) | 22,620 | 25,309 | 620 | 3,456 | 41.0 | 1,048,576 | public-kernel-setup | 721 (+1%) | 3,754 | 45,486 (+2%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | public-kernel-app-logic | 633 | 4,759 (+1%) | 46,333 (-2%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | public-kernel-tail | 1,407 | 39,357 (+5%) | 194,843 | 511,910 | 10,014 | 14,912 | 399 | 8,388,608 | private-kernel-reset-small | 561 | 2,177 (+9%) | 47,504 (+2%) | 123,313 | 67,190 | 92,352 | 2,819 | 2,097,152 | public-kernel-teardown | 634 | 4,761 | 46,272 (+1%) | 116,905 | 93,334 | 125,344 | 3,850 | 2,097,152 | merge-rollup | 29.1 | N/A | N/A | 16,542 | 756 | N/A | N/A | N/A | private-kernel-tail-to-public | N/A | 7,216 (+1%) | 99,853 (+4%) | 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 | 424 | N/A | N/A | N/A | N/A | ContractInstanceDeployer:deploy | 1,408 | 9,944 | 39.9 | N/A | N/A | N/A | N/A | MultiCallEntrypoint:entrypoint | 1,920 | 9,944 | 1,791 | N/A | N/A | N/A | N/A | GasToken:deploy | 1,376 | 9,944 | 995 (+2%) | N/A | N/A | N/A | N/A | SchnorrAccount:constructor | 1,312 | 9,944 | 1,411 | N/A | N/A | N/A | N/A | SchnorrAccount:entrypoint | 2,304 | 9,944 | 2,830 | 16,768 | 56,666 (-1%) | 2,097,152 | 457 | Token:privately_mint_private_note | 1,280 | 9,944 | 1,635 | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_public | 1,344 | 9,944 | 367 (+3%) | 16,768 | 11,113 (-8%) | 524,288 | 457 | Token:transfer | 1,312 | 9,944 | 4,555 (+2%) | 16,768 | 46,777 (+2%) | 2,097,152 | 457 | AuthRegistry:set_authorized (avm) | 21,043 | N/A | N/A | 87,200 | 1,364 (+1%) | N/A | N/A | FPC:prepare_fee (avm) | 28,495 | N/A | N/A | 88,032 | 5,817 (-1%) | N/A | N/A | Token:transfer_public (avm) | 44,885 | N/A | N/A | 87,754 | 4,065 (+4%) | N/A | N/A | AuthRegistry:consume (avm) | 34,973 | N/A | N/A | 87,616 | 3,208 (+11%) | N/A | N/A | FPC:pay_refund (avm) | 41,394 | N/A | N/A | 88,864 | 22,635 (-10%) | N/A | N/A | Benchmarking:create_note | 1,344 | 9,944 | 1,397 | N/A | N/A | N/A | N/A | SchnorrAccount:verify_private_authwit | 1,280 | 9,944 | 74.9 (+2%) | N/A | N/A | N/A | N/A | Token:unshield | 1,376 | 9,944 | 3,878 (+5%) | N/A | N/A | N/A | N/A | FPC:fee_entrypoint_private | 1,376 | 9,944 | 4,838 (+5%) | 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 | 66.6 (-1%) | 13,873 (+1%) | GasToken:set_portal | 17.0 | 3,495 (+5%) | Token:constructor | 95.1 (+2%) | 24,207 (+2%) | FPC:constructor | 75.6 (+20%) | 13,893 (+2%) | GasToken:mint_public | 52.9 (-1%) | 10,241 (+1%) | Token:mint_public | :warning: 619 (**+851%**) | 19,216 (+1%) | Token:assert_minter_and_mint | :warning: 61.3 (**-71%**) | 13,034 (+1%) | AuthRegistry:set_authorized | 35.3 (+10%) | 7,869 (+1%) | FPC:prepare_fee | 153 (+2%) | 15,129 | Token:transfer_public | 39.2 (-24%) | 31,425 (+1%) | FPC:pay_refund | 218 (+4%) | 28,061 | Benchmarking:increment_balance | 2,714 | 15,407 (+1%) | Token:_increase_public_balance | 61.8 (+10%) | 15,089 (+1%) | FPC:pay_refund_with_shielded_rebate | 162 (-20%) | 29,148 | ### Public DB Access Time to access various public DBs. | Function | time_ms | | - | - | get-nullifier-index | 0.156 (+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.3 | 16.9 (+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.597 | 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.7 (+1%) | 75.5 (-1%) | 131 (-1%) | 244 | 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.497 (+1%) | 0.464 (-1%) | 0.450 | 0.441 (-1%) | 0.438 | batch_insert_into_indexed_tree_20_depth_ms | N/A | N/A | 59.4 | 111 (-2%) | 182 (-3%) | 352 | 691 (-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.502 (-1%) | 0.499 (-2%) | 0.482 (-2%) | 0.476 (-1%) | 0.474 (-2%) | batch_insert_into_indexed_tree_40_depth_ms | N/A | N/A | 72.6 (-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.517 (-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 | 85,672 | 670,983 | Transaction size based on fee payment method | Metric | | | - | |