Skip to content

Commit 6c7cb35

Browse files
pablodeymoOppeniovoidjrchatruc
authored
perf(l1, l2): pipeline VM merklelization (#5084)
**Motivation** We want to parallelize VM execution and merkelization. **Description** <!-- A clear and concise general description of the changes this PR introduces --> <!-- Link to issues: Resolves #111, Resolves #222 --> Closes #issue_number --------- Co-authored-by: Mario Rugiero <[email protected]> Co-authored-by: Lucas Fiegl <[email protected]> Co-authored-by: Javier Rodríguez Chatruc <[email protected]> Co-authored-by: Javier Chatruc <[email protected]>
1 parent 5bc0f9e commit 6c7cb35

File tree

40 files changed

+770
-130
lines changed

40 files changed

+770
-130
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### 2025-10-30
66

7+
- Pipeline Merkleization and Execution [#5084](https://github.com/lambdaclass/ethrex/pull/5084)
78
- Add bloom filters to snapshot layers [#5112](https://github.com/lambdaclass/ethrex/pull/5112)
89
- Make trusted setup warmup non blocking [#5124](https://github.com/lambdaclass/ethrex/pull/5124)
910

Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/ethrex/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ pub async fn import_blocks(
575575
}
576576

577577
blockchain
578-
.add_block(block)
578+
.add_block_pipeline(block)
579579
.inspect_err(|err| match err {
580580
// Block number 1's parent not found, the chain must not belong to the same network as the genesis file
581581
ChainError::ParentNotFound if number == 1 => warn!("The chain file is not compatible with the genesis file. Are you sure you selected the correct network?"),

cmd/ethrex/initializers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ pub async fn regenerate_head_state(
557557
.await?
558558
.ok_or_else(|| eyre::eyre!("Block {i} not found"))?;
559559

560-
blockchain.add_block(block)?;
560+
blockchain.add_block_pipeline(block)?;
561561
}
562562

563563
info!("Finished regenerating state");

cmd/ethrex/l2/command.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,12 @@ impl Command {
423423
let state_diff = StateDiff::decode(&blob)?;
424424

425425
// Apply all account updates to trie
426-
let trie = store.open_direct_state_trie(current_state_root)?;
426+
let mut trie = store.open_direct_state_trie(current_state_root)?;
427427

428428
let account_updates = state_diff.to_account_updates(&trie)?;
429429

430430
let account_updates_list = store
431-
.apply_account_updates_from_trie_batch(trie, account_updates.values())
431+
.apply_account_updates_from_trie_batch(&mut trie, account_updates.values())
432432
.map_err(|e| format!("Error applying account updates: {e}"))
433433
.unwrap();
434434

cmd/ethrex/l2/initializers.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,19 @@ pub async fn init_l2(
269269
info!("P2P is disabled");
270270
}
271271

272+
let l2_url = Url::parse(&format!(
273+
"http://{}:{}",
274+
opts.node_opts.http_addr, opts.node_opts.http_port
275+
))
276+
.map_err(|err| eyre::eyre!("Failed to parse L2 RPC URL: {err}"))?;
277+
272278
let l2_sequencer = ethrex_l2::start_l2(
273279
store,
274280
rollup_store,
275281
blockchain,
276282
l2_sequencer_cfg,
277283
cancellation_token.clone(),
278-
#[cfg(feature = "metrics")]
279-
Url::parse(&format!(
280-
"http://{}:{}",
281-
opts.node_opts.http_addr, opts.node_opts.http_port
282-
))
283-
.map_err(|err| eyre::eyre!("Failed to parse L2 RPC URL: {err}"))?,
284+
l2_url,
284285
genesis,
285286
checkpoints_dir,
286287
)

crates/blockchain/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ documentation.workspace = true
1111
ethrex-rlp.workspace = true
1212
ethrex-common.workspace = true
1313
ethrex-storage.workspace = true
14+
ethrex-trie.workspace = true
1415
ethrex-vm.workspace = true
1516
secp256k1.workspace = true
1617

1718
thiserror.workspace = true
1819
sha3.workspace = true
1920
tracing.workspace = true
2021
bytes.workspace = true
22+
hex.workspace = true
23+
rustc-hash.workspace = true
2124
tokio = { workspace = true, features = ["time", "rt"] }
2225
tokio-util.workspace = true
2326

0 commit comments

Comments
 (0)