Foundations · Blockchain

Consensus

Consensus is the process by which the independent computers of a blockchain network agree on a single history of transactions without relying on a central authority.

  • Beginner
  • 5 min read
  • Updated

Why it matters

A blockchain has no head office to settle disputes. Thousands of computers each hold a copy of the ledger, hear about transactions at different moments, and may include some that are trying to cheat. Consensus is how they end up with the same record anyway. It is the part of the design that replaces a trusted record-keeper, and it determines how secure, how fast and how costly a network is.

The problem being solved

Suppose someone sends the same coin to two different people at nearly the same instant. Half the network hears about one payment first, half hears the other. Both are properly signed. Only one can count. This is the double-spend problem, and no node can solve it alone, because no node knows which message was “really” first.

The network needs a shared procedure that produces one answer everyone accepts. That procedure is the consensus mechanism.

In plain words

A group of friends is choosing a restaurant by text message, and messages arrive in a different order on each phone. They agree a rule in advance: one person, picked by lot each night, announces the choice, and everyone checks that the place is on the approved list. Nobody is the boss, but there is always exactly one decision.

How it works

From many copies to one history
  1. Transactions spreadEach node hears them at slightly different times.
  2. A proposer is chosenBy computation or by stake.
  3. A block is proposedOne ordering of the waiting transactions.
  4. Nodes verifyInvalid blocks are discarded.
  5. The chain extendsAll nodes follow the same rule for which chain counts.
The cycle repeats for every block.

Every consensus design has to settle two things.

Two questions every design must answer

WHO MAY PROPOSE?

Influence must cost something real.

  • Proof of work: computation and energy
  • Proof of stake: locked capital
  • Stops one actor posing as thousands

WHICH CHAIN COUNTS?

A rule for choosing between competing versions.

  • Most accumulated work, or
  • Most validator votes
  • Every node applies the same rule
Proof of work and proof of stake answer the first question. A fork-choice rule answers the second.

Who gets to propose the next block. If proposing were free, an attacker could create a million fake identities and dominate. So influence is tied to a resource that is costly to acquire. In proof of work the resource is computation. In proof of stake it is locked capital.

Proof of Work vs Proof of Stake

PROOF OF WORK

Miners spend energy to earn the right to add a block.

  • Security comes from computing power
  • Attack cost: hardware and electricity
  • Used by Bitcoin

PROOF OF STAKE

Validators lock up coins to earn the right to add a block.

  • Security comes from capital at stake
  • Attack cost: coins that can be slashed
  • Used by Ethereum since 2022
Both are ways for strangers to agree on one transaction history without a central authority.

Which chain counts when there is more than one. Occasionally two valid blocks appear at the same height, and the chain briefly splits into two versions. This is a fork. Each network has a fork-choice rule telling nodes which version to follow, such as the chain with the most accumulated work. The losing branch is abandoned, and its transactions return to the waiting pool to be included later.

When a node switches from one branch to another, the blocks it drops are said to be reorganised. Short reorganisations of one block are a normal part of some networks. Deep ones are rare and are a sign of trouble.

Going deeper

Honest-majority assumptions. No consensus mechanism is unconditionally secure. Each works as long as a sufficient share of the relevant resource is controlled by participants who follow the rules:

Design family Remains secure while
Longest-chain proof of work Attackers hold less than half of the computing power
Voting-based proof of stake Attackers hold less than one third of the stake, for guaranteed finality

What a majority attacker gains. An actor controlling most of the block-producing power can build a longer competing chain in private and release it, replacing recent blocks. That lets them reverse their own recent payments and spend those coins again, or keep chosen transactions out of the chain. This is commonly called a 51% attack.

What an attacker with majority power can and cannot do
AspectCanCannot
Own recent paymentsReverse them by building a competing chainSpend coins belonging to other keys
Other people's transactionsDelay or exclude themForge their signatures
The rulesFollow them selectivelyCreate coins beyond the issuance rules
Nodes reject invalid blocks whoever produces them. Majority power affects ordering and reversal, not validity.

Incentives. Block producers receive new coins and fees for blocks that the network accepts. Honest behaviour is the paid behaviour, and cheating risks wasted energy or forfeited stake. Consensus therefore rests on economics as well as on mathematics.

Trade-offs. Designs differ in how quickly a transaction becomes irreversible, how many participants can take part, and how much capacity the chain has. Improving one of these usually costs something on another. See finality and throughput.

A fork that resolves itselfHypothetical illustration

A hypothetical network has just reached block 500. Two producers, far apart, each find a valid block 501 within the same second. Call them 501-A and 501-B.

  • About half of the nodes hear of 501-A first and build on it. The rest build on 501-B.
  • A payment from Zoe to Sam happens to be in 501-A and not in 501-B.
  • The next block found is built on 501-B. That branch is now longer: 500, 501-B, 502.
  • Nodes that were following 501-A apply the fork-choice rule and switch. Block 501-A is dropped.
  • Zoe’s payment returns to the waiting pool and is included in block 503.

Nobody cheated and nothing was lost. Sam, however, saw the payment as “confirmed” for a few seconds before it briefly was not. This is why a single confirmation is treated as provisional.

What it does NOT mean

  • Consensus does not mean everyone voted. Nodes follow rules automatically. Most users take no part.
  • Consensus does not make information true. It establishes which transactions happened and in what order, not whether a claim about the outside world is correct.
  • A 51% attack does not let anyone take coins from arbitrary wallets. It affects ordering and recent history. Signatures still cannot be forged.
  • Decentralised consensus is not unconditional. It depends on an honest majority of work or stake.
  • A brief fork is not a failure. It is an expected event that the fork-choice rule resolves.

Common misunderstandings

  1. Calling proof of work or proof of stake “the consensus”. They decide who may propose. The fork-choice rule and validity checks complete the mechanism.
  2. Treating the first confirmation as final. Recent blocks can still be reorganised.
  3. Thinking a majority can do anything. Invalid blocks are rejected regardless of who made them.

Risks and limits

  • Small networks can be attacked at relatively low cost, and some have been.
  • Concentration among miners, validators or pools weakens the honest-majority assumption.
  • Software bugs can cause nodes to disagree and the chain to split.
  • Changes to the rules need broad coordination and can divide a community.

Key takeaway

Consensus is the shared procedure that turns many independent copies of a ledger into one agreed history. It ties influence to a costly resource and gives every node the same rule for choosing between competing chains.

Sources and further reading