How will node handle two branches of same length?


Let's say node is on a chain of length N+4, and receives a block from the chain of the same length N+4, but diverged by 4 blocks.

  1. Is the information of the length and accumulated difficulty broadcasted along with mined block?

  2. How will the recipient node handle this situation?


Posted 2017-10-22T12:52:59.573

Reputation: 1 142



This phenomenon is known as a chain-split (i.e. the bitcoin network can no longer agree which chain is the canonical chain).

Nodes will be network-partitioned until one chain becomes dominant.


Is the information of the length and accumulated difficulty broadcasted along with mined block?


How will the recipient node handle this situation?

Nodes will handle equal branches on a First Come, First Serve basis, so there will be a network partition where some nodes agree chain A with length N+4 is the canonical chain and the other set of nodes will assume chain B with length N+4 is the canonical chain. In the event of such a chain-split, the race is on for miners to produce a new block-tip and broadcast it across the bitcoin network ASAP to achieve convergence. When the contention is resolved, the node can switch to longer branch and obsolete the old branch.


Posted 2017-10-22T12:52:59.573

Reputation: 2 282

But then, if I recieve a block that is not for the tip of my blockchain, I will reject it immediately if along I don't recieve the information that it is for the tip of some other heavier chain. I will then never switch to another chain. – croraf – 2017-10-22T13:15:36.070

Sure, but say you have adopted chain A with length N+4, and suddenly you receive a block-tip of length N+5 that mines on top of chain B, your node will immediately recognise that the block-tip you just received may belong to a longer & heavier chain, so your node will probe the peer that has sent your that block tip for all the relevant blocks. – rny – 2017-10-22T13:17:52.900

How will my node immediately recognise it was a block for the heavier chain, and not some erroneous block for example? – croraf – 2017-10-22T13:18:54.323

But I dont know if proof of work is correct as it was made with different inputs (unknown to me). – croraf – 2017-10-22T13:22:10.837

So I looked the bitcoin core implementation and it looks like all blocks are stored so as long as they obey consensus rules. And there's a function in src/validation.cpp that activates the best chain. – rny – 2017-10-22T13:29:17.670

So all the blocks from all the branches from entire history of blockchain are stored? You can also join the chat:

– croraf – 2017-10-22T13:31:40.733