1

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, where it just stores all block candidates in memory and drops them once blocks are finalized? Or is it something else?

1 Answer 1

1

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

2
  • 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? Aug 23, 2022 at 5:51
  • I believe the term you're looking for is "chain selection" , you can find the logic used for Praos chain selection at tip here. 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
    Aug 23, 2022 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.