Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
dd83c34
Changed fixtures to Fusaka ones and added basic support in the runners
SDartayet Aug 25, 2025
3b8956c
Merge branch 'main' into add-fusaka-fixtures
SDartayet Aug 25, 2025
fce102e
Merge branch 'main' into add-fusaka-fixtures
SDartayet Aug 26, 2025
cc12b0a
Merge branch 'main' into add-fusaka-fixtures
SDartayet Aug 26, 2025
0f3d680
Made it so RPC tests coincide with the updated Chainconfig
SDartayet Aug 26, 2025
9c74188
Updated ordered config in genesis json parser
SDartayet Aug 26, 2025
690ac54
Merge branch 'main' into add-fusaka-fixtures
SDartayet Aug 26, 2025
7d3c01c
Remove dbg! accidentally left in
SDartayet Aug 26, 2025
1ff99ff
Update genesis.rs
SDartayet Aug 26, 2025
ee01072
Further fixes
SDartayet Aug 26, 2025
1d9bd33
Update levm_runner.rs
SDartayet Aug 26, 2025
75ccca1
Update mod.rs
SDartayet Aug 26, 2025
743af2f
Added better ways to unskip osaka tests
SDartayet Aug 27, 2025
0025aef
Small fixes to previous commit
SDartayet Aug 27, 2025
762aba7
Uncommented line that prints fusaka report in cli
SDartayet Aug 27, 2025
e71ab5d
Merge branch 'main' into add-fusaka-fixtures
SDartayet Aug 27, 2025
c140755
Small fix to previous commit
SDartayet Aug 27, 2025
3effd10
Added missing report line for Osaka tests
SDartayet Aug 27, 2025
08724e7
Made it so revm skips osaka tests
SDartayet Aug 27, 2025
d04cbcf
Initial implementation
SDartayet Aug 28, 2025
645e52f
Added initial implementation
SDartayet Aug 29, 2025
c8b241a
Implemented size limit on block validation
SDartayet Aug 29, 2025
c77b491
Small fixes
SDartayet Aug 29, 2025
b5c5541
Fixed linting errors
SDartayet Sep 4, 2025
7b12203
Merge branch 'main' into block-size-limit
SDartayet Sep 4, 2025
dadc3fc
Fixed small error
SDartayet Sep 4, 2025
36b376b
Merge branch 'main' into block-size-limit
SDartayet Sep 4, 2025
0cfbc2c
Skipped block RLP cached elements from serde and rkyv
SDartayet Sep 4, 2025
e5bb9bc
Merge branch 'main' into block-size-limit
SDartayet Sep 4, 2025
b518b64
Merge branch 'main' into block-size-limit
SDartayet Sep 4, 2025
74b180f
Fix
SDartayet Sep 5, 2025
cc33e10
Fix
SDartayet Sep 5, 2025
e4aa61d
Changed block initialization
SDartayet Sep 5, 2025
5d891c5
Fix to previous commit
SDartayet Sep 5, 2025
2a1b13b
Fixing compile errors
SDartayet Sep 5, 2025
dc2c063
Merge branch 'main' into block-size-limit
SDartayet Sep 5, 2025
35bc578
Merge branch 'main' into block-size-limit
SDartayet Sep 5, 2025
7473025
Update test_runner.rs
SDartayet Sep 5, 2025
12d916d
Update test_runner.rs
SDartayet Sep 5, 2025
3634bd3
Update test_runner.rs
SDartayet Sep 5, 2025
ff21cc9
Added block size check to the payload module
SDartayet Sep 8, 2025
652dd94
Revert "Added block size check to the payload module"
SDartayet Sep 8, 2025
5b9fceb
Merge branch 'main' into block-size-limit
SDartayet Sep 9, 2025
c7911f2
Removed RLP caching
SDartayet Sep 9, 2025
4c0c021
Renamed error and constant
SDartayet Sep 9, 2025
3093265
Adding file left out from previous commit
SDartayet Sep 9, 2025
e6840cf
Initial size check implementation on building
SDartayet Sep 9, 2025
acf0e98
Merge branch 'main' into block-size-limit-building
SDartayet Sep 25, 2025
be31342
Merge branch 'main' into block-size-limit-building
cdiielsi Oct 13, 2025
92e7570
set new exception for testing
cdiielsi Oct 16, 2025
7c9f024
stop adding txs when block size cap is surpassed
cdiielsi Oct 16, 2025
a1b504f
Merge branch 'main' into block-size-limit-building
cdiielsi Oct 16, 2025
4351c7e
Merge branch 'main' into block-size-limit-building
cdiielsi Oct 17, 2025
a6d26b0
Merge branch 'main' into block-size-limit-building
cdiielsi Oct 21, 2025
591b3ce
add endpoint addPeer
cdiielsi Oct 22, 2025
036b751
have p2p_context as a parameter for init_network
cdiielsi Oct 22, 2025
5e660a8
pass genserver instead of P2P context as a parameter
cdiielsi Oct 23, 2025
f814ee0
use default_with_store to create blockchain
cdiielsi Oct 27, 2025
c7e29bd
reduce code by setting signer randomly
cdiielsi Oct 27, 2025
12baa88
drop unused import
cdiielsi Oct 27, 2025
8add4d8
fix clippy
cdiielsi Oct 27, 2025
3459565
drop commented code
cdiielsi Oct 27, 2025
7206f7f
merge main into branch
cdiielsi Oct 27, 2025
d95b72e
add_peer returns true if the conection was made
cdiielsi Oct 28, 2025
a79fb9a
include extra logs for testing
cdiielsi Oct 29, 2025
e51ca4f
restore log level
cdiielsi Oct 29, 2025
b3d2249
merge main into branch
cdiielsi Oct 31, 2025
ce6526a
add sleep and timeout to make sure connection is made of possible
cdiielsi Oct 31, 2025
7600030
restore hive parallelism
cdiielsi Oct 31, 2025
88cfbee
Merge branch 'admin_addPeer' of github.com:lambdaclass/ethrex into ad…
cdiielsi Oct 31, 2025
16c18f7
merge main into branch
cdiielsi Oct 31, 2025
e3a4784
Merge branch 'main' into admin_addPeer
cdiielsi Oct 31, 2025
d96c071
Merge branch 'main' into admin_addPeer
cdiielsi Oct 31, 2025
96fc4ef
add comment on loop
cdiielsi Oct 31, 2025
d429580
Merge branch 'admin_addPeer' of github.com:lambdaclass/ethrex into ad…
cdiielsi Oct 31, 2025
33e87c9
merge main into branch
cdiielsi Nov 3, 2025
59d3f43
Merge branch 'main' into admin_addPeer
cdiielsi Nov 3, 2025
26a21b9
Merge branch 'main' into admin_addPeer
cdiielsi Nov 3, 2025
e541fe0
put dummies under the test flag and set parallelism to 8
cdiielsi Nov 3, 2025
3b9b438
Merge branch 'admin_addPeer' of github.com:lambdaclass/ethrex into ad…
cdiielsi Nov 3, 2025
9ee1a18
include copilot's comments
cdiielsi Nov 4, 2025
45a65cf
restore og ci parallelism for running hive tests
cdiielsi Nov 4, 2025
84d1c7f
Merge branch 'main' into admin_addPeer
cdiielsi Nov 4, 2025
d17f68a
add corrections mentioned in review
cdiielsi Nov 4, 2025
301d196
Merge branch 'main' into admin_addPeer
cdiielsi Nov 4, 2025
84b5db1
Merge branch 'main' into admin_addPeer
cdiielsi Nov 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cmd/ethrex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ thiserror.workspace = true
itertools = "0.14.0"
url.workspace = true

