Saturday, March 7, 2026
HomeBitcoinchain reorganization - How does Bitcoin Core deal with lengthy reorgs?

chain reorganization – How does Bitcoin Core deal with lengthy reorgs?

I can reply for Bitcoin Core, however know there exists software program that works very in a different way.

I can think about that within the state of affairs the brand new chain is clearly longer, the node must revert its UTXO set to the purpose at which the chains diverged, add again mempool transactions that had been used because the chains diverged, after which re validate all blocks within the new chain.

Precisely.

How is the UTXO set reverted? Do nodes preserve a historical past of UTXO set diffs?

Sure. For each block that’s a part of the lively principal chain, “undo” knowledge is maintained, which incorporates all of the UTXOs spent by the block. In the event you see the UTXO set as a database, and blocks as “patches” of modifications utilized to it (along with signatures to authorize the modifications), then the undo knowledge consists of the reverse patches (with out signatures). The undo knowledge is saved within the blocks/rev?????.dat recordsdata within the knowledge listing.

Within the case the place the size of the chains will not be considerably totally different, I can think about {that a} node would possibly wish to preserve each chains concurrently till it turns into clear one shall be longer. Are nodes programmed to do that?

No, there may be at all times precisely one lively chain, and Bitcoin Core solely maintains a UTXO set for the tip block of that chain. The rule is:

  1. Think about all blocks which aren’t invalid and don’t have any invalid ancestors.
  2. Think about solely these amongst that set whose accrued chain work is maximal.
  3. If there are a number of, choose the one for which the tip was obtained first.

What’s the longest reorg a node can deal with with out revalidating your complete chain from the genesis block?

Any depth reorg ought to be dealt with appropriately, all the way down to the final checkpoint that has been handed. However these could also be eliminated quickly.

If a reorg is sufficiently deep (I consider 10 blocks or extra), re-adding transactions again to the mempool will not be carried out (simply protecting observe of these transactions in the course of the reorg can use unbounded a lot reminiscence in any other case).

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments