Extend deadlines for valid-but-unconfirmed legs#500
Merged
Conversation
13bb488 to
2b8300e
Compare
3e6de37 to
7629477
Compare
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.
What
D3 — deadline extensions. Protects honest miners from a false slash when a swap leg is broadcast-and-valid but just slow to reach its required confirmations.
The false slash this fixes
The contract slashes a miner whose leg is on-chain and matches every detail (recipient, amount, sender) but still sits below
min_confirmationswhen the deadline passes. The validator loop never called the extension builders, so a slow source/dest confirm turned into a false slash.Trigger — valid-but-unconfirmed only
_fetch_legis now tri-state:('no')absent/mismatch (slash-eligible),('pending', info)matched-but-unconfirmed (the new extendable case),('ok', info)confirmed,('down')unreachable.verify_transaction(require_confirmed=False)already returned the matched info while unconfirmed; the only blocker was_fetch_legcollapsingnot info.confirmedinto'no'.decide()extends only onpending, only near the deadline ((deadline - now) <= EXTENSION_PADDING_SECONDS), only with room below the contract ceiling (max_extend_at):EXTEND_RESERVATIONEXTEND_TIMEOUT(at ceiling + overdue → TIMEOUT)mark_fulfilled= no broadcast evidence → overdue slashes)The contract ceiling is the only bound — no client-side extension counters.
decide()returns a(decision, target_at)SwapActionso_cast_votecastsextend_reservation/extend_timeoutwith the computed target. Extension casts tolerateExtensionNotLater/ExtensionExceedsCeiling/ lost races as no-ops.Seconds-based target replacing block rot
chains.py'scompute_extension_targetreturned subtensor blocks and cited deleted ink!lib.rslines. Replaced withcompute_extension_target_secs(unix seconds):now + max(0, min_confirmations - confs) * seconds_per_block + EXTENSION_PADDING_SECONDS, bucketed on a seconds grid derived from existing constants (EXTENSION_BUCKET_BLOCKS * SUBTENSOR_BLOCK_SECONDS), clamped tomax_extend_at. The block-basedcompute_extension_targetandconfirmations_to_subtensor_blockswere dead in production (tests only) and are removed.Notes
m3-d1-attestation-rate-check) — both editdecide()/SwapDecision/_cast_vote. Base is D1; retarget tom3once D1 merges.seconds_per_block,min_confirmations) come fromchains.py— no scattered literals.MAX_EXTENSIONS_PER_*constants left untouched (miner cache sizing references them).