In my previous article, I have covered one of the most famous consensus mechanism i.e Proof of Work. But like any technology, that protocol also has a certain drawback, and to overcome these issues another protocol has been developed i.e Proof Of Stake.
Proof Of Stake, as the name implies depends upon the stake of a validator. Like Miners in PoW, PoS consists of a group of validators. These validators use a pseudo-random algorithm to select a node that will act as a validator for the next block. The validator was decided based on a combination of different factors which includes the staking age and the node’s wealth. This means that the more coin one has, the more mining power he or she will have. Thus unlike PoW which is quite a power extensive because it depends upon solving a complex computational puzzle to decide the next block, the validation and generation of next block in PoS solely depend on the owner's stake. In Proof of Stake systems, the blocks that were mined are termed as ‘forged’.
This algorithm was introduced in 2011 with the idea to solve the problems with Proof of Work. Though both these algorithm is used to achieve consensus in the blockchain network, the underlying process to reach the final goal is different.
Some of the crypto coins like Nxt (NXT), Blackcoin, ShadowCoin, and Peercoin (PPC) uses the PoS method. Ethereum (ETH) is also planning to switch to a PoS system.
How do PoS works?
The blockchain network consists of a series of a node which acts as a miner (Forge in this case). Any network user who wants to participate in the forging activity needs to stake a certain amount of coin into the network. One can do this by sending a special transaction that will lock up their base cryptocurrency(in Ethereum's case, ether). The stake size determines the chances of a node to be selected as the next validator who will forge the next block. The bigger the stake, the higher the chances.
The newly created node which got selected to forge the next block checks the validity of the transactions in the block. If the transactions are valid, it then signs the block and adds it to the blockchain network. The node receives the transaction fees that are associated with the transactions in the block as a reward.
In the case when the node doesn’t want to serve as a forger, it can withdraw its stake along with the rewards earned. The network verifies and releases the node once it successfully checks that the node has not been involved in any malicious activity.
Advantages of using PoS:-
- Enhanced security.
- Reduced risk of centralization.
Forge selection method:-
Two unique methods are being used in case there is a requirement of not selecting the node with the maximum stake. These are:-
- Randomized Block Selection
In this method, a node gets selected as the validators which are having a combination of the lowest hash value and the highest stake. The account which will receive the right to forge a block can be easily predicted by each node because the stakes are public
- Coin Age Selection method
In this method, a node gets selected as the validators who have kept their stake for a longer period. The Coin age is calculated by multiplying the number of days the coins have been reserved as stake by the number of coins that are available as stake.
Coin age=no.of days coined staked *total no of coins staked
The coin age of a node has been reset to zero once it forged a block. To forge another block, the node has to wait for a certain period. Hence this method prevents the large stake nodes from dominating the blockchain network.
Different types of PoS
Proof Of Stake can be categorized into two parts:-
- Chain-based proof of stake
This algorithm randomly selects a validator during the time slot (e.g. every period of 10 seconds might be a time slot) available to create a block, and then assign it an authority to create a block with the constraint that the block must point to some previous block. Generally, it points to the last block of the longest chain. Hence over time, the blocks converge into one growing chain.
Blockchain projects that implemented this model are Nxt, Peercoin, Ardor.
- BFT-style proof of stake
This model offers ‘consistency’. Here the randomly chosen validators decide whether a particular block can be included in the chain or not at the end of each round. This type could be favored for a more “permission” approach. In this case, the consensus on a block does not depend on the length or size of the chain.
Blockchain projects that implemented this model are Neo, Tendermint, Polkadot, Hyperledge Fabric.
How it reduces the risk of a Network attack?
Since this model works on the concept of the stake owned by the validator, thus to effectively control the network and approve fraudulent transactions, a node has to own a majority stake in the network (also known as the 51% attack) which is quite impractical because if a hacker tries to purchase 51% of the total number of coins, the market reacts by the fast price appreciation.
Also, wherever the network detects any fraudulent transaction, not only the forger node loses a part of its stake but is also restricted from participating in future activities. Till the time the cost of staking is higher than the reward, the validator is at a loss in case of attempting fraud.
With the “Casper” upgrade underway for Ethereum, Proof-of-Stake (POS) model is gaining more popularity among other Blockchain consensus designs. With this upgrade, the protocols will set certain criteria that will identify a bad validator. The bad validator would lose their deposit if proven, thus making this model more secure.