How Does Ethereum's New PoS Protocol Actually Work?
A guide to Ethereums new Proof of Stake, and how it really works under the hood
Table of Contents for How Does Ethereum's New PoS Protocol Actually Work?
Ethereum recently upgraded their system to use proof of stake. (see our history of Ethereum here).
But how does the proof of stake actually work?
Proof of stake is a consensus mechanism. Before the merge, Ethereum used proof of work required lots of computational power to give rewards to those who solve cryptographic puzzles to validator transactions. Proof of work (PoW) has miners do this computation to prove that they are using energy (= have capital at risk), and they are rewarded with block rewards (ether).
What is proof of stake (PoS)?
Proof of stake uses ‘staked’ ETH as collateral. This means they lock away their ETH (32 ETH), and in return they can validate blocks.
Validators have this stake assigned to them.
If the validators behave dishonestly then this ‘stake’ can be destroyed.
Validators are the ones who check that the new blocks propagated on the network are valid. They also create/propagate their own blocks.
There is a concept known as
weight in Proof of stake. The weight for a block is based on the amount of staked eth for the validators that vote for that block.
What are the advantages of Proof of Stake, compared to proof of work?
- Better for the environment. Instead of requiring lots of computational power to prove they did that work, proof of stake only requires minimal computational power (to validate new blocks).
- Reduced hardware requirements, which can mean lower barrier to entry. On Proof of Work powerful computers are required to be able to mine blocks.
- More secure network, due to reduced centralization. 51% attacks are exponentially more expensive for an attacker too, compared to proof of work.
What are some cons of PoS compared to PoW?
- PoW is tried and tested over many years. It works! But PoS is much newer. Other blockchains are successfully using PoS, but it is still much newer especially for a blockchain the size of Ethereum.
- PoS is much more complex than PoW
What are validators
To be a validator, you have to deposit 32 ETH into the validator deposit smart contract.
A validator is represented by your public key on the ethereum network.
You use a validator client is the software/application that you use to make attestations about new blocks. A validator client uses your private key.
What are node operators
Node operators are the actual humans (not code/software) who make sure the client software runs correctly
Can you stake more than 32 eth?
There is nothing stopping you from staking more than 32 ETH (you send it to the validator contract). But there is no advantage from doing so. Your rewards will still be the same as if you staked 32 eth.
What happens when you stake 32 eth?
When you deposit your 32 ETH deposit, you activate a set of validator keys.
These are what are used by your validator client, to make attestations about new blocks.
How to see the proof of stake validator deposit contract address
Note: do NOT send funds to this contract address without fully understanding what you are doing.
You can’t just send ETH to this address and start validating :). I’m linking it here only for people who want to see the contract, and not for people who want to start staking. If you are looking to stake 32 ETH find other guides. I copied the contract address from https://ethereum.org/en/staking/deposit-contract/ - if you go there you will see additional warnings and information
You can see the staking deposit contract at
0x00000000219ab540356cBB839Cbe05303d7705Fa. View it on Etherscan here.
When a transaction has finality on Eth PoS?
Finality is when a transaction is in a block, and changing that block cannot be changed without a very large financial loss (loss of ETH).
With proof of stake, there is a new concept called “checkpoints”.
These checkpoints are in the first block of each epoch.
Validators get to vote for pairs of checkpoints that they see as valid. If there are enough votes for a pair of checkpoints - which means over 2/3 of the total staked ETH - then the checkpoints are upgraded.
What happens when the pair of checkpoints get upgraded?
The most recent of the pair of blocks gets changed to “justified”.
The older of the two blocks is already “justified”, as it was the “target” of the previous epoch. So this gets upgraded to finalized.
Once a block is finalized, it would mean losing over 1/3rd of total supply of staked eth.
Read this really nice guide on settlement finality.
One possible attack on the PoS eth blockchain is if an attacker had 1/3rd of total stake, they could stop a block from ever reaching finality. There is a prevention - called the inactivity leak. If there are four epochs without finalized blocks, then the inactivity leak kicks in which starts to remove staked ETH from validators voting against the majority. This means the majority can regain the two thirds majority to start finalizing blocks again.
How do validators make a profit (how do they get ETH for validating on PoS)?
As a reward for validating, their staked balance increases.
How does Proof of Stake increase security
By running a validator, you are committing to being able to maintain a connection to keep validating blocks.
Validators miss out of the ETH rewards if they do not take part in the validation. If they behave dishonestly their stake can be destroyed (known as slashing).
There are two defined ways of acting dishonestly as a PoS validator:
- proposing multiple block in a single slot
- submitting contradicting attestations
The amount of ETH that is slashed ranges from around 1% of staked amount, up to 100%.
The calculated amount is defined in the “correlation penalty”. If a validator is the only one with the dishonest practice then it will be close to 1%. If there are multiple validators being dishonest at the same time then the penalty is much higher (up to 100%). This is known as a mass slashing event.
Because of this correlation penalty, an attacker coordinating multiple validators would have significant amount of ETH slashed.
51% attack on PoS
Even on PoS, there is still a theoretical chance of a 51% attack. However compared to proof of work, it has much more risk for the attackers of losing their ETH.
An attacker would need 51% of the staked ETH. (this is a crazy high number…)
Then they can create their own attestations to force a fork.
If this happens on PoW the blockchain has less options in terms of penalties. But on PoS there are some options for a so called counter-attack, including removing the attackers from the network / slashing their staked ETH.
How does the blockchain deal with forks?
Ethereum blockchain runs on the internet, with the types of network issues that come up from time to time. Some honest validators might have different ideas of what the head of the chain is.
When this happens in the Proof of Stake blockchain there is an algorithm called LMD-GHOST which decides which fork to use (based on the fork with higher weight of attestations in the history).
What are block builders in Ethereum Proof of stake
There is another new concept introduced for Ethereum Proof of Stake - block builders.
They are the ones who group up a bunch of transactions and the order in which they happen.
They pay to get their transactions in the blockchain.
What are proposers in Ethereum Proof of Stake
Proposers take these ordered lists of transactions (blocks), and they take the blocks with the highest bid (so they get paid more). They then propagate this block to the ethereum network for inclusion on the blockchain.
This post is incomplete and a work-in-progress
I'll update it soon and flesh it out with more info!
Spotted a typo or have a suggestion to make this crypto dev article better? Please let me know!
📙 Solidity Auditing online quiz
Learn how to audit smart contracts by looking at some example code and trying to find the bugs
⛽ Solidity Gas Optimizations Guide
How to optimize and reduce gas usage in your smart contracts in Solidity
🧪 Guide to testing with Foundry
Guide to adding testing for your Solidity contracts, using the Foundry and Forge tools
📌 Guide to UTXO
UTXO and the UTXO set (used by blockchains such as Bitcoin) explained
📐 Solidity Assembly Guide
Introduction guide to using assembly in your Solidity smart contracts
📦 Ethereum EOF format explained
Information explaining what the upcoming Ethereum EOF format is all about