Consensus
Chapter 5: Blockchain Consensus Mechanisms
Section titled βChapter 5: Blockchain Consensus MechanismsβOverview
Section titled βOverviewβConsensus mechanisms are the protocols that ensure all nodes in a blockchain network agree on a single version of the truth. Understanding consensus is crucial for node operators, as it affects node behavior, security, and performance.
5.1 What is Consensus?
Section titled β5.1 What is Consensus?βConsensus in blockchain refers to the process by which network participants agree on:
- Which transactions are valid
- The order of transactions
- The current state of the blockchain
- Which blocks should be added to the chain
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ CONSENSUS PROCESS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ Transaction Created ββ β ββ βΌ ββ ββββββββββββββββ ββββββββββββββββ ββ β Node A β β Node B β ββ β Validates β β Validates β ββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββ β β ββ β ββββββββββββββββββ΄βββββββββββββββββ ββ β β β ββ βΌ βΌ βΌ ββ ββββββββββββββββ ββββββββββββββββ ββ β Vote β β Vote β ββ β "Valid" β β "Valid" β ββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββ β βββββββββββββββββββ ββ β β ββ βΌ βΌ ββ βββββββββββββββββββββββββββββββββββββββββββββββ ββ β CONSENSUS REACHED β ββ β Block Added to Chain β ββ βββββββββββββββββββββββββββββββββββββββββββββββ ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ5.2 Proof of Work (PoW)
Section titled β5.2 Proof of Work (PoW)βHow PoW Works
Section titled βHow PoW WorksβMiners compete to solve a complex mathematical puzzle. The first to solve it gets to add the next block.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ PROOF OF WORK PROCESS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ Block Header ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β version β prev_hash β merkle_root β timestamp β nonce β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββ Target: Hash must be less than: ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β 0000000000000000000a7c1... (adjustable difficulty) β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββ Mining Loop: ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β for nonce in range(2^32): β ββ β hash = sha256(block_header + nonce) β ββ β if hash < target: β ββ β found! β Submit block β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββ Properties: ββ - Energy intensive (electricity) ββ - Hardware specialized (ASICs) ββ - 51% attack requires massive resources ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββDifficulty Adjustment
Section titled βDifficulty AdjustmentβNetworks adjust difficulty to maintain consistent block times:
Bitcoin: Every 2016 blocks (~2 weeks)
new_difficulty = old_difficulty Γ (time_for_2016_blocks / 20160_minutes)Ethereum (PoW era):
- Difficulty bomb: Gradually increases to encourage transition to PoS
- Adjusted per block based on parent timestamp
PoW Characteristics
Section titled βPoW Characteristicsβ| Aspect | Description |
|---|---|
| Block Time | Bitcoin: 10 min, Ethereum: 12-14 sec |
| Finality | Probabilistic (6 confirmations for BTC) |
| Energy | Very high (TWh annually for Bitcoin) |
| Hardware | ASIC miners required |
5.3 Proof of Stake (PoS)
Section titled β5.3 Proof of Stake (PoS)βHow PoS Works
Section titled βHow PoS WorksβValidators stake cryptocurrency as collateral. The protocol randomly selects validators to propose and validate blocks based on their stake.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ PROOF OF STAKE PROCESS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ Validators Staking ββ ββ Validator A βββΆ 100 ETH stake ββ Validator B βββΆ 50 ETH stake ββ Validator C βββΆ 200 ETH stake ββ Validator D βββΆ 75 ETH stake ββ ββ Selection Algorithm: ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β Random selection weighted by stake β ββ β Probability = validator_stake / total_staked β ββ β β ββ β Example: If total = 425 ETH β ββ β - Validator A: 100/425 = 23.5% β ββ β - Validator B: 50/425 = 11.8% β ββ β - Validator C: 200/425 = 47.1% β ββ β - Validator D: 75/425 = 17.6% β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββ Block Production: ββ 1. Select validator to propose block ββ 2. Other validators attest (vote) ββ 3. 2/3+ attestations β checkpoint finalized ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββEthereum PoS (Beacon Chain)
Section titled βEthereum PoS (Beacon Chain)βAfter βThe Merge,β Ethereum uses PoS with these components:
| Component | Description |
|---|---|
| Beacon Chain | PoS coordination layer |
| Validators | Stakers running consensus client |
| Epoch | 32 slots (6.4 minutes) |
| Slot | 12 seconds (block time) |
| Checkpoint | First slot of each epoch |
| Finality | 2 epochs (12.8 minutes) |
Slashing Conditions
Section titled βSlashing ConditionsβValidators can lose stake (slashed) for:
- Double Proposing: Signing two different blocks at same height
- Double Voting: Attesting to two conflicting blocks
- Surround Voting: Creating conflicting attestations
PoS Characteristics
Section titled βPoS Characteristicsβ| Aspect | Description |
|---|---|
| Block Time | 12 seconds (Ethereum) |
| Finality | ~12 minutes (2 epochs) |
| Energy | Very low (99.9% reduction vs PoW) |
| Hardware | Standard server (no ASICs) |
5.4 Delegated Proof of Stake (DPoS)
Section titled β5.4 Delegated Proof of Stake (DPoS)βHow DPoS Works
Section titled βHow DPoS WorksβToken holders vote for a small number of delegates who validate transactions on their behalf.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ DELEGATED PROOF OF STAKE ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β TOKEN HOLDERS VOTING β ββ β β ββ β User A βββΆ 1000 tokens βββΆ Vote for Delegate 1 β ββ β User B βββΆ 500 tokens βββΆ Vote for Delegate 2 β ββ β User C βββΆ 2000 tokens βββΆ Vote for Delegate 1 β ββ β β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β ββ βΌ ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β TOP 21 DELEGATES BECOME VALIDATORS β ββ β β ββ β Delegate 1 βββΆ 15% of votes βββΆ Block Producer β ββ β Delegate 2 βββΆ 10% of votes βββΆ Block Producer β ββ β Delegate 3 βββΆ 8% of votes βββΆ Block Producer β ββ β ... β ββ β β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββ Block Production: ββ - Delegates take turns producing blocks ββ - Typically 1-3 second block times ββ - High throughput ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββDPoS Examples
Section titled βDPoS Examplesβ| Blockchain | Delegates | Block Time |
|---|---|---|
| EOS | 21 | 0.5 sec |
| Tron | 27 | 3 sec |
| Cosmos | 100 (active) | 5-7 sec |
| Solana | Varies (PoH+PoS) | 0.4 sec |
5.5 Practical Byzantine Fault Tolerance (PBFT)
Section titled β5.5 Practical Byzantine Fault Tolerance (PBFT)βHow PBFT Works
Section titled βHow PBFT WorksβA consensus algorithm where a leader proposes blocks and validators vote on them. Can tolerate up to 1/3 Byzantine (malicious) nodes.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ PBFT CONSENSUS PHASES ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ Phase 1: Pre-Prepare ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β Leader βββΆ Proposes Block β ββ β β β ββ β βΌ β ββ β All Validators receive pre-prepare message β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β ββ βΌ ββ Phase 2: Prepare ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β Validator 1 βββΆ Prepare βββΆ All other validators β ββ β Validator 2 βββΆ Prepare βββΆ All other validators β ββ β Validator 3 βββΆ Prepare βββΆ All other validators β ββ β β ββ β Need 2f+ prepare messages to proceed β ββ β (f = number of Byzantine faults tolerated) β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β ββ βΌ ββ Phase 3: Commit ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β Validator 1 βββΆ Commit βββΆ All other validators β ββ β ... β ββ β β ββ β Need 2f+ commit messages to finalize β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β ββ βΌ ββ Block Finalized ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββTendermint (Cosmos)
Section titled βTendermint (Cosmos)βCosmos uses a BFT-based consensus called Tendermint:
- Validators: 100-200 typically
- Block Time: 5-7 seconds
- Finality: Immediate (1 block)
- Byzantine Tolerance: Up to 1/3 malicious validators
5.6 Comparison of Consensus Mechanisms
Section titled β5.6 Comparison of Consensus Mechanismsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ CONSENSUS COMPARISON βββββββββββββββββ¬ββββββββββ¬ββββββββββ¬ββββββββββ¬βββββββββββββββ¬ββββββββββββββ€β Mechanism β PoW β PoS β DPoS β PBFT/Tendermintβ PoH+PoS βββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌβββββββββββββββΌββββββββββββββ€β Block Time β 10-15s β 12s β 0.5-3s β 5-7s β 0.4s βββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌβββββββββββββββΌββββββββββββββ€β Finality β 60 min β 12 min β 3s β Immediate β Immediate βββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌβββββββββββββββΌββββββββββββββ€β Transactions β 7 TPS β 15-30 β 1000+ β 1000+ β 65,000 ββ β (BTC) β TPS β TPS β TPS β TPS βββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌβββββββββββββββΌββββββββββββββ€β Energy Use β Very β Low β Low β Low β Low ββ β High β β β β βββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌβββββββββββββββΌββββββββββββββ€β Decentral- β High β High β Medium β Medium β Medium ββ ization β β β β β βββββββββββββββββΌββββββββββΌββββββββββΌββββββββββΌβββββββββββββββΌββββββββββββββ€β Examples β BTC, β ETH2, β EOS, β Cosmos, β Solana ββ β ETH(legacy)β ADA β Tron β Hyperledger β βββββββββββββββββ΄ββββββββββ΄ββββββββββ΄ββββββββββ΄βββββββββββββββ΄ββββββββββββββ5.7 Node Role in Consensus
Section titled β5.7 Node Role in ConsensusβValidator Node Operations
Section titled βValidator Node Operationsβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ VALIDATOR NODE OPERATIONS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β PROPOSER DUTY β ββ β β ββ β 1. Select transactions from mempool β ββ β 2. Create block β ββ β 3. Execute state transitions β ββ β 4. Sign and broadcast block β ββ β β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β ββ βΌ ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ β ATTESTOR DUTY β ββ β β ββ β 1. Receive proposed block β ββ β 2. Validate block β ββ β 3. Sign attestation (vote) β ββ β 4. Broadcast attestation β ββ β β ββ βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββFull Node Consensus Participation
Section titled βFull Node Consensus ParticipationβNon-validating full nodes still participate by:
- Validating all blocks and transactions independently
- Propagating valid blocks to peers
- Rejecting invalid blocks
- Maintaining chain fork information
5.8 Fork Choice Rules
Section titled β5.8 Fork Choice RulesβWhen there are multiple valid chains, nodes use fork choice rules to determine which chain to follow.
Ethereum: LMD-GHOST
Section titled βEthereum: LMD-GHOSTβLatest Message-Driven Greedy Heaviest Observed SubTree
At slot N:1. Start at genesis2. At each step, follow the subtree with the most recent attestation3. Select block with most validator supportBitcoin: Longest Chain
Section titled βBitcoin: Longest Chainβ1. Count total work (cumulative difficulty)2. Follow chain with highest total work3. Orphaned blocks are discarded5.9 Interview Questions
Section titled β5.9 Interview Questionsβ| Question | Answer |
|---|---|
| What is the difference between PoW and PoS? | PoW uses computational work; PoS uses staked tokens |
| What is finality in blockchain? | The point at which a block cannot be reversed |
| What is slashing in PoS? | Penalty for validator misbehavior |
| What is 51% attack? | When attacker controls majority of hash/stake |
Summary
Section titled βSummaryβ- Consensus mechanisms ensure agreement on blockchain state
- PoW: Energy-intensive, secure (Bitcoin)
- PoS: Energy-efficient, randomized selection (Ethereum)
- DPoS: Fast, elected validators (EOS, Tron)
- PBFT/Tendermint: BFT consensus, fast finality (Cosmos)
- Node operators must understand consensus to manage validators
Next Chapter
Section titled βNext ChapterβIn Chapter 6: Ethereum Network & Ecosystem, weβll explore Ethereum in detail.
Last Updated: 2026-02-20