Chain Reorganization in Blockchain Technology
What do we mean by chain reorganization?
Reorganization is a crucial part of blockchain technology. If a block is deleted or removed from the blockchain in order to add more blocks to the chain, a reorganization takes place. This is also known as reorg and though it has a lot of potentials, it is not an easy task. At present, a major hurdle in blockchain design is block conflict. This flaw occurs when two blocks are added/published on a blockchain at the same time. This can often result in a fork in the blockchain.
Any change that takes place in the underlying protocol of the blockchain is referred to as a fork. It is a vital upgrade in the network which could either imply a dramatic or a minor change. Both developers, as well as community members, can create a fork in the blockchain.
Node operators play an important role in changing the blockchain. Nodes are basically computer systems that are linked via the blockchain. The protocol gets upgraded when the change/new transaction is recorded in all copies of the blockchain that lies with the nodes.
Currently, all conflicts on the blockchain are resolved through the Longest Chain Rule, i.e LCR. Under this method, the longest chain is considered valid, if there are numerous blocks. Hence, as directed by the protocol, every node is already aware of the most extended brand and works only towards furthering that very branch. Now, there may be some transactions that take place on the other, invalid side of the fork. In this case, the fork gets restructured into new blocks which result in blockchain reorganization.
Blockchains like Bitcoin and Ethereum tend to get more traffic and hence chain reorganization is more common here as simultaneous generation of new blocks at the same time and place occurs. What happens is that two different nodes update copies of the ledger that is specific to them. When this happens, the node which has a shorter follow-up chain is the one that reorgs the blockchain. In a nutshell, chain reorg makes sure that all node operators on the blockchain have the exact same copy of the distributed ledger.
Ehh…that doesn’t sound right! How does it even work?
In case nodes start receiving blocks from a new chain even when the old chains are still in existence, the chain splits and this is called a blockchain reorganization attack.
The Ethereum Beacon chain went through a massive seven-block reorg on May 25. This led to a major security threat known as a chain organization. Validators operating the Eth2 Beacon Chain fell out of sync following a client update that elevated specific clients. This led to a lot of confusion across the blockchain network and the validators did not update their clients.
But what does a seven-block reorganization mean? It implies that seven different blocks that represented different transactions were added to the blockchain fork that was later discarded. This happened so fast that the network could not identify it as part of a non-canonical chain. Generally, if a node is faster than the others it can lead to blockchain reorganization. This happens because the nodes that are quicker will find it hard to reach a consensus on the block that must be processed first. As a result, they would go on adding more data blocks to their blockchain which will eventually leave out the shorter chain as and when the next block comes into the picture.
Let’s say for example between miners X and Y, the two manage to spot a valid block simultaneously. However, because of the way the blocks are distributed on the network, some peers will see X’s block before they spot Y’s block.
If we assume that both the blocks are at par in terms of the difficulty level, there would be a draw between and the decision would depend on the clients as to which block they pick at random. In case yet another miner, say Z starts creating a new block over X’s or Y’s blocks, the tie breaks, and the blockchain is reorganized as the other block is left out.
How are the blocks in the blockchain chained together?
At the time the first block of a chain is created, a nonce generates the cryptographic hash. Until the block is mined, the data which the block contains is considered signed and permanently linked to the nonce and hash.
Every single block will have a header and of course numerous transactions. After this, due to the transactions that get noted in the block, a fixed-length hash output is formed and added to the block header.
Once the first valid block is in place, every following block should have the previous block header’s hash output. Each valid block must be connected to the hash of the last block header and this is uniform across all blocks. This is how a blockchain is formed–by linking every block to the one that precedes it.
Proof-of-Stake is used to process transactions and create new data blocks on the blockchain. Essentially, it is a consensus mechanism for cryptocurrency which is used to validate new entries on the distributed ledger that ensures that the database remains safe on the blockchain.
Proof-of-Stake vs. Proof-of-Work
While Proof of Stake (POS) chooses miners randomly, Proof of Work (POW) adopts a competitive approach for validating transactions and adding data blocks to the blockchain.
Pros and cons of PoS
The most prominent aspect of choosing Proof-of-Stake over Proof-of-Work as a consensus mechanism is that it uses less energy which makes it relatively more environment-friendly. This is important because then, miners would not have to devote resources to take measures to keep the network safe.
Next, centralization is not a problem as in POW. While in POW there’s a single, sophisticated unit and a particular miner could have their monopoly, POS remains largely CPU friendly.
But a prominent downside to POS is the ‘nothing at stake’ problem. As miners can vote for many blockchain histories, they don’t have much to lose since the cost of mining on multiple chains is low. Thus, miners may want to double spend without worrying about the cost which may ultimately lead to blockchain reorganization.