This repository contains a distributed simulation of the Tendermint consensus algorithm. The system executes in a fully containerized environment, simulating the state machine transitions of an arbitrary, highly-scalable number of validator nodes communicating over a sparse gossip network. The network topology and scale can be easily customized via the provided Python generator.
-
Consensus Engine (Rust)
- Implements the core Tendermint state machine (
Propose,Prevote,Precommit). - Utilizes
tokiofor asynchronous I/O and non-blocking TCP socket management. - Nodes communicate via a connected sparse gossip graph to minimize socket overhead while maintaining logarithmic network propagation.
- Implements the core Tendermint state machine (
-
Telemetry Aggregator (Python)
- Acts as an Out-of-Band (OOB) monitoring service.
- Receives non-blocking UDP telemetry packets from the consensus nodes.
- Aggregates node state transitions and broadcasts them to clients via WebSockets.
-
Presentation Layer (HTML/JS/CSS)
- A real-time, browser-based dashboard.
- Visually maps the state of up to 56-node cluster, providing immediate feedback on quorum progression and Byzantine fault disruptions.
-
Byzantine Fault Injection: Supports simulating malicious actors (e.g.,
DoubleVote,Silent,SendInvalid) to observe the robust$2f+1$ quorum resilience. -
Artificial Network Latency: Integrates Linux Traffic Control (
tcviaiproute2) to inject artificial packet delay directly at the container's ethernet interface, making it easy to observe consensus dynamics under slow-network conditions. - Dependency Isolation: Everything is inside docker.
- Docker Engine
- Docker Compose (v2 with
buildxis highly recommended) - Python (required only for generating the initial topology)
Prior to deployment, generate the network topology and configuration manifests:
python generate_compose.pyCustomization Options: You can manually edit the Python script to test different scenarios. The following configurations are natively supported:
num_nodes: The total number of nodes in the cluster (e.g.,50).latency_ms: Artificial network delay per hop in milliseconds (e.g.,500).behaviour: The string determining a node's Byzantine fault logic. Supported values are:"standard": Honest node execution."double-vote": Maliciously casts an extra vote for an invalid block to disrupt quorum."silent": Simulates a crashed node by ignoring all incoming packets and refusing to broadcast."send-invalid": Maliciously acts as a proposer for invalid block payloads.
rust_log:debugfor logs for every event/message,infofor only state transitions,round starts, etc.
Build the master container image and initialize the cluster. The Rust compiler executes within a multi-stage Dockerfile. To prevent your system from attempting to compile Rust for all nodes simultaneously, explicitly build the image for the first node (the rest will automatically clone it):
docker compose build node0
docker compose up -dOnce the containers are actively computing consensus, the telemetry server will automatically begin bridging UDP packets. Open a web browser and navigate to the local presentation layer:
To safely terminate the simulation and prune the associated virtual bridge networks from the host:
docker compose downWhile the current implementation successfully demonstrates
- Crash Recovery & State Syncing: Allowing a node that crashes to securely request and rebuild the consensus history from its peers upon rebooting.
- Dynamic Validator Sets: Implementing the ability to securely add or remove nodes from the active consensus pool while the network is running, without halting block production.
- Cryptographic Signatures: Implementing Ed25519 public-key cryptography to cryptographically sign and verify every proposal and vote, preventing malicious nodes from spoofing messages on behalf of honest peers.