@@ -122,7 +122,7 @@ impl SubmitTask {
122
122
) -> eyre:: Result < ControlFlow > {
123
123
let tx = self . prepare_tx ( retry_count, resp, block) . await ?;
124
124
125
- self . send_transaction ( resp, tx) . await
125
+ self . send_transaction ( retry_count , resp, tx) . await
126
126
}
127
127
128
128
/// Prepares the transaction by extracting the signature components, creating the transaction
@@ -155,13 +155,7 @@ impl SubmitTask {
155
155
if let Err ( TransportError :: ErrorResp ( e) ) =
156
156
self . provider ( ) . call ( tx. clone ( ) ) . block ( BlockNumberOrTag :: Pending . into ( ) ) . await
157
157
{
158
- error ! (
159
- code = e. code,
160
- message = %e. message,
161
- data = ?e. data,
162
- "error in transaction submission"
163
- ) ;
164
-
158
+ // NB: These errors are all handled the same way but are logged for debugging purposes
165
159
if e. as_revert_data ( )
166
160
. map ( |data| data. starts_with ( & IncorrectHostBlock :: SELECTOR ) )
167
161
. unwrap_or_default ( )
@@ -186,6 +180,12 @@ impl SubmitTask {
186
180
return Some ( Ok ( ControlFlow :: Skip ) ) ;
187
181
}
188
182
183
+ error ! (
184
+ code = e. code,
185
+ message = %e. message,
186
+ data = ?e. data,
187
+ "unknown error in host transaction simulation call"
188
+ ) ;
189
189
return Some ( Ok ( ControlFlow :: Skip ) ) ;
190
190
}
191
191
@@ -209,7 +209,7 @@ impl SubmitTask {
209
209
let ( max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas) =
210
210
calculate_gas_limits ( retry_count) ;
211
211
212
- // manually retrieve nonce
212
+ // manually retrieve nonce // TODO: Maybe this should be done in Env task and passed through elsewhere
213
213
let nonce =
214
214
self . provider ( ) . get_transaction_count ( self . provider ( ) . default_signer_address ( ) ) . await ?;
215
215
debug ! ( nonce, "assigned nonce" ) ;
@@ -233,59 +233,51 @@ impl SubmitTask {
233
233
. with_max_fee_per_blob_gas ( max_fee_per_blob_gas)
234
234
. with_nonce ( nonce) ;
235
235
236
- debug ! ( ?tx, "prepared transaction request" ) ;
237
236
Ok ( tx)
238
237
}
239
238
240
239
/// Fills the transaction request with the provider and sends it to the network
241
240
/// and any additionally configured broadcast providers.
242
241
async fn send_transaction (
243
242
& self ,
243
+ retry_count : usize ,
244
244
resp : & SignResponse ,
245
245
tx : TransactionRequest ,
246
246
) -> Result < ControlFlow , eyre:: Error > {
247
- debug ! (
248
- ?tx,
249
- host_block_number = %resp. req. host_block_number,
250
- gas_limit = %resp. req. gas_limit,
251
- "sending transaction to network"
252
- ) ;
253
-
254
247
// assign the nonce and fill the rest of the values
255
- debug ! ( ?tx, "blob transaction request before fill" ) ;
256
248
let SendableTx :: Envelope ( tx) = self . provider ( ) . fill ( tx) . await ? else {
257
249
bail ! ( "failed to fill transaction" )
258
250
} ;
259
- debug ! ( ?tx, "filled blob transaction") ;
251
+ debug ! ( tx_hash = ?tx. hash ( ) , host_block_number = %resp . req . host_block_number , "sending transaction to network ") ;
260
252
261
253
// send the tx via the primary host_provider
262
254
let fut = spawn_provider_send ! ( self . provider( ) , & tx) ;
263
255
264
- // spawn send_tx futures for all additional broadcast host_providers
265
- for host_provider in self . config . connect_additional_broadcast ( ) {
266
- spawn_provider_send ! ( & host_provider, & tx) ;
256
+ // spawn send_tx futures on retry attempts for all additional broadcast host_providers
257
+ if retry_count > 0 {
258
+ for host_provider in self . config . connect_additional_broadcast ( ) {
259
+ spawn_provider_send ! ( & host_provider, & tx) ;
260
+ }
267
261
}
268
262
269
263
// send the in-progress transaction over the outbound_tx_channel
270
264
if self . outbound_tx_channel . send ( * tx. tx_hash ( ) ) . is_err ( ) {
271
265
error ! ( "receipts task gone" ) ;
272
266
}
273
267
274
- // question mark unwraps join error, which would be an internal panic
275
- // then if let checks for rpc error
276
268
if let Err ( e) = fut. await ? {
277
- let err_str = e. to_string ( ) ;
278
- if err_str. contains ( "replacement transaction underpriced" ) {
269
+ // Detect and handle transaction underprice errors
270
+ if matches ! ( e, TransportError :: ErrorResp ( ref err) if err. code == -32000 && err. message. contains( "replacement transaction underpriced" ) )
271
+ {
279
272
debug ! ( ?tx, "underpriced transaction error - retrying tx with gas bump" ) ;
280
273
return Ok ( ControlFlow :: Retry ) ;
281
274
}
282
- error ! ( error = %e, "Primary tx broadcast failed. Skipping transaction." ) ;
275
+
276
+ // Unknown error, log and skip
277
+ error ! ( error = %e, "Primary tx broadcast failed" ) ;
283
278
return Ok ( ControlFlow :: Skip ) ;
284
279
}
285
280
286
- // Okay so the code gets all the way to this log
287
- // but we don't see the tx hash in the logs or in the explorer,
288
- // not even as a failed TX, just not at all.
289
281
info ! (
290
282
tx_hash = %tx. tx_hash( ) ,
291
283
ru_chain_id = %resp. req. ru_chain_id,
@@ -339,10 +331,7 @@ impl SubmitTask {
339
331
340
332
let inbound_result =
341
333
match self . handle_inbound ( retries, block) . instrument ( span. clone ( ) ) . await {
342
- Ok ( control_flow) => {
343
- debug ! ( ?control_flow, retries, "successfully handled inbound block" ) ;
344
- control_flow
345
- }
334
+ Ok ( control_flow) => control_flow,
346
335
Err ( err) => {
347
336
// Delay until next slot if we get a 403 error
348
337
if err. to_string ( ) . contains ( "403 Forbidden" ) {
@@ -353,7 +342,6 @@ impl SubmitTask {
353
342
error ! ( error = %err, "error handling inbound block" ) ;
354
343
}
355
344
356
- retries += 1 ;
357
345
ControlFlow :: Retry
358
346
}
359
347
} ;
@@ -437,7 +425,7 @@ impl SubmitTask {
437
425
last_block_attempted = block. block_number ( ) ;
438
426
debug ! ( last_block_attempted, "resetting last block attempted" ) ;
439
427
440
- if self . retrying_handle_inbound ( & block, 20 ) . await . is_err ( ) {
428
+ if self . retrying_handle_inbound ( & block, 3 ) . await . is_err ( ) {
441
429
debug ! ( "error handling inbound block" ) ;
442
430
continue ;
443
431
} ;
0 commit comments