Skip to content

Merge lnd v0.21.8-beta into Lightning Fork - #26

Merged
paulscode merged 79 commits into
paulscode:blake2bfrom
Kilombino:merge-lnd-v0.21.8
Nov 12, 2026
Merged

paulscode merged 79 commits into
paulscode:blake2bfrom
Kilombino:merge-lnd-v0.21.8

Conversation

@Kilombino

Copy link
Copy Markdown

Summary

Merges lnd v0.21.8-beta (released 11 Nov) into blake2b. This includes v0.21.7-beta, tagged the same day and replaced within hours by v0.21.8. It is done the same way as the v0.21.6 merge: build/version.go AppPatch moves to 8 and upstream's release notes come along. The fork's pre-release suffix is left for the release commit.

What v0.21.7/v0.21.8 bring (release notes):

Conflicts

There were 13 conflicts in 8 files. Each was resolved to keep both sides:

  • contractcourt/channel_arbitrator.go: upstream's comment on rejected replacements, plus the fork's splice case and chain.ErrTooManyReplacements. In the test table, the fork's two extra cases stay, with upstream's name for the ErrDoubleSpend case.
  • lnwallet/channel.go RevokeCurrentCommitment: the fork's spliceRestoreErr / requireAllSigned checks first, then upstream's MaxUint16 check on the unsigned acked updates (getUnsignedAckedUpdates now takes the index, as upstream).
  • htlcswitch/link.go: the fork's splice fields and channels, plus upstream's htlcManagerDone. On reconnect, amendChanSync still runs, and the message is then sent unless the peer already queued it for a pending channel (ChanSyncMsgSent, upstream).
  • sweep/fee_bumper.go: getSpentInputs keeps the fork's grace wait (readSpend, spentLookupGrace) and returns errors as upstream does. A failed spend notification registration, or a closed one, is an inconclusive check: handleMissingInputs fails the record with errSpendCheckFailed, and the per-block check logs it and proceeds as unspent. Both behaviours are upstream's. The fork's grace test now checks the error too.
  • peer/test_utils.go: both mock methods (ResumeQuiescence, OnCommitOnce).
  • go.sum: tidied. go.mod takes upstream's btcwallet pseudo-version, which the replace overrides.

btcwallet

lnd v0.21.8 bumps btcwallet to 245ce39ba343 for new rejection classification in chain/, which the sweeper fixes above use. btcwallet-blake2b v0.16.20-blake2b.3 predates it. This builds and passes without it, but those rejections would come back as unknown errors. paulscode/btcwallet-blake2b#1 merges the four upstream commits cleanly; after a tag, only the replace line here needs bumping.

Tests

  • go build ./... and go vet on the touched packages pass.
  • go test passes in sweep, contractcourt, peer, lnwallet, channeldb and the root package.
  • htlcswitch fails 5 tests (TestChannelLinkBandwidthConsistency, TestChannelLinkTrimCircuitsNoCommit, TestChannelLinkCleanupSpuriousResponses, TestSwitchDustForwarding, TestPipelineSettle), the same 5 that fail on blake2b today (aa875b5) without this merge.

starius and others added 30 commits October 30, 2026 21:14
Create and validate host cache directories before Docker bind mounts them.

On a fresh Go installation, Docker otherwise creates missing sources as
root. The release helper runs as the invoking user and cannot write
to those caches.
Mount a linked worktree's shared Git directory into the release helper
at its original path.

Its .git pointer otherwise resolves to a path absent from the container,
preventing tag checks and source archiving.
…er-fixes-v0.21.x

Backport builder fixes v0.21.x
In this commit, we prevent restored channel shells from entering the local force-close path. These shells do not have a local commitment transaction, so attempting to sign one can panic and leave the arbitrator in a persisted broadcast state.

We treat the restored status like local data loss and let the arbitrator wait for the remote close. We also handle the resulting nil close transaction in the peer failure path instead of dereferencing it for logging.

(cherry picked from commit 06b0784)
In this commit, we rewrap the overlong comment, test name, and restart
call in the channel arbitrator restart test, keep a blank line before
the early return, split the long force close errorf in brontide, and
move the restored-status check in the force close guard into its own
expression so the multi-line condition formats cleanly.

(cherry picked from commit 44f2b92)
In this commit, we key confirmation hints by the same txid and output
script that a confirmation request uses to match a transaction. Two
pending requests can share a txid while watching different scripts,
and the txid-only cache key let one request's scan advance the other's
hint, so the request could resume from its caller-provided height
instead of the block where its transaction confirmed.

We add a cache regression for requests with the same txid and different
scripts, plus an integration case that runs the breach confirmation
with bitcoind without txindex and requires the justice transaction to
sweep the revoked outputs while the funding request remains pending.

(cherry picked from commit 22a68df)
Continue contractcourt processing when a recorded commitment or legacy
HTLC timeout transaction is rejected for paying an insufficient
replacement fee. This result can indicate that another transaction
spending the same output is already in the mempool.

