Skip to content

Commit 0004416

Browse files
authored
fix(flashbots): Do not block on submission (#184)
There's no point of blocking when we send the bundle to flashbots. The only thing we do after is record metrics. This will matter more on a production environment where network lag could occur on services we don't control (flashbots). I think blocking on quincey/getting the nonce on `prepare` is OK.
1 parent 7c96333 commit 0004416

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

src/tasks/submit/flashbots.rs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use alloy::{
1414
use eyre::OptionExt;
1515
use init4_bin_base::{deps::metrics::counter, utils::signer::LocalOrAws};
1616
use tokio::{sync::mpsc, task::JoinHandle};
17-
use tracing::{Instrument, debug, debug_span};
17+
use tracing::{Instrument, debug, debug_span, error};
1818

1919
/// Handles preparation and submission of simulated rollup blocks to the
2020
/// Flashbots relay as MEV bundles.
@@ -188,28 +188,33 @@ impl FlashbotsTask {
188188

189189
// Send the bundle to Flashbots, instrumenting the send future so all
190190
// events inside the async send are attributed to the submit span.
191-
let response = self
192-
.flashbots()
193-
.send_mev_bundle(bundle.clone())
194-
.with_auth(self.signer.clone())
195-
.into_future()
196-
.instrument(submit_span.clone())
197-
.await;
198-
199-
match response {
200-
Ok(resp) => {
201-
counter!("signet.builder.flashbots.bundles_submitted").increment(1);
202-
span_debug!(
203-
submit_span,
204-
hash = resp.map(|r| r.bundle_hash.to_string()),
205-
"received bundle hash after submitted to flashbots"
206-
);
191+
let flashbots = self.flashbots().to_owned();
192+
let signer = self.signer.clone();
193+
194+
tokio::spawn(
195+
async move {
196+
let response = flashbots
197+
.send_mev_bundle(bundle.clone())
198+
.with_auth(signer.clone())
199+
.into_future()
200+
.await;
201+
202+
match response {
203+
Ok(resp) => {
204+
counter!("signet.builder.flashbots.bundles_submitted").increment(1);
205+
debug!(
206+
hash = resp.map(|r| r.bundle_hash.to_string()),
207+
"received bundle hash after submitted to flashbots"
208+
);
209+
}
210+
Err(err) => {
211+
counter!("signet.builder.flashbots.submission_failures").increment(1);
212+
error!(%err, "MEV bundle submission failed - error returned");
213+
}
214+
}
207215
}
208-
Err(err) => {
209-
counter!("signet.builder.flashbots.submission_failures").increment(1);
210-
span_error!(submit_span, %err, "MEV bundle submission failed - error returned");
211-
}
212-
}
216+
.instrument(submit_span.clone()),
217+
);
213218
}
214219
}
215220

0 commit comments

Comments
 (0)