SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
  • Consensus Algorithms
  • Paxos
  • Raft
  • Leader Election
  • ZooKeeper and etcd
  • Distributed Locks
  • Fencing Tokens
  • Gossip Protocol
  • CRDTs
  • Operational Transformation
  • Distributed Unique ID Generation (Snowflake, UUID)
  • Two Generals Problem
  • Byzantine Fault Tolerance (BFT)
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Distributed Systems/Coordination and Consensus

Byzantine Fault Tolerance (BFT)

Reaching agreement even when some machines lie. The idea behind PBFT and blockchains.

⏱ 13 min readAdvancedHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Byzantine Fault Tolerance (BFT) is the ability of a group of machines to agree on one answer even when some of them lie, send conflicting messages, or are controlled by an attacker.

  • To survive f liars you need at least 3f + 1 nodes (crash-only designs need 2f + 1).
  • Nodes exchange signed messages in several rounds and decide only when 2f + 1 match.
  • Two families: voting protocols like PBFT, and puzzle-based ones like Bitcoin's proof of work.

02Concept: What is it?

The Byzantine Generals Problem (Lamport, Shostak, Pease, 1982): several generals surround a city. They must all attack or all retreat. Some may be traitors who tell one general "attack" and another "retreat". The loyal generals must still agree on the same plan, and if the commander is loyal, they must follow the commander.

The key result: with 3 generals and 1 traitor it is impossible. A loyal general cannot tell whether the commander or the other lieutenant is lying. With 4 generals and 1 traitor it works, as long as the generals compare what they were told. The rule is n β‰₯ 3f + 1.

Why three is not enough
Case 1: commander lies
🎭Commandertells 2: attack, tells 3: retreat
πŸ–₯️Node 2 hears: attack, and 3 says retreat
Case 2: node 3 lies
πŸ›οΈCommanderhonestly says attack to both
πŸ–₯️Node 2 hears: attack, and 3 says retreat
Node 2 hears two conflicting stories and has no way to find who lies.

Node 2 sees exactly the same messages in both cases, so it cannot tell which case it is in. With a fourth node, there is a third voice that breaks the tie.

🧠The size rule in one line
You must be able to decide using only n βˆ’ f answers (f nodes may be silent), and still have a majority of honest ones among them even if f of those lie. That gives n βˆ’ f βˆ’ f > f, which means n > 3f.

03Real-Life Example

🍡Four Friends and One Fibber
Four friends decide where to eat. The rule is simple: after everyone shares what they heard, go with whatever three of you agree on. One friend, the fibber, tells you "pizza" and tells another friend "sushi". The three honest friends compare notes, notice the fibber said two different things, and still agree on what the honest ones were told. With only three friends, the same trick would leave you stuck.
Dinner story
BFT system
Four friends
n = 4 nodes
One fibber
f = 1 Byzantine node
Sharing what you heard
The prepare round of messages
Needing three to agree
A quorum of 2f + 1
Writing your promise in ink
Digital signatures
The friend who proposes the place
The primary (leader)
Replacing a fibbing organiser
A view change
The PBFT message rounds
πŸ“£Pre-prepareprimary proposes
→↓
🀝Prepareall share what they saw
→↓
βœ…Commit2f + 1 agree, then run it
Three rounds of talking, so no single liar can fool the honest nodes.

04Why Do We Need It?

πŸ”“Trust no single node
Even if one machine is hacked or buggy, the group still gives the right answer.
🀝Parties that do not trust each other
Banks, companies or strangers can share one record with no boss.
🧬Bugs and corruption
A bit flip or buggy release can make a node send plausible nonsense. BFT catches it.
πŸ›°οΈSafety-critical hardware
Flight and spacecraft computers vote so one failed unit cannot steer the vehicle.
⛓️Open networks
Public blockchains must assume some participants are attackers.
πŸ“œAuditable agreement
Signed votes make it clear who said what.
Crash tolerance covers honest accidents. BFT covers lying, hacking and arbitrary bugs, at a higher cost.

05Where Do We Use It?

⛓️Blockchains
Tendermint (Cosmos), HotStuff variants (Diem, Aptos) and others vote on each block.
🏦Permissioned ledgers
Hyperledger Fabric has used BFT ordering among known but distrusting organisations.
πŸ›©οΈAvionics
Airbus and Boeing flight computers cross-check redundant units.
πŸ”‘Key management
Some systems split a signing key across nodes that must agree to use it.
πŸ›οΈReplicated services research
PBFT and BFT-SMaRt replicate services that stay correct with liars.
πŸ’ΎIntegrity layers
Checksums and Merkle trees give a lightweight, partial form of Byzantine defence.

06Types / Parts / How It Works

PBFT in plain steps

StepWho sendsWhat happensWhy
RequestClient to primaryThe client sends a signed requestStart
Pre-preparePrimary to allPrimary picks a sequence number and sends the proposalOrder requests
PrepareEvery replica to allEach tells the others what it acceptedSpot a primary that sends different things to different nodes
CommitEvery replica to allAfter 2f + 1 matching prepares, each sends a commitMake sure enough honest nodes are ready
ReplyReplicas to clientRun the request, reply. The client waits for f + 1 equal repliesAt least one honest node agrees
View changeReplicasIf the primary looks faulty, elect a new oneDo not rely on one leader

Two families of BFT

FamilyExamplesHow agreement is reachedCost
Voting (classical BFT)PBFT, Tendermint, HotStuffKnown nodes vote in rounds, need 2f + 1 matchingMany messages, small groups (tens to hundreds)
Puzzle-based (Nakamoto)Bitcoin (proof of work)The chain with the most work wins. Lying costs real energySlow finality, huge energy use, open to anyone
Stake-basedEthereum, Cosmos (proof of stake)Voters lock coins that are lost if they cheatNeeds a stake and a mechanism to punish
✍️Signaturesa liar cannot forge another node's vote
πŸ”’n β‰₯ 3f + 1enough honest voices
πŸ—³οΈ2f + 1 quorumany two quorums share an honest node
Proof of who said what Size rule Overlap rule
VisualizerHow many liars can the group survive?Set the number of nodes and traitors. Try 3 nodes with 1 traitor, then 4 nodes with 1 traitor. Switch between a plain majority and the PBFT-style wait for 2f + 1 matching votes.
How do honest nodes decide?
The commander (node 0) honestly orders ATTACK. Every node then tells the others what it heard.
πŸ–₯️
Node 0 (commander)
honest
hears: 4 attack, 0 retreat
πŸ–₯️
Node 1
honest
hears: 3 attack, 1 retreat
πŸ–₯️
Node 2
honest
hears: 4 attack, 0 retreat
🎭
Node 3
lies
Need n β‰₯ 3f + 1
4
you have 4
Decide ATTACK
3
honest nodes
Decide RETREAT
0
honest nodes
Waiting
0
no quorum yet
All 3 honest nodes decide ATTACK, the commander's real order. With 4 nodes and 1 traitor(s) the rule n β‰₯ 3f + 1 holds (4 β‰₯ 4).

A simplified teaching model with a fixed lie pattern (no random numbers): traitors are the last f nodes, and they send RETREAT to odd-numbered honest nodes and ATTACK to the others. Real PBFT also uses signatures and three message rounds (pre-prepare, prepare, commit).

07How to Use It / Steps / Implementation

If you decide you need it

  1. 1
    First ask if you really need it
    If every node belongs to one trusted team, crash tolerance (Raft) is simpler and faster.
  2. 2
    Choose f
    How many liars must you survive at once?
  3. 3
    Run n β‰₯ 3f + 1 nodes
    One liar needs 4 nodes. Two need 7. Ten need 31.
  4. 4
    Sign everything
    Every message carries a signature, so a node cannot deny what it said or forge another's message.
  5. 5
    Use a proven library
    Pick Tendermint, BFT-SMaRt or a HotStuff implementation. Do not write your own.
  6. 6
    Diversify the nodes
    Different owners, software versions and locations, so one bug or one attacker does not hit all.
  7. 7
    Plan for view changes
    A faulty primary must be replaced quickly, and the replacement must be tested.
⚠️BFT does not protect against everyone colluding
If more than f nodes are bad, all promises are off. Spread control of nodes, so no single party can own a third of them.

08Key Terms to Know

TermMeaning in easy words
Byzantine faultA node behaves arbitrarily, including lying or contradicting itself
Byzantine Generals ProblemAgreement among generals when some may be traitors
BFTByzantine fault tolerance: staying correct despite Byzantine nodes
n β‰₯ 3f + 1The minimum number of nodes to survive f Byzantine nodes
Quorum (2f + 1)A group so large that two of them always share an honest node
PBFTPractical Byzantine Fault Tolerance (1999), a voting protocol with three rounds
PrimaryThe leader who proposes the next request in a round
View changeReplacing a primary that is slow or faulty
Digital signatureA proof that a message came from a given node and was not changed
Proof of workSolving a costly puzzle to earn the right to add a block
FinalityThe point after which a decision cannot be undone
Sybil attackOne attacker pretending to be many nodes

