In last article, I discussed briefly about consensus mechanism and how the first use case of blockchain i.e. bitcoin, uses Proof of Work as a consensus mechanism to maintain and secure the ledger. Today I will provide an overview about a different approach to consensus called “Proof of Stake”.
Consensus is important in a distributed ledger system because it determines the truth. In a centralized system (banks, government etc.), there is a single entity which dictates and provides the truth. But in a distributed system, how to decide which version is the truth? How to come to a common agreement? This is called the byzantine general problem and people are trying to solve to for the past 20–30 years.
I recommend this video to know about the byzantine problem in detail. In a nutshell, the problem arises when a group of generals surround the city from different directions. Some want to attack and some want to surrender. They are far apart and are unable to communicate with one another. So how will they come to an agreement? If there is no majority, then neither the attack nor the retreat is going to be successful. If the majority come to an agreement, that would result in the best outcome for the generals.
There lies the problem- how will people come to consensus if they are distributed? How will the 51% (majority) agree on something so that the best outcome can be obtained? That’s where Proof of Work (PoW) and Proof of Stake (PoS) comes in. There are other consensus mechanisms as well like proof of storage, proof of authority, hashgraph etc. But the PoW and PoS are the widely used ones.
One of the major criticisms for PoW is that it is inefficient, wasteful and costly. Just for bitcoin mining, the electricity consumption is tremendous. With a lot of distributed ledger systems (cryptocurrencies) popping up, more and more electricity is being spent every year.
Proof of Stake
That’s when people started talking about PoS back in 2011. Instead of spending computing resources, the consensus can be reached by assigning certain individuals and staking their investment/number of coins they had. Based on number of coins an individual has, a person is pseudo randomly chosen and trusted to validate the transaction and create the next block. Why can a random person be trusted to secure the system? Because they have thousands or millions of coins invested and if something goes wrong, they have a lot at stake. So their best interest would be to keep the chain secure and valid. One of the first use cases of PoS were Peercoin, ShadowCash, Nxt, BlackCoin, Nav Coin and Qora.
The individuals who stake their coin are rewarded with a percentage of transaction fees and hence are incentivised to secure the network. There are no block rewards and hence the miners are also called forges in PoS as the validators get paid only by transaction fees for creating a block.
If a particular cryptocurrency uses PoS, then anybody can stake provided they meet the criteria for minimum number of coins possessed and the age of coin. In some contracts, the person should have “x” amount of coins for “y” amount of time before they can start staking. The time duration can be anywhere from few hours to days depending on the code.
Proof of work requires to buy mining rigs, pay for power, real estate etc. to participate in securing the network. Those are real incurred costs, whether or not the miner is successful.
In proof of stake, it is the potential loss of economic value that secures the network. So during an ideal execution, the validator actually does not incur realized costs.
Nothing at stake problem
In the early stages of PoS development, there were only rewards to forges for adding blocks and there were no penalties.
When two forges are able to arrive at a threshold (which creates a new block) at the same (or almost similar) time, then two valid blocks are formed on the chain. This is called soft fork and I have explained this in my last article. The fork is solved by majority going in one direction and the longest chain becomes the official chain and the other fork gets orphaned. A miner’s reward depends on allocating the resources to the correct chain or correct branch of the fork. If not, they will not be incentivised.
However, in PoS, because the process of securing the network does not have an intrinsic cost (such as power and opportunity cost of using power on another branch of the fork), there’s an inherent problem of the validator having no downside to staking both forks.
Thus, the validator, can forge on multiple blocks or both the forks on the same time as they care only about the transaction fees. So there arises a situation where basically a validator can forge on one fork, wait for it to confirm, spend it and then come back and forge on the forked block thus making the other fork invalid and thereby double spending it. This is called “Nothing at stake” problem.
Many PoS chains including Ethereum (which is planning to convert from PoW to PoS later down the road) has come up with many unique and different ways to tackle this problem. Checkpoints on timestamp history is one way to do this. Ethereum will be implementing what is called a Casper protocol, along with a feature called “slasher”. In simple terms, a security deposit is collected from the validators and if the validator signs on two different blocks, the deposit is forfeited. Thus the validators are made to behave as it is in their best interest to secure the network, not causing double spending else they will lose their money. The Casper protocol is still in development and the community is eagerly awaiting its implementation.
Delegated Proof of Stake (DPoS)
DPoS is a consensus algorithm in which the community elects certain delegates to act on their behalf to secure the network, create the blocks and come to consensus. Thus DPoS is a trade-off and is a semi-centralised consensus mechanism. Not everyone can become a delegate and everyone cannot participate. Thus it is a compromise between the centralised and decentralised systems. Bitshares (2013) is a popular DPoS algorithm chain. In Bitshares, if you have a stake or voting power, you can delegate a node on your behalf which you think have your interests in mind. In Bitshares, there are 101 delegates/nodes who help in validating transactions and create a block every 5–10 seconds. Other projects which uses DPoS are Steem, EOS and Lisk.
Electricity consumption is a big positive for PoS. Since the system randomly chooses the person, there is no computational resources or expensive mining rigs involved. PoS also eliminates the race to acquire the latest and most sophisticated mining rigs. Thousands of dollars are spent on this every day as the difficulty of mining increases over time.
It is also difficult to cause a 51% attack in PoS. A 51% attack is when a person or group of person controls the majority of a chain and they can basically re-write the history (i.e. blockchain transactions) as they please. In PoW, the 51% attack is in the form of hashing power, in PoS, 51% attack is possible in the form of shareholder attack. With PoS, if there is an increased demand to obtain 51% of the network, this demand would cause the price to increase drastically and thus it becomes very costly to acquire the 51%. Even if they did acquire the 51%, their best interest would be to secure the network and keep it valid else the network will be rendered useless and their entire investment is at stake.
But whether be it PoW or PoS, the rich will get richer. If it is PoW, they will be investing in latest mining rigs and technology to increase the computational power to obtain the block reward and if it is PoS, they would be just straight up putting up their capital and reaping the rewards by transaction fees for validating and securing the network.
One of the criticisms for PoS is that it creates a centralisation issue if all the coins are minted on genesis block. Investors with huge capital can accumulate significant portions of coins in its early stages and thus creating unequal wealth distribution. In order to circumvent this problem, some coins have adopted a dual or hybrid system of PoW and PoS.
In conclusion, we are still in development period and there is no single consensus algorithm which has become the one algorithm to rule them all. Both PoW and PoS has its own merits and demerits. I personally see a hybrid version of it being an effective and efficient system.