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: sort public call requests in the circuits #6650

Merged
merged 5 commits into from
May 27, 2024

Conversation

just-mitch
Copy link
Collaborator

This removes some patching we were doing in TS around the public call stack items.

Now, we follow the existing pattern to sort public call stack items in TS, then assert the sort in the circuit.

The only difference is that call stack items need a reverse sort, so the one with the lowest side effect counter is last (and so is run first).

Also, started making circuit types in TS readonly.

@just-mitch just-mitch requested a review from LeilaWang May 23, 2024 19:34
Copy link
Contributor

github-actions bot commented May 23, 2024

Changes to circuit sizes

Generated at commit: 77a66e5e883a6b2fe317bedeb8f6f7b05b371497, compared to commit: fbe9fc125caef5aeb4db16139cb6ddba420f1a62

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail_to_public +4,086 ❌ +0.71% +5,197 ❌ +0.24%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_tail_to_public 576,158 (+4,086) +0.71% 2,168,083 (+5,197) +0.24%

@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,721 1,547 711 782 785

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,440 9,476 9,476
l1_rollup_execution_gas 616,081 616,117 616,117
l2_block_processing_time_in_ms 1,286 4,788 9,490 (-2%)
l2_block_building_time_in_ms 46,941 (-1%) 185,463 (-1%) 370,687 (-1%)
l2_block_rollup_simulation_time_in_ms 46,773 (-1%) 184,824 (-1%) 369,438 (-1%)
l2_block_public_tx_process_time_in_ms 24,945 (-1%) 104,076 212,947 (-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 9,486 (-1%) 14,447 (-1%)
node_database_size_in_bytes 14,483,536 21,356,624
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 165 3,546 (+1%) 24,538 (-1%) 20,630 64,614 89,536 2,731 1,048,576
private-kernel-inner 626 4,110 (+1%) 50,805 (-6%) 92,318 64,614 89,536 2,731 2,097,152
private-kernel-tail 572 (+4%) 2,779 (+1%) 41,152 (-4%) 96,541 (+7%) 77,498 10,656 266 2,097,152
base-parity 6.42 1,180 (-7%) 2,787 128 64.0 2,208 2.00 131,072
root-parity 49.0 (-1%) 64.9 (-1%) 52,047 (+5%) 27,084 64.0 2,720 18.0 2,097,152
base-rollup 763 (-1%) 2,391 (-3%) 84,274 (-2%) 119,610 756 3,648 47.0 4,194,304
root-rollup 113 76.3 (+1%) 22,571 (-2%) 25,297 620 3,456 41.0 1,048,576
public-kernel-app-logic 522 (-1%) 2,862 (-2%) 50,461 (-4%) 104,941 86,302 114,784 3,520 2,097,152
public-kernel-tail 1,188 (-1%) 25,014 (+1%) 183,757 (-2%) 395,386 7,522 10,656 266 8,388,608
private-kernel-reset-small 597 (+1%) 2,321 (+14%) 49,602 (+2%) 120,733 64,614 89,536 2,731 2,097,152
merge-rollup 28.7 (-1%) N/A N/A 16,534 756 N/A N/A N/A
public-kernel-setup 628 (-2%) N/A N/A 104,941 86,302 N/A N/A N/A
public-kernel-teardown 538 N/A N/A 104,941 86,302 N/A N/A N/A
private-kernel-tail-to-public N/A 8,255 (+1%) 93,731 (-2%) N/A N/A 114,784 3,520 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 464 N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 41.4 (-1%) N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,441 N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,007 N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,120 16,768 51,442 (+2%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,127 N/A N/A N/A N/A
Token:transfer 1,376 9,944 4,052 (-1%) 16,768 49,720 (-11%) 2,097,152 457
Benchmarking:create_note 1,312 9,944 983 N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 228 (-1%) N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 77.2 (-1%) N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,282 (-1%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,064 (-1%) 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.4 (-1%) 16.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.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.602 (-1%) 0.517 (-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 48.3 (-1%) 76.2 245 475 929 1,838 (-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.494 (-1%) 0.470 0.446 0.443 0.440 0.439 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.2 112 (-1%) 356 699 1,383 2,755 (-1%) 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 0.504 0.481 0.480 0.478 0.478 (-1%) 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.3
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.553

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 83,794 665,117

Transaction size based on fee payment method

| Metric | |
| - | |

@just-mitch just-mitch force-pushed the order-enqueued-public-calls-in-circuits branch from 27cff65 to 590e14f Compare May 24, 2024 18:44
@ludamad
Copy link
Collaborator

ludamad commented May 24, 2024

Merging as necessary CI files got in

@just-mitch just-mitch force-pushed the order-enqueued-public-calls-in-circuits branch from 0ec371d to 36f0823 Compare May 24, 2024 21:43
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! 💪

@@ -58,7 +58,7 @@ export class PublicAccumulatedData {
/**
* Current public call stack.
*/
public publicCallStack: Tuple<CallRequest, typeof MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX>,
public readonly publicCallStack: Tuple<CallRequest, typeof MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX>,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great! In the future we might also want to consider using Readonly* types (e.g. ReadonlyArray, ReadonlyMap) to prevent internal modifications

@just-mitch just-mitch merged commit f67d6f3 into master May 27, 2024
84 checks passed
@just-mitch just-mitch deleted the order-enqueued-public-calls-in-circuits branch May 27, 2024 10:24
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