Skip to content

chainreg: wait for a restarting node before calling a chain mismatch - #31

Merged
paulscode merged 1 commit into
paulscode:blake2bfrom
Kilombino:chain-check-warmup
Nov 20, 2026
Merged

paulscode merged 1 commit into
paulscode:blake2bfrom
Kilombino:chain-check-warmup

Conversation

@Kilombino

Copy link
Copy Markdown

The periodic chain-identity re-check shuts lnd down the first time the node fails to answer, even when the node is only restarting.

On our node the bitcoind is restarted after a block when the AirVPN exit IP changes (so it announces the new externalip). Today the restart landed on the 5-minute tick and lnd stopped with:

[CRT] CHRE: The Bitcoin node changed chains under a running daemon: the connected Bitcoin node is not on the Bitcoin BLAKE2b chain: the node cannot serve block 961640: -28: Loading P2P addresses…
[INF] CHRE: Sending request for shutdown

The node was back two seconds later; Docker restarted lnd, but every channel reconnected for nothing.

This tells a node that cannot answer (-28 RPC warm-up, connection refused/reset, EOF, other net.Error) from one that answers with another chain. The first is asked again every 15 s for up to 5 min before it counts as a mismatch; the second (wrong header, height out of range, any other RPC error) is still reported at once. The start-up check is unchanged.

Test: go test -race -run 'ChainIdentity|NodeUnreachable' ./chainreg/

The periodic chain-identity re-check shut lnd down the first time the
node failed to answer, even when the node was only restarting: a bitcoind
restart that lands on the 5-minute tick answers -28 (RPC warm-up) or
refuses the connection, and that was reported as "the connected Bitcoin
node is not on the Bitcoin BLAKE2b chain".

The re-check now tells a node that cannot answer (warm-up, connection
refused or dropped) from one that answers with another chain. The first
is asked again every 15 seconds for up to 5 minutes before it counts as a
mismatch; the second is still reported at once. The start-up check is
unchanged.

@paulscode paulscode left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks right, and I'd like it in the next release (0.21.8-beta-blake2b.24.1).

I checked how errors reach nodeUnreachable: rpcclient passes http.Client.Do's error back as it is, a *url.Error, so a refused or dropped connection matches net.Error, and -28 comes back as a *btcjson.RPCError. One thing to know, not to change: rpcclient retries a failed POST 10 times with a growing backoff, so during an outage each verifyOnce takes about a minute before it returns, and the 5 minutes hold about five tries rather than twenty. A node that answers from another chain is still reported on the first answer, and the start-up check is unchanged, which is what matters.

Passes under -race on top of the release branch, with the rest of chainreg.

@paulscode
paulscode merged commit 82490c1 into paulscode:blake2b Nov 20, 2026
4 checks passed
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.

2 participants