The channel arbitrator advances to its existing commitment-broadcast
state, where anchor handling covers whichever commitment confirms. The
legacy nursery continues startup and registers for its timeout transaction
rather than treating the publication result as fatal. Other publication
errors retain their current behavior.

Leave legacy success publication unchanged because it has no independent
watcher for the original HTLC spend and must not checkpoint a prospective
success output after a rejected publication.

(cherry picked from commit eb51b5c)
In this commit, we bound the persisted unsigned acked update list before advancing the local commitment tail. The disk serializer rejects lists larger than its uint16 count can express, so an overflow cannot silently discard a remote settle on restart.

We also recover complete lists written by older nodes with a wrapped count. The database decoder checks the trailing entries and their count before accepting the value.

(cherry picked from commit 96daf22)
Rewrap long lines and use an integer range in the update log limit tests.

(cherry picked from commit acd7ad8)
In this commit, we reject a peer alias when the channel graph already
assigns that SCID to another funding outpoint. An alias must identify
the channel that owns it, so we don't sign updates that attribute it to
another channel.

We validate aliases when channel_ready admits or rotates them and
repeat the check before each status or policy update substitutes the
alias. Rechecking at the signing boundary also covers graph edges that
appear after admission and the zero-conf RemoteAlias path.

Aliases in the reserved alias range remain valid because nodes allocate
them independently, so equal aliases from different peers are
legitimate. Only collisions outside that range can name a real channel
SCID and are rejected.

(cherry picked from commit 293fd8b)
In this commit, we decouple link failure reporting from the peer's channel manager with a typed concurrent queue. A link can otherwise report its terminal failure while the channel manager is waiting for that same link to accept a close hook, which leaves both goroutines waiting on each other.

We also make hook registration observe the link event-loop lifetime and the caller's context. This lets close negotiation stop cleanly when the receiver exits, while preserving the existing hook ordering when registration succeeds.

The failure queue starts before active links are loaded, so a link that fails during peer startup also has a live receiver.

(cherry picked from commit 0a4f3ce)
In this commit, we add real-node coverage for link failures that overlap legacy cooperative-close handling. The test holds a forwarded HTLC, fails a separate close link and the HTLC link with unknown settles, then mines to the outgoing deadline.

We assert that the node broadcasts its commitment, publishes the outgoing HTLC timeout transaction after confirmation, and continues processing later blocks. This covers the on-chain path that the focused peer and link tests can't exercise.

(cherry picked from commit 123094d)
…ort-11478-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11478: scidalias: reject peer aliases for other channels
…ort-11479-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11479: funding: preserve batch state after publish errors
…ort-11480-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11480: lnwallet: reject force close for restored channels
…ort-11481-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11481: channeldb: scope confirmation hints by script
The ConfirmHintCache doc comments updated in lightningnetwork#11481 exceed the
80-character line limit, which fails the ll linter on master and on
every open PR that is linted against it.

(cherry picked from commit 45c3896)
…ort-11482-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11482: lnwallet: reject oversized unsigned acked update logs
…ort-11484-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11484: contractcourt: handle replacement fee rejections
…ort-11483-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11483: peer: decouple link failure delivery
…ort-11497-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11497: chainntnfs: wrap ConfirmHintCache comments at 80 columns
The backported test imported the btcutil, chainhash and wire v2 modules,
which this branch does not depend on, so the itest package failed to
compile. Use the v1 import paths the rest of the branch uses.
…ort-fix-itest-btcd-imports-v0.21.x-branch

[v0.21.x-branch] itest: use btcd v1 module paths in conf hint poison test
Roasbeef and others added 19 commits November 10, 2026 09:56
In this commit, we reject a CSV delay of zero during constraint
verification.

The CSV delay is the time the owner of a commitment must wait before
sweeping their own output, and it is the window the other party has to
respond to a breach. A delay of zero removes that window entirely and
is never a sensible value, but VerifyConstraints only bounded the delay
from above.

VerifyConstraints is the one place every delay passes through:
CommitConstraints calls it for the delay the remote party requires of
us, in both the initiator and responder roles, and the funding manager
calls it for the delay we require of the remote party. Checking for zero
there covers every channel type and both directions.

(cherry picked from commit 266eba7)
…ort-11542-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11542: htlcswitch: recover forwarded adds across link shutdowns
…ort-11485-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11485: sweep: bound wallet input selection
The backport of lightningnetwork#11542 (lightningnetwork#11544) added htlcswitch/link_forward_replay_test.go
with an import of the btcd btcutil/v2 module. This branch doesn't depend
on it, so the htlcswitch package fails to build its tests with
"no required module provides package github.com/btcsuite/btcd/btcutil/v2".

Switch the import to the v1 btcutil path the rest of the branch uses.
…tch-btcutil-import-v0.21.x-branch

