Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): Update token tutorial #7241

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

critesjosh
Copy link
Contributor

@critesjosh critesjosh commented Jun 28, 2024

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

closes: AztecProtocol/dev-rel#304

@critesjosh critesjosh requested a review from a team June 28, 2024 19:21
@AztecBot
Copy link
Collaborator

AztecBot commented Jun 28, 2024

Docs Preview

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

@AztecBot
Copy link
Collaborator

AztecBot commented Jun 28, 2024

Benchmark results

Metrics with a significant change:

  • avm_simulation_time_ms (Token:mint_public): 622 (+856%)
  • avm_simulation_time_ms (Token:assert_minter_and_mint): 60.9 (-71%)
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.

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,424 3,142 (+3%) 1,754 (+5%) 1,567 (-2%) 1,460 (-3%)
proof_construction_time_sha256_100_ms 45,874 (+5%) 11,761 5,607 (+3%) 5,429 5,365
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 58.0 (-2%) 88.0 (-1%)
proof_construction_time_poseidon_hash_30_ms 1,518 417 200 258 (+12%) 270 (+2%)
proof_construction_time_poseidon_hash_100_ms 5,739 1,581 (+2%) 724 (+1%) 787 (+5%) 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,464 9,464
l1_rollup_execution_gas 610,285 610,285 610,285
l2_block_processing_time_in_ms 758 (-2%) 1,431 (+1%) 2,711 (-1%)
l2_block_building_time_in_ms 25,490 (-1%) 50,961 (-1%) 100,446
l2_block_rollup_simulation_time_in_ms 25,489 (-1%) 50,960 (-1%) 100,446
l2_block_public_tx_process_time_in_ms 21,895 (-1%) 47,158 (-1%) 96,716

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,109 (+2%) 9,996 (+2%)
node_database_size_in_bytes 12,157,008 16,072,784
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 120 (-1%) 465 (-8%) 13,830 (+9%) 20,634 67,190 92,352 2,819 524,288
private-kernel-inner 382 963 (-9%) 48,778 (-2%) 94,902 67,190 92,352 2,819 2,097,152
private-kernel-tail 311 1,772 52,513 (+6%) 99,121 71,733 14,912 399 2,097,152
base-parity 6.39 (+3%) 1,981 2,866 (+4%) 128 64.0 2,208 2.00 131,072
root-parity 51.0 (+4%) 80.6 (+8%) 41,324 (-2%) 27,100 64.0 2,720 18.0 2,097,152
base-rollup 7,950 (-1%) 5,168 (+4%) 88,629 (+6%) 170,330 756 3,648 47.0 4,194,304
root-rollup 111 (+1%) 94.5 (+2%) 24,382 (+8%) 25,309 620 3,456 41.0 1,048,576
public-kernel-setup 725 (+2%) 3,836 (+2%) 46,801 (+5%) 116,905 93,334 125,344 3,850 2,097,152
public-kernel-app-logic 632 4,939 (+5%) 47,502 (+1%) 116,905 93,334 125,344 3,850 2,097,152
public-kernel-tail 1,400 36,929 (-1%) 202,966 (+5%) 511,910 10,014 14,912 399 8,388,608
private-kernel-reset-small 560 2,169 (+8%) 45,535 (-2%) 123,313 67,190 92,352 2,819 2,097,152
public-kernel-teardown 638 (+1%) 4,922 (+4%) 47,083 (+3%) 116,905 93,334 125,344 3,850 2,097,152
merge-rollup 29.4 (+1%) N/A N/A 16,542 756 N/A N/A N/A
private-kernel-tail-to-public N/A 7,050 (-2%) 99,897 (+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 426 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,789 N/A N/A N/A N/A
GasToken:deploy 1,376 9,944 986 (+1%) N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,416 N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,843 (+1%) 16,768 57,498 (+1%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,642 (+1%) N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 366 (+3%) 16,768 11,916 (-1%) 524,288 457
Token:transfer 1,312 9,944 4,639 (+4%) 16,768 47,235 (+3%) 2,097,152 457
AuthRegistry:set_authorized (avm) 21,043 N/A N/A 87,200 1,398 (+3%) N/A N/A
FPC:prepare_fee (avm) 28,495 N/A N/A 88,032 6,074 (+3%) N/A N/A
Token:transfer_public (avm) 44,885 N/A N/A 87,754 4,150 (+6%) N/A N/A
AuthRegistry:consume (avm) 34,973 N/A N/A 87,616 3,146 (+9%) N/A N/A
FPC:pay_refund (avm) 41,394 N/A N/A 88,864 23,767 (-5%) N/A N/A
Benchmarking:create_note 1,344 9,944 1,403 N/A N/A N/A N/A
SchnorrAccount:verify_private_authwit 1,280 9,944 84.1 (+15%) N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,771 (+2%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,711 (+2%) 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 68.6 (+2%) 13,873 (+1%)
GasToken:set_portal 17.1 3,495 (+5%)
Token:constructor 95.0 (+2%) 24,207 (+2%)
FPC:constructor 64.8 (+3%) 13,893 (+2%)
GasToken:mint_public 53.4 10,241 (+1%)
Token:mint_public ⚠️ 622 (+856%) 19,216 (+1%)
Token:assert_minter_and_mint ⚠️ 60.9 (-71%) 13,034 (+1%)
AuthRegistry:set_authorized 33.6 (+5%) 7,869 (+1%)
FPC:prepare_fee 151 (+1%) 15,129
Token:transfer_public 57.2 (+11%) 31,425 (+1%)
FPC:pay_refund 206 (-2%) 28,061
Benchmarking:increment_balance 2,702 (-1%) 15,407 (+1%)
Token:_increase_public_balance 57.6 (+2%) 15,089 (+1%)
FPC:pay_refund_with_shielded_rebate 202 29,148

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.163 (+5%)

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 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.602 (+1%) 0.516 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.7 (+1%) 132 247 (+1%) 473
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.471 (+1%) 0.453 0.446 0.441 (+1%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 59.9 113 184 (-2%) 355 (+1%) 696 (-1%)
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.505 0.487 (-1%) 0.480 0.478 (-1%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 73.3 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.521 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 | |
| - | |


#### `balance_of_private`

A getter function for checking the private balance of the provided Aztec account. Note that the [Private Execution Environment (PXE)](https://github.com/AztecProtocol/aztec-packages/tree/#include_aztec_version/yarn-project/pxe) must have `ivsk_app` ([app-specific secret key](../../aztec/concepts/accounts/keys.md#scoped-keys)) in order to decrypt the notes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nsk_app is an app-specific secret key. Should ivsk_app have a different name and link to "incoming-viewing-keys" section instead of "scoped-keys" section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the link to the appropriate section.

nsk_app is the app specific nullifier secret key. are you suggesting we change what the ivsk_app is called? I think that would be a larger discussion with mike and others working on keys.

@critesjosh critesjosh requested a review from jzaki July 1, 2024 16:17
Copy link
Contributor

github-actions bot commented Jul 1, 2024

Changes to circuit sizes

Generated at commit: 28d684895c1552c3467ded98be42f3ca5e32ba28, compared to commit: d4359a34668fc389a8a5c5a8b8493f0dc8a5d4ae

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_reset +106,707 ❌ +78.98% +847,413 ❌ +49.94%
private_kernel_tail_to_public +14,084 ❌ +3.17% +441,152 ❌ +26.31%
private_kernel_init_simulated 0 ➖ 0.00% +576 ❌ +25.81%
private_kernel_inner_simulated 0 ➖ 0.00% +576 ❌ +25.81%
private_kernel_reset_simulated 0 ➖ 0.00% +576 ❌ +25.81%
private_kernel_reset_simulated_big 0 ➖ 0.00% +576 ❌ +25.81%
private_kernel_reset_simulated_medium 0 ➖ 0.00% +576 ❌ +25.81%
private_kernel_reset_simulated_small 0 ➖ 0.00% +576 ❌ +25.81%
public_kernel_tail +246,491 ❌ +25.38% +1,020,150 ❌ +23.15%
public_kernel_setup +97,600 ❌ +53.23% +336,012 ❌ +22.91%
public_kernel_app_logic +97,840 ❌ +40.32% +362,976 ❌ +21.82%
public_kernel_teardown +97,840 ❌ +40.28% +362,975 ❌ +21.82%
private_kernel_tail_to_public_simulated 0 ➖ 0.00% +576 ❌ +17.65%
public_kernel_app_logic_simulated 0 ➖ 0.00% +576 ❌ +17.65%
public_kernel_setup_simulated 0 ➖ 0.00% +576 ❌ +17.65%
public_kernel_teardown_simulated 0 ➖ 0.00% +576 ❌ +17.65%
private_kernel_reset_small +61,184 ❌ +87.34% +155,730 ❌ +17.01%
private_kernel_reset_medium +61,184 ❌ +71.27% +155,730 ❌ +13.83%
private_kernel_inner +9,376 ❌ +21.24% +132,822 ❌ +11.45%
private_kernel_reset_big +61,184 ❌ +52.10% +155,730 ❌ +10.07%
private_kernel_tail +728 ❌ +3.43% +93,286 ❌ +7.50%
private_kernel_init +5,439 ❌ +21.54% +16,839 ❌ +4.50%
rollup_root -23 ✅ -1.06% -405 ✅ -0.04%
rollup_merge -24 ✅ -1.79% -405 ✅ -0.07%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_reset 241,816 (+106,707) +78.98% 2,544,408 (+847,413) +49.94%
private_kernel_tail_to_public 458,562 (+14,084) +3.17% 2,118,154 (+441,152) +26.31%
private_kernel_init_simulated 1 (0) 0.00% 2,808 (+576) +25.81%
private_kernel_inner_simulated 1 (0) 0.00% 2,808 (+576) +25.81%
private_kernel_reset_simulated 1 (0) 0.00% 2,808 (+576) +25.81%
private_kernel_reset_simulated_big 1 (0) 0.00% 2,808 (+576) +25.81%
private_kernel_reset_simulated_medium 1 (0) 0.00% 2,808 (+576) +25.81%
private_kernel_reset_simulated_small 1 (0) 0.00% 2,808 (+576) +25.81%
public_kernel_tail 1,217,548 (+246,491) +25.38% 5,427,671 (+1,020,150) +23.15%
public_kernel_setup 280,955 (+97,600) +53.23% 1,802,693 (+336,012) +22.91%
public_kernel_app_logic 340,521 (+97,840) +40.32% 2,026,181 (+362,976) +21.82%
public_kernel_teardown 340,719 (+97,840) +40.28% 2,026,420 (+362,975) +21.82%
private_kernel_tail_to_public_simulated 1 (0) 0.00% 3,839 (+576) +17.65%
public_kernel_app_logic_simulated 1 (0) 0.00% 3,839 (+576) +17.65%
public_kernel_setup_simulated 1 (0) 0.00% 3,839 (+576) +17.65%
public_kernel_teardown_simulated 1 (0) 0.00% 3,839 (+576) +17.65%
private_kernel_reset_small 131,240 (+61,184) +87.34% 1,071,366 (+155,730) +17.01%
private_kernel_reset_medium 147,037 (+61,184) +71.27% 1,281,801 (+155,730) +13.83%
private_kernel_inner 53,510 (+9,376) +21.24% 1,292,648 (+132,822) +11.45%
private_kernel_reset_big 178,629 (+61,184) +52.10% 1,702,669 (+155,730) +10.07%
private_kernel_tail 21,972 (+728) +3.43% 1,336,812 (+93,286) +7.50%
private_kernel_init 30,686 (+5,439) +21.54% 390,775 (+16,839) +4.50%
rollup_root 2,145 (-23) -1.06% 910,781 (-405) -0.04%
rollup_merge 1,315 (-24) -1.79% 601,662 (-405) -0.07%

@critesjosh critesjosh requested a review from jzaki July 3, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update "unconstrained" section of token tutorial
3 participants