From 73c421e2c82b3522002ab3b3df567a4a02281dcf Mon Sep 17 00:00:00 2001 From: Prithvish Date: Thu, 6 Nov 2025 05:19:24 +0530 Subject: [PATCH 1/2] Refactor error handling and nonce checks in EoaExecutorWorker - Simplified error handling for balance threshold updates by consolidating conditions. - Added logic to check nonce movement during gas bump attempts, allowing for early exit if the transaction is confirmed. - Enhanced logging to provide clearer context on transaction states and errors encountered during processing. --- executors/src/eoa/worker/confirm.rs | 60 ++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/executors/src/eoa/worker/confirm.rs b/executors/src/eoa/worker/confirm.rs index a0c547d..6d9bc19 100644 --- a/executors/src/eoa/worker/confirm.rs +++ b/executors/src/eoa/worker/confirm.rs @@ -389,24 +389,64 @@ impl EoaExecutorWorker { inner_error, .. } = &e { - if should_update_balance_threshold(inner_error) { - if let Err(e) = self.update_balance_threshold().await { - tracing::error!("Failed to update balance threshold: {}", e); - } + if should_update_balance_threshold(inner_error) + && let Err(e) = self.update_balance_threshold().await + { + tracing::error!("Failed to update balance threshold: {}", e); } - } else if let EoaExecutorWorkerError::RpcError { inner_error, .. } = &e { - if should_update_balance_threshold(inner_error) { - if let Err(e) = self.update_balance_threshold().await { - tracing::error!("Failed to update balance threshold: {}", e); - } + } else if let EoaExecutorWorkerError::RpcError { inner_error, .. } = &e + && should_update_balance_threshold(inner_error) + && let Err(e) = self.update_balance_threshold().await + { + tracing::error!("Failed to update balance threshold: {}", e); + } + // Check if nonce has moved ahead since we started the gas bump + // This handles the race condition where the original transaction + // confirmed between our initial nonce check and the gas bump attempt + let fresh_transaction_counts = match self + .chain + .provider() + .get_transaction_counts_with_flashblocks_support( + self.eoa, + self.chain.chain_id(), + ) + .await + { + Ok(counts) => counts, + Err(rpc_error) => { + tracing::warn!( + transaction_id = ?newest_transaction_data.transaction_id, + nonce = expected_nonce, + error = ?e, + rpc_check_error = ?rpc_error, + "Failed to build typed transaction for gas bump and also failed to check nonce" + ); + return Err(e); } + }; + + // If nonce has moved ahead, the transaction likely confirmed + // Break out of gas bump flow and let regular confirmation flow handle it + if fresh_transaction_counts.preconfirmed > expected_nonce { + tracing::info!( + transaction_id = ?newest_transaction_data.transaction_id, + nonce = expected_nonce, + current_preconfirmed_nonce = fresh_transaction_counts.preconfirmed, + current_latest_nonce = fresh_transaction_counts.latest, + "Gas bump simulation failed but nonce has moved ahead - transaction likely confirmed. Breaking out of gas bump flow." + ); + // Return success to break out of gas bump flow + // The regular confirmation flow will handle the confirmed transaction + return Ok(true); } tracing::warn!( transaction_id = ?newest_transaction_data.transaction_id, nonce = expected_nonce, + current_preconfirmed_nonce = fresh_transaction_counts.preconfirmed, + current_latest_nonce = fresh_transaction_counts.latest, error = ?e, - "Failed to build typed transaction for gas bump" + "Failed to build typed transaction for gas bump and nonce has not moved ahead" ); return Err(e); } From b59b1bf1b97c72b7246ae9508e4a3450028d041f Mon Sep 17 00:00:00 2001 From: Prithvish Date: Thu, 6 Nov 2025 05:36:19 +0530 Subject: [PATCH 2/2] update eoa health if nonce movement detected at gas bump attempt --- executors/src/eoa/worker/confirm.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/executors/src/eoa/worker/confirm.rs b/executors/src/eoa/worker/confirm.rs index 6d9bc19..6bd06d7 100644 --- a/executors/src/eoa/worker/confirm.rs +++ b/executors/src/eoa/worker/confirm.rs @@ -435,6 +435,19 @@ impl EoaExecutorWorker { current_latest_nonce = fresh_transaction_counts.latest, "Gas bump simulation failed but nonce has moved ahead - transaction likely confirmed. Breaking out of gas bump flow." ); + + if let Ok(mut health) = self.get_eoa_health().await { + let now = EoaExecutorStore::now(); + health.last_nonce_movement_at = now; + health.last_confirmation_at = now; + if let Err(update_err) = self.store.update_health_data(&health).await { + tracing::warn!( + error = ?update_err, + nonce = expected_nonce, + "Detected nonce movement but failed to refresh health data" + ); + } + } // Return success to break out of gas bump flow // The regular confirmation flow will handle the confirmed transaction return Ok(true);