@@ -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" ) ;
@@ -249,22 +252,26 @@ impl SubmitTask {
249252 // drop guard before await
250253 drop ( guard) ;
251254
255+ // Fetch the previous host block, not the current host block which is currently being built
256+ let prev_host_block = host_block_number - 1 ;
257+
252258 let Ok ( Some ( prev_host) ) = self
253259 . provider ( )
254- . get_block_by_number ( host_block_number . into ( ) )
260+ . get_block_by_number ( prev_host_block . into ( ) )
255261 . into_future ( )
256262 . instrument ( span. clone ( ) )
257263 . await
258264 else {
259- let _guard = span. enter ( ) ;
260- warn ! ( ru_block_number, host_block_number, "failed to get previous host block" ) ;
265+ span. in_scope ( || {
266+ warn ! ( ru_block_number, host_block_number, "failed to get previous host block" )
267+ } ) ;
261268 continue ;
262269 } ;
263270
264271 // Prep the span we'll use for the transaction submission
265272 let submission_span = debug_span ! (
266- parent: span,
267- "SubmitTask::tx_submission " ,
273+ parent: & span,
274+ "SubmitTask::task_future::transaction_submission " ,
268275 tx_count = sim_result. block. tx_count( ) ,
269276 host_block_number,
270277 ru_block_number,
@@ -285,7 +292,9 @@ impl SubmitTask {
285292 {
286293 Ok ( bumpable) => bumpable,
287294 Err ( error) => {
288- error ! ( %error, "failed to prepare transaction for submission" ) ;
295+ submission_span. in_scope ( || {
296+ error ! ( %error, "failed to prepare transaction for submission" ) ;
297+ } ) ;
289298 continue ;
290299 }
291300 } ;
@@ -294,15 +303,19 @@ impl SubmitTask {
294303 if let Err ( error) =
295304 self . sim_with_call ( bumpable. req ( ) ) . instrument ( submission_span. clone ( ) ) . await
296305 {
297- error ! ( %error, "simulation failed for transaction" ) ;
306+ submission_span. in_scope ( || {
307+ error ! ( %error, "simulation failed for transaction" ) ;
308+ } ) ;
298309 continue ;
299310 } ;
300311
301312 // Now send the transaction
302313 if let Err ( error) =
303314 self . retrying_send ( bumpable, 3 ) . instrument ( submission_span. clone ( ) ) . await
304315 {
305- error ! ( %error, "error dispatching block to host chain" ) ;
316+ submission_span. in_scope ( || {
317+ error ! ( %error, "error dispatching block to host chain" ) ;
318+ } ) ;
306319 continue ;
307320 }
308321 }
0 commit comments