Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
3 changes: 1 addition & 2 deletions src/tasks/submit/builder_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ impl BuilderHelperTask {
let host_block_number = sim_result.host_block_number();

let span = sim_result.sim_env.span.clone();

span_debug!(span, "submit channel received block");
span_debug!(span, "builder helper task received block");

// Don't submit empty blocks
if sim_result.block.is_empty() {
Expand Down
40 changes: 28 additions & 12 deletions src/tasks/submit/flashbots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
use tracing::{Instrument, debug, debug_span};

/// Handles construction, simulation, and submission of rollup blocks to the
/// Flashbots network.
Expand Down Expand Up @@ -117,38 +117,54 @@ impl FlashbotsTask {
debug!("upstream task gone - exiting flashbots task");
break;
};
let span = sim_result.span();
span_debug!(span, "received sim result");

let span = sim_result.sim_env.clone_span();

// Don't submit empty blocks
if sim_result.block.is_empty() {
counter!("signet.builder.flashbots.empty_block").increment(1);
span_debug!(span, "received empty block - skipping");
continue;
}
span_debug!(span, "flashbots task received block");

// Prepare a MEV bundle with the configured call type from the sim result
let Ok(bundle) =
self.prepare(&sim_result).instrument(span.clone()).await.inspect_err(|error| {
counter!("signet.builder.flashbots.bundle_prep_failures").increment(1);
span_debug!(span, %error, "bundle preparation failed");
})
else {
let res = self.prepare(&sim_result).instrument(span.clone()).await;
let Ok(bundle) = res else {
counter!("signet.builder.flashbots.bundle_prep_failures").increment(1);
let error = res.unwrap_err();
span_debug!(span, %error, "bundle preparation failed");
continue;
};

// Send the bundle to Flashbots
// Make a child span to cover submission
let submit_span = debug_span!(
parent: &span,
"flashbots.submit",
);

// 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!(
span,
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!(span, %err, "MEV bundle submission failed - error returned");
span_error!(submit_span, %err, "MEV bundle submission failed - error returned");
}
}
}
Expand Down
Loading