Skip to content

chainreg: wait for a node whose chain is below the activation block - #35

Merged
paulscode merged 1 commit into
blake2bfrom
chain-check-reindex
Nov 20, 2026
Merged

paulscode merged 1 commit into
blake2bfrom
chain-check-reindex

Conversation

@paulscode

Copy link
Copy Markdown
Owner

A Bitcoin node running a reindex keeps answering, but its active chain starts again from genesis, so for hours it answers "Block height out of range" when asked for the BLAKE2b activation block. The periodic chain check took that for another chain and shut LND down. At startup the wait on headers passed (headers survive a chain state rebuild), and the first check refused the node the same way. A node still syncing blocks behind its headers was refused at startup too.

  • The startup wait now waits on blocks, which is what the check reads.
  • The periodic re-check, when the node lacks the activation block, asks how far its chain reaches. If it is on the expected network and below the activation height, it is waited for, with the waiting status written, and checked again once it has the block. Such a node can only serve blocks from before the activation, which both chains share.
  • A node on another chain under the same network name is far past that height, so it is still reported at once, as is a node past the height that lacks the block.

Tests: TestChainIdentityWaitsForBlocks and TestChainIdentityWatchWaitsForReindex; each fails with its half of the fix reverted. go test -race ./chainreg/... passes.

A Bitcoin node rebuilding its chain (a -reindex or -reindex-chainstate,
after an upgrade or a corruption recovery) keeps answering RPCs, but its
active chain starts again from genesis. Asked for the activation block, it
answers "Block height out of range" for hours. The periodic check took that
answer for another chain and shut LND down, and at startup the wait on
headers passed, since headers survive a chain state rebuild, so the first
check refused the node the same way. A node syncing blocks behind its
headers was refused at startup for the same reason.

The startup wait now waits on blocks, the active chain the check reads. The
periodic re-check, when the node lacks the activation block, asks the node
how far its chain reaches: on the expected network and below the activation
height, it is waited for as long as it stays there, with the waiting status
written. Such a node can only serve blocks from before the activation,
which both chains share, and it is checked again once it has the block. A
node on another chain under the same network name is far past that height
and is still reported at once, as is one past it that lacks the block.
@paulscode
paulscode merged commit d6fd64b into 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.

1 participant