Consensus Algorithm Simulator: Byzantine Fault Tolerance Visualized

simulator advanced ~12 min
Loading simulation...
Consensus in 3 rounds — 7 nodes, 2 Byzantine

With 7 nodes and 2 Byzantine faults (below the N/3 threshold), the network reaches consensus in 3 rounds of message exchange, tolerating any behavior from the faulty nodes.

Formula

N ≥ 3f + 1 (BFT threshold)
Message complexity: O(N²) per round
Rounds to consensus: f + 1 (synchronous)

The Agreement Problem

How do you get computers that do not trust each other to agree? This is the fundamental problem of distributed consensus, formalized as the Byzantine Generals Problem by Lamport, Shostak, and Pease in 1982. Some generals (nodes) may be traitors (Byzantine faults) sending contradictory messages. The loyal generals must still agree on a common plan of action — attack or retreat — despite the traitors' interference.

Classical BFT

The original proof showed that 3f+1 nodes are necessary and sufficient to tolerate f Byzantine faults. Practical BFT (pBFT), proposed by Castro and Liskov in 1999, made this feasible for real systems: nodes exchange messages in structured rounds (pre-prepare, prepare, commit), and each honest node waits for 2f+1 matching messages before accepting a value. This simulator visualizes these message exchanges as animated arcs between nodes.

Message Complexity

Classical BFT protocols require O(N squared) messages per round — every node must communicate with every other node. This limits scalability to tens or hundreds of nodes. Modern protocols like HotStuff reduce this to O(N) messages using a leader-based approach with threshold signatures, enabling BFT consensus at much larger scale. The trade-off is increased reliance on the leader, mitigated by view-change protocols.

Nakamoto vs Classical

Bitcoin took a radically different approach: instead of identifying and excluding faulty nodes through message exchange, Nakamoto consensus uses proof-of-work to make block creation costly and follows the longest chain. This achieves consensus among millions of anonymous nodes — something classical BFT cannot do — but provides only probabilistic finality. A transaction is considered final after several confirmations, each making reversal exponentially harder.

FAQ

What is a consensus algorithm?

A consensus algorithm enables a group of distributed nodes to agree on a single value or sequence of values, even when some nodes are faulty or malicious. It is the core mechanism that allows blockchains to maintain a consistent shared ledger without a central authority. Key properties are safety (all honest nodes agree) and liveness (the system eventually makes progress).

What is Byzantine fault tolerance?

Byzantine fault tolerance (BFT) means the system can reach correct consensus even when some nodes exhibit arbitrary (Byzantine) behavior — sending conflicting messages, lying, or going silent. The classic result by Lamport, Shostak, and Pease (1982) proves that BFT requires at least 3f+1 total nodes to tolerate f Byzantine faults.

How does Bitcoin achieve consensus?

Bitcoin uses Nakamoto consensus: nodes follow the longest valid chain (most cumulative proof-of-work). This provides probabilistic finality — the more confirmations a block receives, the harder it becomes to reverse. Unlike classical BFT, Nakamoto consensus works with any number of participants but sacrifices instant finality.

What is the FLP impossibility result?

Fischer, Lynch, and Paterson (1985) proved that no deterministic consensus algorithm can guarantee both safety and liveness in an asynchronous network with even one faulty process. Practical systems circumvent this by assuming partial synchrony (eventual message delivery within some bound) or using randomization.

Sources

Embed

<iframe src="https://homo-deus.com/lab/cryptocurrency/consensus-algorithm/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub