fix(provider): timeout transactions in large gaps to prevent infinite polling #3551
+121
−2
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.
Motivation
Fixes #3408
When blocks are missed, transactions could poll forever if their confirmation block was in the missed range.
Example from the issue on Arbitrum:
Transaction was confirmed in block
413480106, but blocks 104-110 were not observed ->watch_pending_transactionpolls forever.The existing code only handled unconfirmed transactions during large gaps, but transactions in
waiting_confswere not moved back to unconfirmed, causing them to wait forever even though their confirmation block was missed.Solution
Modified
move_reorg_to_unconfirmedto move gap-affected transactions fromwaiting_confsback tounconfirmedbefore timeout. Transactions are timed out when gap >= 10 blocks to balance between handling legitimate reorgs and preventing infinite polling.Added 3 tests covering large gaps (>= 10), small gaps (< 10), and transactions confirmed within missed blocks.
PR Checklist