Hi all,
I was wondering about the following scenario:
When a node receives two valid blocks, a fork occurs. Then, when a next block is found and send to that node, the longest chain will be considered as valid. This is the process called forking.
First question, at what rate does a fork occur in Bitcoin? With thousands of nodes mining, it seems that a fork must occur on a regular basis – are there any stats on how often a fork happens?
Those are known as orphan blocks and blockchain.info has some stats on them here:
https://blockchain.info/charts/n-orphaned-blocksSecond, knowing that Bitcoin uses a P2P network, assume there's a single connection that connects two parts of the network (a single point of failure in a P2P network). That connection fails for 24 hours, and the two separate networks continue mining. Both are working on their own version of the blockchain. Then, a smart network engineer fixes the cable and the connection is restored. Effectively, there are two versions of the blockchain and both are valid (for each part of the network). New blocks from network A are rejected by B (and vice versa), because the longest chain rule is applied. Instead of a 'fork', we have 'knife', cutting the network in half.
Second question, how does Bitcoin deal with such an issue (though theoretically, considering it's an P2P network)?
Cheers,
Fevir
First of all, the p2p such a scenario is unlikely given that nodes connect to more than 1 peer and given the size of the netowrk.
But theoretically if that were to happen and the chains were being built at the same rate and at the same height, upon reconnection, Bitcoin Core would detect that a hard fork had occurred and something had gone wrong. AFAIK It would alert the operator and continue to use the chain it had been (or it might go into safe mode, don't remember). There would probably be an alert sent out by the developers and then they would decide whether to roll back the blockchain back to the fork point, or choose one chain and set checkpoints into the software to make sure that is the one used. It is hard to know what will happen, and is unlikely to happen. However, Bitcoin Core does not do much when such a situation happens, it can only alert the operator that something has happened.