-
Notifications
You must be signed in to change notification settings - Fork 8
Refactor error handling and nonce checks in EoaExecutorWorker #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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.
WalkthroughAdds nonce-freshness checks and consolidated balance-threshold error handling in the gas-bump/confirmation path; exits the gas-bump flow when on-chain nonce advances, updates health timestamps on nonce movement, and preserves original error when bump fails without nonce advancement. Changes
Sequence Diagram(s)sequenceDiagram
participant Flow as Confirmation Flow
participant GasBump as Gas Bump Builder
participant Balance as Balance Threshold Updater
participant Nonce as Nonce Freshness Checker
participant Chain as On-Chain State
participant Health as Health Timestamps
Flow->>GasBump: Attempt to build gas bump
alt Build succeeds
GasBump-->>Flow: Proceed with bump
else Build fails (TransactionSimulationFailed / RpcError)
GasBump->>Balance: Attempt update_balance_threshold() and log on failure
Balance-->>GasBump: Result (ok/err)
GasBump->>Nonce: Fetch on-chain tx counts (preconfirmed/latest)
Nonce->>Chain: Query transaction counts
Chain-->>Nonce: Return counts
alt Preconfirmed nonce advanced
note right of Nonce: Nonce moved ahead → treat as confirmed
Nonce->>Health: Update last_nonce_movement_at & last_confirmation_at
Health-->>Nonce: Ack (or log failure)
Nonce-->>Flow: Return Ok(true) (exit gas-bump flow)
else Preconfirmed nonce unchanged
Nonce-->>Flow: Log current preconfirmed/latest nonces
Flow-->>GasBump: Return original error (no nonce advancement)
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
executors/src/eoa/worker/confirm.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-20T05:30:35.171Z
Learnt from: joaquim-verges
Repo: thirdweb-dev/engine-core PR: 48
File: executors/src/eoa/worker/send.rs:20-21
Timestamp: 2025-09-20T05:30:35.171Z
Learning: In executors/src/eoa/worker/send.rs, there is a critical bug where HEALTH_CHECK_INTERVAL is defined as 300 seconds but compared against millisecond timestamps, causing balance checks to occur every 300ms instead of every 5 minutes (1000x more frequent than intended).
Applied to files:
executors/src/eoa/worker/confirm.rs
📚 Learning: 2025-09-20T06:58:40.230Z
Learnt from: d4mr
Repo: thirdweb-dev/engine-core PR: 48
File: executors/src/eoa/store/submitted.rs:229-230
Timestamp: 2025-09-20T06:58:40.230Z
Learning: The diff in executors/src/eoa/store/submitted.rs shows correct brace structure - the first closing brace closes the remove_transaction_from_redis_submitted_zset method and the second closing brace closes the impl CleanSubmittedTransactions block. The change only adds whitespace formatting.
Applied to files:
executors/src/eoa/worker/confirm.rs
🧬 Code graph analysis (1)
executors/src/eoa/worker/confirm.rs (1)
executors/src/eoa/worker/error.rs (1)
should_update_balance_threshold(215-235)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
executors/src/eoa/worker/confirm.rs (1)
392-402: Good consolidation of balance threshold update logic.The refactor unifies error handling for both
TransactionSimulationFailedandRpcErrorpaths, reducing duplication while preserving the original behavior. Error handling is appropriate—failures to update the balance threshold are logged but don't prevent the subsequent nonce freshness check.If you want to reduce the nesting further, consider extracting the update logic into a small helper:
async fn try_update_balance_threshold_for_error(&self, error: &EoaExecutorWorkerError) { let inner_error = match error { EoaExecutorWorkerError::TransactionSimulationFailed { inner_error, .. } => Some(inner_error), EoaExecutorWorkerError::RpcError { inner_error, .. } => Some(inner_error), _ => None, }; if let Some(inner) = inner_error { if should_update_balance_threshold(inner) { if let Err(e) = self.update_balance_threshold().await { tracing::error!("Failed to update balance threshold: {}", e); } } } }Then call
self.try_update_balance_threshold_for_error(&e).await;at line 392.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
executors/src/eoa/worker/confirm.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-20T05:30:35.171Z
Learnt from: joaquim-verges
Repo: thirdweb-dev/engine-core PR: 48
File: executors/src/eoa/worker/send.rs:20-21
Timestamp: 2025-09-20T05:30:35.171Z
Learning: In executors/src/eoa/worker/send.rs, there is a critical bug where HEALTH_CHECK_INTERVAL is defined as 300 seconds but compared against millisecond timestamps, causing balance checks to occur every 300ms instead of every 5 minutes (1000x more frequent than intended).
Applied to files:
executors/src/eoa/worker/confirm.rs
🧬 Code graph analysis (1)
executors/src/eoa/worker/confirm.rs (2)
executors/src/eoa/worker/error.rs (1)
should_update_balance_threshold(215-235)executors/src/eoa/store/mod.rs (1)
now(832-834)
🔇 Additional comments (1)
executors/src/eoa/worker/confirm.rs (1)
403-464: Excellent addition of nonce freshness check—previous review concern addressed.The nonce freshness check correctly handles the race condition where the transaction confirms between the initial nonce check and the gas bump attempt. The health timestamp update (lines 439-450) directly implements the suggestion from the previous review comment, preventing false stuck alerts in subsequent iterations.
Implementation details verified:
- Fresh transaction counts are fetched after the gas bump build fails (lines 403-426)
- When
preconfirmed > expected_nonce, health timestamps are updated and the flow exits with success (lines 428-454)- If fetching fresh counts fails, the original error is returned (line 424)
- Enhanced logging includes fresh nonce values for debugging (lines 459-460)
Note on health update resilience:
Ifget_eoa_health()fails at line 439, the code logs a warning but continues and returnsOk(true). This is acceptable—the regular confirmation flow will update health timestamps when it processes the confirmed transaction in the next iteration (as seen in lines 267-280 ofconfirm_flow).
Summary by CodeRabbit
Bug Fixes
Monitoring