What is consensus?
By Consensus, we mean that a general agreement has been reached. Consider you and your friends decide to go on a vacation and you decide to go to Goa. If there is no disagreement on the proposed place then we can say that a Consensus has been reached.
In blockchain reaching consensus means that at least 51% of the nodes on the network agree on the next global state of the network.
But the question is how do nodes on the blockchain agree on a decision, if some of the nodes are likely to be malicious or fail? This Problem is called the Byzantine Generals’ problem and solutions to this problem are given by Byzantine fault tolerance.
Byzantine Generals’ problem:
The Byzantine Generals’ Problem is a generalised version of Two Generals’ problem. So the problem goes like this:
Each general is located with their army in different locations around the city they intend to attack. The generals need to decide whether to attack or to retreat. It doesn’t matter if they attack or retreat unless they agree on the same decision and once the decision is made it cannot be changed. Above are the requirements that need to be fulfilled.
The communication challenges are that one general can communicate the message to another general through courier and there are chances that message can get delayed, destroyed or lost. Then there might be a traitor among the generals who may send a fraudulent message to confuse the other generals which might result in failure of the plan.
In such uncertain conditions it becomes difficult for generals to carry out the operation (attack / retreat). In order to avoid complete failure, the majority of generals need to agree and execute some action.
If we apply the same thing in blockchain then each general can be looked at as nodes in the network. In order to agree on the next state of the global network, nodes need to agree on some decision or reach consensus and the only way to achieve this on a network is by having ⅔ or more honest nodes on the network. This means that the system is prone to failures and attacks if the majority of nodes on the network decide to act dishonestly.
Byzantine Fault Tolerance (BFT):
The failures which were derived from Byzantine Generals’ Problem are resisted by the BFT system. The Operation of the BFT system is not stopped even if some nodes fail or act dishonestly.
There are various ways for blockchain to achieve BFT and this brings us to the Consensus Algorithm.
The consensus of blockchain is that all nodes maintain the same distributed ledger. In web 2 architecture, due to the existence of the centre server, the other nodes only need to be aligned with the server and hence the consensus is hardly a problem. However, in a distributed network each node is both a host and a server, and it needs to exchange information with other nodes to reach a consensus. To avoid the damage caused by malicious nodes we need excellent consensus protocol.
There are three types of blockchain: Private, Public and consortium blockchain. Each type of blockchain has different application scenarios and according to need one needs to adopt a different consensus protocol.
Here we will see some consensus protocol which can effectively address the Byzantine Generals’ Problem.
PoW (Proof of Work):
PoW has widely adopted consensus protocols since it was first introduced by Bitcoin in 2001. Apart from Bitcoin it is also used by Ethereum, Litecoin, Dogecoin etc. In PoW, nodes on the network use computational power to win the right to add new blocks to the blockchain. Once the block is added to the network that node receives predefined reward or transition fees.
To add a new block to the blockchain, nodes need to solve the cryptographic puzzle. The PoW puzzle is very difficult to solve. Here nodes adjust nonce in order to solve the puzzle which inturn requires much computational power. The node that first solves the puzzle has the right to add the new block to the blockchain.
Malicious attackers are capable of overthrowing one block in a chain, but since the valid blocks in the chain increase, the workload is also accumulated, hence overthrowing a long chain requires a huge amount of computational power.
PoS (Proof of Stake):
In PoS, the one who will create the new block is decided by looking at the stake held by nodes in the blockchain unlike in PoW where it is decided by looking at the computational power. If someone on the blockchain held 10% of the stake (Cryptocurrency) then there are 10% chances that they might mine the next block in the blockchain. Although nodes still have to solve the cryptographic puzzle. Here nodes do not need to adjust the nonce to solve the puzzle but the solution to the puzzle is the amount of stake. Hence, PoS is an energy-saving consensus protocol. It was first used by PPcoin.
DPoS (Proof of Stake):
In DPoS stakeholders vote to select the block creators. This way stakeholders give the right of creating blocks to the delegates they support instead of creating blocks themselves, thus reducing computational power consumption to zero. It is based on democratic system. If the delegates are unable to generate blocks in their turn, they will be dismissed and the stakeholders will select new nodes to replace them. DPoS is a low-cost and high-efficiency consensus protocol. Bit Shares and EOS use the DPoS to reach consensus.
Practical Byzantine Fault Tolerance:
PBFT is a consensus protocol based on replication between known parties that can tolerate a failure of upto ⅓ of the parties. It is an algorithm for solving Byzantine faults resulting from a failure in achieving consensus caused by the Byzantine Generals Problem. In PBFT the primary node forwards the message sent by the client to the other three nodes. If suppose one node crashes, the message goes through all the five phases to reach a consensus among these nodes. Finally, these nodes reply to the client to complete a round of consensus. PBFT ensures network fault tolerance and allows thousands of operations per second with a negligible increase in waiting time. Tendermint, Hyperledger Fabric and many others use this protocol to achieve consensus.
All the above protocols are used according to different application scenarios. Apart from their usefulness it’s also true that the above protocols also have their downside. For example, if someone on the blockchain with PoW consensus accumulates superior computing assets compared to combined computing assets of all honest mining entities then they can disrupt the consensus. This is referred to as 51% attack. In PoS, nothing at stake is a major drawback; where multiple chains can be voted on by block generators because there is nothing to lose.
This act in PoS prevents achieving consensus. DPoS tends towards centralisation. If someone in the network has major stacks they can vote themselves and become valiators. BPFT is hard to implement as it requires a large amount of calculation.
Apart from these consensus protocols there are other consensus protocols like Ripple Protocol, Proof of Importance, Proof of Authority, Delayed Proof of Work, Delegated Byzantine Fault Tolerance, Federated Byzantine Agreement, Proof of Elapsed Time, Proof of Capacity, Proof of Burn etc.
Do follow our LinkedIn page for updates: [ Myraah IO on LinkedIn ]