Validation of New Blocks in Blockchain
The distributed nature of blockchain’s architecture brings with it inherent trust and transparency. All changes made to the chain are recorded, and every block can be traced back to the Genesis Block, which is the very first block of that chain. However, none of this would have been possible had it not been for the delicate and complex consensus algorithms that ensure a chain’s validity and integrity. Such algorithms are responsible for adding new blocks to the chain without compromising the security and integrity of the data stored in the distributed ledger. In other words, consensus algorithms provide a set of rules that enable the addition of new blocks to the chain while protecting the network against attackers. Blocks cannot be added to the chain until they are validated.
Many consensus algorithms are now being used for different use cases. They differ in terms of the participation of validators in the network, since validation of new blocks is done by peers in blockchain architecture. Consensus algorithms incentivize miners to broadcast the discovered block to the network immediately. However, there is no perfect algorithm that can fit every situation. We list here some of the most widely used consensus algorithms:
- Proof of work (PoW)
- Proof of stake (PoS)
- Byzantine fault tolerance (BTF)
- Delegated Byzantine fault tolerance (DBGT)
- Ripple protocol consensus algorithm (RPCA)
- Proof of importance (PoI)
- Delegated proof of stake (DPoS)
- Proof of activity (PoA)
In this article, we discuss the working of PoW and PoS. The importance of these algorithms is evident from the fact that Bitcoin is based on PoW, while Ethereum, which is currently PoW-based, is planning to transition to PoS as part of its roadmap.
Proof of Work
Satoshi Nakamoto proposed PoW in the whitepaper that set the architectural ground for Bitcoin. In this consensus mechanism, validators are required to solve an arbitrary mathematical problem. In general, the cryptocurrency architecture requires every node to maintain its own copy of the blockchain, which is in sync with other participants. Whenever a transaction is projected on the blockchain network, the validators (also called miners) start a computation to solve the puzzle.
At first, the consensus algorithm bundles all of the data in the block into a string and then hashes it into binary format. However, the hash of specific information is always constant; to produce different strings that fulfill the criteria set by the network for adding a new block to the chain, miners compete each time to find the correct nonce. A nonce is an arbitrary number that is used in the authentication protocol to ensure that the same communication is never reused. It is a valid number that is used for hashing the value of the block.
As soon as a miner finds the precise nonce that will solve the mathematical problem, they will broadcast the hashed string to the network along with the nonce. Other miners then validate the block and add it to the chain after it is validated by over 50% of the validators. The miner who wins the race to solve the puzzle and finds the correct nonce is awarded in cryptocurrency.
- Although PoW is secure and provides an effective validation mechanism for a blockchain transaction, the algorithm is prone to so-called 51% attacks. These attacks are staged when the attacker controls 51% of the network’s total computing power, and they eventually leads to the centralization of authority.
- An enormous amount of processing power is required for the computational calculations. Moreover, as the chain grows, the calculations become more and more time-expensive, requiring much higher processing capability. Therefore, PoW is not suitable for a rapidly growing network.
- Such computationally intensive processing is ecologically unfriendly and requires an uninterrupted electricity supply.
The need for excessive computational power is a blessing in disguise as far as PoW’s security is concerned. As the reward is associated with being the first to solve the problem, miners are incentivized to deploy more computational resources for continuous mining. As the network’s computational power grows, it becomes very costly to stage a 51% attack, making PoW extremely secure.
Proof of Stake
The cost required to maintain PoW-based infrastructure can make it unaffordable. It has been argued that the Bitcoin architecture consumes as much energy as some of the world’s biggest residential and industrial cities. Therefore, a relatively cost- and energy-efficient mining solution was needed as a substitute to PoW.
PoS was first publicly mentioned in 2011 and functionally implemented in Peercoin the following year. This consensus algorithm was primarily proposed to solve the computational problems associated with PoW. Instead of needing enormous computational power, PoS requires validators who wish to mine blocks in the chain to stake their own cryptocurrency. The chance of mining a block gets higher as the staked cryptocurrency increases. The logic behind this stake-based consensus mechanism is that people with a higher stake will be the most incentivized to maintain the integrity of the network. Therefore, since everyone has some stake in the network, they will all act faithfully to ensure the chain’s integrity. Anyone with more than a 51% stake can, however, influence the transaction, although having such a large stake will be extremely costly for popular cryptocurrencies.
Some Important Terms Used
Node: Every participant of the blockchain network represents a node in the network.
Mining: The process of solving the mathematical problems is called mining.
Miner: Users who compete to solve the mathematical problems are miners.
Nonce: A nonce is the random number that is used in the authentication protocol to ensure that the same communication is never reused. It is an essential part of PoW because it is always unique, and it is required for producing the hash with a value equal to or lower than that set by the network difficulty.