fix(scoring): reject sub-dust-only rates in is_executable_rate#434
Merged
Conversation
A rate whose only in-bounds source is below the source chain's dust / existential floor (e.g. 1 sat -> 0.5 TAO at 5e7 TAO/BTC) is unfundable on the source chain, yet currently passes is_executable_rate. So crown-squat miners posting these boundary rates are still rewarded, and a reservation taken against one forces an unfulfillable swap that times out and slashes the miner. Floor the routable-source search at a per-chain min_onchain_amount (BTC 1000 sat, TAO 500 rao existential deposit; default 1 = no floor). BTC uses 1000 rather than the bare 546 P2PKH dust line for margin against higher dustrelayfee / wallet quirks, and it tightens the executable-rate ceiling to TAO_max/(10*1000) = 50,000 TAO/BTC (~171x market). The existing inverse-symmetry path covers tao->btc with the same change.
65cea1f to
5e34d1d
Compare
LandynDev
approved these changes
May 30, 2026
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.
Problem
is_executable_rateis the crown-eligibility gate (scoring.pyexecutable_check). It only checks that some positive integer source ≥ 1 maps a TAO leg into[min_swap, max_swap]. At the live SN7 bounds (0.1–0.5 TAO) that lets a rate whose only in-bounds source is a single satoshi through as "executable":btc→taoat5e7 TAO/BTC→ 1 sat → 0.5 TAOtao→btcat2e-8 TAO/BTC→ the inverse of the same boundary (swap 1670)A 1-sat BTC output is below Bitcoin's dust limit (P2WPKH dust = 294 sat,
bitcoin/policy.cpp), so it can never be broadcast. The rate is therefore unfundable, yet today it:btc→taothe timeout pays the reserver the full TAO leg for a sub-dust BTC input.Fix
Floor the routable-source search at a per-chain
min_onchain_amount(the smallest amount that can actually exist/move on-chain):IsDustuses strict<and 546 is the P2PKH dust line, so 1000 clears every standard output type with margin against higherdustrelayfeeand wallet quirks. Also tightens the executable-rate ceiling toTAO_max/(10·1000) = 50,000 TAO/BTC(~171× market)._has_integer_routable_sourceis only ever called with the non-TAO side), so TAO behavior is unchanged; defined for future chains.One line in
_has_integer_routable_source:max(1, …)→max(src.min_onchain_amount, …). The existing inverse-symmetry path means the same change rejects both crown-squat directions.Effect (and honest scope)
executable_check→ dropped from crown qualification, and the surviving rate band becomes fundable, so an honest arbitrageur can finally reserve-and-punish an absurd rate (reserving makes the minerbusy, which ends its crown, and forces deliver-or-slash). This is the breadth/depth doc's "allow extreme rates only if they can be backed up against a real reserver" — min_sat is the prerequisite that makes "backed up" physically possible.axon_handlersstill only checks slippage). Gating reservations byis_executable_rateis a planned follow-up that closes the dust self-park at the source.Deferred (consciously)
max_sat/ dest-dust check — the sub-dust destination edge on absurd hightao→btcrates (a crown-loser, never triggers at market rates). Hygiene.is_executable_rateat the reservation path.Tests
min_onchain_amountso they track the constant.