Skip to content

fix: use in_scope to narrow down guard usage #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 19, 2025
Merged
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
3 changes: 2 additions & 1 deletion src/tasks/submit/prep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use signet_sim::BuiltBlock;
use signet_types::{SignRequest, SignResponse};
use signet_zenith::BundleHelper;
use std::sync::OnceLock;
use tracing::Instrument;

/// Preparation logic for transactions issued to the host chain by the
/// [`SubmitTask`].
Expand Down Expand Up @@ -134,7 +135,7 @@ impl<'a> SubmitPrep<'a> {

/// Prepares a transaction for submission to the host chain.
pub async fn prep_transaction(self, prev_host: &Header) -> eyre::Result<Bumpable> {
let req = self.new_tx_request().await?;
let req = self.new_tx_request().in_current_span().await?;
Ok(Bumpable::new(req, prev_host))
}
}
Expand Down
31 changes: 22 additions & 9 deletions src/tasks/submit/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ impl SubmitTask {
// Retry loop
let result = loop {
let span = debug_span!(
parent: None,
"SubmitTask::retrying_send",
retries = bumpable.bump_count(),
nonce = bumpable.req().nonce,
Expand Down Expand Up @@ -231,11 +232,13 @@ impl SubmitTask {
let host_block_number = self.constants.rollup_block_to_host_block_num(ru_block_number);

let span = debug_span!(
"SubmitTask::loop",
parent: None,
"SubmitTask::task_future::transaction_prep",
ru_block_number,
host_block_number,
block_tx_count = sim_result.block.tx_count(),
);

let guard = span.enter();

debug!(ru_block_number, "submit channel received block");
Expand All @@ -249,22 +252,26 @@ impl SubmitTask {
// drop guard before await
drop(guard);

// Fetch the previous host block, not the current host block which is currently being built
let prev_host_block = host_block_number - 1;

let Ok(Some(prev_host)) = self
.provider()
.get_block_by_number(host_block_number.into())
.get_block_by_number(prev_host_block.into())
.into_future()
.instrument(span.clone())
.await
else {
let _guard = span.enter();
warn!(ru_block_number, host_block_number, "failed to get previous host block");
span.in_scope(|| {
warn!(ru_block_number, host_block_number, "failed to get previous host block")
});
continue;
};

// Prep the span we'll use for the transaction submission
let submission_span = debug_span!(
parent: span,
"SubmitTask::tx_submission",
parent: &span,
"SubmitTask::task_future::transaction_submission",
tx_count = sim_result.block.tx_count(),
host_block_number,
ru_block_number,
Expand All @@ -285,7 +292,9 @@ impl SubmitTask {
{
Ok(bumpable) => bumpable,
Err(error) => {
error!(%error, "failed to prepare transaction for submission");
submission_span.in_scope(|| {
error!(%error, "failed to prepare transaction for submission");
});
continue;
}
};
Expand All @@ -294,15 +303,19 @@ impl SubmitTask {
if let Err(error) =
self.sim_with_call(bumpable.req()).instrument(submission_span.clone()).await
{
error!(%error, "simulation failed for transaction");
submission_span.in_scope(|| {
error!(%error, "simulation failed for transaction");
});
continue;
};

// Now send the transaction
if let Err(error) =
self.retrying_send(bumpable, 3).instrument(submission_span.clone()).await
{
error!(%error, "error dispatching block to host chain");
submission_span.in_scope(|| {
error!(%error, "error dispatching block to host chain");
});
continue;
}
}
Expand Down
Loading