Repository navigation
chainreg: wait for a restarting node before calling a chain mismatch - #31
Conversation
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
left a comment
There was a problem hiding this comment.
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.
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:The node was back two seconds later; Docker restarted lnd, but every channel reconnected for nothing.
This tells a node that cannot answer (
-28RPC warm-up, connection refused/reset, EOF, othernet.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/