Skip to content

Commit 2ffd28e

Browse files
ilitteriJereSaloCopilotLeanSerra
authored
fix(l1): ethrex-replay block execution in different networks (#3992)
**Motivation** The `ethrex-replay` tool is not working correctly in many aspects. From the starts block execution is not working correctly in the different networks (Hoodi, Sepolia, and Mainnet). **Description** This PR fixes the following related to `ethrex-replay`: - `ExecutionWitnessResult` serialization and deserialization to make it compliant with Reth nodes. - Ensures the use of the correct chain configuration on each command. - The latest block is now correctly cached and labeled (by network and block number, e.g. `cache_network_number.json`). - Ensures the replay of the last canonical block when replaying the latest block. And the following extras: - Improves logging. - Renames some functions and variables. > [!NOTE] > - This PR ensures the correct execution of most of blocks produced by reth and ethrex clients. > - Some block execution may fail, and their corresponding fixes should be done in other PRs. > - To ensure block execution from other clients than the stated above, we need to support retrieving block execution data using the endpoint `eth_getProofs` (this is a WIP, we're currently using `debug_executionWitness`, but only Reth and ethrex nodes support this endpoint). **Test it out** ``` # reth RPCs Hoodi = http://65.108.69.58:8545 Sepolia = http://65.109.97.102:8545 Mainnet = http://157.180.1.98:8545 # Executing cargo run --release --package ethrex-replay --bin ethrex-replay -- execute block --rpc-url http://65.108.69.58:8545 --network hoodi # Executing (SP1) cargo run --release --package ethrex-replay --bin ethrex-replay --features sp1 -- execute block 1033114 --rpc-url http://65.108.69.58:8545 --network hoodi 
# Proving (SP1) 
SP1_PROVER=cuda cargo run --release --package ethrex-replay --bin ethrex-replay --features sp1,gpu -- execute block 1033114 --rpc-url http://65.108.69.58:8545 --network hoodi ``` --------- Co-authored-by: Jeremías Salomón <48994069+JereSalo@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: JereSalo <jeresalo17@gmail.com> Co-authored-by: LeanSerra <46695152+LeanSerra@users.noreply.github.com>
1 parent 1eb58c8 commit 2ffd28e

File tree

32 files changed

+643
-529
lines changed

32 files changed

+643
-529
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Generated by Cargo
22
# will have compiled files and executables
3-
debug/
43
**/target/
54

65
# These are backup files generated by rustfmt

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ members = [
3131
"tooling/load_test",
3232
"tooling/loc",
3333
"tooling/archive_sync",
34+
"crates/common/config",
3435
]
3536
resolver = "2"
3637

@@ -52,6 +53,7 @@ debug = 2
5253
[workspace.dependencies]
5354
ethrex-blockchain = { path = "./crates/blockchain" }
5455
ethrex-common = { path = "./crates/common" }
56+
ethrex-config = { path = "./crates/common/config" }
5557
ethrex-p2p = { path = "./crates/networking/p2p" }
5658
ethrex-rpc = { path = "./crates/networking/rpc" }
5759
ethrex-storage = { path = "./crates/storage" }

cmd/ef_tests/blockchain/test_runner.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,7 @@ async fn re_run_stateless(
409409
let mut witness = blockchain.generate_witness_for_blocks(&blocks).await;
410410
// Set a default witness if execution should fail as db will not have the required data to generate the witness
411411
if test_should_fail && witness.is_err() {
412-
witness = Ok(ExecutionWitnessResult {
413-
state_trie_nodes: Some(Vec::new()),
414-
storage_trie_nodes: Some(HashMap::new()),
415-
..Default::default()
416-
})
412+
witness = Ok(ExecutionWitnessResult::default())
417413
} else if !test_should_fail && witness.is_err() {
418414
return Err("Failed to create witness for a test that should not fail".into());
419415
}

cmd/ethrex/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ build = "build.rs"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10+
ethrex-config.workspace = true
1011
ethrex-blockchain.workspace = true
1112
ethrex-rpc.workspace = true
1213
ethrex-common.workspace = true

cmd/ethrex/bench/import_blocks_benchmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use criterion::{Criterion, criterion_group, criterion_main};
22
use ethrex::{
33
cli::{import_blocks, remove_db},
4-
networks::Network,
54
utils::{default_datadir, init_datadir},
65
};
76
use ethrex_blockchain::BlockchainType;
7+
use ethrex_config::networks::Network;
88
use ethrex_vm::EvmEngine;
99

1010
#[inline]

cmd/ethrex/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use crate::{
2020
self,
2121
command::{DB_ETHREX_DEV_L1, DB_ETHREX_DEV_L2},
2222
},
23-
networks::Network,
2423
utils::{self, default_datadir, get_client_version, init_datadir},
2524
};
25+
use ethrex_config::networks::Network;
2626

2727
#[allow(clippy::upper_case_acronyms)]
2828
#[derive(ClapParser)]

cmd/ethrex/ethrex.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use ethrex::{
44
initializers::{init_l1, init_tracing},
55
utils::{NodeConfigFile, store_node_config_file},
66
};
7-
use ethrex_p2p::{kademlia::KademliaTable, types::NodeRecord};
7+
use ethrex_p2p::kademlia::KademliaTable;
8+
use ethrex_p2p::types::NodeRecord;
89
use std::{path::PathBuf, sync::Arc, time::Duration};
910
use tokio::{
1011
signal::unix::{SignalKind, signal},

cmd/ethrex/initializers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::{
22
cli::Options,
3-
networks::Network,
43
utils::{
54
get_client_version, init_datadir, parse_socket_addr, read_jwtsecret_file,
65
read_node_config_file,
76
},
87
};
98
use ethrex_blockchain::{Blockchain, BlockchainType};
109
use ethrex_common::types::Genesis;
10+
use ethrex_config::networks::Network;
1111

1212
use ethrex_metrics::profiling::{FunctionProfilingLayer, initialize_block_processing_profile};
1313

cmd/ethrex/l2/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ use crate::{
66
deployer::{DeployerOptions, deploy_l1_contracts},
77
options::{Options, ProverClientOptions},
88
},
9-
networks::Network,
109
utils::{default_datadir, init_datadir, parse_private_key},
1110
};
1211
use clap::{FromArgMatches, Parser, Subcommand};
1312
use ethrex_common::{
1413
Address, H256, U256,
1514
types::{BYTES_PER_BLOB, BlobsBundle, BlockHeader, batch::Batch, bytes_from_blob},
1615
};
16+
use ethrex_config::networks::Network;
1717
use ethrex_l2_common::{calldata::Value, l1_messages::get_l1_message_hash, state_diff::StateDiff};
1818
use ethrex_l2_sdk::call_contract;
1919
use ethrex_rpc::{

0 commit comments

Comments
 (0)