09Pros, Cons and Trade-offs

βœ… Pros
  • Survives liars, hackers and arbitrary bugs
  • Works without trusting any single node or owner
  • Signed votes give a clear audit trail
  • Classical BFT gives fast final decisions
  • Also covers every crash and slow-node case
⚠️ Cons
  • Needs 3f + 1 nodes, not 2f + 1
  • Many messages (often n squared per round)
  • Hard to scale beyond hundreds of nodes
  • Complex to implement and test
  • Useless if more than f nodes collude

Trade-offs

ChoiceWe gainWe lose
Crash-fault tolerant (Raft)Simple, fast, fewer nodesNo protection from lies
Voting BFT (PBFT)Quick finality, no miningSmall, known group and heavy messaging
Proof of workOpen to anyone, no member listSlow and energy hungry
Proof of stakeOpen and cheaper than workNeeds careful design against stake abuse
Checksums and signatures onlyCheap, catches small liesNot full agreement under attack

10Common Problems and Mistakes

Common mistakes

  1. Using BFT inside one trusted company. It adds cost and complexity for a risk you may not have.
  2. Running 3f nodes. Three nodes cannot tolerate one liar. You need 3f + 1.
  3. All nodes run the same software. A single bug becomes f + 1 "liars" at once.
  4. One owner controls many nodes. The count of nodes means nothing if one party can corrupt a third of them.
  5. Unsigned messages. Without signatures, a liar can claim others said things they did not.
  6. Mixing it up with Two Generals. That problem is about an unreliable link. This one is about lying nodes.

Things to watch

πŸ“ˆMessage growth
All-to-all rounds cost n squared messages. 100 nodes means about 10,000 per round.
πŸͺͺSybil attacks
In open networks, an attacker can create many identities. Work or stake makes this expensive.
πŸ”„Slow view changes
A faulty primary can slow everything down before it is replaced.
⏱️Timing assumptions
PBFT is safe always, but only makes progress when the network is reasonably timely.

11Real-World Examples

πŸ“„PBFT (Castro and Liskov, 1999)
Showed BFT could be fast enough for real services, starting the modern line of work.
β‚ΏBitcoin
Proof of work makes rewriting history cost more than it earns. Agreement is probabilistic.
🌌Tendermint and Cosmos
Voting BFT with a rotating proposer. Blocks are final once 2/3 of voting power signs.
πŸ”·Ethereum
Proof of stake with finality, where validators lose their stake if they sign conflicting blocks.
🏭Hyperledger Fabric
Supports BFT ordering for consortiums of companies.
✈️Avionics voting
Triple or quadruple redundant flight computers compare outputs on every cycle.
Mini case: a liar among four
πŸ“£Primary proposes X
→↓3 honest, 1 liar
🎭Liar says Y to somesigned, so provable
→↓honest nodes compare
βœ…3 matching votes for Xcommit X, ignore Y
The three honest nodes still reach 2f + 1 = 3 matching votes.

12Related Topics to Read Next

Failure Types: Crash vs Byzantine→

Where the Byzantine model sits among failure models.

Consensus Algorithms→

The wider family of agreement protocols.

Raft→

The crash-fault tolerant alternative.

Two Generals Problem→

The related problem about unreliable links, not liars.

Quorum (R + W > N)β†’

The overlap idea that BFT strengthens to 2f + 1.

Checksums→

A cheap defence against small lies from disks and networks.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”Goal: agree even when some nodes lie.
  • βœ”Size: n β‰₯ 3f + 1 (crash-only needs 2f + 1).
  • βœ”Quorum: 2f + 1 matching votes.
  • βœ”PBFT: pre-prepare, prepare, commit, plus view change.
  • βœ”Signatures: make every message provable.
  • βœ”Other route: proof of work or stake (Bitcoin, Ethereum).
  • βœ”Use when: parties do not trust each other. Otherwise use Raft.
  • βœ”One line: β€œTo outvote a liar, you need more honest voices than the liar can drown out.”
← Previous
Two Generals Problem
Next β†’
The Problem with Distributed Transactions