Consensus protocols coordinate a group of replicas so they agree on an ordered log of commands despite process crashes or network faults. They rely on quorums, stable storage, and deterministic state machines to keep every node in step with the decisions made by the group. Safety ensures the chosen log never forks, while liveness guarantees progress when a quorum of replicas can communicate.
Viewstamped Replication follows a primary/backup model that advances through numbered views. Within a view, a leader assigns log slots to client operations and gathers acknowledgements from a quorum before committing the result. When the leader fails or communication stalls, replicas initiate a view change to nominate a new leader while preserving the already committed prefix. The protocol balances leader-driven ordering with rapid recovery so clients continue to observe a single coherent history.
This repository contains an experimental, async Rust implementation of Viewstamped Replication along with a deterministic network, storage, and state-machine simulator. The goal is to create a Rust-idiomatic port of the original TigerBeetle reference implementation (tigerbeetle/viewstamped-replication-made-famous). The codebase is under active development and may diverge from the paper or the TigerBeetle version while functionality is still being validated.
src/replica.rs: replica logic, leader election, log management, and timeout handling.src/sim: in-memory simulation of clients, network conditions, storage latency, and protocol invariants.src/main.rs: entry point that drives a multi-replica simulation and validates convergence.
The protocol details and simulator behaviour are still evolving. This implementation should be considered work in progress and might not be 100% faithful to the original Viewstamped Replication paper or the TigerBeetle code yet.
- Rust toolchain with the
cargoCLI andrustupcomponents (tested with stable toolchain supporting edition 2024).
cargo buildcargo clippy --all-targets --all-features -- -D warningscargo testcargo run --release -- <optional-seed>If no seed is supplied, a random one is chosen. The simulation prints the seed so test runs can be reproduced.