Consensus and the Byzantine generals problem
Consensus in distributed systems: the Byzantine Generals Problem, impossibility and bounds (n ≥ 3m+1) for oral messages, how authentication and practical protocols (PBFT) change requirements, and worked traces showing OM and PBFT steps.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Consensus is the problem of getting multiple independent computers (nodes) to agree on a single value even when some behave badly. Engineers designing blockchain protocols, permissioned ledgers (e.g. Hyperledger Fabric), and replicated state machines use Byzantine fault-tolerant (BFT) consensus results to choose the right protocol, set the required number of nodes, and understand the security limits under attacker or faulty-node scenarios.
Key ideas
Start from first principles: a distributed system has multiple processes (nodes) communicating by message passing. We must define the main terms before using them.
Process (node): an independent computation unit that sends and receives messages.
Message passing: nodes communicate by sending discrete messages over links (no shared memory).
Fault: any deviation from the specified behavior (including crash, omission, timing, or arbitrary behaviour).
Byzantine fault: a fault where a node can behave arbitrarily, including lying, colluding, sending different messages to different nodes. Often caused by bugs or malicious attackers.
Byzantine Generals Problem (BGP) (formal definition): there are n processes (generals). One designated process is the commander and the others are lieutenants. The commander sends an order (value) to the lieutenants. Some processes (at most m) may be Byzantine. The protocol must satisfy three properties:
- Agreement: All non-faulty lieutenants must agree on the same value.
- Validity (or Consistency with honest commander): If the commander is non-faulty, then all non-faulty lieutenants agree on the commander’s value.
- Termination (Liveness): All non-faulty lieutenants eventually decide on some value. These properties must hold despite up to m Byzantine processes.
Oral messages model: no digital signatures (no unforgeable authentication). Messages are delivered correctly and the receiver knows the immediate sender, but Byzantine nodes can equivocate (send different contents to different receivers) and lie about what others said.
Signed (authenticated) messages model: each message carries an unforgeable signature proving sender identity; a Byzantine node cannot forge another node's signature.
Byzantine Agreement: a general term for any protocol meeting Agreement, Validity, and Termination above.
Important theorem (Lamport, Shostak, Pease 1982), stated exactly as typically used in exams:
- In the oral messages model (no authentication), Byzantine Agreement is solvable if and only if n ≥ 3m + 1, where n is total number of processes and m is maximum number of Byzantine processes.
- Assumptions: synchronous reliable channels (messages delivered within known bound), deterministic algorithms, at most m Byzantine nodes, no signatures (oral messages). The proof is constructive (recursive OM(k) algorithm) and requires induction on k = m.
Sketch of why n ≥ 3m + 1 is necessary (informal derivation asked in exams):
- If n ≤ 3m, split nodes into three groups of size ≤ m. A malicious arrangement can make two groups see different consistent worlds and cause disagreement among honest nodes. Formal proof uses indistinguishability argument: two honest nodes cannot distinguish two different configurations and therefore might output different values, violating Agreement.
With signed (authenticated) messages, Lamport et al. show that Byzantine Agreement becomes easier: signatures prevent undetectable impersonation and let correct nodes verify the origin of values. As a result, consensus (interactive consistency) is solvable for any number of Byzantine nodes m < n under the authenticated model (provided signatures cannot be forged and the system is synchronous).
Additional fundamental impossibility: the FLP impossibility result (Fischer, Lynch, Paterson 1985): In a fully asynchronous system (no known upper bound on message delay) with even one unreliable process that may crash, no deterministic algorithm can guarantee consensus. This tells us why many practical BFT protocols rely on partial synchrony assumptions or randomness.
Practical protocols and their assumptions:
- Practical Byzantine Fault Tolerance (PBFT): a replicated state machine protocol for asynchronous networks with eventual synchrony assumptions. PBFT tolerates f Byzantine faults when n ≥ 3f + 1. It uses three phases (pre-prepare, prepare, commit), a primary (leader), and view-change to handle faulty leaders. Safety is guaranteed as long as at most f nodes are faulty; liveness requires eventual synchrony.
What to draw for common exam diagrams:
- For the BGP impossibility sketch: draw three groups A, B, C with ≤ m nodes each, arrows showing messages among groups; label possible conflicting orders and show how indistinguishable states for honest nodes cause disagreement.
- For PBFT message flow: draw four nodes (n = 4, f = 1) and show primary sending pre-prepare to all, then each node sending prepare to all, and then commit to all. Label counts needed to advance (2f+1 prepares to commit, etc.).
Formulas
n ≥ 3m + 1
- n: total number of nodes (no units). m: maximum number of Byzantine faulty nodes (no units). Applies to oral (unauthenticated) messages model: to tolerate m Byzantine faults, need at least 3m+1 nodes.
n ≥ 3f + 1
- n: total nodes. f: maximum number of Byzantine faulty nodes. Same interpretation; used in PBFT literature where f denotes faults.
2f + 1
- the number of matching Prepare/Commit messages (including yourself) required to ensure safety in PBFT before delivering a request. f: maximum faulty nodes.
(Notes: these are inequalities/counts—no SI units apply.)
Worked examples
Example 1 — OM(1) trace (oral messages) with n = 4, m = 1 (one traitor). Problem: Commander is node C, lieutenants L1, L2, L3. Commander sends an order (Attack or Retreat). Show OM(1) works and leads to Agreement and Validity. Steps:
- OM(0): a lieutenant uses the commander's direct message. OM(0) algorithm: each lieutenant uses the value received from commander (if none, default Retreat).
- OM(1) (recursive): Commander sends value v to all lieutenants. Then each lieutenant acts as commander and sends the value it got to the other lieutenants. After receiving these values, each lieutenant applies majority among the set {value from commander, values from other lieutenants}. Trace with concrete values: suppose commander C (honest) sends Attack to all.
- Round 1: C->L1: Attack, C->L2: Attack, C->L3: Attack.
- Round 2: Each Li forwards the value it received:
- L1 sends Attack to L2 and L3.
- L2 sends Attack to L1 and L3.
- L3 sends Attack to L1 and L2.
- Each lieutenant sees three Attack values → majority is Attack → All honest lieutenants decide Attack. Validity holds. If commander is traitor and sends Attack to L1 and Retreat to L2 and L3, the lieutenants forward what they see; a majority decision among the three values at each honest lieutenant leads to Agreement (since with m =1 and n =4 the majority rule yields same output). Final answer: Agreement and Validity hold for n = 4, m = 1.
Example 2 — PBFT trace with n = 4, f = 1 (commit path for a request). Problem: Show message counts and phases needed to commit. Steps (simplified):
- Client sends request to primary P.
- Pre-prepare: P multicasts Pre-Prepare(seq, request) to all replicas.
- Prepare: On receiving valid Pre-Prepare, replica R multicasts Prepare(seq, digest(request)). Each correct replica must collect 2f + 1 = 3 Prepare messages (including its own) with same digest and sequence number to move to commit stage.
- Commit: After 2f + 1 Prepares are seen, replica multicasts Commit(digest). Each correct replica that collects 2f + 1 Commits can safely execute the request and reply to client. The client waits for f + 1 matching replies to consider the operation complete. Counts: with n = 4 and f = 1, 2f + 1 = 3; thus any two quorums of size 3 intersect in at least one honest replica, ensuring safety. Final: The request is executed only when each honest replica has seen enough matching messages (3) — this prevents a minority of faulty nodes from making honest nodes diverge.
Common mistakes
- Quoting the 3m+1 bound but forgetting its model assumptions (oral messages, synchrony). Always state model assumptions.
- Saying FLP applies directly to synchronous systems or to Byzantine faults without qualification. FLP is about deterministic consensus in fully asynchronous systems with crash faults; use it carefully.
- Misstating the authenticated (signed) messages bound: some answers wrongly claim the same 3m+1 bound applies with signatures — it does not; authentication reduces requirements.
- Forgetting to describe what to draw for diagram-based questions (e.g., group split for the impossibility proof).
For your exam
Kinds of questions:
- Definitions: Define Byzantine fault, consensus, agreement, validity, oral vs signed message models.
- Short notes: State the 3m+1 theorem and explain assumptions; explain FLP; describe PBFT phases.
- Derivations/proofs: Prove necessity of n ≥ 3m + 1 in oral messages model (indistinguishability argument) or give the inductive construction of OM(k).
- Numericals/traces: Trace OM(1) or OM(2) for small n and m, or PBFT message counts for given f and n.
- Diagrams: Draw group splitting for impossibility proofs or message flow for PBFT. What a full-marks answer includes:
- Clear statement of the model and assumptions (synchrony, authentication, max faults m/f).
- Exact theorem/formula (e.g., n ≥ 3m+1) and a short proof or sketch (indistinguishability or recursive OM(k) outline).
- Correct diagram when required, and a clear trace/example showing message contents and final outputs.
Quick check
- State the necessary and sufficient condition (oral messages) to tolerate m Byzantine nodes.
- What does FLP impossibility say in one sentence (which model)?
- In PBFT with f faulty nodes, how many replicas (n) are required and how many matching Prepare messages are needed to commit? Answers: 1) n ≥ 3m + 1. 2) FLP: In a fully asynchronous system, no deterministic algorithm can guarantee consensus if even one process may crash. 3) n ≥ 3f + 1 and 2f + 1 matching Prepare/Commit messages are required to proceed.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?