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: introduce initialize_or_replace #6519

Merged
merged 7 commits into from
May 23, 2024
Merged

Conversation

nventuro
Copy link
Contributor

This fixes the issue described in these comments, which highlighted that PrivateMutable was providing a poor API as it forced users to call unconstrained functions and leave correctness up to them. This is a simple replacement to make #6442 cleaner and help guide future development, but it should only be considered a patch - we'll eventually do a more thoughtful complete pass over the entire API to bring coherency to it.

I tried adding tests for this (I wanted to test that regardless what the return value of the nullifier check oracle was, either an inclusion proof or a new nullifier would be included in the context), but this proved to be very hard because notes are sent to the oracle as raw fields in a custom packed format which oracle::get_notes decodes on the spot. We'd need to have that be a separate library, but that exceeds the scope of this PR.

@AztecProtocol AztecProtocol deleted a comment from github-actions bot May 17, 2024
@AztecBot
Copy link
Collaborator

AztecBot commented May 23, 2024

Benchmark results

No metrics with a significant change found.

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 5,704 1,548 (-1%) 715 777 (+2%) 776

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 1,412 1,412 1,412
l1_rollup_calldata_gas 9,464 9,428 (-1%) 9,464
l1_rollup_execution_gas 616,105 616,069 616,105
l2_block_processing_time_in_ms 1,322 (-5%) 5,114 (-1%) 10,114 (-1%)
l2_block_building_time_in_ms 45,289 (-4%) 179,325 (-4%) 371,918
l2_block_rollup_simulation_time_in_ms 45,120 (-4%) 178,706 (-4%) 370,668
l2_block_public_tx_process_time_in_ms 24,235 (-4%) 100,829 (-4%) 215,413 (+1%)

L2 chain processing

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

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 10,015 (+1%) 15,303 (+1%)
node_database_size_in_bytes 14,463,056 21,348,432
pxe_database_size_in_bytes 18,071 29,868

Circuits stats

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

Circuit protocol_circuit_simulation_time_in_ms protocol_circuit_witness_generation_time_in_ms protocol_circuit_proving_time_in_ms protocol_circuit_input_size_in_bytes protocol_circuit_output_size_in_bytes protocol_circuit_proof_size_in_bytes protocol_circuit_num_public_inputs protocol_circuit_size_in_gates
private-kernel-init 158 (-1%) 3,648 22,153 19,990 61,798 86,720 2,643 1,048,576
private-kernel-inner 600 (-1%) 4,208 47,671 (-2%) 88,862 61,798 86,720 2,643 2,097,152
private-kernel-tail 526 (-1%) 3,007 (+6%) 35,343 86,653 76,438 10,624 265 2,097,152
base-parity 6.48 (-1%) 1,223 2,898 (-1%) 128 64.0 2,208 2.00 131,072
root-parity 49.2 (-1%) 48.6 (-12%) 44,071 (+1%) 27,084 64.0 2,720 18.0 2,097,152
base-rollup 777 2,293 (-1%) 74,271 119,578 756 3,648 47.0 4,194,304
root-rollup 114 63.5 (-6%) 19,258 (-1%) 25,297 620 3,456 41.0 1,048,576
public-kernel-app-logic 521 2,846 47,322 103,405 84,766 116,832 3,584 2,097,152
public-kernel-tail 1,181 (-1%) 25,509 (+2%) 156,893 (+2%) 393,850 7,490 10,624 265 8,388,608
private-kernel-reset-small 579 2,182 (-4%) 27,027 (+8%) 118,173 61,798 86,720 2,643 1,048,576
merge-rollup 28.6 (-1%) N/A N/A 16,534 756 N/A N/A N/A
public-kernel-setup 624 N/A N/A 103,405 84,766 N/A N/A N/A
public-kernel-teardown 527 (-1%) N/A N/A 103,405 84,766 N/A N/A N/A
private-kernel-tail-to-public N/A 9,584 (+1%) 83,598 (+2%) N/A N/A 116,832 3,584 4,194,304

Stats on running time collected for app circuits

Function app_circuit_proof_size_in_bytes app_circuit_proving_time_in_ms app_circuit_size_in_gates app_circuit_num_public_inputs
SchnorrAccount:entrypoint 16,128 46,102 2,097,152 437
Token:transfer 16,128 46,141 (+7%) 2,097,152 437

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 11.3 18.4 (-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.7 31.8 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.657 0.566 (-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 52.9 80.5 (-1%) 256 (-3%) 504 991 1,960 N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 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.541 0.496 (-1%) 0.465 (-3%) 0.471 0.470 0.468 N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 62.3 (-1%) 119 367 (-4%) 743 1,498 (+1%) 2,937 N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 106 208 692 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.540 (-1%) 0.534 0.498 (-4%) 0.511 0.511 0.511 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 66.7
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 107
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.592

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 82,705 664,768

Transaction size based on fee payment method

| Metric | |
| - | |

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes 2 new note hashes
tx_pxe_processing_time_ms 11,598 (+4%) 4,193 (-1%) 70,017
Metric 1 public data writes 2 public data writes 3 public data writes 4 public data writes 8 public data writes
tx_sequencer_processing_time_ms 3,190 2,108 (-2%) 6,038 2,294 2,587

@nventuro nventuro enabled auto-merge (squash) May 23, 2024 19:18
@nventuro nventuro merged commit b59cd4c into master May 23, 2024
77 of 78 checks passed
@nventuro nventuro deleted the nv/immut-init-or-replace branch May 23, 2024 19:53
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.

3 participants