From 245388899fd7ab941797c43285714da24360963c Mon Sep 17 00:00:00 2001 From: evalir Date: Tue, 25 Nov 2025 12:25:20 +0100 Subject: [PATCH 1/3] fix(flashbots): do not block on submission No reason to block the entire loop on the time it takes to send the bundle and record metrics. This can happen in a spawned task while the loop just waits for the next value. --- src/tasks/submit/flashbots.rs | 46 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/tasks/submit/flashbots.rs b/src/tasks/submit/flashbots.rs index 7ec68a2a..11e5e6de 100644 --- a/src/tasks/submit/flashbots.rs +++ b/src/tasks/submit/flashbots.rs @@ -191,28 +191,32 @@ impl FlashbotsTask { // Send the bundle to Flashbots, instrumenting the send future so all // events inside the async send are attributed to the submit span. - let response = self - .flashbots() - .send_mev_bundle(bundle.clone()) - .with_auth(self.signer.clone()) - .into_future() - .instrument(submit_span.clone()) - .await; - - match response { - Ok(resp) => { - counter!("signet.builder.flashbots.bundles_submitted").increment(1); - span_debug!( - submit_span, - hash = resp.map(|r| r.bundle_hash.to_string()), - "received bundle hash after submitted to flashbots" - ); + let flashbots = self.flashbots().to_owned(); + let signer = self.signer.clone(); + + tokio::spawn(async move { + let response = flashbots + .send_mev_bundle(bundle.clone()) + .with_auth(signer.clone()) + .into_future() + .instrument(submit_span.clone()) + .await; + + match response { + Ok(resp) => { + counter!("signet.builder.flashbots.bundles_submitted").increment(1); + span_debug!( + submit_span, + hash = resp.map(|r| r.bundle_hash.to_string()), + "received bundle hash after submitted to flashbots" + ); + } + Err(err) => { + counter!("signet.builder.flashbots.submission_failures").increment(1); + span_error!(submit_span, %err, "MEV bundle submission failed - error returned"); + } } - Err(err) => { - counter!("signet.builder.flashbots.submission_failures").increment(1); - span_error!(submit_span, %err, "MEV bundle submission failed - error returned"); - } - } + }); } } From ad75d0938194e98086020b88498fb37a9e75fe7f Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 4 Dec 2025 15:16:40 +0100 Subject: [PATCH 2/3] chore: correctly instrument submission --- src/tasks/submit/flashbots.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tasks/submit/flashbots.rs b/src/tasks/submit/flashbots.rs index 11e5e6de..89a0c173 100644 --- a/src/tasks/submit/flashbots.rs +++ b/src/tasks/submit/flashbots.rs @@ -188,6 +188,7 @@ impl FlashbotsTask { parent: &span, "flashbots.submit", ); + let submit_span_clone = submit_span.clone(); // Send the bundle to Flashbots, instrumenting the send future so all // events inside the async send are attributed to the submit span. @@ -199,24 +200,23 @@ impl FlashbotsTask { .send_mev_bundle(bundle.clone()) .with_auth(signer.clone()) .into_future() - .instrument(submit_span.clone()) .await; match response { Ok(resp) => { counter!("signet.builder.flashbots.bundles_submitted").increment(1); span_debug!( - submit_span, + submit_span_clone, hash = resp.map(|r| r.bundle_hash.to_string()), "received bundle hash after submitted to flashbots" ); } Err(err) => { counter!("signet.builder.flashbots.submission_failures").increment(1); - span_error!(submit_span, %err, "MEV bundle submission failed - error returned"); + span_error!(submit_span_clone, %err, "MEV bundle submission failed - error returned"); } } - }); + }.instrument(submit_span.clone())); } } From 0bb02aceb918b5cdb531c28b41c9f40512f1c81a Mon Sep 17 00:00:00 2001 From: evalir Date: Thu, 4 Dec 2025 15:20:59 +0100 Subject: [PATCH 3/3] chore: use debug and error instead of span_* --- src/tasks/submit/flashbots.rs | 45 ++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/tasks/submit/flashbots.rs b/src/tasks/submit/flashbots.rs index 89a0c173..2c1427e4 100644 --- a/src/tasks/submit/flashbots.rs +++ b/src/tasks/submit/flashbots.rs @@ -14,7 +14,7 @@ use alloy::{ use eyre::OptionExt; use init4_bin_base::{deps::metrics::counter, utils::signer::LocalOrAws}; use tokio::{sync::mpsc, task::JoinHandle}; -use tracing::{Instrument, debug, debug_span}; +use tracing::{Instrument, debug, debug_span, error}; /// Handles preparation and submission of simulated rollup blocks to the /// Flashbots relay as MEV bundles. @@ -188,35 +188,36 @@ impl FlashbotsTask { parent: &span, "flashbots.submit", ); - let submit_span_clone = submit_span.clone(); // Send the bundle to Flashbots, instrumenting the send future so all // events inside the async send are attributed to the submit span. let flashbots = self.flashbots().to_owned(); let signer = self.signer.clone(); - tokio::spawn(async move { - let response = flashbots - .send_mev_bundle(bundle.clone()) - .with_auth(signer.clone()) - .into_future() - .await; - - match response { - Ok(resp) => { - counter!("signet.builder.flashbots.bundles_submitted").increment(1); - span_debug!( - submit_span_clone, - hash = resp.map(|r| r.bundle_hash.to_string()), - "received bundle hash after submitted to flashbots" - ); - } - Err(err) => { - counter!("signet.builder.flashbots.submission_failures").increment(1); - span_error!(submit_span_clone, %err, "MEV bundle submission failed - error returned"); + tokio::spawn( + async move { + let response = flashbots + .send_mev_bundle(bundle.clone()) + .with_auth(signer.clone()) + .into_future() + .await; + + match response { + Ok(resp) => { + counter!("signet.builder.flashbots.bundles_submitted").increment(1); + debug!( + hash = resp.map(|r| r.bundle_hash.to_string()), + "received bundle hash after submitted to flashbots" + ); + } + Err(err) => { + counter!("signet.builder.flashbots.submission_failures").increment(1); + error!(%err, "MEV bundle submission failed - error returned"); + } } } - }.instrument(submit_span.clone())); + .instrument(submit_span.clone()), + ); } }