improve(tx-client): typed error when broadcast tx cannot be confirmed#3467
Draft
droplet-rl wants to merge 1 commit into
Draft
improve(tx-client): typed error when broadcast tx cannot be confirmed#3467droplet-rl wants to merge 1 commit into
droplet-rl wants to merge 1 commit into
Conversation
`TransactionClient._submit`'s confirmation loop previously warned and returned the broadcast `TransactionResponse` when `wait()` never produced a receipt within `maxTries` retries. Callers couldn't distinguish a confirmed tx from one that was broadcast but stuck unconfirmed — `sendAndConfirmTransaction` would then call `.wait()` again on the same response, potentially polling forever, while the gasless relayer's stuck-queue reporting (PR #3464) had no signal to count it against. Introduce `TransactionConfirmationFailedError`, throw it from `_submit` after exhausting retries, and whitelist it in `TransactionClient.submit` so it propagates out rather than being swallowed alongside generic submission errors. Other error categories continue to be logged and swallowed at submit's existing surface. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Slack discussion: continuation of the gasless stuck-queue reporting thread (PRs #3464, #3465, #3466). Opening as a draft because this changes
TransactionClient.submit's contract slightly — worth a sanity check before merging.TransactionClient._submit's confirmation loop previously warned and returned the broadcastTransactionResponsewhenwait()never produced a receipt withinmaxTriesretries. Two problems flow from that:sendAndConfirmTransactionwould call.wait()again on the same response, potentially polling indefinitely against the RPC. The bot's state machine treated the tx as confirmed.Change
TransactionConfirmationFailedError(insrc/utils/TransactionUtils.ts) — extendsError, carries the submittedTransactionResponseso callers can correlate to the broadcast tx hash, and exposes akind: "confirmation_failed"literal for future discriminated unions._submitthrows it after themaxTriesloop completes without a receipt, in addition to the existing warn-level log.TransactionClient.submitwhitelists it in the catch and re-throws (with its own warn log), so it propagates out rather than being swallowed alongside generic submission errors. All other error categories continue to be logged atinfoand swallowed at submit's existing surface — no regression for the ~15 direct callers that depend on submit's lenient contract.Behavior change worth noting
Today:
_submitwithensureConfirmation: trueand await()that keeps failing eventually returns the broadcast response —sendAndConfirmTransaction's outertxResponse.wait()then potentially retries forever or returns late, and the caller proceeds as if confirmed.After this change: the same scenario throws →
sendAndConfirmTransaction(which catches all errors and returnsundefined) treats it as a failure → caller's existing!isDefined(receipt)branch fires and logs "Failed to submit X tx". For the DepositAddressHandler and (post-#3464) GaslessRelayer callers, this is the desired behavior — silent give-up becomes loud failure.Only callers that set
ensureConfirmation: trueare affected. In production today, onlysendAndConfirmTransactionsets it (DepositAddressHandler× 3 sites + gasless × 2 sites).Doc updates considered
No
AGENTS.md/README.mdshifts. The error class is a new export but the module map and runtime flow stay the same.Test plan
yarn typecheck— clean.yarn lint— clean.yarn hardhat test test/TransactionClient.ts— 11/11 passing.yarn hardhat test test/TransactionClient.ts test/DepositAddressHandler.ts test/MultiCallerClient.ts test/TryMulticallClient.ts— 40/40 passing (broader sanity check on adjacent surfaces).ensureConfirmation: trueoutside ofsendAndConfirmTransaction.Stacking
submission_failedoutcome (viasendAndConfirmTransaction's existing try/catch). Adding a fourthTransactionOutcomevariant forconfirmation_failedspecifically is a follow-up if desired.🤖 Generated with Claude Code