Skip to main content

Consensus Mechanisms

Consensus lets N nodes, some of which may be faulty or malicious, agree on a single ordered log. Two properties matter:

  • Safety - no two honest nodes finalise conflicting histories.
  • Liveness - the network keeps finalising new blocks.

Theory You Must Know

ResultStatementImplication
FLP (1985)In a fully asynchronous network, deterministic consensus is impossible with even one crash faultReal protocols add timeouts (partial synchrony) or randomness
CAPUnder partition choose consistency or availabilityBitcoin/Ethereum favour availability (chains fork, reconcile later); Tendermint favours consistency (halts without 2/3)
BFT boundTolerating f Byzantine nodes needs n >= 3f + 1Classic BFT tolerates < 1/3 malicious
Crash-fault boundRaft/Paxos need n >= 2f + 1Cheaper but assumes nodes are not malicious

1. Proof of Work - Nakamoto Consensus

Blockchain Core Mechanics

Mempool txs
Miners hash header + nonce
First hash < target wins
Gossip block
Nodes verify & extend longest-work chain
Security = energy burned; finality is probabilistic (β‰ˆ6 confirmations)

Consensus is how mutually distrusting nodes agree on one canonical history. PoW pays with external energy; PoS pays with slashable internal capital.

  • Anyone can append a block by finding H(header) < target.
  • Fork choice: heaviest cumulative work (not "longest by count").
  • Safety is probabilistic: attacker with fraction q of hash power catches up from z blocks behind with probability (q/p)^z (p = 1-q) for q < 0.5.
  • Incentives: block reward + fees; honest mining is the profit-maximising strategy for q < ~0.33 (selfish mining can profit above that).
ProsCons
Permissionless, Sybil resistance via physical cost~150 TWh/yr (Bitcoin) energy
Simple, battle-tested since 2009Low TPS, probabilistic finality
Objective weak-subjectivity-free sync (just verify work)ASIC / pool centralisation

Attacks: 51% (double-spend, censorship), selfish mining, eclipse attacks (isolate a node's peers), timestamp manipulation, and rental attacks on small chains (Ethereum Classic 2019/2020 reorgs).

2. Proof of Stake

Validators lock capital; misbehaviour is slashed.

Ethereum Gasper = LMD-GHOST + Casper FFG

ConceptDetail
Slot / Epoch12 s slot, 32 slots = 1 epoch (6.4 min)
ProposerOne pseudo-random validator per slot (RANDAO)
CommitteesValidators split into committees that attest each slot; BLS signatures aggregated
Fork choiceLMD-GHOST - follow the subtree with most recent attestation weight
FinalityCasper FFG - checkpoint is justified with 2/3 stake, finalized when the next is justified (~2 epochs ~ 12.8 min)
SlashingDouble-vote, surround-vote, double-proposal. Reverting a finalized block burns >= 1/3 of total stake
Inactivity leakIf no finality, non-attesting validators bleed stake until the active set is 2/3 again

PoS-Specific Attacks

AttackDescriptionMitigation
Nothing-at-stakeValidators vote on all forks because it is freeSlashing makes equivocation costly
Long-rangeOld keys rewrite history from far backWeak subjectivity checkpoints - new nodes sync from a trusted recent state root
Liveness / censorship>1/3 offline stalls finality; >1/2 can censorInactivity leak, proposer-builder separation
Stake centralisationLiquid staking (Lido) holding large shareSocial pressure, DVT, protocol limits

3. Classical BFT (PBFT, Tendermint/CometBFT, HotStuff)

Known validator set; rounds of voting; instant deterministic finality if > 2/3 are honest.

Tendermint round (height H, round R):
Propose : designated proposer broadcasts block B
Prevote : each validator prevotes B (or nil on timeout)
Precommit: on seeing > 2/3 prevotes -> precommit B (and lock)
Commit : on seeing > 2/3 precommits -> block committed, H+1
  • Locking guarantees safety across rounds: a validator that precommitted B only prevotes B (or a block with a newer valid proof-of-lock) later.
  • Cost: O(n^2) messages in PBFT; HotStuff makes it linear with leader-aggregated threshold signatures, which Diem/Aptos/Sui-style protocols adopt.
  • Used by Cosmos, Binance Smart Chain-like validators sets, many permissioned ledgers.

4. Raft / Paxos vs BFT

Raft / PaxosBFT (PBFT/Tendermint)Nakamoto (PoW/PoS)
Fault modelCrash onlyByzantine (< 1/3)Byzantine (< 1/2 resource)
MembershipFixedFixed or stake-weightedOpen
FinalityImmediateImmediateProbabilistic / economic
Scale3-7 nodes4-200 validatorsThousands of nodes
UseKafka KRaft, etcd, ConsulCosmos, permissioned chainsBitcoin, Ethereum

See also: Raft Consensus in Kafka.

5. Other Mechanisms (quick reference)

MechanismIdeaExample
Delegated PoSToken holders elect a small block-producer setEOS, Tron
Proof of HistoryVerifiable delay function sequence acts as a clock; combined with Tower BFTSolana
Proof of AuthorityIdentified approved signersPrivate/test networks, Clique
DAG-based (Narwhal/Bullshark, Avalanche)Separate data dissemination from ordering, or metastable samplingSui, Avalanche
Proof of Space/TimeCommitted storageFilecoin, Chia

6. Fork Choice vs Finality - Do Not Confuse

  • Fork choice picks the head now (may flip).
  • Finality is a promise it will never flip without slashing/enormous cost.

Services should expose three block tags: latest (head), safe (justified), finalized. Use finalized for custody and bridge actions.

Senior Interview Gotchas

  1. Why is "longest chain" wrong? Must be most accumulated work; a long chain of low-difficulty blocks is cheaper to fake.
  2. Why can PoS be "cheaper" yet secure? Attack cost is stake slashed (burned) vs PoW miners keeping hardware after failed attack.
  3. Why does Tendermint halt rather than fork? It prefers consistency (CP) - no commit without 2/3 precommits.
  4. Is 51% needed to attack? Not for censorship in BFT (1/3 halts), nor for selfish mining (~25-33%).
  5. Finality gadget on top of PoW? Yes - e.g. checkpointing (Bitcoin has none by design; some chains add it for exchange safety).

Next: Bitcoin Internals.

πŸ“–
Track Page Progress0 / 635 Read
Knowledge Base Completion0%