A consensus mechanism is a fault-tolerant mechanism used in software and blockchain architecture to achieve an agreement on the state of the network among distributed processes or systems. Proof of stake (PoS) is a type of consensus mechanism by which a blockchain network achieves distributed consensus. Proof of stake (first mentioned in Bitcoin talk forum in 2011) was created as an alternative to Proof of Work (PoW) aka Nakamoto consensus (implemented in 2008), PoW is the first consensus algorithm in blockchain technology working on bitcoin, used to mine blocks and verify transactions in the blockchain.
Consensus Mechanism Algorithm
Blockchain being a distributed ledger, a consensus mechanism is needed among peer nodes of a blockchain network to ensure its working. Blockchain consensus mechanism algorithm is a procedure via which all the multiple peers of a blockchain network reach a common agreement or consensus about the real-time state of the distributed ledger on the true state of the network. These sets of processes and rules are called consensus algorithms. There are a lot of other consensus mechanism algorithms apart from PoW and PoW. Read more about 10 Useful Consensus Mechanism Algorithms.
Proof of Work Consensus Algorithm
Proof of Work was the first consensus algorithm introduced by Satoshi Nakamoto in the 2008 Bitcoin white paper, but the PoW technology was introduced in 2004, by Hal Finney as RPoW, Reusable Proof Of Work.
During mining, the user/ node process gathers blockchain data and hash it along with a nonce until a particular hash is identified. If the identified hash satisfies the conditions set out by the protocol, the new block is added to the network and is broadcasted to everyone.
For cryptocurrencies that are getting old, the conditions are getting incredibly challenging to complete. As the hash rate on the network increases, the difficulty to identify valid hash increases. This is done while designing the blockchain genesis block which ensures that blocks aren’t found too quickly with time. Read more about Genesis Block of Bitcoin
While trying to guess the correct nonce, massive amounts of hashes are calculated, which can be expensive for your computer. As you’re wasting computational cycles and electricity.
Proof of Stake Consensus Algorithm
In the PoS-based concept, the miner or validator is chosen via stake i.e. the combinations of random selection and wealth or age for holding a cryptocurrency of that particular blockchain. Being dependent on staking, PoS is mostly used in public blockchain consensus algorithms instead of consortium blockchain consensus algorithms and private blockchain consensus algorithms. Read more about Complete Guide to Blockchain.
The miner selected by staking produces a block that is added to the blockchain. The miner will be rewarded if successful, and if it fails to add a block in the blockchain, then the miner will be fined as much as the reward. The mining depends on the amount of stake a person has in the system. If a miner has more stake in the blockchain, the chances of mining are more.
Benefits of Proof of Stake
Energy consumption in transaction validation and mining
The probability of creating a block does not depend upon the computational power like PoW, instead, it depends on your stake in the given cryptocurrency system. It means that if your stake in the given cryptocurrency is at 5%, you can mine up to 5% of the transactions.
Time & Speed consumption
With PoS the mining process will be replaced by a constant amount of computation. Which will, consequently, improve the speed of the entire blockchain network.
Solving 51% attack double spend
The PoS algorithm also addresses the 51% problem as the attacker or malicious node would have to own 51% of the stake in order to validate invalid transactions. Hoarding 51% of a currency would be very difficult and will only lead to the devaluation of the currency i.e. If a node is caught cheating or tampering with a block, it will lose all of its staked coins. Read more about 51% Attack Double Spend Attack on Ethereum
Peercoin concept with PoS
In the proof-of-stake system, new coins are generated based on individual holdings. In simple words, if someone holds 5% of the cryptocurrency it will generate 5% of all proof-of-stake crypto coin. It creates a monopoly to increase the coins cost and separates the risk of this monopoly by proof-of-work mining shares.
Also, the transaction fee prevents spam and is burned (instead of being collected by miners like earlier cases), benefiting the overall network. To discourage hoarding and to recover the lost coins the currency supply targets growth at 1% per year, in the long run, is implemented in most blockchains using PoS.
Selection in Proof of Stake
The Proof of Stake consensus algorithm uses a random selection process to select a node to be the next block validator, based on a combination of factors like the age of staking, pseudo-randomization, and wealth of the nodes.
Blockchain using Proof of Stake starts by selling pre-mined coins or coins launched with the Proof of Work algorithm and later switching over to Proof of Stake. These pre-mined coins are offered by Initial Coin Offering (ICO), takeaways, and gifts based on certain work to promote the cryptocurrency.
After initial offerings, the users interested in participating in this forging process, are needed to lock a certain amount of crypto coins into the network as their stake. The coin quantity in the stake will determine the chances for a node to get selected as the next validator to forge the next block – the bigger the stake, the bigger the chances to get selected.
In order to make sure that the selection process remains random in the network, more unique methods are implemented into the selection process. Right now, the most common methods are ‘Coin Age Selection’ and ‘Randomized Block Selection’. Though each blockchain using the Proof of Stake algorithm has its own set of rules and methods suitable according to their ideology. Cardano, Polkadot, and EOS are few examples of Blockchain Technology working on the Proof of Stake consensus mechanism.
Coin Age Selection
This method chooses nodes based on the time the tokens were staked and are staked for. It is calculated by multiplying the stake coins duration by the number of coins.
Once a node has forged a block, their coin age is reset to zero and they have to wait a certain period of time to be eligible to forge another block again- this technique prevents not to favor only the wealthiest nodes in the network from dominating the blockchain.
Consider one simple example with three nodes trying to be miner
The node having address 3 is going to be the miner to add a new block in the existing blockchain based on the staked coins quantity.
Randomized Block Selection
In Randomized Block Selection the validators are selected by identifying the nodes with a combination of the highest stake and the lowest hash value and as we know the size of stakes are public in public blockchains, the next forger can be predicted by other nodes.
When a node gets selected to forge the next block, it checks if the transactions in the block are valid, signs the block, and then adds it to the blockchain. As a reward, the node receives the transaction fees associated with the block transactions.
In case, If a node wants to stop being a forger, its stake and earned rewards will be released after a certain period of time, giving them time in the network to verify that there are no fraudulent blocks added previously to the blockchain by that node. If a node is caught cheating or tampering with a block, it loses its all-staked coins which creates an environment for miners to be honest.