[v0.21.x-branch] htlcswitch: use btcd v1 btcutil path in forward replay test
…ort-11440-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11440: multi: tighten wire, fee and transaction invariants
BOLT 2 requires a node to send channel_reestablish for every
remembered channel when a peer reconnects. Pending channels are remembered
but have no link, so lnd previously sent nothing until funding confirmed. A
peer waiting for the message could disconnect the shared connection.

Queue the message while loading pending channels and record the handoff so
the link created after confirmation still processes the remote state without
sending a duplicate.

Add regression coverage for the pending funding-node case.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
(cherry picked from commit 14efa3d)
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
(cherry picked from commit 6e47397)
…ort-11540-to-v0.21.x-branch

[v0.21.x-branch] Backport lightningnetwork#11540: peer: reestablish pending channels on reconnect
…ending-reestablish-checks

peer: fix pending reestablish backport checks
…8-final-stacked

build: bump version to v0.21.8
@paulscode

Copy link
Copy Markdown
Owner

Thanks, Kilombino, this is a careful merge. I went through it against the fork's diff before and after: every fork hunk survives byte for byte outside the files you resolved, and the 13 resolutions look right to me. That covers RevokeCurrentCommitment's order, amendChanSync with ChanSyncMsgSent, the fee bumper's grace wait with upstream's errors, and the arbitrator's two replacement errors. go build, go vet and the unit tests pass under Go 1.27.3.

The BLAKE2b integration failure is ours, not the merge's. Upstream's new link_failure_force_close starts Mallory with --protocol.custom-message overrides for Shutdown and UpdateFulfillHTLC so she can send her own, and since October the fork refused overrides of types lnd decodes itself, so she never started. #27 restores upstream's behaviour, with a startup warning. With it applied on your branch, the case passes locally on the BLAKE2b regtest.

btcwallet: I merged your btcwallet-blake2b#1 and tagged v0.16.20-blake2b.4 (e5916f15). Without it, on a btcd or neutrino backend, an input rejection lnd v0.21.8 now classifies comes back as ErrUndefined, and the sweeper retries a permanently invalid sweep every block.

Could you:

  1. bump the replace to github.com/paulscode/btcwallet-blake2b v0.16.20-blake2b.4 and fix the "move them together" comment above it;
  2. rebase on blake2b once lnwire, config: accept custom message overrides of types lnd handles, as upstream does #27 is in, so the integration job runs with it;
  3. optionally, drop one of the two ErrInsufficientFee cases in channel_arbitrator_test.go: the fork's "replacement of a splice paying more" and upstream's "Commitment replacement pays insufficient fee" test the same thing.

If you'd rather, I can push those to your branch. About the five htlcswitch failures in the description: they pass with -tags dev, which those tests need, on both your branch and blake2b.

@Kilombino

Copy link
Copy Markdown
Author

Thanks, Paul. Pushed 1 and 3:

  • replace → github.com/paulscode/btcwallet-blake2b v0.16.20-blake2b.4, and the comment now names the commit it follows (245ce39ba343, upstream's ver-0-16.19, which v0.21.8 pins). go mod tidy only swapped the two go.sum lines.
  • Dropped the fork's "replacement of a splice paying more" case; upstream's "Commitment replacement pays insufficient fee" covers it.

go build ./... passes. go test passes for contractcourt and sweep, and -tags dev ./htlcswitch/ passes too. You're right about the five failures: they were only the missing tag. Sorry for the noise in the description.

I'll rebase on blake2b once #27 is in.

@paulscode

Copy link
Copy Markdown
Owner

Thanks. #27 is in (39acf68), so the rebase can go ahead whenever you're ready; I'll merge once the integration job is green.

Brings in lnd v0.21.7-beta and v0.21.8-beta (the backports since v0.21.6). Conflicts resolved keeping the fork's splice and BLAKE2b behaviour; see the pull request.
…jection mapping); contractcourt: drop the duplicate ErrInsufficientFee case
@Kilombino

Copy link
Copy Markdown
Author

Rebased onto blake2b at 39acf68 (with #25 and #27). I redid the merge with the same 13 resolutions and put the btcwallet / test follow-up on top. Compared with the branch you reviewed, the tree differs only in the files #25 and #27 changed (config.go, lnwire/custom*.go, server.go, server_connreq_test.go).

go build ./... passes. go test passes for contractcourt, sweep, peer and the root package, and -tags dev ./htlcswitch/ passes too. One local note: TestQueryShortChanIDsZlibCompatibility in lnwire fails here on blake2b itself as well. I'm on Go 1.26.8, and zlib's output size changes between Go versions, so it should pass under your 1.27.3.

@paulscode
paulscode merged commit a604ce8 into paulscode:blake2b Nov 12, 2026
3 of 4 checks passed
@paulscode

Copy link
Copy Markdown
Owner

Merged, thanks, Kilombino. The integration job's one failure after the rebase was onion_message_forwarding timing out at node start; it passes locally on the same tree and passed on a re-run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants