What is a Chain Reorganization?
Chain reorganization is a phenomenon that can occur in blockchain-based systems, such as Bitcoin, when two different blocks are mined at roughly the same time, resulting in the creation of two competing versions of the blockchain.
When a new block is mined, it is broadcast to the network and other nodes in the network will add it to their local copy of the blockchain. However, if two blocks are mined at roughly the same time, it is possible that different nodes in the network will receive and add different blocks to their local copy of the blockchain. This can result in a temporary split in the network, with different nodes following different versions of the blockchain.
When this happens, the network will continue to mine new blocks on each of the competing chains, until one of the chains becomes longer than the other. The longer chain is then considered to be the valid version of the blockchain, and all nodes in the network will switch to following that chain.
The process of switching to a longer chain is known as chain reorganization. During this process, any transactions that were included in the shorter chain but not the longer chain will be considered invalid and will be removed from the network. This means that any transactions that were conducted during the time when the network was split may be temporarily reversed or invalidated.
Chain reorganization is a natural and expected part of the operation of blockchain-based systems, and it is designed to help ensure the integrity and security of the network. By allowing competing blocks to be created and resolved in a decentralized way, without the need for a centralized authority to resolve conflicts, blockchain-based systems are able to maintain their trustworthiness and robustness, even in the face of unexpected events or malicious actors.
Popular Examples of Chain Reorganization
Fork: A fork is a change in the protocol of a blockchain network, resulting in the creation of two separate chains. For example, in 2017, the Bitcoin blockchain network underwent a hard fork, resulting in the creation of two separate chains: Bitcoin and Bitcoin Cash.
Reorg: A reorg is a short-term change to the blockchain. It occurs when a miner or group of miners take control of more than 50% of the network's hashrate, allowing them to reverse transactions.
Rollback: A rollback is a change to the blockchain that involves removing some blocks and returning to an earlier state. This is done to reverse a hack or a mistake in the system.
Imagine you are playing a game of Jenga, where you and your friends are taking turns removing blocks from a tall tower, one block at a time. The goal is to keep the tower standing for as long as possible.
In blockchain, each block contains a set of transactions that are verified and added to the chain. Just like how the Jenga blocks are stacked on top of each other, the blocks in the blockchain are linked together in a chain, with each new block added to the top of the previous one.
Now, imagine that one of your friends accidentally removes a block from near the bottom of the Jenga tower. Suddenly, the tower becomes unstable and starts to wobble, and some of the blocks on top fall off, creating a new, smaller tower.
In blockchain, a chain reorganization happens when a longer chain is created, causing the previous shorter chain to become obsolete. This can happen when two or more miners create new blocks at roughly the same time, resulting in two competing versions of the blockchain. The version with more blocks added to it will become the new longer chain and the other version will be discarded.