Skip to content

feat(l2): commit blocks in batches #2397

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

Merged
merged 116 commits into from
Apr 29, 2025
Merged

feat(l2): commit blocks in batches #2397

merged 116 commits into from
Apr 29, 2025

Conversation

avilagaston9
Copy link
Contributor

@avilagaston9 avilagaston9 commented Apr 3, 2025

Motivation

To reduce the number of times we go to the L1 to commit/verify blocks.

Description

  • Modifies l1_committer to merge as many blocks as possible into a single StateDiff before committing, limited by the blob size.
  • Modifies StateDiff to now contain both the resulting AccountUpdates from executing all blocks in the batch and the header of the last block.
  • Adapts contracts to use batchNumbers instead of blockNumbers.
  • Adds a new RPC endpoint, ethrex_getWithdrawalProof, which returns all necessary data to claim an L1 withdrawal for a given L2 withdrawal transaction hash.
  • Implements apply_account_updates for the ExecutionDB to prepare the db for executing the next block in the batch.
  • Adds a L2/storage with the following tables:
    • block_number => batch_number: Maps block numbers to batches (used by the endpoint to locate a withdrawal's batch).
    • batch_number => Vec<block_number>: Lists all block numbers included in a given batch.
    • batch_number => withdrawal_hashes: Stores withdrawal hashes per batch (used to construct merkle proofs).

Closes None

Created issues:

Copy link

github-actions bot commented Apr 3, 2025

Lines of code report

Total lines added: 1238
Total lines removed: 328
Total lines changed: 1566

Detailed view
+--------------------------------------------------------------+-------+------+
| File                                                         | Lines | Diff |
+--------------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/ethrex.rs                                  | 88    | +4   |
+--------------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/initializers.rs                            | 374   | +22  |
+--------------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/l2.rs                                      | 256   | +4   |
+--------------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex_l2/src/commands/stack.rs                   | 403   | +42  |
+--------------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex_l2/src/commands/wallet.rs                  | 564   | -54  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/src/backends/exec.rs                 | 81    | +20  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/zkvm/interface/pico/src/main.rs      | 63    | +18  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/zkvm/interface/risc0/src/main.rs     | 69    | +23  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/zkvm/interface/sp1/src/main.rs       | 70    | +21  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sdk/src/sdk.rs                              | 214   | -81  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/block_producer/payload_builder.rs | 227   | +2   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_committer.rs                   | 505   | +82  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_proof_sender.rs                | 165   | -1   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/l1_watcher.rs                     | 281   | +1   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/metrics.rs                        | 81    | -1   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/mod.rs                            | 65    | +5   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/proof_coordinator.rs              | 293   | +29  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/state_diff.rs                     | 469   | +3   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/api.rs                          | 34    | +34  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/lib.rs                          | 5     | +5   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/rlp.rs                          | 74    | +74  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store.rs                        | 121   | +121 |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/in_memory.rs           | 97    | +97  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/libmdbx.rs             | 141   | +141 |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/mod.rs                 | 5     | +5   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/storage/src/store_db/redb.rs                | 151   | +151 |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/l2/utils/test_data_io.rs                       | 87    | +1   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/clients/eth/errors.rs           | 209   | +13  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/clients/eth/mod.rs              | 1039  | +46  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/filter.rs                   | 542   | -63  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/gas_price.rs                | 112   | -27  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/eth/max_priority_fee.rs         | 129   | +5   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/l2/mod.rs                       | 2     | +1   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/l2/withdrawal.rs                | 82    | +82  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/rpc.rs                          | 643   | -78  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/utils.rs                        | 411   | +77  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/storage/account_update.rs                      | 39    | +39  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/storage/lib.rs                                 | 12    | +1   |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/storage/store.rs                               | 1225  | -23  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/vm/backends/levm/db.rs                         | 193   | +13  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/vm/backends/levm/mod.rs                        | 648   | +21  |
+--------------------------------------------------------------+-------+------+
| ethrex/crates/vm/db.rs                                       | 81    | +35  |
+--------------------------------------------------------------+-------+------+

@avilagaston9 avilagaston9 changed the title feat(l2): commit and verify block in batches feat(l2): commit and verify blocks in batches Apr 3, 2025
@avilagaston9 avilagaston9 self-assigned this Apr 3, 2025
@avilagaston9 avilagaston9 force-pushed the l2/feat/commit_in_batches branch from 54a1e03 to 3af5fc3 Compare April 7, 2025 19:10
@avilagaston9 avilagaston9 changed the title feat(l2): commit and verify blocks in batches feat(l2): commit blocks in batches Apr 9, 2025
@avilagaston9 avilagaston9 mentioned this pull request Apr 10, 2025
@avilagaston9 avilagaston9 force-pushed the l2/feat/commit_in_batches branch from 5f1ff8e to 25ec922 Compare April 10, 2025 22:31
@avilagaston9 avilagaston9 force-pushed the l2/feat/commit_in_batches branch from 7a90f20 to 2facbef Compare April 25, 2025 18:05
@avilagaston9 avilagaston9 force-pushed the l2/feat/commit_in_batches branch from fb8f0b2 to 1eeb1eb Compare April 25, 2025 18:50
@jrchatruc jrchatruc added this pull request to the merge queue Apr 29, 2025
Merged via the queue into main with commit a8d2ec4 Apr 29, 2025
30 checks passed
@jrchatruc jrchatruc deleted the l2/feat/commit_in_batches branch April 29, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L2 Rollup client
Projects
None yet
Development

Successfully merging this pull request may close these issues.