Proof of Stake for Dummies (Part 1)
Today, I will introduce another consensus mechanism, Proof of Stake (PoS). This mechanism was introduced in 2011 with the aim to solve Proof of Work's problem. Even though they both try to reach the consensus goal, the process is quite different. Let's find out how different they are and which one is better than the other.
Topic will be divided into two parts. The first part (Part 1) will discuss about what is PoS and how it works. Part 2 will mention about penalties for fraud activities, "nothing at stake" problem and PoS benefit.
Before diving into, there are few terminology explanation we should know first.
Forging and forgers: In PoS mechanism, blocks are forged or minted instead of mined and the one who does the forging or validate the transactions is called forgers.
Okie, now let's move to Part 1.
What is Proof of Stake?
Individuals who want to become validators or forgers will lock their coins as a stake and receive the reward through transaction fee. It is where the word "Stake" comes from. The fixed amount of coin staked is different in each blockchain. For example, in ETH 2.0, you have to have 32 ETH if you want to stake.
In PoS mechanism, it uses pseudo random selection process to choose the node to be a validator of next block. It means that this process is not random totally, but it considers several different factors, such as:
- Node's wealth
- Staking age
- Randomization
(i) Node's wealth: So in PoS, the size of the stake determines the chances for the node to be selected to validate the next block. The bigger the stake, the higher the chances. The forgers will validate transactions and create new blocks in the network. And the process of creating new block is called forging. As you can see that, unlike Proof of Work mechanism using computational power to add new block, PoS requires validators to show an ownership of an certain number of coin to add new block to the network.
Figure 1: Proof of Stake mechanism
In order to avoid the favor of wealthy nodes, there is other techniques combined in the selection process. Two common used methods are:
(ii) Coin age selection: Validator is chosen based on how long tokens have been staked and how many coins staked. The coin age is calculated by multiplying number of coins with how many days they have been stakes. For example, if you have 100 coins and you have staked for 60 days then your coin age is 6000. After a node forges the new block, coin age will be set back to 0 and has to wait some period of time to forge another block. This will help to avoid the large stake node will dominate the blockchain.
(iii) Randomized block selection: A forger with a particular value called "hit value" will be chosen to create a new block. What is "hit value"? Each forger will use his/her private key to generate a hash of previous block. The initial 64bits of this hashed value are extracted as "hit value". Because his/her private key is unique, "hit value" encoded is also distinct. Any forger who has "hit value" is lower or equal "target value" will be chosen as a forger of a new block.
The formula to calculate the "target value" is formed from:
T = Tb x L x Se
while:
Tb = "base target value" = previous block target value x time used to forge that block.
L = time since the last block was forged.
Se = the number of coins staked.
- If "target value" is high, then the chances node is selected will be high. From the formula, we can see that the increasing in target value does not depend only on the number of coins staked but also on the time and target value of previous block. It will prevent the dominance of large stake.
In summary, coin age and randomized block selection will promote a healthy and decentralized network.
How does PoS work?
(i) Individuals who want to become a "validator/forger", they have to stake a certain amount of coin.
(ii) Validator will be selected by a pseudo random selection process to validate transactions.
(iii) After chosen, like in PoW, validator has to verify transactions by checking authenticity and sufficient account balance. If transaction is verified successfully, it will be hashed through hash function and wrapped into a block.
(iv) After verifying the transaction, forger will sign the block with his private key and broadcast that block on the network. Validators who are not chosen as a forger will become an "attestors". They will verify if the block is valid. At least 2/3 attestation from attestors are required for a block to be valid and added to a blockchain.
(v) After forging the block, validator/forger will receive the reward. A attester will also have the reward for his/her attestation.
(vi) Different blockchain will have their own way to calculate and distribute the rewards so that their tokenomic is healthy and decentralized.
The PoS process will be illustrated shortly in the diagram below:
Figure 2: Proof of Stake process
If you find this post is interesting, please feel free to subscribe, share and comment. I will come back with Part 2 later. And as always, thank you so much for your interest in math, technologies and science.
Charlotte.