fix: queue SwapConfirm on tx_not_found instead of rejecting#333
Open
LandynDev wants to merge 1 commit into
Open
fix: queue SwapConfirm on tx_not_found instead of rejecting#333LandynDev wants to merge 1 commit into
LandynDev wants to merge 1 commit into
Conversation
Validators previously rejected SwapConfirm outright when the source tx wasn't visible to the local BTC node + Esplora at axon time, forcing users to retry across a propagation race they had no control over. Treat tx_info=None the same as "found but not yet confirmed" — enqueue into pending_confirms and let the forward drain re-verify, bounded by PENDING_CONFIRM_NULL_RETRY_LIMIT for bogus entries. The user gets a "Queued — source tx not yet visible" response that the CLI already renders as queued, so no client change is required. Logging: split the silent None paths in BitcoinProvider so operators can distinguish "tx not in RPC/Esplora" (DEBUG) from "tx returned but no vout matches recipient + amount" (WARNING). Sender-mismatch already warns at the base class.
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
SwapConfirmwhen the source tx wasn't yet visible to the local BTC node + Esplora at axon time. A user who broadcast and immediately confirmed (a 20s reserve→confirm window) raced propagation and got bounced withSource transaction not found, amount or sender mismatch, forcing a retry.forward.pydrain re-verifies on each step, andPENDING_CONFIRM_NULL_RETRY_LIMITbounds bogus entries so the abuse surface is unchanged.BitcoinProvider:DEBUGwhen neither RPC nor Esplora has the tx,WARNINGwhen the tx exists but no vout matches recipient + amount. Sender-mismatch already warns inbase.py. The previous catchall log conflated all three failure modes.Reasoning
Real incident: reservation at
15:02:25Z→SwapConfirm20s later → rejected at15:02:46Z→ tx confirmed in block at15:58:36Z. The tx was real and valid; the validator just couldn't see it yet. The CLI already softens the rejection to "yellow" + a "usually propagation lag, retry" message (cli/validator_rejections.py:217-232), which is itself an admission that this rejection should be a queue.The new "Queued — source tx not yet visible..." response is
accepted=True, so the existing CLI renderer treats it as queued (validator_rejections.py:340) — no client-side change required, and old-validator rejection text continues to map to the legacytx_not_foundrule for backward compatibility.Test plan
pytest tests/test_axon_handlers.py tests/test_validator_rejections.py tests/test_pending_confirm_queue.py— 42 passedpytest— full suite, 472 passedruff format+ruff check— clean./tests/run.sh --chains btc --suite 02) on dev environment to confirm the queued path drains correctly when the tx eventually landsalw swapwith the matching reservation, confirm validator logs showqueued: source tx not yet visibleand the swap initiates once the tx propagates