lnwallet+lnwire: handle boundary cases - #11035
Conversation
cc78907 to
a0cafac
Compare
a0cafac to
bb7ff27
Compare
🔴 PR Severity: CRITICAL
🔴 Critical (3 files)
🟢 Low (3 files)
AnalysisThis PR touches both To override, add a |
MPins
left a comment
There was a problem hiding this comment.
Fix looks right, and I confirmed the behavior locally.
One thought on coverage: TestChannelRangeLastBlockHeight pins the arithmetic, but the bug it's fixing only exists where callers act on the result, and all of those are in discovery/syncer.go.
TestGossipSyncerReplyChanRangeQueryBlockRange is already the boundary table for this (full range, small query, overflow) — it's just missing the empty one. Two entries complete it:
// overflow example
{
FirstBlockHeight: uint32(1000),
NumBlocks: uint32(math.MaxUint32),
},
+
+ // empty range at the genesis block
+ {
+ FirstBlockHeight: uint32(0),
+ NumBlocks: uint32(0),
+ },
+
+ // empty range after the genesis block
+ {
+ FirstBlockHeight: uint32(1000),
+ NumBlocks: uint32(0),
+ },
}
{
startHeight: uint32(1000),
endHeight: uint32(math.MaxUint32),
},
+ {
+ startHeight: uint32(0),
+ endHeight: uint32(0),
+ },
+ {
+ startHeight: uint32(1000),
+ endHeight: uint32(1000),
+ },
}
|
Non-blocking proposal: as a follow-up, we could replace the separate completion and error channels with a single buffered result channel.
return <-completeChan, <-errChanThat makes every terminal handler path responsible for sending both halves, which is how this missing-reservation branch was able to leave the caller blocked. A small internal result type could make the response atomic: type fundingCompletionResult struct {
channel *chanstate.OpenChannel
err error
}Both I don't think this should block or expand this PR: the current one-line fix is correct, focused, and easier to audit/backport. The single-result-channel change would just remove this class of half-response bug in a separate cleanup. |
Return both completion results when the reservation is no longer present. Add a focused regression test for the missing-reservation response.
Clamp zero-block range boundaries without treating them as valid empty ranges. Avoid emitting a zero-block prefix when the first queried block exceeds the reply chunk size, and cover both discovery paths.
Document the channel funding and channel range boundary fixes for the v0.21.3 maintenance release.
bb7ff27 to
081adeb
Compare
|
One remaining sender-side zero path is the wrong-chain early return in replyChanRangeQuery. It runs before LastBlockHeight is used and copies query.NumBlocks verbatim. A peer can send a QueryChannelRange with a mismatched ChainHash and NumBlocks=0, and we reply with Complete=0 and NumBlocks=0. Since this PR also prevents lnd from constructing the dense-first-block zero prefix, should we ensure this branch cannot emit a zero-block reply either? For the current defensive-clamping approach, the narrow fix would be to use at least one block in the wrong-chain response. It would also be good to add a zero-block case to TestGossipSyncerQueryChannelRangeWrongChainHash so the outbound response is covered. |
ziggie1984
left a comment
There was a problem hiding this comment.
LGTM, had a small thing regarding a wrong chain-hash were we would set the numBlos=0, other than that this is gtg
|
Successfully created backport PR for |
…21.x-branch [v0.21.x-branch] Backport #11035: lnwallet+lnwire: handle boundary cases
|
Created backport PR for
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-11035-to-v0.20.x-branch
git worktree add --checkout .worktree/backport-11035-to-v0.20.x-branch backport-11035-to-v0.20.x-branch
cd .worktree/backport-11035-to-v0.20.x-branch
git reset --hard HEAD^
git cherry-pick -x 081adebca6d2726f232211f437e8e1f8806aeb18
git push --force-with-lease |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin v0.21.x-branch
git worktree add -d .worktree/backport-11035-to-v0.21.x-branch origin/v0.21.x-branch
cd .worktree/backport-11035-to-v0.21.x-branch
git switch --create backport-11035-to-v0.21.x-branch
git cherry-pick -x 8bf173e5638db989741a935067f4a66985614692 b423c8bf07af197f6a56c9c3456b06fec320ba40 081adebca6d2726f232211f437e8e1f8806aeb18 |
…20.x-branch [v0.20.x-branch] Backport #11035: lnwallet+lnwire: handle boundary cases
The p2p wedge fixes from lightningnetwork#11035 are being backported to the v0.20.x branch, so mirror their entries in the 0.20.4 notes on master.
The p2p wedge fixes from lightningnetwork#11035 are being backported to the v0.20.x branch, so mirror their entries in the 0.20.4 notes on master.
The regression test added by the backport of lightningnetwork#11035 was taken verbatim from master, where the `OpenChannel` type lives in the `chanstate` package. That package does not exist on this branch, so the `lnwallet` test package failed to compile. Because the missing package is unresolvable in the module graph, this broke far more than `go test ./lnwallet`: the unit test jobs, the linter, `make release` (and therefore cross compilation) and the `Check commits` job all failed for every PR targeting this branch. Use `channeldb.OpenChannel`, which is the type `completeChan` actually carries here.
The regression test added by the backport of lightningnetwork#11035 was taken verbatim from master, where the `OpenChannel` type lives in the `chanstate` package. That package does not exist on this branch, so the `lnwallet` test package failed to compile. Because the missing package is unresolvable in the module graph, this broke far more than `go test ./lnwallet`: the unit test jobs, the linter, `make release` (and therefore cross compilation) and the `Check commits` job all failed for every PR targeting this branch. Use `channeldb.OpenChannel`, which is the type `completeChan` actually carries here.
XCreateAccount is being backported to the v0.21.x branch in #11086, so its entries belong with the release that first ships it rather than with 0.22.0. This matches how the other changes backported to 0.21.3 (#11035, #11075, #10869) are documented: their entries live only in the 0.21.3 notes, even though their code is on master and will also ship in 0.22.0. The entry text is moved verbatim. Elle Mouton is added to the 0.21.3 contributor list.
Summary
prefixes.
Change Description
The wallet funding handler now returns both completion results when a pending
reservation is absent. Channel-range helpers retain their first height for
zero-block input, and the graph syncer skips a nonexistent prefix when the
first queried block exceeds one reply chunk.
Verified with:
go test ./lnwallet ./lnwire ./discovery -count=1go test -race ./lnwallet -run '^TestHandleFundingCounterPartySigsMissingReservation$' -count=1go test -race ./discovery -run '^(TestGossipSyncerReplyChanRangeQueryBlockRange|TestGossipSyncerReplyChanRangeQueryDenseFirstBlock)$' -count=1