An introduction to Proof-of-Stake
Tags: blockchain, web3, programming, computerscience
Published: 2022-06-12 07:18:51

When it comes to blockchains like **Tezos**, which are, in essence, distributed databases, the network's nodes must reach an agreement on the network's current state. This agreement is achieved using consensus mechanisms. To understand proof of stake, it is important to have a basic idea of **consensus mechanisms** and **proof of work**.
<br/>
### What is consensus?

By consensus, we mean that a general agreement has been reached. Consider a group of people going to the cinema. If there is not a disagreement on a proposed choice of film, then a consensus is achieved. In the extreme case the group will eventually split.

In regards to blockchain, the process is formalized, and reaching consensus means that at least 51% of the nodes on the network agree on the next global state of the network.
<br/>

![Consensus image](https://i-invdn-com.akamaized.net/content/pic4b514c91a8c1c68c0827ed632501fec6.jpg)
<br/>

### Sybil resistance & chain selection

Now technically, proof-of-work and proof-of-stake are not consensus protocols by themselves, but they are often referred to as such for simplicity. They are actually Sybil resistance mechanisms and block author selectors; they are a way to decide who is the author of the latest block. It's this Sybil resistance mechanism combined with a chain selection rule that makes up a true consensus mechanism.

**Sybil resistance** measures how a protocol fares against a Sybil attack. Sybil attacks are when one user or group pretends to be many users. Resistance to this type of attack is essential for a decentralized blockchain and enables miners and validators to be rewarded equally based on resources put in. Proof-of-work and proof-of-stake protect against this by making users expend a lot of energy or put up a lot of collateral. These protections are an economic deterrent to Sybil attacks.

**A chain selection rule** is used to decide which chain is the "correct" chain. Ethereum and Bitcoin currently use the "longest chain" rule, which means that whichever blockchain is the longest will be the one the rest of the nodes accept as valid and work with. For proof-of-work chains, the longest chain is determined by the chain's total cumulative proof-of-work difficulty.
<br/>

### Proof of Work

The Proof of Work consensus algorithm involves solving a computational challenging puzzle in order to create new blocks in the blockchain. Colloquially, the process is known as ‘mining’, and the nodes in the network that engage in mining are known as ‘miners’. The incentive for mining transactions lies in economic payoffs, where competing miners are rewarded with some amount of cryptocurrency and a small transaction fee.
<br />

![proof-of-work image](https://img.capital.com/glossary/-infographics-Proof-of-Work-PoW-.png)


You can think of proof-of-work as a competition to approve transactions. Each entry in the competition costs a little bit of computing power. A miner’s chance of winning the competition is (roughly, and with some caveats) equal to the proportion of the total computing power that they control. So, for instance, if a miner controls one percent of the computing power being used to validate transactions, then they have roughly a one percent chance of winning the competition.

Multiple miners on the network attempt to be the first to find a solution for the mathematical problem concerning the candidate block. The first miner to solve the problem announces their solution simultaneously to the entire network, in turn receiving the newly created cryptocurrency unit provided by the protocol as a reward.

So provided a lot of computing power is being brought to bear on the competition, a dishonest miner is likely to have only a relatively small chance to corrupt the validation process, unless they expend a huge amount of computing resources.

**You can refer to this twitter thread to better understand Proof-of-work:** [What, Why, and How of PoW.🚀
](https://twitter.com/vivaceTempo/status/1533396473748258816) 
<br/>
Now that we have a decent idea of consensus mechanisms and proof-of-work we can begin to understand proof-of-stake.
<br/>
### Proof of Stake

A simple one-liner definition can be a good starting point to understand complex ideas. So, in short :
<br/>
> _“Proof-of-Stake algorithms achieve consensus by requiring users to stake an amount of their tokens so as to have a chance of being selected to validate blocks of transactions, and get rewarded for doing so.”_


You put a certain amount of your coins/tokens at stake, which gives you the right to become a validator in the network. A validator node is a special type of full node that participates in “consensus.” By participating in consensus, validator nodes become responsible for verifying, voting on, and maintaining a record of transactions. The staked coins then acts as collateral that can be destroyed if the validator behaves dishonestly or lazily. The validator is then responsible for checking that new blocks propagated over the network are valid and occasionally creating and propagating new blocks themselves.
<br/>

![proof-of-stake image](https://www.ledger.com/wp-content/uploads/2019/10/What-is-proof-of-stake-2.jpg)

PoS differs with PoW in a fundamental way. PoS essentially does away with the computational waste of proof of work entirely. Rather than requiring the prover(validator) to perform a certain amount of computational work, a proof of stake system requires the prover to show ownership of a certain amount of money. 

When creating a new block, the proof of stake algorithm chooses who is the block validator by checking how many coins a person is staking. The bigger the stake, the higher the probability of being chosen as a block validator. In proof of stake, we call the nodes doing the work block validators instead of miners, and we say that block validators mint new blocks instead of mining new blocks.

When a new transaction is issued, it is placed into a block with other transactions, and the block is limited to a certain size in MB. The validating node verifies the transactions’ validity in a block and broadcasts the block to the other nodes in the blockchain. After validating the block and sharing it with the other nodes, the validating node will receive a reward if the other nodes agree with the content of the block.

Block validators increase their chance of being selected to validate a block based on how much do they have at stake. Bigger the stake, the higher the odds of being selected to validate the block and win then reward. In other words, the more lottery tickets you buy, the higher the probability of winning the prize.

Of course, if the only statistic to be considered was the amount of coins a participant has staked on the network, then the system would be skewed in favor of the rich. Only the wealthiest stakers would be chosen to create blocks, which would lead those participants to earn more tokens than others, thus reinforcing their wealth and making them more likely to earn more and more block rewards. That may be the case for some PoS blockchains out there, but it is not a hallmark of a durable and robust one. Some models take into consideration how long the validator has been staking and some even bring randomness into the picture, so that everyone has a fair chance of creating a block.
<br/>

### Proof of Stake and Security

The 51% attack threat still exists on proof-of-stake as it does on proof-of-work but it is even riskier for the attacker.

To perform a 51% attack, one’s would need to buy at least 51% of the cryptocurrency available, which would be very expensive. Although it would be very expensive for someone to acquire 51% of all the coins of a cryptocurrency, a person could indeed do it and try an attack. They could then use their own attestations to ensure their preferred fork was the one with the most accumulated attestations. The 'weight' of accumulated attestations is what consensus clients use to determine the correct chain, so this attacker would be able to make their fork the canonical one.

However, a strength of proof-of-stake over proof-of-work is that the community has flexibility in mounting a counter-attack. For example, the honest validators could decide to keep building on the minority chain and ignore the attacker's fork while encouraging apps, exchanges, and pools to do the same. They could also decide to forcibly remove the attacker from the network and destroy their staked tokens. 

It wouldn’t be in his best interest to attack the network on which he holds a majority. This would harm the network and make the cryptocurrency value to fall, which means that the attacker’s holdings would also fall. Consequently, someone who holds a majority in the network would be incentivized to maintain the network secure. These are strong economic defenses against a 51% attack.
<br/>
### Summary

The impact of PoS extends beyond the security and functional capacity of blockchains. The algorithm has allowed decrease in gas fees while maintaining security against malicious intent. Also, it has reduced the ecological impact PoW blockchains have been known to have due to their high energy drainage. It has also paved the way for faster transactions that closely simulate centralized finance.

Several consensus algorithms make use of PoS as their foundation to provide increased security and confidence. These can be found [here](https://tokens-economy.gitbook.io/consensus/chain-based-proof-of-stake) . At the same time, considerable deviations from PoW and PoS mechanism have turned out to be rewarding. For instance, PoH (Proof of History) provides a significant advantage in terms of transaction speed while maintaining security and simplicity. 
<br/>
**Further reading**

**Liquid PoS in Tezos:** https://opentezos.com/tezos-basics/liquid-proof-of-stake/
**How PoS works in Tezos:** https://tezos.gitlab.io/active/proof_of_stake.html
**PoS vs PoW - An ecological footprint:** https://medium.com/tqtezos/proof-of-work-vs-proof-of-stake-the-ecological-footprint-c58029faee44