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: extract tx validation to separate class #5266

Merged

Conversation

alexghr
Copy link
Contributor

@alexghr alexghr commented Mar 16, 2024

Refactor tx validation the sequencer did to a separate class so it's easier to extend.

Copy link
Contributor Author

alexghr commented Mar 16, 2024

@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from c95af69 to 61d4bef Compare March 16, 2024 19:29
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from d49662f to 8ef4d64 Compare March 16, 2024 19:30
@AztecBot
Copy link
Collaborator

AztecBot commented Mar 16, 2024

Benchmark results

Metrics with a significant change:

  • note_trial_decrypting_time_in_ms (8): 91.5 (+114%)
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 640c89a0 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,424 239,092 468,968
l1_rollup_execution_gas 647,522 929,450 1,305,148
l2_block_processing_time_in_ms 1,356 (+2%) 4,839 (+2%) 8,936 (-2%)
note_successful_decrypting_time_in_ms 187 (-21%) 567 (+3%) 1,012 (-1%)
note_trial_decrypting_time_in_ms ⚠️ 91.5 (+114%) 83.9 (+17%) 38.8 (-31%)
l2_block_building_time_in_ms 18,279 (-2%) 68,408 (-2%) 135,403 (-2%)
l2_block_rollup_simulation_time_in_ms 8,258 28,716 (-1%) 56,200 (-2%)
l2_block_public_tx_process_time_in_ms 10,001 (-4%) 39,641 (-2%) 79,115 (-2%)

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 14,176 27,206
note_history_successful_decrypting_time_in_ms 1,229 (-2%) 2,421 (-6%)
note_history_trial_decrypting_time_in_ms 57.6 (-42%) 118 (-8%)
node_database_size_in_bytes 18,681,936 35,029,072
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 282 44,366 28,244
private-kernel-ordering 214 (-2%) 52,868 14,326
base-parity 1,801 (-3%) 128 311
base-rollup 719 (-1%) 165,787 925
root-parity 1,599 (+2%) 1,244 311
root-rollup 51.6 (-1%) 4,487 725
private-kernel-inner 645 (-1%) 73,771 28,244
public-kernel-app-logic 447 (-1%) 35,260 28,215
public-kernel-tail 173 (-1%) 40,926 28,215
merge-rollup 8.31 (-1%) 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.580 (-1%) 0.494 (-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 45.6 71.8 (-2%) 230 (-2%) 442 (-1%) 875 (-1%) 1,718 (-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.468 0.443 (-1%) 0.420 (-1%) 0.414 (-1%) 0.415 (-1%) 0.412 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 53.5 (-1%) 106 (-3%) 337 (-1%) 656 (-1%) 1,307 (-1%) 2,605 (-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.477 0.480 (-1%) 0.458 0.452 (-1%) 0.452 (-1%) 0.453 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 60.9 (-1%)
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.532 (-1%)

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,218 (-4%) 1,754 (-1%)
Metric 0 public data writes 1 public data writes
tx_sequencer_processing_time_ms 10.9 (+2%) 1,245 (-1%)

@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from 61d4bef to e044688 Compare March 17, 2024 18:34
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from 8ef4d64 to a2eba26 Compare March 17, 2024 18:34
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from e044688 to 0b94879 Compare March 17, 2024 22:10
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from a2eba26 to 6427a18 Compare March 17, 2024 22:10
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from 0b94879 to a26f1a0 Compare March 17, 2024 22:39
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from 6427a18 to aabacb5 Compare March 17, 2024 22:39
@alexghr alexghr marked this pull request as ready for review March 18, 2024 07:15
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from a26f1a0 to b06c08c Compare March 18, 2024 07:18
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from aabacb5 to b92b276 Compare March 18, 2024 07:18
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from b06c08c to 2b2e931 Compare March 18, 2024 14:22
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from b92b276 to 84faea1 Compare March 18, 2024 14:22
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from 2b2e931 to 80b3bac Compare March 18, 2024 15:07
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from 84faea1 to fd2f15f Compare March 18, 2024 15:07
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from 80b3bac to b8c6299 Compare March 18, 2024 15:40
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from fd2f15f to 95e524a Compare March 18, 2024 15:40
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from b8c6299 to 12101f5 Compare March 18, 2024 15:50
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from 95e524a to 39c4539 Compare March 18, 2024 15:50
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from 12101f5 to 52db87e Compare March 19, 2024 08:49
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from 39c4539 to b208811 Compare March 19, 2024 08:49
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from 52db87e to aa5e662 Compare March 19, 2024 10:19
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from b208811 to 727100f Compare March 19, 2024 10:19
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from aa5e662 to 5b64cf1 Compare March 19, 2024 10:40
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from 727100f to e72aed1 Compare March 19, 2024 10:40
@alexghr alexghr force-pushed the alexg/feat/gas-token-portal-address branch from 5b64cf1 to 3216d40 Compare March 19, 2024 11:35
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from e72aed1 to 80390a1 Compare March 19, 2024 11:35
Base automatically changed from alexg/feat/gas-token-portal-address to master March 19, 2024 12:11
@alexghr alexghr force-pushed the 03-16-refactor_extract_tx_validation_to_separate_class branch from 80390a1 to 9db8e44 Compare March 19, 2024 12:12
Copy link
Contributor

Changes to circuit sizes

Generated at commit: 75fdd85cbc4e94e366ea5ffd8f78873cc997a2e6, compared to commit: acffa7b4d41496dea0d16fd94ab98a1a977d14a8

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
rollup_root -1,098 ✅ -50.14% -26,213 ✅ -25.18%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
rollup_root 1,092 (-1,098) -50.14% 77,898 (-26,213) -25.18%

@alexghr alexghr merged commit ba9bc4c into master Mar 19, 2024
98 of 100 checks passed
@alexghr alexghr deleted the 03-16-refactor_extract_tx_validation_to_separate_class branch March 19, 2024 13:21
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