spawned-rt.workspace = true
spawned-concurrency.workspace = true

# L2 external dependencies

tui-logger = { workspace = true, optional = true }
Expand Down
56 changes: 23 additions & 33 deletions cmd/ethrex/initializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use ethrex_common::types::Genesis;
use ethrex_config::networks::Network;

use ethrex_metrics::profiling::{FunctionProfilingLayer, initialize_block_processing_profile};
#[cfg(feature = "l2")]
use ethrex_p2p::rlpx::l2::l2_connection::P2PBasedContext;
use ethrex_p2p::rlpx::initiator::RLPxInitiator;
use ethrex_p2p::{
discv4::peer_table::PeerTable,
network::P2PContext,
Expand Down Expand Up @@ -193,13 +192,10 @@ pub async fn init_network(
opts: &Options,
network: &Network,
datadir: &Path,
local_p2p_node: Node,
signer: SecretKey,
peer_handler: PeerHandler,
store: Store,
tracker: TaskTracker,
blockchain: Arc<Blockchain>,
#[cfg(feature = "l2")] based_context: Option<P2PBasedContext>,
context: P2PContext,
) {
if opts.dev {
error!("Binary wasn't built with The feature flag `dev` enabled.");
Expand All @@ -210,26 +206,6 @@ pub async fn init_network(

let bootnodes = get_bootnodes(opts, network, datadir);

#[cfg(feature = "l2")]
let based_context_arg = based_context;

#[cfg(not(feature = "l2"))]
let based_context_arg = None;

let context = P2PContext::new(
local_p2p_node,
tracker.clone(),
signer,
peer_handler.peer_table.clone(),
store,
blockchain.clone(),
get_client_version(),
based_context_arg,
opts.tx_broadcasting_time_interval,
)
.await
.expect("P2P context could not be created");

ethrex_p2p::start_network(context, bootnodes)
.await
.expect("Network starts");
Expand Down Expand Up @@ -439,17 +415,35 @@ pub async fn init_l1(

let local_node_record = get_local_node_record(datadir, &local_p2p_node, &signer);

let peer_handler = PeerHandler::new(PeerTable::spawn(opts.target_peers));
let peer_table = PeerTable::spawn(opts.target_peers);

// TODO: Check every module starts properly.
let tracker = TaskTracker::new();

let cancel_token = tokio_util::sync::CancellationToken::new();

let p2p_context = P2PContext::new(
local_p2p_node.clone(),
tracker.clone(),
signer,
peer_table.clone(),
store.clone(),
blockchain.clone(),
get_client_version(),
None,
opts.tx_broadcasting_time_interval,
)
.await
.expect("P2P context could not be created");

let initiator = RLPxInitiator::spawn(p2p_context.clone()).await;

let peer_handler = PeerHandler::new(peer_table.clone(), initiator);

init_rpc_api(
&opts,
peer_handler.clone(),
local_p2p_node.clone(),
local_p2p_node,
local_node_record.clone(),
store.clone(),
blockchain.clone(),
Expand All @@ -471,14 +465,10 @@ pub async fn init_l1(
&opts,
&network,
datadir,
local_p2p_node,
signer,
peer_handler.clone(),
store.clone(),
tracker.clone(),
blockchain.clone(),
#[cfg(feature = "l2")]
None,
p2p_context,
)
.await;
} else {
Expand Down
64 changes: 39 additions & 25 deletions cmd/ethrex/l2/initializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ use ethrex_l2::SequencerConfig;
use ethrex_l2::sequencer::l1_committer::regenerate_head_state;
use ethrex_p2p::{
discv4::peer_table::PeerTable,
network::P2PContext,
peer_handler::PeerHandler,
rlpx::l2::l2_connection::P2PBasedContext,
rlpx::{initiator::RLPxInitiator, l2::l2_connection::P2PBasedContext},
sync_manager::SyncManager,
types::{Node, NodeRecord},
};
Expand All @@ -35,7 +36,7 @@ use url::Url;
async fn init_rpc_api(
opts: &L1Options,
l2_opts: &L2Options,
peer_table: PeerTable,
peer_handler: PeerHandler,
local_p2p_node: Node,
local_node_record: NodeRecord,
store: Store,
Expand All @@ -46,8 +47,6 @@ async fn init_rpc_api(
log_filter_handler: Option<reload::Handle<EnvFilter, Registry>>,
gas_ceil: Option<u64>,
) {
let peer_handler = PeerHandler::new(peer_table);

init_datadir(&opts.datadir);

// Create SyncManager
Expand Down Expand Up @@ -198,18 +197,51 @@ pub async fn init_l2(

let local_node_record = get_local_node_record(&datadir, &local_p2p_node, &signer);

let peer_handler = PeerHandler::new(PeerTable::spawn(opts.node_opts.target_peers));
let peer_table = PeerTable::spawn(opts.node_opts.target_peers);

// TODO: Check every module starts properly.
let tracker = TaskTracker::new();
let mut join_set = JoinSet::new();

let p2p_context = P2PContext::new(
local_p2p_node.clone(),
tracker.clone(),
signer,
peer_table.clone(),
store.clone(),
blockchain.clone(),
get_client_version(),
#[cfg(feature = "l2")]
Some(P2PBasedContext {
store_rollup: rollup_store.clone(),
// TODO: The Web3Signer refactor introduced a limitation where the committer key cannot be accessed directly because the signer could be either Local or Remote.
// The Signer enum cannot be used in the P2PBasedContext struct due to cyclic dependencies between the l2-rpc and p2p crates.
// As a temporary solution, a dummy committer key is used until a proper mechanism to utilize the Signer enum is implemented.
// This should be replaced with the Signer enum once the refactor is complete.
committer_key: Arc::new(
SecretKey::from_slice(
&hex::decode(
"385c546456b6a603a1cfcaa9ec9494ba4832da08dd6bcf4de9a71e4a01b74924",
)
.expect("Invalid committer key"),
)
.expect("Failed to create committer key"),
),
}),
opts.node_opts.tx_broadcasting_time_interval,
)
.await
.expect("P2P context could not be created");

let initiator = RLPxInitiator::spawn(p2p_context.clone()).await;
let peer_handler = PeerHandler::new(PeerTable::spawn(opts.node_opts.target_peers), initiator);

let cancel_token = tokio_util::sync::CancellationToken::new();

init_rpc_api(
&opts.node_opts,
&opts,
peer_handler.peer_table.clone(),
peer_handler.clone(),
local_p2p_node.clone(),
local_node_record.clone(),
store.clone(),
Expand Down Expand Up @@ -241,28 +273,10 @@ pub async fn init_l2(
&opts.node_opts,
&network,
&datadir,
local_p2p_node,
signer,
peer_handler.clone(),
store.clone(),
tracker,
blockchain.clone(),
Some(P2PBasedContext {
store_rollup: rollup_store.clone(),
// TODO: The Web3Signer refactor introduced a limitation where the committer key cannot be accessed directly because the signer could be either Local or Remote.
// The Signer enum cannot be used in the P2PBasedContext struct due to cyclic dependencies between the l2-rpc and p2p crates.
// As a temporary solution, a dummy committer key is used until a proper mechanism to utilize the Signer enum is implemented.
// This should be replaced with the Signer enum once the refactor is complete.
committer_key: Arc::new(
SecretKey::from_slice(
&hex::decode(
"385c546456b6a603a1cfcaa9ec9494ba4832da08dd6bcf4de9a71e4a01b74924",
)
.expect("Invalid committer key"),
)
.expect("Failed to create committer key"),
),
}),
p2p_context,
)
.await;
} else {
Expand Down
1 change: 1 addition & 0 deletions crates/networking/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ default = ["c-kzg"]
c-kzg = ["ethrex-blockchain/c-kzg", "ethrex-common/c-kzg"]
sync-test = []
l2 = ["dep:ethrex-storage-rollup"]
test-utils = []

[lints.clippy]
unwrap_used = "deny"
Expand Down
33 changes: 30 additions & 3 deletions crates/networking/p2p/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use crate::{
metrics::METRICS,
rlpx::{
connection::server::{PeerConnBroadcastSender, PeerConnection},
initiator::RLPxInitiator,
message::Message,
p2p::SUPPORTED_SNAP_CAPABILITIES,
},
Expand Down Expand Up @@ -94,6 +93,36 @@ impl P2PContext {
tx_broadcaster,
})
}

#[cfg(any(test, feature = "test-utils"))]
/// Creates a dummy P2PContext for tests
/// This should only be used in tests as it won't be able to connect to the p2p network
pub async fn dummy(peer_table: PeerTable) -> P2PContext {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely happy with these dummy functions for testing purposes. Maybe we should have a test_utils module to create these structures separately from our main modules.
In any case, that's for another PR, probably.

Copy link
Collaborator

Choose a reason for hiding this comment

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

at least it should be behind the test flag

use ethrex_storage::EngineType;

let storage = Store::new("./temp", EngineType::InMemory).expect("Failed to create Store");
let blockchain: Arc<Blockchain> = Arc::new(Blockchain::default_with_store(storage.clone()));
let local_node = Node::from_enode_url(
"enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303",
).expect("Bad enode url");
let (channel_broadcast_send_end, _) =
tokio::sync::broadcast::channel::<(tokio::task::Id, Arc<Message>)>(100000);
P2PContext {
tracker: TaskTracker::default(),
signer: SecretKey::from_byte_array(&[0xcd; 32]).expect("32 bytes, within curve order"),
table: peer_table.clone(),
storage,
blockchain: blockchain.clone(),
broadcast: channel_broadcast_send_end,
local_node: local_node.clone(),
client_version: "".to_string(),
#[cfg(feature = "l2")]
based_context: None,
tx_broadcaster: TxBroadcaster::spawn(peer_table.clone(), blockchain, 1000)
.await
.expect("Failed to spawn tx broadcaster"),
}
}
}

#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -123,8 +152,6 @@ pub async fn start_network(context: P2PContext, bootnodes: Vec<Node>) -> Result<
error!("Failed to start discovery server: {e}");
})?;

RLPxInitiator::spawn(context.clone()).await;

context.tracker.spawn(serve_p2p_requests(context.clone()));

Ok(())
Expand Down
20 changes: 15 additions & 5 deletions crates/networking/p2p/peer_handler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#[cfg(any(test, feature = "test-utils"))]
use crate::discv4::peer_table::TARGET_PEERS;
use crate::rlpx::initiator::RLPxInitiator;
use crate::{
discv4::peer_table::{PeerData, PeerTable, PeerTableError, TARGET_PEERS},
discv4::peer_table::{PeerData, PeerTable, PeerTableError},
metrics::{CurrentStepValue, METRICS},
rlpx::{
connection::server::PeerConnection,
Expand Down Expand Up @@ -34,6 +37,7 @@ use ethrex_rlp::{decode::RLPDecode, encode::RLPEncode};
use ethrex_storage::Store;
use ethrex_trie::Nibbles;
use ethrex_trie::{Node, verify_range};
use spawned_concurrency::tasks::GenServerHandle;
use std::{
collections::{BTreeMap, HashMap, HashSet, VecDeque},
io::ErrorKind,
Expand Down Expand Up @@ -68,6 +72,7 @@ pub const MAX_BLOCK_BODIES_TO_REQUEST: usize = 128;
#[derive(Debug, Clone)]
pub struct PeerHandler {
pub peer_table: PeerTable,
pub initiator: GenServerHandle<RLPxInitiator>,
}

pub enum BlockRequestOrder {
Expand Down Expand Up @@ -142,14 +147,19 @@ async fn ask_peer_head_number(
}

impl PeerHandler {
pub fn new(peer_table: PeerTable) -> PeerHandler {
Self { peer_table }
pub fn new(peer_table: PeerTable, initiator: GenServerHandle<RLPxInitiator>) -> PeerHandler {
Self {
peer_table,
initiator,
}
}

#[cfg(any(test, feature = "test-utils"))]
/// Creates a dummy PeerHandler for tests where interacting with peers is not needed
/// This should only be used in tests as it won't be able to interact with the node's connected peers
pub fn dummy() -> PeerHandler {
PeerHandler::new(PeerTable::spawn(TARGET_PEERS))
pub async fn dummy() -> PeerHandler {
let peer_table = PeerTable::spawn(TARGET_PEERS);
PeerHandler::new(peer_table.clone(), RLPxInitiator::dummy(peer_table).await)
}

async fn make_request(
Expand Down
Loading
Loading