Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ macro_rules! span_scoped {
($span:expr, $level:ident!($($arg:tt)*)) => {
$span.in_scope(|| {
$level!($($arg)*);
});
})
};
}

Expand Down
7 changes: 2 additions & 5 deletions src/tasks/block/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,7 @@ impl Simulator {
let Some(sim_env) = self.sim_env.borrow_and_update().clone() else { return };

let span = sim_env.span();

span.in_scope(|| {
info!("new block environment received");
});
span_scoped!(span, info!("new block environment received"));

// Calculate the deadline for this block simulation.
// NB: This must happen _after_ taking a reference to the sim cache,
Expand All @@ -222,7 +219,7 @@ impl Simulator {
.handle_build(constants.clone(), sim_cache, finish_by, sim_env.block_env.clone())
.instrument(span.clone())
.await
.inspect_err(|err| span.in_scope(|| error!(%err, "error during block build")))
.inspect_err(|err| span_scoped!(span, error!(%err, "error during block build")))
else {
continue;
};
Expand Down
4 changes: 1 addition & 3 deletions src/tasks/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ impl EnvTask {
let mut headers = match self.ru_provider.subscribe_blocks().await {
Ok(poller) => poller,
Err(err) => {
span.in_scope(|| {
error!(%err, "Failed to subscribe to blocks");
});
span_scoped!(span, error!(%err, "Failed to subscribe to blocks"));
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/submit/builder_helper/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl BuilderHelperTask {
// Set up a span for the send operation. We'll add this to the spawned
// tasks
let span = debug_span!("BuilderHelperTask::send_transaction", tx_hash = %tx.hash());
span.in_scope(|| debug!("sending transaction to network"));
span_scoped!(span, debug!("sending transaction to network"));

// send the tx via the primary host_provider
let fut = spawn_provider_send!(self.provider(), &tx, &span);
Expand Down
51 changes: 26 additions & 25 deletions src/tasks/submit/flashbots/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use signet_constants::SignetSystemConstants;
use signet_types::SignRequest;
use signet_zenith::{Alloy2718Coder, Zenith::BlockHeader, ZenithBlock};
use tokio::{sync::mpsc, task::JoinHandle};
use tracing::Instrument;

/// Errors that the `FlashbotsTask` can encounter.
#[derive(Debug)]
Expand Down Expand Up @@ -94,7 +95,7 @@ impl FlashbotsTask {
self.constants.clone(),
);

let tx = prep.prep_transaction(&sim_result.env.prev_header).await.map_err(|err| {
let tx = prep.prep_transaction(&sim_result.sim_env.prev_header).await.map_err(|err| {
error!(?err, "failed to prepare bumpable transaction");
FlashbotsError::PreparationError(err.to_string())
})?;
Expand Down Expand Up @@ -224,37 +225,37 @@ impl FlashbotsTask {
debug!("upstream task gone - exiting flashbots task");
break;
};
debug!(?sim_result.env.block_env.number, "simulation block received");

let span = sim_result.span();
span_scoped!(span, debug!("simulation result received"));

// Prepare a MEV bundle with the configured call type from the sim result
let bundle = if let Ok(bundle) = self.prepare(&sim_result).await {
debug!("bundle prepared");
bundle
} else {
debug!("bundle preparation failed");
let Ok(bundle) = self.prepare(&sim_result).instrument(span.clone()).await else {
span_scoped!(span, debug!("bundle preparation failed"));
continue;
};

// simulate the bundle against Flashbots then send the bundle
let sim_bundle_result = flashbots.simulate_bundle(bundle.clone()).await;
match sim_bundle_result {
Ok(_) => {
debug!("bundle simulation successful, ready to send");
match flashbots.send_bundle(bundle).await {
Ok(bundle_hash) => {
debug!(?bundle_hash, "bundle successfully sent to Flashbots");
}
Err(err) => {
error!(?err, "failed to send bundle to Flashbots");
continue;
}
}
}
Err(err) => {
error!(?err, "bundle simulation failed");
continue;
}
if let Err(err) =
flashbots.simulate_bundle(bundle.clone()).instrument(span.clone()).await
{
span_scoped!(span, debug!(%err, "bundle simulation failed"));
continue;
}

let _ = flashbots
.send_bundle(bundle)
.instrument(span.clone())
.await
.inspect(|bundle_hash| {
span_scoped!(
span,
debug!(bunlde_hash = %bundle_hash.bundle_hash, "bundle sent to Flashbots")
);
})
.inspect_err(|err| {
span_scoped!(span, error!(?err, "failed to send bundle to Flashbots"));
});
}
}

Expand Down