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

feat!: automatic NoteInterface and NoteGetterOptions auto select #4508

Merged
merged 57 commits into from
Mar 19, 2024

Conversation

Thunkar
Copy link
Contributor

@Thunkar Thunkar commented Feb 8, 2024

Partially addresses: #4519 (moved autogeneration to the macro, even if not incremental)
Closes: #3011

Added the #[aztec(note)] attribute, which automatically implements most of the NoteInterface trait in a struct marked as such, plus several utilities. Even if this adds a fair share of "magic" to the note implementation logic, it is structured in a way that it's hopefully easy to follow, including meaningful errors attached to the correct span during the process.

Screenshot 2024-03-14 at 14 59 07

Hey you! Implement the trait!

Screenshot 2024-03-14 at 14 46 39
But only the meat and potatoes though.

As long as the user doesn't want to do any custom stuff, get_header, set_header, compute_note_content_hash, get_note_type_id, serialize_content and deserialize_content get automatically implemented. Any combination of them can be overridden by the developer though.

A metadata struct is also added, which takes the following form:

struct CardNote {
    points: FieldSelector,
    randomness: FieldSelector,
    owner: FieldSelector,
}

This is used to implement a properties() function, which in turn can be used in conjunction with the NoteGetterOptions.select and .sort

Screenshot 2024-03-18 at 15 27 27

@AztecBot
Copy link
Collaborator

AztecBot commented Feb 8, 2024

Benchmark results

Metrics with a significant change:

  • note_trial_decrypting_time_in_ms (8): 75.9 (+419%)
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.

Values are compared against data from master at commit c0a1abf3 and shown if the difference exceeds 1%.

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 8 txs 32 txs 64 txs
l1_rollup_calldata_size_in_bytes 5,668 18,820 36,356
l1_rollup_calldata_gas 66,436 239,200 469,772
l1_rollup_execution_gas 647,534 929,558 1,305,952
l2_block_processing_time_in_ms 1,320 (-12%) 4,942 (+5%) 9,384 (+3%)
note_successful_decrypting_time_in_ms 175 (-16%) 532 (+1%) 1,013 (+3%)
note_trial_decrypting_time_in_ms ⚠️ 75.9 (+419%) 52.8 (+12%) 37.0 (-68%)
l2_block_building_time_in_ms 18,407 (+1%) 69,667 (+2%) 138,425 (+1%)
l2_block_rollup_simulation_time_in_ms 8,046 (-1%) 28,617 56,393 (-1%)
l2_block_public_tx_process_time_in_ms 10,340 (+3%) 40,995 (+3%) 81,934 (+3%)

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 16 txs.

Metric 5 blocks 10 blocks
node_history_sync_time_in_ms 15,660 (+4%) 24,450 (-11%)
note_history_successful_decrypting_time_in_ms 1,201 (-1%) 2,426 (-1%)
note_history_trial_decrypting_time_in_ms 61.5 (-5%) 147 (-5%)
node_database_size_in_bytes 19,091,536 35,676,240
pxe_database_size_in_bytes 29,859 59,414

Circuits stats

Stats on running time and I/O sizes collected for every circuit run across all benchmarks.

Circuit circuit_simulation_time_in_ms circuit_input_size_in_bytes circuit_output_size_in_bytes
private-kernel-init 283 (-1%) 44,366 28,244
private-kernel-ordering 217 (+1%) 52,868 14,326
base-parity 1,797 (-1%) 128 311
base-rollup 716 165,787 925
root-parity 1,567 (-1%) 1,244 311
root-rollup 63.2 4,487 789
private-kernel-inner 656 (+2%) 73,771 28,244
public-kernel-app-logic 454 (+2%) 35,260 28,215
public-kernel-tail 175 (+1%) 40,926 28,215
merge-rollup 8.30 2,696 925

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 512 leaves 1024 leaves 2048 leaves 4096 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 9.95 (-1%) 15.9 (-1%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.6 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.581 (-1%) 0.492 (-1%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 47.6 (+4%) 72.0 (-1%) 229 (-1%) 442 880 (+1%) 1,713 (-1%) N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 96.0 159 543 1,055 2,079 4,127 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.489 (+4%) 0.445 (-1%) 0.419 (-1%) 0.414 0.418 (+1%) 0.411 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 54.2 (+1%) 107 336 (-1%) 657 1,302 (-1%) 2,601 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 104 207 691 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.483 (+1%) 0.483 (+1%) 0.458 0.453 0.451 (-1%) 0.454 N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A N/A 61.2
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A N/A 109
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A N/A 0.536

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes
tx_size_in_bytes 22,012

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes
tx_pxe_processing_time_ms 3,320 (+3%) 1,761
Metric 0 public data writes 1 public data writes
tx_sequencer_processing_time_ms 10.5 (-11%) 1,261 (+2%)

noir/noir-repo/aztec_macros/src/lib.rs Outdated Show resolved Hide resolved
noir/noir-repo/aztec_macros/src/lib.rs Outdated Show resolved Hide resolved
@Thunkar Thunkar force-pushed the gj/notegetteroptions_auto_select branch from 72cfa76 to 4049d99 Compare March 11, 2024 10:52
@Thunkar Thunkar changed the base branch from master to gj/aztec-macros-refactor March 11, 2024 10:53
Base automatically changed from gj/aztec-macros-refactor to master March 11, 2024 15:52
Thunkar added 2 commits March 19, 2024 06:52
…otocol/aztec-packages into gj/notegetteroptions_auto_select
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-aztec.nr Component: Aztec smart contract framework
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

feat(AztecMacro): Autogenerate constants for struct field slots for better note-getter options
6 participants