Skip to content

Commit d823e4e

Browse files
committed
fix: use in_scope to narrow down guard usage
1 parent 6ecca6e commit d823e4e

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/tasks/submit/prep.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use signet_sim::BuiltBlock;
1717
use signet_types::{SignRequest, SignResponse};
1818
use signet_zenith::BundleHelper;
1919
use std::sync::OnceLock;
20+
use tracing::Instrument;
2021

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

135136
/// Prepares a transaction for submission to the host chain.
136137
pub async fn prep_transaction(self, prev_host: &Header) -> eyre::Result<Bumpable> {
137-
let req = self.new_tx_request().await?;
138+
let req = self.new_tx_request().in_current_span().await?;
138139
Ok(Bumpable::new(req, prev_host))
139140
}
140141
}

src/tasks/submit/task.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl SubmitTask {
139139
// Retry loop
140140
let result = loop {
141141
let span = debug_span!(
142+
parent: None,
142143
"SubmitTask::retrying_send",
143144
retries = bumpable.bump_count(),
144145
nonce = bumpable.req().nonce,
@@ -231,11 +232,13 @@ impl SubmitTask {
231232
let host_block_number = self.constants.rollup_block_to_host_block_num(ru_block_number);
232233

233234
let span = debug_span!(
234-
"SubmitTask::loop",
235+
parent: None,
236+
"SubmitTask::task_future::transaction_prep",
235237
ru_block_number,
236238
host_block_number,
237239
block_tx_count = sim_result.block.tx_count(),
238240
);
241+
239242
let guard = span.enter();
240243

241244
debug!(ru_block_number, "submit channel received block");
@@ -256,15 +259,16 @@ impl SubmitTask {
256259
.instrument(span.clone())
257260
.await
258261
else {
259-
let _guard = span.enter();
260-
warn!(ru_block_number, host_block_number, "failed to get previous host block");
262+
span.in_scope(|| {
263+
warn!(ru_block_number, host_block_number, "failed to get previous host block")
264+
});
261265
continue;
262266
};
263267

264268
// Prep the span we'll use for the transaction submission
265269
let submission_span = debug_span!(
266270
parent: span,
267-
"SubmitTask::tx_submission",
271+
"SubmitTask::task_future::transaction_submission",
268272
tx_count = sim_result.block.tx_count(),
269273
host_block_number,
270274
ru_block_number,
@@ -285,7 +289,9 @@ impl SubmitTask {
285289
{
286290
Ok(bumpable) => bumpable,
287291
Err(error) => {
288-
error!(%error, "failed to prepare transaction for submission");
292+
submission_span.in_scope(|| {
293+
error!(%error, "failed to prepare transaction for submission");
294+
});
289295
continue;
290296
}
291297
};
@@ -294,15 +300,19 @@ impl SubmitTask {
294300
if let Err(error) =
295301
self.sim_with_call(bumpable.req()).instrument(submission_span.clone()).await
296302
{
297-
error!(%error, "simulation failed for transaction");
303+
submission_span.in_scope(|| {
304+
error!(%error, "simulation failed for transaction");
305+
});
298306
continue;
299307
};
300308

301309
// Now send the transaction
302310
if let Err(error) =
303311
self.retrying_send(bumpable, 3).instrument(submission_span.clone()).await
304312
{
305-
error!(%error, "error dispatching block to host chain");
313+
submission_span.in_scope(|| {
314+
error!(%error, "error dispatching block to host chain");
315+
});
306316
continue;
307317
}
308318
}

0 commit comments

Comments
 (0)