Blockchain forks in Bitcoin and Ethereum

Posted By : Amit Kumar | 09-Apr-2017

BLOCKCHAIN FORKS 

The thing about forks is that , since the blockchain keeps on growing as more and more transactions are generated,validated,propogated and then mined into blocks which themselves are propogated along the network . There are moments when the blockchain starts deviating which means that there is a difference in the blockchain structure as perceived by one client node against the one perceived by the other node.

HOW DO BLOCKCHAIN-FORKS COME INTO EXISTENCE

Suppose there are two miner nodes ,and the latest block in the blockchain is with the blockNumber X , now there is a very high probability that these two miners mine a new block at ALMOST
the same time (or very small milliseconds difference ) .

So now suppose that miners A and B mine the block X+1 at nearly the same time . Now since they have successfully mined a block , they need to make the network aware about this event . How do they do that is via
broadcasting that they have found a new block (with the block header info ).

And now since A and B broadcast their newly found block at the same time , nodes around the world will start accepting either the block mined by Node A or B and adding it to their chain data .

Hence at that moment of time the world is divided based on the blockchain that they have accepted, based on the latest block they validated and added at the top of their current blockchain structure.

HOW OFTEN DO BLOCKCHAIN-FORKS HAPPEN

Bitcoin Blockchain-Forks can be divided based on they deviation the have created . A deviation like the one explained above occurs often , a deviation of two blocks can occur almost a week or almost a month in some cases .
But a deviation of 3 or more than 3 blocks is unnatural and is clearly pointing towards some bigger issue.

In case of Ethereum one block blockchain forks are large in comparison to the Bitcoin blockchain majorly due to the block times (time in which a new block is mined ) is approximately 1/30th of that of the Bitcoin protocol .
So one block forks occur very very often.

HOW ARE BITCOIN BLOCKCHAIN-FORKS RESOLVED

Blockchain forks are resolved based on the fact that , the longest chain is to be assumed correct. At one moment the whole network will abide by the longest chain because at some moment this is the chain that will
eventually get propogated to them because the forks are rare .

Let me explain how (relating to the above case of X+1 block and miners A and B)

In the above case A and B have the same blockchain structure till the block number X , at X+1 they have resulted in the fork and due to block broadcasting by A and B the whole network is relying on two different blockchains .
At this moment some node C mines a block number X+2 , suppose on the top of the X+1 block mined by B and suppose it does not face competition or it's broadcast spread is much larger than any other competing miner.

In that case the nodes which thought that A's blockchain was the correct chain , receive block X+2 and tries to validate the block X+2 within it's own chain but is unable to do so because the hash of this new block has it's parent hash set to
the block on the right side of the fork and is not compatible with A's fork of blockchain .

And at this moment node D sees that it's on the wrong side of the fork and tries to move to the correct side of the fork and this will be the state of the whole network if there are no srict competing miners. So  what C does is orphan the X+1 block it got from A and uses the X+1 block mined by B and
the X+2 mined by Block C and reorganises its chain and broadcasts the last validated block to the network so clients still on the wrong side of the fork can correct their states.

HOW ARE ETHEREUM BLOCKCHAIN-FORKS RESOLVED

Ethereum blockchain forks are resolved almost similarly but with one or two major differences induced due to less block times . What ethereum does is it tries to compensate the orphaned blocks so the orphaned blocks as described above are compensated and instead
get added to the fork . Now once these uncle blocks / ommer blocks get added to the blockchain , to resolve the next blockchain-fork in ethereum the consensus is based NOT upon the longest chain but instead on the heaviest chain which is the basic definition of the GHOST protocol.

 

THANKS

About Author

Author Image
Amit Kumar

Amit is an seasoned Backend Developer with expertise in Java, particularly the Spring framework as well as Javascript and related frameworks such as Node.js and Express. He possesses a solid understanding of blockchain fundamentals and has hands-on experience integrating major blockchains like Ethereum and Bitcoin into both centralized and decentralized applications. He is proficient in working with relational and non-relational databases, enabling him to handle various data storage requirements effectively. He has successfully contributed to a range of projects, including Belfrics, a cryptocurrency exchange platform, Daxxcoin, an Ethereum Proof-Of-Work fork, and Wethio blockchain, an Ethereum-based Proof-Of-Stake fork. His strong technical skills and practical experience make him a valuable asset, particularly in the blockchain domain. Amit's ability to integrate blockchain technologies into applications showcases his versatility and innovation.

Request for Proposal

Name is required

Comment is required

Sending message..