<p>When electing a chain at a fork, the other chain will be discarded.</p>
<p>The chain selection is using the order below:</p>
<ol>
<li>chain length</li>
<li>if 2 chains have a new block with same slot, then prefer block minted ourselves - if applicable</li>
<li>if 2 chains have latest block by same producer, compare Operational certificate (the one that is higher than last minted block on chain from producer, post Vasil - by exactly 1)</li>
<li>Descending order of leader VRF hash</li>
</ol>
<p>Note that the max chain depth for fork resolution is limited and specified via genesis</p>

CC BY-SA 4.0
2022-08-23T05:51:27.863Z
Thank you for the answer. Two questions come to mind. 1. Does Cardano have a name for this process that I can find in the source code? The word reorg doesn't appear in the source code. And 2. Where do the competing chains reside before "finalizing" one of them, in memory or on disk, in the key-value store?
The Quantum Physicist
CC BY-SA 4.0
2022-08-23T07:55:17.050Z
I believe the term you're looking for is "chain selection" , you can find the logic used for Praos chain selection at tip [here](https://github.com/input-output-hk/ouroboros-network/blob/master/ouroboros-consensus-protocol/src/Ouroboros/Consensus/Protocol/Praos/Common.hs). The chain resolution would occur at tip (first instance of where node sees a fork), and accordingly be committed to disk. If it encounters a block that requires a rollback of chain node was on, it can do so. Since there is a protocol limit for chain depth, the immutable DB vs volatile can be precisely maintained
RdLrT
CC BY-SA 4.0
2022-08-22T15:06:40.677Z
2022-08-22T15:06:40.677Z
RdLrT
<p>In bitcoin, a longer chain will cause a reorg if it's not the &quot;main-chain&quot;, where some blocks' side-effects will be reverted, and others in another branch will be processed and become part of the main-chain. I can't find any resources on how Cardano does that and whether it's done in the same way.</p>
<p>So my question is, how does Cardano handle reorgs? Is it exactly like Bitcoin, where it stores all orphans and decides where to go based on the longest chain rule? Or is it <a href="https://www.mintlayer.org/en/news/2022-02-01-mintlayer-moves-off-substrate/" rel="nofollow noreferrer">like Polkadot/Substrate</a>, where it just stores all block candidates in memory and drops them once blocks are finalized? Or is it something else?</p>

<blockchain><block-production><consensus>
How does Cardano technically handle reorgs?
# How does Cardano technically handle reorgs?

(Asked by: username_0 on 2022-08-22)

In bitcoin, a longer chain will cause a reorg if it's not the "main-chain", where some blocks' side-effects will be reverted, and others in another branch will be processed and become part of the main-chain. I can't find any resources on how Cardano does that and whether it's done in the same way.

So my question is, how does Cardano handle reorgs? Is it exactly like Bitcoin, where it stores all orphans and decides where to go based on the longest chain rule? Or is it [like Polkadot/Substrate](https://www.mintlayer.org/en/news/2022-02-01-mintlayer-moves-off-substrate/), where it just stores all block candidates in memory and drops them once blocks are finalized? Or is it something else?

**Tags:** blockchain, block-production, consensus

---

## 1 answers

### Answer by username_1 on 2022-08-22. Score: 1 | Accepted answer

When electing a chain at a fork, the other chain will be discarded.

The chain selection is using the order below:

1. chain length
2. if 2 chains have a new block with same slot, then prefer block minted ourselves - if applicable
3. if 2 chains have latest block by same producer, compare Operational certificate (the one that is higher than last minted block on chain from producer, post Vasil - by exactly 1)
4. Descending order of leader VRF hash

Note that the max chain depth for fork resolution is limited and specified via genesis

> **Comments:**
> **username_0**: Thank you for the answer. Two questions come to mind. 1. Does Cardano have a name for this process that I can find in the source code? The word reorg doesn't appear in the source code. And 2. Where do the competing chains reside before "finalizing" one of them, in memory or on disk, in the key-value store?  
> **username_1**: I believe the term you're looking for is "chain selection" , you can find the logic used for Praos chain selection at tip [here](https://github.com/input-output-hk/ouroboros-network/blob/master/ouroboros-consensus-protocol/src/Ouroboros/Consensus/Protocol/Praos/Common.hs). The chain resolution would occur at tip (first instance of where node sees a fork), and accordingly be committed to disk. If it encounters a block that requires a rollback of chain node was on, it can do so. Since there is a protocol limit for chain depth, the immutable DB vs volatile can be precisely maintained  

---

