Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 41 ยท Consensus and Networks

Proof of Stake

Learn how proof of stake picks validators by locked-up stake, how slashing and finality work, what nothing-at-stake means, and run a live lottery simulation.

Proof of work protects a chain by burning electricity: the more computing power an attacker would need, the safer the chain. Proof of stake (PoS) protects it with money instead. Participants called validators lock up coins as a deposit, the stake, and the protocol picks who proposes and votes on blocks in proportion to that stake. If a validator cheats, the protocol destroys part of the deposit.

This lesson explains how selection works, why the penalty system (slashing) is essential, what finality means, and which problems PoS has to solve that proof of work does not. You will run a stake-weighted lottery and a slashing demo in Python. If you have not seen mining yet, read Proof of Work and Mining first.

The core idea

In proof of work, the right to add the next block goes to whoever finds a lucky hash. In proof of stake it goes to a validator chosen by a (pseudo)random process, where each validator's chance is proportional to its stake. A validator with 10% of the total stake proposes about 10% of the blocks.

Where proof of work attaches a cost to creating blocks (hardware and electricity), proof of stake attaches a cost to misbehaving: the stake is at risk. The security assumption becomes "an attacker would have to own and risk a huge amount of the coin".

A typical PoS life cycle:

  1. Deposit. A user locks coins in a special deposit and becomes a validator after a waiting period.
  2. Duty. In each time slot, the protocol selects one proposer and a committee of voters.
  3. Reward. Validators that do their job on time earn rewards, paid in the coin itself.
  4. Penalty. Validators that are offline lose a small amount. Validators that break the rules lose a lot (slashing).
  5. Exit. A validator can withdraw after an unbonding delay, during which the stake still can be penalized for earlier misbehavior.

Stake-weighted selection

The selection must be unpredictable enough that nobody can aim an attack at the next proposer, yet every node must agree on the result. Real chains derive randomness from values the validators commit to and reveal, or from verifiable random functions, so every node can recompute the same schedule. The statistics are the same as a weighted lottery, which we can simulate with a seeded generator.

Python A stake-weighted lottery

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Over 10,000 slots, each validator's share of slots lands close to its share of stake: alice holds 53.3% and wins 52.8%. Over only eight slots the luck is much more visible, which is why small validators see income that is lumpy in the short term and proportional in the long term. Note that nobody had to burn any energy to run this lottery. The draw costs almost nothing.

flowchart LR
    S["Stake deposits<br/>(validator set)"] --> R["Random seed<br/>for the slot"]
    R --> P["Proposer chosen<br/>by stake weight"]
    P --> B["Block proposed"]
    B --> V["Committee votes<br/>(attestations)"]
    V --> F["Block becomes<br/>final"]

Each slot: stake picks a proposer and a voting committee; enough votes finalize the block.

Slashing: making cheating expensive

If misbehaving cost nothing, a validator could sign two competing blocks at the same height and be rewarded on whichever one wins. This is the nothing-at-stake problem. In proof of work, mining two forks means splitting your hash power, so you pay for each one. In proof of stake, signing is nearly free, so a rational validator would support every fork.

The fix is slashing: signatures are public, so two conflicting signatures from the same validator in the same slot form a proof of misbehavior that anyone can submit. The protocol then burns a part of the offender's stake and removes them from the validator set. The following code finds double signers and applies a penalty:

Python Detecting double-signing and slashing

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Dave signed two blocks for slot 41, so he loses half of his 400 coins. Real chains use different rules (a penalty that depends on how many validators misbehave at the same time, plus a forced exit), but the principle is exactly this one: equivocation is detectable and costs real money.

Offline validators are not slashed that harshly. A small "inactivity leak" slowly drains validators that fail to vote, which lets the chain recover if a large share of validators disappears.

Finality

Under proof of work, a block becomes "more final" with each new block on top of it, but it is never absolutely final; a long enough reorganization could still replace it (see Longest Chain Rule, Forks and Reorgs). Many proof-of-stake chains add economic finality. Validators vote on checkpoints, and when validators holding at least two thirds of the stake vote for the same checkpoint, it is finalized. The last lines of the demo above compute this: alice, bob and carol hold 96.6% of the stake, far above two thirds.

Why two thirds? If two conflicting checkpoints could both reach two thirds, at least one third of the stake would have voted for both, which is slashable. Reverting a finalized block therefore requires at least a third of all stake to be provably cheating and destroyed. The last line of the demo prints the size of that price in this tiny system: 1,933 coins. That is a very different security argument from "an attacker would need most of the hash power": here the attacker's loss is written into the protocol.

Other PoS problems and trade-offs

  • Long-range attacks. Old validators' keys, after they have withdrawn, could be used to forge an alternative history from long ago. Defenses include "weak subjectivity" checkpoints: a new node must obtain a recent trusted checkpoint (from several sources) instead of syncing from genesis blindly.
  • Rich get richer. Rewards are proportional to stake, so large holders earn more coins. Pooling services let small holders participate, but they also concentrate power. Always look at how the stake is distributed.
  • Liquid staking and custody. If most stake sits with a few services, the chain depends on a few companies behaving.
  • Grinding. If a validator can influence the random seed, they may try many inputs to bias future selection. Good randomness design prevents this.
  • Initial distribution. Proof of work lets anybody with hardware earn coins from nothing. In proof of stake you need coins to begin, so the first distribution (sale, airdrop, mining phase) shapes who holds power.

Energy comparison

A proof-of-stake validator is an ordinary server; a network of thousands of them consumes roughly what a few thousand computers use. A proof-of-work network pays for hashing continuously, and the total reflects the market value of the rewards. Ethereum's move from proof of work to proof of stake in 2022 reduced its estimated energy use by more than 99%. The security argument changes with it: PoW security is bought with ongoing external costs, PoS security is bought with locked capital and the threat of losing it.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How is the next block proposer chosen in proof of stake?

    Selection is pseudo-random but weighted by stake, so a validator with 10% of the stake proposes about 10% of the blocks.
  2. 2. What is the nothing-at-stake problem?

    Without a penalty, a validator can sign every fork and collect rewards on whichever wins. Slashing for conflicting signatures removes that incentive.
  3. 3. Two conflicting finalized checkpoints would require at least what to be slashed?

    Each finalized checkpoint needs two thirds of the stake. Two such groups must overlap in at least one third, and those validators signed conflicting votes.
  4. 4. Which statement about energy and security is accurate?

    Validators run ordinary servers, so energy use is tiny. The security comes from stake that can be destroyed, though centralization of stake remains a concern.

Summary

  • Proof of stake picks proposers and voters with a random draw weighted by locked-up stake.
  • Rewards pay honest validators, while slashing destroys the stake of those who sign conflicting blocks.
  • Slashing solves the nothing-at-stake problem by making equivocation provable and expensive.
  • Finality arrives when validators holding two thirds of the stake vote for a checkpoint; reverting it would cost at least a third of the stake.
  • PoS trade-offs include long-range attacks, stake concentration and the need for a fair initial distribution.
  • Energy use is a small fraction of proof of work.

Next: BFT, Delegated and Other Consensus Mechanisms, the family of voting-based protocols behind many modern chains.