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: make public data update requests, note hashes, and unencrypted logs readonly in TS #6658

Merged
merged 9 commits into from
May 29, 2024

Conversation

just-mitch
Copy link
Contributor

@just-mitch just-mitch commented May 24, 2024

Continue making fields in TS readonly.

We do so by forcing side effect counters to be set in public, and then waiting until public kernel tail to:

  • recombine the non/revertible side effects and get hints (in TS)
  • provide the hints to the public kernel tail
  • using the hints in the public kernel tail while recombining to sort the public data update requests

@AztecBot
Copy link
Collaborator

AztecBot commented May 24, 2024

Benchmark results

Metrics with a significant change:

  • app_circuit_proving_time_in_ms (Token:transfer): 45,892 (-24%)
  • protocol_circuit_proving_time_in_ms (private-kernel-tail-to-public): 84,322 (-20%)
  • protocol_circuit_proving_time_in_ms (private-kernel-tail): 35,922 (-19%)
  • protocol_circuit_proving_time_in_ms (root-rollup): 19,623 (-16%)
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,663 (-2%) 1,550 (-1%) 707 (-2%) 762 (-4%) 771 (-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 1,412 1,412 1,412
l1_rollup_calldata_gas 9,464 9,476 9,476
l1_rollup_execution_gas 616,105 616,117 616,117
l2_block_processing_time_in_ms 1,284 4,813 (+2%) 9,591 (+1%)
l2_block_building_time_in_ms 47,312 (+7%) 187,842 (+7%) 374,627 (+8%)
l2_block_rollup_simulation_time_in_ms 47,141 (+7%) 187,198 (+7%) 373,354 (+8%)
l2_block_public_tx_process_time_in_ms 25,865 (+12%) 105,498 (+6%) 215,258 (+7%)

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 9,461 (+2%) 14,503 (+2%)
node_database_size_in_bytes 14,454,864 21,352,528
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 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 164 (+4%) 3,714 (+7%) 22,489 (-12%) 20,630 64,614 89,536 2,731 1,048,576
private-kernel-inner 626 (+2%) 4,373 (+9%) 46,379 (-10%) 92,318 64,614 89,536 2,731 2,097,152
private-kernel-tail 570 (+1%) 2,918 (+7%) ⚠️ 35,922 (-19%) 96,541 77,732 11,648 (+9%) 297 (+12%) 2,097,152
base-parity 6.53 (+3%) 1,232 (+12%) 2,884 (+3%) 128 64.0 2,208 2.00 131,072
root-parity 49.8 (+2%) 63.3 (-2%) 44,185 (-13%) 27,084 64.0 2,720 18.0 2,097,152
base-rollup 801 (+5%) 2,388 (+6%) 74,479 (-15%) 119,734 756 3,648 47.0 4,194,304
root-rollup 115 (+6%) 68.6 (-10%) ⚠️ 19,623 (-16%) 25,297 620 3,456 41.0 1,048,576
public-kernel-app-logic 532 (+3%) 3,010 (+5%) 48,007 (-6%) 105,253 86,550 116,768 (+2%) 3,582 (+2%) 2,097,152
public-kernel-tail 1,229 (+15%) 25,016 (+8%) 152,190 (-15%) 401,002 (+1%) 7,646 (+2%) 11,648 (+9%) 297 (+12%) 8,388,608
private-kernel-reset-small 594 (+2%) 2,222 (-6%) 45,401 (-10%) 120,733 64,614 89,536 2,731 2,097,152
merge-rollup 28.8 (+1%) N/A N/A 16,534 756 N/A N/A N/A
public-kernel-setup 634 (+2%) N/A N/A 105,253 86,550 N/A N/A N/A
public-kernel-teardown 536 (+1%) N/A N/A 105,253 86,550 N/A N/A N/A
private-kernel-tail-to-public N/A 8,545 (+4%) ⚠️ 84,322 (-20%) N/A N/A 116,768 (+2%) 3,582 (+2%) 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 466 (+1%) N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 42.1 (+3%) N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,479 (+6%) N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,033 (+8%) N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,158 (+5%) 16,768 46,477 (-14%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,177 (+10%) N/A N/A N/A N/A
Token:transfer 1,376 9,944 4,136 (+6%) 16,768 ⚠️ 45,892 (-24%) 2,097,152 457
Benchmarking:create_note 1,312 9,944 1,004 (+7%) N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 234 (+5%) N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 77.5 (-9%) N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,277 (+2%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,070 (+2%) N/A N/A N/A N/A

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 10.5 (+2%) 17.0 (+2%) 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.609 (+2%) 0.522 (+2%) 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 48.7 (+2%) 76.2 247 (-1%) 476 (+2%) 933 (+3%) 1,853 (+1%) 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.498 (+2%) 0.470 0.448 (-1%) 0.444 (+2%) 0.442 (+3%) 0.442 (+1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.3 (+1%) 113 (+2%) 357 (+1%) 700 (+2%) 1,390 (+3%) 2,773 (+3%) 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.504 (+1%) 0.507 (+2%) 0.482 (+1%) 0.480 (+2%) 0.480 (+3%) 0.481 (+3%) 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 62.7 (+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 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.556 (+2%)

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 84,050 665,267

Transaction size based on fee payment method

| Metric | |
| - | |

@just-mitch just-mitch force-pushed the order-enqueued-public-calls-in-circuits branch 2 times, most recently from 0ec371d to 36f0823 Compare May 24, 2024 21:43
@just-mitch just-mitch force-pushed the no-patching-of-public-data-update-requests branch from 188641c to 666259c Compare May 27, 2024 09:36
Base automatically changed from order-enqueued-public-calls-in-circuits to master May 27, 2024 10:24
@just-mitch just-mitch force-pushed the no-patching-of-public-data-update-requests branch from 666259c to 6380883 Compare May 27, 2024 11:32
@just-mitch just-mitch force-pushed the no-patching-of-public-data-update-requests branch from 6380883 to f779eda Compare May 27, 2024 11:33
Copy link
Contributor

github-actions bot commented May 27, 2024

Changes to circuit sizes

Generated at commit: a00bb1f409458fb1b8ef00c3f65951e993e26b44, compared to commit: 8d1788de43c41929ce131c3dbd4687ce555e48bc

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail_simulated 0 ➖ 0.00% +31 ❌ +12.16%
public_kernel_tail_simulated 0 ➖ 0.00% +31 ❌ +12.16%
public_kernel_tail +52,166 ❌ +5.49% +93,737 ❌ +2.13%
public_kernel_setup +6,747 ❌ +3.06% +27,604 ❌ +1.81%
private_kernel_tail_to_public_simulated 0 ➖ 0.00% +62 ❌ +1.77%
public_kernel_app_logic_simulated 0 ➖ 0.00% +62 ❌ +1.77%
public_kernel_setup_simulated 0 ➖ 0.00% +62 ❌ +1.77%
public_kernel_teardown_simulated 0 ➖ 0.00% +62 ❌ +1.77%
public_kernel_app_logic +1,845 ❌ +0.72% +27,186 ❌ +1.64%
public_kernel_teardown +1,848 ❌ +0.72% +27,189 ❌ +1.64%
rollup_base +14,342 ❌ +7.78% +27,218 ❌ +1.28%
private_kernel_reset_small +7,128 ❌ +5.43% +7,128 ❌ +0.67%
private_kernel_reset_medium +8,488 ❌ +5.77% +8,488 ❌ +0.66%
private_kernel_reset_big +11,208 ❌ +6.27% +11,208 ❌ +0.66%
private_kernel_reset +16,648 ❌ +6.88% +16,648 ❌ +0.65%
private_kernel_tail_to_public +6,404 ❌ +1.12% +6,466 ❌ +0.30%
private_kernel_init +2,011 ❌ +0.87% +2,011 ❌ +0.23%
private_kernel_inner +2,151 ❌ +0.81% +2,151 ❌ +0.12%
private_kernel_tail +1,529 ❌ +0.77% +1,560 ❌ +0.11%
rollup_root +164 ❌ +7.65% +164 ❌ +0.02%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail_simulated 1 (0) 0.00% 286 (+31) +12.16%
public_kernel_tail_simulated 1 (0) 0.00% 286 (+31) +12.16%
public_kernel_tail 1,002,100 (+52,166) +5.49% 4,491,026 (+93,737) +2.13%
public_kernel_setup 227,367 (+6,747) +3.06% 1,551,985 (+27,604) +1.81%
private_kernel_tail_to_public_simulated 1 (0) 0.00% 3,571 (+62) +1.77%
public_kernel_app_logic_simulated 1 (0) 0.00% 3,571 (+62) +1.77%
public_kernel_setup_simulated 1 (0) 0.00% 3,571 (+62) +1.77%
public_kernel_teardown_simulated 1 (0) 0.00% 3,571 (+62) +1.77%
public_kernel_app_logic 258,652 (+1,845) +0.72% 1,689,477 (+27,186) +1.64%
public_kernel_teardown 259,012 (+1,848) +0.72% 1,689,878 (+27,189) +1.64%
rollup_base 198,779 (+14,342) +7.78% 2,150,533 (+27,218) +1.28%
private_kernel_reset_small 138,518 (+7,128) +5.43% 1,075,808 (+7,128) +0.67%
private_kernel_reset_medium 155,675 (+8,488) +5.77% 1,288,223 (+8,488) +0.66%
private_kernel_reset_big 189,987 (+11,208) +6.27% 1,713,051 (+11,208) +0.66%
private_kernel_reset 258,614 (+16,648) +6.88% 2,562,710 (+16,648) +0.65%
private_kernel_tail_to_public 576,220 (+6,404) +1.12% 2,184,224 (+6,466) +0.30%
private_kernel_init 233,188 (+2,011) +0.87% 867,504 (+2,011) +0.23%
private_kernel_inner 268,093 (+2,151) +0.81% 1,785,363 (+2,151) +0.12%
private_kernel_tail 201,320 (+1,529) +0.77% 1,466,706 (+1,560) +0.11%
rollup_root 2,309 (+164) +7.65% 910,945 (+164) +0.02%

@just-mitch just-mitch marked this pull request as ready for review May 28, 2024 08:34
Copy link
Contributor

@alexghr alexghr left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -138,7 +138,6 @@ export class AvmPersistableStateManager {
* @param value - the value being written to the slot
*/
public writeStorage(storageAddress: Fr, slot: Fr, value: Fr) {
this.log.debug(`Storage write (address=${storageAddress}, slot=${slot}): value=${value}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mistake. Will add back.

@just-mitch just-mitch changed the title chore: make public data update requests readonly in TS chore: make public data update requests and note hashes readonly in TS May 28, 2024
@just-mitch just-mitch changed the title chore: make public data update requests and note hashes readonly in TS chore: make public data update requests, note hashes, and unencrypted logs readonly in TS May 28, 2024
@@ -273,7 +273,7 @@ impl BaseRollupInputs {
);

let new_value = compute_public_data_tree_value(existing_update.new_value - tx_fee);
let protocol_update_request = PublicDataUpdateRequest { leaf_slot, new_value };
let protocol_update_request = PublicDataUpdateRequest { leaf_slot, new_value, counter: 0 };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's probably worth a comment in the code, but by the time we're in the base rollup, we don't care about the counters, which is why we arbitrarily set it to 0.

@@ -548,23 +548,32 @@ mod tests {
}

#[test]
unconstrained fn correctly_updates_revert_code() {
unconstrained fn correctly_updates_revert_code_0() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed to split this into multiple tests because I was getting a panic on "stack too deep".

@@ -292,13 +300,52 @@ mod tests {
let mut previous_kernel = self.previous_kernel.to_public_kernel_data(false);
previous_kernel.public_inputs.end = self.previous_revertible.to_public_accumulated_data();

// Note: note hashes are a bit odd here: whereas we'd like to use `combined` and then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Dead comment. I will remove in the next PR.

Copy link
Contributor

@LeilaWang LeilaWang left a comment

Choose a reason for hiding this comment

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

🚀

@just-mitch just-mitch merged commit 1230e56 into master May 29, 2024
85 checks passed
@just-mitch just-mitch deleted the no-patching-of-public-data-update-requests branch May 29, 2024 08:44
TomAFrench added a commit that referenced this pull request May 29, 2024
* master:
  feat: prepare circuit output for validation (#6678)
  chore: stop building/publishing `acvm_backend.wasm` (#6584)
  chore: add bench programs (#6566)
  chore: make public data update requests, note hashes, and unencrypted logs readonly in TS (#6658)
  git subrepo push --branch=master noir-projects/aztec-nr
  git_subrepo.sh: Fix parent in .gitrepo file. [skip ci]
  chore: replace relative paths to noir-protocol-circuits
  git subrepo push --branch=master barretenberg
  feat: update honk recursion constraint (#6545)
  feat: Add code-workspace and update build dirs (#6723)
  feat: Sync from noir (#6717)
  feat: folding acir programs (#6685)
  feat: sumcheck part of ECCVM recursive verifier instantiated as an UltraCircuit (#6413)
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.

4 participants