From 9bb40b6c34a1abea4fa79b1650b1b856297e98b2 Mon Sep 17 00:00:00 2001 From: Camila Di Ielsi Date: Thu, 2 Oct 2025 18:24:03 -0300 Subject: [PATCH 1/7] add tx broadcasting time interval flag --- .github/workflows/pr-main_l1.yaml | 2 +- cmd/ethrex/cli.rs | 9 +++++++++ cmd/ethrex/initializers.rs | 1 + crates/networking/p2p/network.rs | 15 ++++++++++----- crates/networking/p2p/tx_broadcaster.rs | 6 ++---- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr-main_l1.yaml b/.github/workflows/pr-main_l1.yaml index 25e230b853e..ea5862c1119 100644 --- a/.github/workflows/pr-main_l1.yaml +++ b/.github/workflows/pr-main_l1.yaml @@ -184,7 +184,7 @@ jobs: test_pattern: engine-(auth|exchange-capabilities)/ - name: "Cancun Engine tests" simulation: ethereum/engine - test_pattern: "engine-cancun/Blob Transactions On Block 1|Blob Transaction Ordering|Parallel Blob Transactions|ForkchoiceUpdatedV3|ForkchoiceUpdatedV2|ForkchoiceUpdated Version|GetPayload|NewPayloadV3 After Cancun|NewPayloadV3 Before Cancun|NewPayloadV3 Versioned Hashes|Incorrect BlobGasUsed|ParentHash equals BlockHash|RPC:|in ForkchoiceState|Unknown SafeBlockHash|Unknown FinalizedBlockHash|Unique|Re-Execute Payload|Multiple New Payloads|NewPayload with|Build Payload with|Re-org to Previously|Safe Re-Org to Side Chain|Transaction Re-Org|Re-Org Back into Canonical Chain|Suggested Fee Recipient Test|PrevRandao Opcode|Fork ID: *|Request Blob Pooled Transactions Single|Invalid NewPayload, Incomplete Transactions|Re-Org Back to Canonical Chain*|Invalid PayloadAttributes*|Invalid NewPayload, VersionedHashes|Invalid NewPayload, Incomplete VersionedHashes|Invalid NewPayload, Extra VersionedHashes|Bad Hash on NewPayload|Unknown HeadBlockHash|In-Order Consecutive Payload Execution|Valid NewPayload->ForkchoiceUpdated|Invalid NewPayload, ParentHash|Syncing=False|Payload Build after New Invalid Payload|Invalid NewPayload|Invalid Missing Ancestor ReOrg|Invalid Missing Ancestor Syncing ReOrG" + test_pattern: "engine-cancun" - name: "Paris Engine tests" simulation: ethereum/engine test_pattern: "engine-api/RPC|Bad Hash on NewPayload|Build Payload|Fork ID|In-Order Consecutive Payload Execution|Inconsistent|Invalid Missing Ancestor ReOrg|Invalid NewPayload|Invalid PayloadAttributes|Multiple New Payloads|NewPayload with|ParentHash equals BlockHash on NewPayload|Payload Build|PrevRandao Opcode Transactions|Re-Execute Payload|Re-Org Back|Re-org to Previously Validated Sidechain Payload|RPC:|Safe Re-Org|Suggested Fee|Transaction Re-Org|Unique Payload ID|Unknown|Valid NewPayload->ForkchoiceUpdated" # |Invalid P9 -> flaky diff --git a/cmd/ethrex/cli.rs b/cmd/ethrex/cli.rs index c2c3f82faea..7a5f6cd45d5 100644 --- a/cmd/ethrex/cli.rs +++ b/cmd/ethrex/cli.rs @@ -175,6 +175,14 @@ pub struct Options { help_heading = "P2P options" )] pub discovery_port: String, + #[arg( + long = "p2p.tx-broadcasting-interval", + default_value = "1000", + value_name = "INTERVAL_MS", + help = "Transaction Broadcasting Time Interval (ms) for batching transactions before broadcasting them", + help_heading = "P2P options" + )] + pub tx_broadcasting_time_interval: u64, #[arg( long = "block-producer.extra-data", default_value = get_minimal_client_version(), @@ -246,6 +254,7 @@ impl Default for Options { dev: Default::default(), force: false, mempool_max_size: Default::default(), + tx_broadcasting_time_interval: Default::default(), extra_data: get_minimal_client_version(), } } diff --git a/cmd/ethrex/initializers.rs b/cmd/ethrex/initializers.rs index bc1f62263b5..3fdead04cf4 100644 --- a/cmd/ethrex/initializers.rs +++ b/cmd/ethrex/initializers.rs @@ -202,6 +202,7 @@ pub async fn init_network( blockchain.clone(), get_client_version(), based_context, + opts.tx_broadcasting_time_interval, ) .await .expect("P2P context could not be created"); diff --git a/crates/networking/p2p/network.rs b/crates/networking/p2p/network.rs index c557cd71c9c..1978c38c9bd 100644 --- a/crates/networking/p2p/network.rs +++ b/crates/networking/p2p/network.rs @@ -60,17 +60,22 @@ impl P2PContext { blockchain: Arc, client_version: String, based_context: Option, + tx_broadcasting_time_interval: u64, ) -> Result { let (channel_broadcast_send_end, _) = tokio::sync::broadcast::channel::<( tokio::task::Id, Arc, )>(MAX_MESSAGES_TO_BROADCAST); - let tx_broadcaster = TxBroadcaster::spawn(peer_table.clone(), blockchain.clone()) - .await - .inspect_err(|e| { - error!("Failed to start Tx Broadcaster: {e}"); - })?; + let tx_broadcaster = TxBroadcaster::spawn( + peer_table.clone(), + blockchain.clone(), + tx_broadcasting_time_interval, + ) + .await + .inspect_err(|e| { + error!("Failed to start Tx Broadcaster: {e}"); + })?; Ok(P2PContext { local_node, diff --git a/crates/networking/p2p/tx_broadcaster.rs b/crates/networking/p2p/tx_broadcaster.rs index 5e580645662..970fe1fcede 100644 --- a/crates/networking/p2p/tx_broadcaster.rs +++ b/crates/networking/p2p/tx_broadcaster.rs @@ -34,9 +34,6 @@ const PRUNE_WAIT_TIME_SECS: u64 = 600; // 10 minutes // Amount of seconds between each prune const PRUNE_INTERVAL_SECS: u64 = 360; // 6 minutes -// Amount of seconds between each broadcast -const BROADCAST_INTERVAL_SECS: u64 = 1; // 1 second - #[derive(Debug, Clone, Default)] struct PeerMask { bits: Vec, @@ -115,6 +112,7 @@ impl TxBroadcaster { pub async fn spawn( kademlia: Kademlia, blockchain: Arc, + tx_broadcasting_time_interval: u64, ) -> Result, TxBroadcasterError> { info!("Starting Transaction Broadcaster"); @@ -129,7 +127,7 @@ impl TxBroadcaster { let server = state.clone().start(); send_interval( - Duration::from_secs(BROADCAST_INTERVAL_SECS), + Duration::from_millis(tx_broadcasting_time_interval), server.clone(), InMessage::BroadcastTxs, ); From 561936706e1f3f3a9cbc2c3832b65e6628c3e809 Mon Sep 17 00:00:00 2001 From: Camila Di Ielsi Date: Thu, 2 Oct 2025 19:14:43 -0300 Subject: [PATCH 2/7] add flag on cli documentation --- cmd/ethrex/cli.rs | 2 +- docs/CLI.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/ethrex/cli.rs b/cmd/ethrex/cli.rs index 7a5f6cd45d5..e58012e7176 100644 --- a/cmd/ethrex/cli.rs +++ b/cmd/ethrex/cli.rs @@ -179,7 +179,7 @@ pub struct Options { long = "p2p.tx-broadcasting-interval", default_value = "1000", value_name = "INTERVAL_MS", - help = "Transaction Broadcasting Time Interval (ms) for batching transactions before broadcasting them", + help = "Transaction Broadcasting Time Interval (ms) for batching transactions before broadcasting them.", help_heading = "P2P options" )] pub tx_broadcasting_time_interval: u64, diff --git a/docs/CLI.md b/docs/CLI.md index 4580fad00fb..1597616fa82 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -83,6 +83,11 @@ P2P options: UDP port for P2P discovery. [default: 30303] + + --p2p.tx-broadcasting-interval + Transaction Broadcasting Time Interval (ms) for batching transactions before broadcasting them. + + [default: 1000] RPC options: --http.addr
From fa0f1d7ec630a12d775bf78948b32407ba525562 Mon Sep 17 00:00:00 2001 From: Camila Di Ielsi Date: Fri, 3 Oct 2025 10:20:22 -0300 Subject: [PATCH 3/7] check tests passes on hive branch --- .github/workflows/pr-main_l1.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-main_l1.yaml b/.github/workflows/pr-main_l1.yaml index ea5862c1119..53cb225a74e 100644 --- a/.github/workflows/pr-main_l1.yaml +++ b/.github/workflows/pr-main_l1.yaml @@ -106,7 +106,7 @@ jobs: - uses: actions/checkout@v4 - name: Setup Hive run: | - git clone --single-branch --branch master https://github.com/lambdaclass/hive + git clone --single-branch --branch add_tx_broadcasting_time_interval_flag https://github.com/lambdaclass/hive cd hive git checkout --detach ${{ env.HIVE_COMMIT_HASH }} go build . From b7fa43e1eab26aed59de6f9f4ae3a3748def33f0 Mon Sep 17 00:00:00 2001 From: Camila Di Ielsi Date: Fri, 3 Oct 2025 12:22:30 -0300 Subject: [PATCH 4/7] back to hive master branch to use in the ci --- .github/workflows/pr-main_l1.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-main_l1.yaml b/.github/workflows/pr-main_l1.yaml index 53cb225a74e..ea5862c1119 100644 --- a/.github/workflows/pr-main_l1.yaml +++ b/.github/workflows/pr-main_l1.yaml @@ -106,7 +106,7 @@ jobs: - uses: actions/checkout@v4 - name: Setup Hive run: | - git clone --single-branch --branch add_tx_broadcasting_time_interval_flag https://github.com/lambdaclass/hive + git clone --single-branch --branch master https://github.com/lambdaclass/hive cd hive git checkout --detach ${{ env.HIVE_COMMIT_HASH }} go build . From df9485e1d4a35afc5951b7123e70bdac4bbccfe3 Mon Sep 17 00:00:00 2001 From: Camila Di Ielsi Date: Mon, 6 Oct 2025 14:59:23 -0300 Subject: [PATCH 5/7] set default value as a constant --- cmd/ethrex/cli.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/ethrex/cli.rs b/cmd/ethrex/cli.rs index e58012e7176..6e06461b18d 100644 --- a/cmd/ethrex/cli.rs +++ b/cmd/ethrex/cli.rs @@ -24,6 +24,9 @@ use crate::{ }; use ethrex_config::networks::Network; +// Amount of seconds between each broadcast +const BROADCAST_INTERVAL_MS: u64 = 1000; // 1 second + #[allow(clippy::upper_case_acronyms)] #[derive(ClapParser)] #[command(name="ethrex", author = "Lambdaclass", version=get_client_version(), about = "ethrex Execution client")] @@ -177,7 +180,7 @@ pub struct Options { pub discovery_port: String, #[arg( long = "p2p.tx-broadcasting-interval", - default_value = "1000", + default_value_t = BROADCAST_INTERVAL_MS, value_name = "INTERVAL_MS", help = "Transaction Broadcasting Time Interval (ms) for batching transactions before broadcasting them.", help_heading = "P2P options" From 99052261aca00dd90ee14ca9b95c3933f7c0d2ca Mon Sep 17 00:00:00 2001 From: Camila Di Ielsi Date: Wed, 8 Oct 2025 15:37:21 -0300 Subject: [PATCH 6/7] take constant back to original place --- cmd/ethrex/cli.rs | 6 +----- crates/networking/p2p/tx_broadcaster.rs | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/ethrex/cli.rs b/cmd/ethrex/cli.rs index 2a396dc12b4..443d5b5a6b7 100644 --- a/cmd/ethrex/cli.rs +++ b/cmd/ethrex/cli.rs @@ -8,8 +8,7 @@ use std::{ use clap::{ArgAction, Parser as ClapParser, Subcommand as ClapSubcommand}; use ethrex_blockchain::{BlockchainOptions, BlockchainType, error::ChainError}; use ethrex_common::types::{Block, Genesis}; -use ethrex_p2p::sync::SyncMode; -use ethrex_p2p::types::Node; +use ethrex_p2p::{sync::SyncMode, tx_broadcaster::BROADCAST_INTERVAL_MS, types::Node}; use ethrex_rlp::encode::RLPEncode; use ethrex_storage::error::StoreError; use tracing::{Level, info, warn}; @@ -24,9 +23,6 @@ use crate::{ }; use ethrex_config::networks::Network; -// Amount of seconds between each broadcast -const BROADCAST_INTERVAL_MS: u64 = 1000; // 1 second - #[allow(clippy::upper_case_acronyms)] #[derive(ClapParser)] #[command(name="ethrex", author = "Lambdaclass", version=get_client_version(), about = "ethrex Execution client")] diff --git a/crates/networking/p2p/tx_broadcaster.rs b/crates/networking/p2p/tx_broadcaster.rs index 3bddaeb0e2e..529f240f4db 100644 --- a/crates/networking/p2p/tx_broadcaster.rs +++ b/crates/networking/p2p/tx_broadcaster.rs @@ -34,6 +34,9 @@ const PRUNE_WAIT_TIME_SECS: u64 = 600; // 10 minutes // Amount of seconds between each prune const PRUNE_INTERVAL_SECS: u64 = 360; // 6 minutes +// Amount of milliseconds between each broadcast +pub const BROADCAST_INTERVAL_MS: u64 = 1000; // 1 second + #[derive(Debug, Clone, Default)] struct PeerMask { bits: Vec, From c09ed502b7af36c136f1c9d0d2b689046692cac0 Mon Sep 17 00:00:00 2001 From: Camila Di Ielsi Date: Tue, 14 Oct 2025 11:56:49 -0300 Subject: [PATCH 7/7] replace lambda/hive with ethereum/hive --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 599af959f1c..076e329a0f8 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,7 @@ setup-hive: ## 🐝 Set up Hive testing framework git pull origin $(HIVE_BRANCH) && \ go build .; \ else \ - git clone --branch $(HIVE_BRANCH) https://github.com/lambdaclass/hive && \ + git clone --branch $(HIVE_BRANCH) https://github.com/ethereum/hive && \ cd hive && \ git checkout $(HIVE_BRANCH) && \ go build .; \