Repository navigation
openingd: fail open_channel at receipt when our dust limit exceeds their reserve - #9479
Amperstrand wants to merge 4 commits into
Conversation
Andezion
left a comment
There was a problem hiding this comment.
Given dualopend.c (v2 / dual-funding) has no equivalent reserve/dust cross-check at all, and the issue flags that a channel under ~~54,600 sat can hit the same class of problem there (derived 1% reserve below 546) - is a follow-up planned for that path, or is it intentionally left out because the reserve there is derived rather than negotiated?
|
Intentionally left out — the derivation closes it. v2 floors the reserve at |
52b7f86 to
04840a3
Compare
|
CI is failing with:
|
|
That's the new receipt check on a shape the test relied on: |
0ef2286 to
630da2c
Compare
|
@Amperstrand FYI: https://t.me/lightningd/39196 |
…eir reserve BOLT #2 requires the accept_channel sender to set dust_limit_satoshis less than or equal to channel_reserve_satoshis from the open_channel message. fundee_channel() quotes this exact MUST in its comment block but implements no check for it: with the chainparams dust limit (546) and an opener reserve below that, CLN replies accept_channel with dust_limit_satoshis=546, violating the sender MUST. Spec-strict peers (e.g. an LDK opener at the 354-sat spec-minimum dust limit) then fail the channel, with nothing above DEBUG on our side recording why. Mirror the existing opener-side check (openingd.c:446-455) in the accepter path, respecting --dev-allowdustreserve like both neighboring checks. The in-suite test sends a true sub-546 reserve by running the opener under --dev-allowdustreserve (a stock fundchannel self-bumps to its dust limit, mirroring test_zeroreserve's construction); it fails on master and passes with this change. Changelog-Fixes: ElementsProject#9439 Fixes: ElementsProject#9439
The new accepter-side check (dust_limit <= their reserve) rejects l1's 0sat-reserve open at l2, whose dust limit is the chainparams 546 -- and a stock accepter has no legal dust_limit against a 0sat reserve at all (the spec floors dust at 354). l2 sets --dev-allowdustreserve, the same crutch its sibling tests already use on every node; mixed/all zeroreserve tests pass on both networks. Changelog-None: test-only Signed-off-by: Amperstrand <amperstrand@localhost>
Changelog-Fixed: 'openingd' no longer sends an 'accept_channel' whose 'channel_reserve_satoshis' is below its own 'dust_limit_satoshis'
Master's comment above the fundee set_reserve() call predates the folded floor in set_reserve_absolute(), which now bumps our reserve to the higher of the two dust limits, not just the peer's. Say so. Changelog-None: comment-only Signed-off-by: Amperstrand <amperstrand@localhost>
630da2c to
54c55b9
Compare
|
Agreed — folded in: #9527's change and its wire-level test are now in this branch (Andezion's commit cherry-picked verbatim, authorship kept), rebased on current master. This PR now closes both #9439 and #9515, so #9527 can be closed (for @Andezion to confirm). CI needs an approval click on the new head. |
BOLT #2 requires the accept_channel sender to set
dust_limit_satoshisless than or equal to
channel_reserve_satoshisfrom theopen_channelmessage. CLN's
fundee_channel()quotes this exact MUST in its commentblock but implements no check for it: with the chainparams dust limit (546)
and an opener reserve below that, CLN replies
accept_channelwithdust_limit_satoshis=546, violating the sender MUST. A spec-strict openerthen fails the channel (the reporter's LDK LSP sits at the 354-sat floor
the spec itself mandates as the minimum dust limit); nothing above DEBUG
on our side records why (#9439).
This adds the mirror of the existing opener-side check (
dust limit … would be above our reserve, nowcheck_dust_limit()inopeningd/common.c)to the accepter path, respecting
--dev-allowdustreservelike bothneighboring checks.
Folded in from #9527 (per reviewer request): the accepter-side self-consistency fix for #9515
As fundee,
set_reserve_absolute()used to floor our 1% channel reserve atthe peer's
dust_limit_satoshisonly, never at our own — so on channelsbelow ~54,600 sat we could send an
accept_channelwhosedust_limit_satoshis(546) exceeds its ownchannel_reserve_satoshis(#9515, found and fixed by @Andezion in #9527; his commit is folded here
verbatim, authorship preserved). The two checks are duals that together
make the accepter side BOLT-#2-clean in both directions:
open_channelat receipt whenour dust limit exceeds the reserve they impose on us;
accept_channelsetschannel_reserve_satoshisbelow our owndust_limit_satoshis#9515) — never send anaccept_channelwhose reserveis below our own dust limit (floor at whichever dust limit is higher).
set_reserve_absolute()'s floor now also covers the master-suppliedabsolute-reserve path used on the v1 accepter side; the
check_dust_limit()refactor on master (both call sites and dualopend)is untouched.
Notes for reviewers
an accept_channel whose dust exceeds our reserve) — two unpatched
CLN nodes reject each other in this shape (the opener under
--dev-allowdustreserve; a stockfundchannelself-bumps itsreserve to 546, so the violating open is unreachable without it).
these limits." — but until the bolts change, the MUST stands, and
stock CLN violates it against strict peers today.
docker v26.06 tag with a BOLT8 wire peer: the violation reproduces
at every reserve below 546 I probed (354, 545), clean at 546.
--dev-allowdustreservetosend a true sub-546 reserve (same crutch as
test_zeroreserve); itfails on master and passes with this change.
CLN fails first, at open_channel receipt.
build clean, and the full dust/reserve test selection passes —
test_dust_limit_above_reserve,test_zeroreserve,test_zeroreserve_mixed,test_zeroreserve_alldust, and Andezion'swire-level
test_accept_channel_reserve_below_our_dust_limit(his
reserve=546deliberately clears the openingd: accept_channel violates BOLT 2 when the peer's channel_reserve_satoshis is below our dust limit (silent open failure) #9439 receipt check, sothe two tests exercise exactly one fix each).
pre-fix wire journal (v26.06.7): accept_channel with dust_limit 546 against opener reserve 354 — expand
post-fix (pr9439): rejection at open_channel receipt + the inclusive 545/546 boundary — expand
Fuller validation record — every cell, the four-version matrix, the red/green transcript, and the repro recipe: https://gist.github.com/Amperstrand/880bf568f792db0227666e9472d2c9b5
Fixes #9439
Fixes #9515
(Second issue and its fix folded in from #9527 by @Andezion, with his
commit cherry-picked verbatim — #9527 can be closed once this merges.)