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

refactor: replace token note with uint note #8143

Merged
merged 2 commits into from
Oct 27, 2024

Conversation

sklppy88
Copy link
Contributor

@sklppy88 sklppy88 commented Aug 22, 2024

In this PR, we are replacing the token note with our previously added U128 note and making BalanceSet hold a UintNote instead of being generic. The token note is now redundant as we have a UintNote in aztec nr now.

Resolves #8107.

Copy link
Contributor Author

sklppy88 commented Aug 22, 2024

@sklppy88 sklppy88 changed the title init replace token note with int note Aug 22, 2024
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch from 265802c to 353b842 Compare August 22, 2024 13:06
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch 2 times, most recently from 230064a to 19b345e Compare August 22, 2024 13:50
@sklppy88 sklppy88 changed the title replace token note with int note refactor: replace token note with int note Aug 22, 2024
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch 3 times, most recently from a8e830b to 8dce58f Compare August 22, 2024 15:33
@AztecBot
Copy link
Collaborator

AztecBot commented Aug 22, 2024

Benchmark results

Metrics with a significant change:

  • protocol_circuit_simulation_time_in_ms (private-kernel-tail-to-public): 1,491 (+94%)
  • avm_simulation_time_ms (Token:mint_public): 468 (+856%)
  • avm_simulation_time_ms (Token:assert_minter_and_mint): 44.9 (-90%)
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_ms 5,755 1,581 (+1%) 715 760 (+3%) 775
proof_construction_time_sha256_30_ms 11,583 (+1%) 3,087 1,380 1,435 1,458 (-1%)
proof_construction_time_sha256_100_ms 44,071 11,813 5,466 5,374 (-1%) 6,010 (+3%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 59.0 (+2%) 87.0 (-1%)
proof_construction_time_poseidon_hash_30_ms 1,529 422 204 231 (+2%) 267 (-1%)
proof_construction_time_poseidon_hash_100_ms 5,651 1,521 (+1%) 680 731 744

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 4,356 7,876 14,884
l1_rollup_calldata_gas 50,292 92,922 178,120
l1_rollup_execution_gas 843,133 1,576,659 3,361,913
l2_block_processing_time_in_ms 256 453 (+2%) 836 (+2%)
l2_block_building_time_in_ms 11,306 (+1%) 22,051 (+1%) 44,231 (+1%)
l2_block_rollup_simulation_time_in_ms 11,305 (+1%) 22,051 (+1%) 44,231 (+1%)
l2_block_public_tx_process_time_in_ms 9,644 (+1%) 20,386 (+1%) 42,527 (+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 2,950 (-1%) 3,959 (+1%)
node_database_size_in_bytes 12,623,952 16,719,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 input_size_in_bytes output_size_in_bytes proving_time_in_ms
private-kernel-init 74.3 387 (+2%) 21,391 44,898 N/A
private-kernel-inner 153 (-4%) 689 (+2%) 72,372 45,020 N/A
private-kernel-reset-tiny 294 (-1%) 702 (+1%) 65,097 44,886 N/A
private-kernel-tail 160 (+1%) 133 (-1%) 50,608 52,921 N/A
base-parity 5.75 (+4%) N/A 160 96.0 N/A
root-parity 35.9 (+2%) N/A 73,948 96.0 N/A
base-rollup 2,980 (-4%) N/A 189,195 664 N/A
block-root-rollup 41.1 N/A 58,205 2,448 N/A
public-kernel-setup 81.9 N/A 105,085 71,222 N/A
public-kernel-app-logic 94.2 N/A 104,898 71,222 N/A
public-kernel-tail 843 (+1%) N/A 390,582 16,414 N/A
private-kernel-reset-small 292 (-1%) N/A 66,341 45,629 N/A
private-kernel-tail-to-public ⚠️ 1,491 (+94%) 592 453,751 1,825 N/A
public-kernel-teardown 80.7 (-1%) N/A 105,349 71,222 N/A
merge-rollup 20.0 (-1%) N/A 38,174 664 N/A
undefined N/A N/A N/A N/A 83,322 (-1%)

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms
ContractClassRegisterer:register 1,344 11,731 344
ContractInstanceDeployer:deploy 1,408 11,731 18.2 (+1%)
MultiCallEntrypoint:entrypoint 1,920 11,731 403 (+1%)
FeeJuice:deploy 1,376 11,731 390 (+1%)
SchnorrAccount:constructor 1,312 11,731 62.7 (+1%)
SchnorrAccount:entrypoint 2,336 11,731 370
FeeJuice:claim 1,344 11,731 34.5 (-4%)
Token:privately_mint_private_note 1,280 11,731 72.5 (-5%)
FPC:fee_entrypoint_public 1,344 11,731 24.6 (+2%)
Token:transfer 1,312 11,731 214
Benchmarking:create_note 1,344 11,731 74.2
SchnorrAccount:verify_private_authwit 1,280 11,731 26.7
Token:unshield 1,376 11,731 511 (+2%)
FPC:fee_entrypoint_private 1,376 11,731 672 (-3%)

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
FeeJuice:_increase_public_balance 48.5 (+7%) 2,431
FeeJuice:set_portal 13.1 (+1%) 2,930
Token:constructor 76.3 (+2%) 15,813
FPC:constructor 48.0 (-3%) 9,720
FeeJuice:check_balance 36.2 (-1%) 2,357
Token:mint_public ⚠️ 468 (+856%) 5,011
Token:assert_minter_and_mint ⚠️ 44.9 (-90%) 3,155
AuthRegistry:set_authorized 35.6 (-24%) 924
FPC:prepare_fee 70.9 (-7%) 4,245
Token:transfer_public 17.4 (-17%) 10,812
FPC:pay_refund 46.1 (+6%) 5,195
Benchmarking:increment_balance 1,204 (+1%) 3,496
Token:_increase_public_balance 39.5 (-1%) 2,408
FPC:pay_refund_with_shielded_rebate 51.6 (+2%) 5,195

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.150 (-3%)

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 2.19 (+1%) 3.90 (+2%) 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.114 (+1%) 0.110 (+2%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 11.2 (+1%) 17.6 (-1%) 30.3 (-3%) 60.0 (+2%) 113 (-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.107 (+1%) 0.103 (-1%) 0.0991 (-2%) 0.103 (+2%) 0.101 (-2%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 14.2 (-1%) 25.9 43.4 (-2%) 84.5 (+3%) 161 (-2%)
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 108 207 355 691 1,363
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.109 (-1%) 0.104 0.105 (-2%) 0.104 (+3%) 0.103 (-2%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 16.7 (+2%) N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A 132 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A 0.107 (+2%) 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 64,838 668,997

Transaction size based on fee payment method

| Metric | |
| - | |

@sklppy88 sklppy88 requested a review from nventuro August 22, 2024 20:33
@sklppy88 sklppy88 marked this pull request as ready for review August 22, 2024 20:33
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch from 353b842 to c5ba475 Compare August 27, 2024 16:04
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from 8dce58f to ebc0127 Compare August 27, 2024 16:04
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch from c5ba475 to ccd8079 Compare August 27, 2024 20:51
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from ebc0127 to 8c392e3 Compare August 27, 2024 20:51
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch from ccd8079 to 583b872 Compare August 28, 2024 06:34
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from 8c392e3 to ed35a2b Compare August 28, 2024 06:34
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch from 583b872 to 4e1422e Compare August 28, 2024 08:49
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from ed35a2b to 5e921f4 Compare August 28, 2024 08:50
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch from 4e1422e to 44e0527 Compare August 28, 2024 20:23
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch 3 times, most recently from 368acf0 to ae20529 Compare August 28, 2024 20:45
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch from 70259b8 to f083f74 Compare August 28, 2024 20:47
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from ae20529 to c92bc4d Compare August 28, 2024 20:47
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch from 3cdff8a to 3f0eb35 Compare August 31, 2024 13:54
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from cccd835 to 26e7db5 Compare August 31, 2024 13:54
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch from 3f0eb35 to a244a4a Compare September 3, 2024 02:36
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch 3 times, most recently from d5dbcb1 to 2e3b28f Compare September 3, 2024 04:54
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/adding-int-note branch 2 times, most recently from dc958a2 to d3fb39d Compare September 4, 2024 05:32
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from 2e3b28f to 9d889cc Compare September 4, 2024 05:32
Base automatically changed from ek/refactor/8107/adding-int-note to master September 6, 2024 21:41
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch 5 times, most recently from 159f51e to a2ea86a Compare September 23, 2024 11:45
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from a2ea86a to c7a7210 Compare September 26, 2024 05:32
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch 2 times, most recently from cb92053 to ff52a55 Compare October 8, 2024 16:21
Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

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

Fantastic thank you!

@@ -146,7 +146,7 @@ export class TokenContract extends ContractBase {
},
balances: {
slot: new Fr(3n),
typ: 'BalancesMap<TokenNote>',
typ: 'BalancesMap<UintNote>',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
typ: 'BalancesMap<UintNote>',
typ: 'BalancesMap',

Quite fragile that this exists in an md file regardless

@nventuro nventuro enabled auto-merge (squash) October 23, 2024 18:11
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from ff52a55 to 34e1f34 Compare October 27, 2024 03:27
@sklppy88 sklppy88 added the e2e-all CI: Enables this CI job. label Oct 27, 2024
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from 34e1f34 to b42f95b Compare October 27, 2024 17:11
@sklppy88 sklppy88 force-pushed the ek/refactor/8107/replacing-token-note-with-int-note branch from b42f95b to 1540c8e Compare October 27, 2024 17:12
@nventuro nventuro merged commit 493a3f3 into master Oct 27, 2024
98 checks passed
@nventuro nventuro deleted the ek/refactor/8107/replacing-token-note-with-int-note branch October 27, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e-all CI: Enables this CI job.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch BalancesMap to use ValueNote instead of TokenNote
3 participants