@@ -17,11 +17,12 @@ use alloy::{
17
17
use eyre:: bail;
18
18
use init4_bin_base:: deps:: {
19
19
metrics:: { counter, histogram} ,
20
- tracing:: { Instrument , debug, debug_span, error, info, warn} ,
20
+ tracing:: { debug, debug_span, error, info, warn} ,
21
21
} ;
22
22
use signet_constants:: SignetSystemConstants ;
23
23
use std:: time:: Instant ;
24
24
use tokio:: { sync:: mpsc, task:: JoinHandle } ;
25
+ use tracing:: Instrument ;
25
26
26
27
macro_rules! spawn_provider_send {
27
28
( $provider: expr, $tx: expr) => {
@@ -130,21 +131,22 @@ impl SubmitTask {
130
131
retry_limit : usize ,
131
132
) -> eyre:: Result < ControlFlow > {
132
133
let submitting_start_time = Instant :: now ( ) ;
133
- let now = utils:: now ( ) ;
134
134
let ( expected_slot, start, end) = self . calculate_slot_window ( ) ;
135
- debug ! ( expected_slot, start, end, now , "calculating target slot window" ) ;
135
+ debug ! ( expected_slot, start, end, "calculating target slot window" ) ;
136
136
137
137
let mut req = bumpable. req ( ) . clone ( ) ;
138
138
139
+ let span = debug_span ! (
140
+ "SubmitTask::retrying_send" ,
141
+ initial_nonce = ?bumpable. req( ) . nonce,
142
+ ) ;
143
+ let _guard = span. enter ( ) ;
144
+
139
145
// Retry loop
140
146
let result = loop {
141
- let span = debug_span ! (
142
- "SubmitTask::retrying_send" ,
143
- retries = bumpable. bump_count( ) ,
144
- nonce = bumpable. req( ) . nonce,
145
- ) ;
147
+ debug ! ( retries = bumpable. bump_count( ) , nonce = ?req. nonce, "attempting transaction send" ) ;
146
148
147
- let inbound_result = match self . send_transaction ( req) . instrument ( span . clone ( ) ) . await {
149
+ let inbound_result = match self . send_transaction ( req. clone ( ) ) . await {
148
150
Ok ( control_flow) => control_flow,
149
151
Err ( error) => {
150
152
if let Some ( value) = self . slot_still_valid ( expected_slot) {
@@ -156,8 +158,6 @@ impl SubmitTask {
156
158
}
157
159
} ;
158
160
159
- let guard = span. entered ( ) ;
160
-
161
161
match inbound_result {
162
162
ControlFlow :: Retry => {
163
163
if let Some ( value) = self . slot_still_valid ( expected_slot) {
@@ -170,7 +170,6 @@ impl SubmitTask {
170
170
debug ! ( "retries exceeded - skipping block" ) ;
171
171
return Ok ( ControlFlow :: Skip ) ;
172
172
}
173
- drop ( guard) ;
174
173
debug ! ( retries = bumpable. bump_count( ) , start, end, "retrying block" ) ;
175
174
continue ;
176
175
}
@@ -230,44 +229,37 @@ impl SubmitTask {
230
229
let ru_block_number = sim_result. block . block_number ( ) ;
231
230
let host_block_number = self . constants . rollup_block_to_host_block_num ( ru_block_number) ;
232
231
232
+ // Don't submit empty blocks
233
+ if sim_result. block . is_empty ( ) {
234
+ debug ! ( ru_block_number, "received empty block - skipping" ) ;
235
+ continue ;
236
+ }
237
+
238
+ // Create a span for the entire block processing operation
233
239
let span = debug_span ! (
234
240
"SubmitTask::loop" ,
235
241
ru_block_number,
236
242
host_block_number,
237
243
block_tx_count = sim_result. block. tx_count( ) ,
238
244
) ;
239
- let guard = span. enter ( ) ;
240
-
245
+ let _guard = span. enter ( ) ;
241
246
debug ! ( ru_block_number, "submit channel received block" ) ;
242
247
243
- // Don't submit empty blocks
244
- if sim_result. block . is_empty ( ) {
245
- debug ! ( ru_block_number, "received empty block - skipping" ) ;
246
- continue ;
247
- }
248
-
249
- // drop guard before await
250
- drop ( guard) ;
251
-
248
+ let prev_host_number = host_block_number - 1 ;
252
249
let Ok ( Some ( prev_host) ) = self
253
250
. provider ( )
254
- . get_block_by_number ( host_block_number . into ( ) )
251
+ . get_block_by_number ( prev_host_number . into ( ) )
255
252
. into_future ( )
256
253
. instrument ( span. clone ( ) )
257
254
. await
258
255
else {
259
- let _guard = span. enter ( ) ;
260
256
warn ! ( ru_block_number, host_block_number, "failed to get previous host block" ) ;
261
257
continue ;
262
258
} ;
263
259
264
- // Prep the span we'll use for the transaction submission
265
- let submission_span = debug_span ! (
266
- parent: span,
267
- "SubmitTask::tx_submission" ,
260
+ debug ! (
268
261
tx_count = sim_result. block. tx_count( ) ,
269
- host_block_number,
270
- ru_block_number,
262
+ host_block_number, ru_block_number, "preparing transaction submission"
271
263
) ;
272
264
273
265
// Prepare the transaction request for submission
@@ -278,30 +270,23 @@ impl SubmitTask {
278
270
self . config . clone ( ) ,
279
271
self . constants ,
280
272
) ;
281
- let bumpable = match prep
282
- . prep_transaction ( & prev_host. header )
283
- . instrument ( submission_span. clone ( ) )
284
- . await
285
- {
286
- Ok ( bumpable) => bumpable,
287
- Err ( error) => {
288
- error ! ( %error, "failed to prepare transaction for submission" ) ;
289
- continue ;
290
- }
291
- } ;
273
+ let bumpable =
274
+ match prep. prep_transaction ( & prev_host. header ) . instrument ( span. clone ( ) ) . await {
275
+ Ok ( bumpable) => bumpable,
276
+ Err ( error) => {
277
+ error ! ( %error, "failed to prepare transaction for submission" ) ;
278
+ continue ;
279
+ }
280
+ } ;
292
281
293
282
// Simulate the transaction to check for reverts
294
- if let Err ( error) =
295
- self . sim_with_call ( bumpable. req ( ) ) . instrument ( submission_span. clone ( ) ) . await
296
- {
283
+ if let Err ( error) = self . sim_with_call ( bumpable. req ( ) ) . instrument ( span. clone ( ) ) . await {
297
284
error ! ( %error, "simulation failed for transaction" ) ;
298
285
continue ;
299
286
} ;
300
287
301
288
// Now send the transaction
302
- if let Err ( error) =
303
- self . retrying_send ( bumpable, 3 ) . instrument ( submission_span. clone ( ) ) . await
304
- {
289
+ if let Err ( error) = self . retrying_send ( bumpable, 3 ) . instrument ( span. clone ( ) ) . await {
305
290
error ! ( %error, "error dispatching block to host chain" ) ;
306
291
continue ;
307
292
}
0 commit comments