@@ -11,28 +11,28 @@ use twmq::job::RequeuePosition;
1111pub enum EoaExecutionError {
1212 /// Nonce too low - transaction might already be in mempool
1313 NonceTooLow { message : String } ,
14-
14+
1515 /// Nonce too high - indicates nonce gap or desync
1616 NonceTooHigh { message : String } ,
17-
17+
1818 /// Transaction already known in mempool
1919 AlreadyKnown { message : String } ,
20-
20+
2121 /// Replacement transaction underpriced
2222 ReplacementUnderpriced { message : String } ,
23-
23+
2424 /// Insufficient funds for transaction
2525 InsufficientFunds { message : String } ,
26-
26+
2727 /// Gas-related error (limit, estimation, etc.)
2828 GasError { message : String } ,
29-
29+
3030 /// Transaction pool is full or has limits
3131 PoolLimitExceeded { message : String } ,
32-
32+
3333 /// Account does not exist or invalid
3434 AccountError { message : String } ,
35-
35+
3636 /// Network/connectivity issues - use existing handling
3737 RpcError {
3838 message : String ,
@@ -65,9 +65,10 @@ impl EoaErrorMapper {
6565 chain : & C ,
6666 ) -> Result < EoaExecutionError , EngineError > {
6767 match error {
68- RpcError :: ErrorResp ( error_payload) => {
69- Ok ( Self :: map_ethereum_error ( error_payload. code , & error_payload. message ) )
70- }
68+ RpcError :: ErrorResp ( error_payload) => Ok ( Self :: map_ethereum_error (
69+ error_payload. code ,
70+ & error_payload. message ,
71+ ) ) ,
7172 _ => {
7273 // Use existing engine error handling for non-actionable errors
7374 Err ( error. to_engine_error ( chain) )
@@ -78,7 +79,7 @@ impl EoaErrorMapper {
7879 /// Map Ethereum-specific errors that we need to act on
7980 fn map_ethereum_error ( code : i64 , message : & str ) -> EoaExecutionError {
8081 let msg_lower = message. to_lowercase ( ) ;
81-
82+
8283 match code {
8384 -32000 => {
8485 // Only handle the specific ethereum errors we care about
@@ -118,15 +119,19 @@ impl EoaErrorMapper {
118119 // Not an actionable error - let engine error handle it
119120 EoaExecutionError :: RpcError {
120121 message : message. to_string ( ) ,
121- inner_error : Some ( EngineError :: InternalError { message : message. to_string ( ) } ) ,
122+ inner_error : Some ( EngineError :: InternalError {
123+ message : message. to_string ( ) ,
124+ } ) ,
122125 }
123126 }
124127 }
125128 _ => {
126129 // Not an actionable error code
127130 EoaExecutionError :: RpcError {
128131 message : format ! ( "RPC error code {}: {}" , code, message) ,
129- inner_error : Some ( EngineError :: InternalError { message : message. to_string ( ) } ) ,
132+ inner_error : Some ( EngineError :: InternalError {
133+ message : message. to_string ( ) ,
134+ } ) ,
130135 }
131136 }
132137 }
@@ -142,63 +147,63 @@ impl EoaErrorMapper {
142147 retryable : false ,
143148 retry_delay : None ,
144149 } ,
145-
150+
146151 EoaExecutionError :: NonceTooHigh { .. } => RecoveryStrategy {
147152 queue_confirmation : false ,
148153 recycle_nonce : true ,
149154 needs_resync : true ,
150155 retryable : true ,
151156 retry_delay : Some ( Duration :: from_secs ( 10 ) ) ,
152157 } ,
153-
158+
154159 EoaExecutionError :: AlreadyKnown { .. } => RecoveryStrategy {
155160 queue_confirmation : true ,
156161 recycle_nonce : false ,
157162 needs_resync : false ,
158163 retryable : false ,
159164 retry_delay : None ,
160165 } ,
161-
166+
162167 EoaExecutionError :: ReplacementUnderpriced { .. } => RecoveryStrategy {
163168 queue_confirmation : true ,
164169 recycle_nonce : false ,
165170 needs_resync : false ,
166171 retryable : true ,
167172 retry_delay : Some ( Duration :: from_secs ( 10 ) ) ,
168173 } ,
169-
174+
170175 EoaExecutionError :: InsufficientFunds { .. } => RecoveryStrategy {
171176 queue_confirmation : false ,
172177 recycle_nonce : true ,
173178 needs_resync : false ,
174179 retryable : true ,
175180 retry_delay : Some ( Duration :: from_secs ( 60 ) ) ,
176181 } ,
177-
182+
178183 EoaExecutionError :: GasError { .. } => RecoveryStrategy {
179184 queue_confirmation : false ,
180185 recycle_nonce : true ,
181186 needs_resync : false ,
182187 retryable : true ,
183188 retry_delay : Some ( Duration :: from_secs ( 30 ) ) ,
184189 } ,
185-
190+
186191 EoaExecutionError :: PoolLimitExceeded { .. } => RecoveryStrategy {
187192 queue_confirmation : false ,
188193 recycle_nonce : true ,
189194 needs_resync : false ,
190195 retryable : true ,
191196 retry_delay : Some ( Duration :: from_secs ( 30 ) ) ,
192197 } ,
193-
198+
194199 EoaExecutionError :: AccountError { .. } => RecoveryStrategy {
195200 queue_confirmation : false ,
196201 recycle_nonce : true ,
197202 needs_resync : false ,
198203 retryable : false ,
199204 retry_delay : None ,
200205 } ,
201-
206+
202207 EoaExecutionError :: RpcError { .. } => {
203208 // This should not be used - let engine error handle it
204209 RecoveryStrategy {
@@ -208,7 +213,7 @@ impl EoaErrorMapper {
208213 retryable : false ,
209214 retry_delay : None ,
210215 }
211- } ,
216+ }
212217 }
213218 }
214219}
@@ -229,7 +234,7 @@ impl EoaExecutionError {
229234 | EoaExecutionError :: RpcError { message, .. } => message,
230235 }
231236 }
232-
237+
233238 /// Convert to appropriate job result for send operations
234239 pub fn to_send_job_result < T , E > (
235240 & self ,
@@ -244,9 +249,11 @@ impl EoaExecutionError {
244249 Ok ( success_factory ( ) )
245250 } else if strategy. retryable {
246251 if let Some ( delay) = strategy. retry_delay {
247- Err ( error_factory ( self . message ( ) . to_string ( ) ) . nack ( Some ( delay) , RequeuePosition :: Last ) )
252+ Err ( error_factory ( self . message ( ) . to_string ( ) )
253+ . nack ( Some ( delay) , RequeuePosition :: Last ) )
248254 } else {
249- Err ( error_factory ( self . message ( ) . to_string ( ) ) . nack ( Some ( Duration :: from_secs ( 5 ) ) , RequeuePosition :: Last ) )
255+ Err ( error_factory ( self . message ( ) . to_string ( ) )
256+ . nack ( Some ( Duration :: from_secs ( 5 ) ) , RequeuePosition :: Last ) )
250257 }
251258 } else {
252259 // Permanent failure
@@ -263,26 +270,29 @@ mod tests {
263270 fn test_nonce_too_low_mapping ( ) {
264271 let error = EoaErrorMapper :: map_ethereum_error ( -32000 , "nonce too low" ) ;
265272 let strategy = EoaErrorMapper :: get_recovery_strategy ( & error) ;
266-
273+
267274 match error {
268275 EoaExecutionError :: NonceTooLow { .. } => { }
269276 _ => panic ! ( "Expected NonceTooLow error" ) ,
270277 }
271-
278+
272279 assert ! ( strategy. queue_confirmation) ;
273280 assert ! ( !strategy. recycle_nonce) ;
274281 }
275282
276283 #[ test]
277284 fn test_insufficient_funds_mapping ( ) {
278- let error = EoaErrorMapper :: map_ethereum_error ( -32000 , "insufficient funds for gas * price + value" ) ;
285+ let error = EoaErrorMapper :: map_ethereum_error (
286+ -32000 ,
287+ "insufficient funds for gas * price + value" ,
288+ ) ;
279289 let strategy = EoaErrorMapper :: get_recovery_strategy ( & error) ;
280-
290+
281291 match error {
282292 EoaExecutionError :: InsufficientFunds { .. } => { }
283293 _ => panic ! ( "Expected InsufficientFunds error" ) ,
284294 }
285-
295+
286296 assert ! ( !strategy. queue_confirmation) ;
287297 assert ! ( strategy. recycle_nonce) ;
288298 assert ! ( strategy. retryable) ;
@@ -292,13 +302,13 @@ mod tests {
292302 fn test_already_known_mapping ( ) {
293303 let error = EoaErrorMapper :: map_ethereum_error ( -32000 , "already known" ) ;
294304 let strategy = EoaErrorMapper :: get_recovery_strategy ( & error) ;
295-
305+
296306 match error {
297307 EoaExecutionError :: AlreadyKnown { .. } => { }
298308 _ => panic ! ( "Expected AlreadyKnown error" ) ,
299309 }
300-
310+
301311 assert ! ( strategy. queue_confirmation) ;
302312 assert ! ( !strategy. recycle_nonce) ;
303313 }
304- }
314+ }
0 commit comments