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: l1 l2 messages cleanup #5270

Merged
merged 13 commits into from
Mar 19, 2024
Merged

Conversation

benesjan
Copy link
Contributor

Fixes #5264

Copy link
Contributor Author

benesjan commented Mar 17, 2024

@benesjan benesjan force-pushed the 03-17-refactor_l1_l2_messages_cleanup branch 3 times, most recently from 049b931 to ee492ca Compare March 17, 2024 18:03
@benesjan benesjan force-pushed the 03-17-refactor_l1_l2_messages_cleanup branch from 1e18fc6 to aff6f38 Compare March 17, 2024 18:33
@benesjan benesjan marked this pull request as ready for review March 18, 2024 09:44
Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

I think the issues are related to the empty tree values. Seems like it is the tests that need the message boxes, and some of the cleanup here have broken it 🤔

yarn-project/circuit-types/src/interfaces/block_number.ts Outdated Show resolved Hide resolved
yarn-project/circuit-types/src/messaging/inbox_leaf.ts Outdated Show resolved Hide resolved
yarn-project/circuit-types/src/messaging/l1_actor.ts Outdated Show resolved Hide resolved
@benesjan benesjan force-pushed the 03-17-refactor_l1_l2_messages_cleanup branch 2 times, most recently from 047f11c to ecae75d Compare March 18, 2024 11:28
Base automatically changed from 03-14-refactor_old_inbox_purge to master March 18, 2024 11:49
@benesjan benesjan force-pushed the 03-17-refactor_l1_l2_messages_cleanup branch from ecae75d to 93ac685 Compare March 18, 2024 11:56
@benesjan benesjan changed the base branch from master to 03-17-refactor_removing_redundant_receipts_check March 18, 2024 11:57
@benesjan benesjan force-pushed the 03-17-refactor_l1_l2_messages_cleanup branch from 93ac685 to e5157b3 Compare March 18, 2024 11:57
Base automatically changed from 03-17-refactor_removing_redundant_receipts_check to master March 18, 2024 12:32
@benesjan benesjan force-pushed the 03-17-refactor_l1_l2_messages_cleanup branch 6 times, most recently from df3f298 to 4d3722f Compare March 19, 2024 07:52
@benesjan benesjan force-pushed the 03-17-refactor_l1_l2_messages_cleanup branch from 5fc9687 to e779f92 Compare March 19, 2024 10:36
*/
nextEthBlockNumber: bigint;
lastProcessedL1BlockNumber: bigint;
Copy link
Contributor Author

@benesjan benesjan Mar 19, 2024

Choose a reason for hiding this comment

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

Did this change because in places where we consume the value we need the last processed block num and not the next one after it so I think it makes sense to pass the value around in that format.

*/
getL1ToL2MessageIndexAndSiblingPath(
blockNumber: BlockNumber,
getL1ToL2MessageMembershipWitness(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did this change because the oracle which calls this func is called getL1ToL2MessageMembershipWitness as well so it makes sense to have it consistent.

* @param l1ToL2Message - The L1 to L2 message to check.
* @returns Whether the message is synced and ready to be included in a block.
*/
isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this func so that I can keep on polling for the message to be available instead of having a hardcoded sleep timeout and hoping that the archiver manages to catch up in that time. Should result in more robust tests.

@@ -64,6 +64,6 @@ export class L1ToL2MessageStore {
return indexInTheWholeTree;
}
}
throw new Error(`L1 to L2 message index not found in the store for message ${l1ToL2Message.toString()}`);
return undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning undefined now because that is how other endpoints returning indices behave and it makes it more convenient for the implementation of the new isL1ToL2MessageSynced func on aztec node.

@AztecBot
Copy link
Collaborator

Benchmark results

Metrics with a significant change:

  • circuit_simulation_time_in_ms (public-kernel-app-logic): 530 (+19%)
  • circuit_simulation_time_in_ms (public-kernel-tail): 203 (+17%)
  • tx_sequencer_processing_time_ms (1): 1,452 (+17%)
  • l2_block_building_time_in_ms (32): 85,632 (+25%)
  • l2_block_building_time_in_ms (64): 174,988 (+29%)
  • l2_block_public_tx_process_time_in_ms (32): 56,374 (+42%)
  • l2_block_public_tx_process_time_in_ms (64): 118,008 (+49%)
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 edb8c679 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,388 239,032 469,832
l1_rollup_execution_gas 647,486 929,390 1,306,012
l2_block_processing_time_in_ms 1,347 (+4%) 5,110 (+11%) 9,784 (+4%)
note_successful_decrypting_time_in_ms 166 (-11%) 543 (+2%) 1,020 (+4%)
note_trial_decrypting_time_in_ms 71.1 (-21%) 64.3 (+16%) 56.1 (-53%)
l2_block_building_time_in_ms 18,136 ⚠️ 85,632 (+25%) ⚠️ 174,988 (+29%)
l2_block_rollup_simulation_time_in_ms 8,090 (-1%) 29,203 (+2%) 56,881 (+1%)
l2_block_public_tx_process_time_in_ms 10,025 ⚠️ 56,374 (+42%) ⚠️ 118,008 (+49%)

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 13,768 (-1%) 27,381
note_history_successful_decrypting_time_in_ms 1,198 (-4%) 2,382 (-1%)
note_history_trial_decrypting_time_in_ms 64.4 (-33%) 113 (-3%)
node_database_size_in_bytes 19,083,344 35,721,296
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 279 (-1%) 44,366 28,244
private-kernel-ordering 212 (-1%) 52,868 14,326
base-parity 1,804 128 311
base-rollup 721 165,787 925
root-parity 1,629 (+3%) 1,244 311
root-rollup 51.6 (-18%) 4,487 725 (-8%)
private-kernel-inner 636 (-1%) 73,771 28,244
public-kernel-app-logic ⚠️ 530 (+19%) 35,260 28,215
public-kernel-tail ⚠️ 203 (+17%) 40,926 28,215
merge-rollup 8.40 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 10.1 (+1%) 16.0 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.589 (+1%) 0.496 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.5 (+3%) 73.6 (+2%) 239 (+3%) 443 911 (+3%) 1,739 (+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.488 (+3%) 0.455 (+2%) 0.436 (+3%) 0.415 0.432 (+3%) 0.417 (+1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 54.2 (-1%) 111 (+4%) 348 (+3%) 659 1,442 (+10%) 2,835 (+9%) 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.501 (+4%) 0.475 (+4%) 0.454 0.501 (+10%) 0.494 (+9%) 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.5 (+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.547 (+2%)

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,189 (-2%) 1,727 (-1%)
Metric 0 public data writes 1 public data writes
tx_sequencer_processing_time_ms 12.0 (+9%) ⚠️ 1,452 (+17%)

@benesjan benesjan requested a review from LHerskind March 19, 2024 11:01
Copy link
Contributor

Changes to circuit sizes

Generated at commit: 6ee3a8d9c6e59d65e2f83efd4052fb16e7b862ea, 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%

Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

Good stuff. 🚢

@benesjan benesjan merged commit 30908eb into master Mar 19, 2024
97 of 100 checks passed
@benesjan benesjan deleted the 03-17-refactor_l1_l2_messages_cleanup branch March 19, 2024 11:13
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.

refactor(Inbox): Cleanup inbox (naming etc.)
3 participants