In the previous blogs on Overview of Bitcoin Blockchain, we looked at
- Complexity & cost of the current financial systems and what constitutes a blockchain
- How hashing ensures data integrity & trust-less verification of blocks
- How p2p network and immutable ledger helps decentralization & integrity of the network
- How mining works and how a miner “wins” the right to write to the blockchain
In this blog, we will understand how the blockchain resolves conflicts when more than one miner solves the puzzle for their blocks
Proof of work
There are many consensus protocols such as proof of work, proof of stake, proof of history, etc. Bitcoin uses Proof of work. Principally all the consensus protocols are trying to solve the same problem; the difference is in the method of arriving at the consensus
Let’s take a step back and ask, why do we need a consensus protocol?
Need for consensus protocol
In the earlier blogs we saw that when a miner “cracks the puzzle” and gets to add a block, thousands of nodes across the globe runs a series of checks to ensure that there is no malicious act. Similarly if a malicious actor is trying to add a block in the middle of the blockchain, then it is almost impossible to do so, as the malicious actor will need to make changes to every node across the globe; however what happens if two or more miners from different part of the globe cracks the cryptographic puzzle around the same time? All of them followed the same rules but which version of the chain is the right chain?
In the below diagram, a miner who also runs Node X (far left top) has solved the cryptographic puzzle and added a block (red block) to his local copy of the blockchain and propagated it to the other nodes. The other nodes did their verification, found it to be valid and accepted the block. Similarly on the far right bottom, a miner who runs Node Y has also solved the puzzle and similar to Miner X has propagated her block (blue block) to other nodes
As we know, a blockchain cannot have this inconsistency, where one some nodes have the red block, while the other has the blue. Every copy of the blockchain has to be the same as the other nodes, so what is the algorithm to resolve this?
![](https://unthinking.org/wp-content/uploads/2022/11/Nodes-1024x724.jpg)
Byzantine Fault Tolerance
To solve the above conundrum, the Bitcoin blockchain borrows the algorithm from the Byzantine Generals problem. Simply put the Byzantine Generals problem assumes that a city is surrounded by Generals & their Lieutenants. They need to coordinate their actions (attack or retreat) and they have to consider the probability of having traitors among them who could distort the message
To prevent the traitor from miscommunicating (for e.g. when the decision is attack & the traitor communicates retreat) all of them agree on a protocol i.e. each will transmit the message that they have received from the general to each other. Each of the personnel then takes action based on the largest consensus
In the below diagram, the General (let us assume in this case he is not the traitor), transmits the message to attack. Every other Lieutenant transmits the message they received to every other personnel. As you can see, the majority decision is attack, therefore the group attacks in spite of the traitor communicating the incorrect message. If you are interested to know more about Byzantine, you can read it here
![](https://unthinking.org/wp-content/uploads/2022/11/Byzantine-1024x683.jpg)
Byzantine Fault Tolerance in the Blockchain
In the blockchain conflict because we now have two groups having different block (see fig 1 – red & blue) as the latest block, no decision is taken as yet. The blockchain waits for the next block to be added and whichever group gets to add the block first, becomes the longest chain and this becomes the pristine blockchain
![](https://unthinking.org/wp-content/uploads/2022/11/Nodes-1-1024x717.jpg)
As you can see in fig 3, the group on the left could crack the next cryptographic puzzle and add their block, therefore the group on the right removed the earlier block (abandoned block) and replaced it with the other two blocks (red & yellow), thus maintaining the integrity of the blockchain
Therefore through sheer computing power, the strongest group wins. This is the reason that when you make a BTC transaction, you would need to wait for at least 3-6 blocks to ensure that your transaction is not part of an abandoned block
Conclusion
This brings us to the end of basics of Bitcoin blockchain. If you have followed through until now, you have a fair understanding of the fundamentals. I would urge you to dig deeper and this will enable you to appreciate how this innovation helps us to make trust-less, decentralized and peer-to-peer cheap transactions. Do comment if you would want to know anything else in detail
In the following blogs, I will delve into few other aspects on why Bitcoin was invented