fix(cli): refuse post-tx inside reservation extension dead-zone#355
Closed
anderdc wants to merge 1 commit into
Closed
fix(cli): refuse post-tx inside reservation extension dead-zone#355anderdc wants to merge 1 commit into
anderdc wants to merge 1 commit into
Conversation
User-side analogue of MINER_TIMEOUT_CUSHION_BLOCKS. Validators refuse propose_extend_reservation once current + CHALLENGE_WINDOW_BLOCKS >= reserved_until, so a confirm broadcast inside that 8-block window has no extension rescue path. On tao→btc the source TAO is already sent to the miner before the swap row exists — a failed reservation in that window is an unrecoverable loss. Adds USER_POST_TX_CUSHION_BLOCKS (= CHALLENGE_WINDOW_BLOCKS) and a shared helper used by `alw swap post-tx` and `alw swap resume-reservation` to abort with a clear message when runway is inside the cushion.
Collaborator
Author
|
Superseded by #328 which gates upstream of this (before source funds are broadcast) and uses a more conservative threshold (EXTEND_THRESHOLD_BLOCKS + buffer vs CHALLENGE_WINDOW_BLOCKS). Closing in favor of that PR. |
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
User-side analogue of the miner timeout cushion. Validators refuse
propose_extend_reservationoncecurrent_block + CHALLENGE_WINDOW_BLOCKS >= reserved_until(optimistic_extensions.py:97), so a confirm broadcast inside that 8-block window has no extension rescue path. On tao→btc the source TAO is already sent to the miner before the swap row exists — a failed reservation inside that window is an unrecoverable loss (no escrow, no slash-to-user).Today
alw swap post-txandalw swap resume-reservationonly checkreserved_until > current_block, so a user can ship a confirm with ~1 block of runway and silently lose funds.This change:
USER_POST_TX_CUSHION_BLOCKS = CHALLENGE_WINDOW_BLOCKSinconstants.py.safe_reservation_remaining()helper incli/swap_commands/helpers.py— returns remaining blocks if safe, elseNoneafter printing a user-facing reason.post_tx.pyandresume.py, replacing the existing "expired or not" check.Counterpart ticket on the miner side (raising
DEFAULT_MINER_TIMEOUT_CUSHION_BLOCKSfrom 5 → ≥CHALLENGE_WINDOW_BLOCKS) is left for a separate PR — that one affects operators and warrants its own announcement.Test plan
pytest tests/test_safe_reservation_remaining.py— 5/5 passpytest tests/test_probe_pending_reservation.py— neighbouring suite still greenpost_tx,resume,helpers,constantsalw swap post-txagainst a near-expiry reservation and confirm the new abort message fires; against a healthy reservation, confirm normal flow proceeds.