<p>In a reorg where a node receives blocks for a longer or equal-length chain than the chain they previously followed as longest, what is the process for that node to handle this situation?</p>
<p>I can imagine that in the situation the new chain is clearly longer, the node would have to revert its UTXO set to the point at which the chains diverged, add back mempool transactions that were used since the chains diverged, and then re validate all blocks in the new chain. I can also imagine that some work that was already done in validating transactions could be reused, but not all of it.</p>
<p>How is the UTXO set reverted? Do nodes maintain a history of UTXO set diffs?</p>
<p>In the case where the length of the chains are not significantly different, I can imagine that a node might want to maintain both chains concurrently until it becomes clear one will be longer. Are nodes programmed to do this?</p>
<p>What is the longest reorg a node can handle without revalidating the entire chain from the genesis block?</p>
<p>These questions are primarily about how the software is currently written, rather than about theoretical ways nodes could handle these cases.</p>

CC BY-SA 4.0
2021-04-19T12:35:20.470Z
Which specific implementation are you asking about?  (Pick one?)
RedGrittyBrick
CC BY-SA 4.0
2021-04-19T23:03:00.553Z
How about core?
B T
<chain-reorganization>
How do nodes handle long reorgs?
B T
# How do nodes handle long reorgs?

(Asked by: username_0 on 2021-04-19)

In a reorg where a node receives blocks for a longer or equal-length chain than the chain they previously followed as longest, what is the process for that node to handle this situation?

I can imagine that in the situation the new chain is clearly longer, the node would have to revert its UTXO set to the point at which the chains diverged, add back mempool transactions that were used since the chains diverged, and then re validate all blocks in the new chain. I can also imagine that some work that was already done in validating transactions could be reused, but not all of it.

How is the UTXO set reverted? Do nodes maintain a history of UTXO set diffs?

In the case where the length of the chains are not significantly different, I can imagine that a node might want to maintain both chains concurrently until it becomes clear one will be longer. Are nodes programmed to do this?

What is the longest reorg a node can handle without revalidating the entire chain from the genesis block?

These questions are primarily about how the software is currently written, rather than about theoretical ways nodes could handle these cases.

**Tags:** chain-reorganization

> **Comments:**
> **username_1**: Which specific implementation are you asking about?  (Pick one?)  
> **username_0**: How about core?  

---

## 0 answers

