paros ~
GitHub →
Consensus

paros-consensus

Every Paxos role as a sans-IO state machine, in one Rust library. Plain Multi-Paxos, single decree, and every flavor of the Paxos pages.

I/O, clock, randomnessnone
Deployments4
Runnable examples11

What it is

paros-consensus holds the Paxos roles as plain state machines: proposer, acceptor, replica, matchmaker, proxy leader, batcher, leaderless reader. It does no I/O, it reads no clock and it draws no random number. It uses std only, and withdefault-features = false it has no dependency. Your program, the driver, owns the sockets, the disk and the timers. So the same code runs in a unit test, in a simulation, in this browser (compiled to wasm) and behind a real network.

It is a general library. You can use it for plain Multi-Paxos with a fixed membership, or for one single-decree choice, with no part of the paros journal. A deployment runs what itsConfig names: the quorum system, the matchmakers, the proxy leaders and the replicas. No cargo feature changes a decision. With no matchmakers, plain Multi-Paxos sends no matchmaker message and writes no extra state, and a reconfiguration is refused. What the paros journal needs comes from optional behaviour and composition, never from a service concept inside the core (architecture §4.3).

Each flavor, and where it is

Each row is a flavor that a Paxos page teaches, the type that builds it, and an example that runs it. Run an example withcargo run -p paros-consensus --example <name>: each prints a trace and asserts the property that it shows.

FlavorIn the cratePageExample
Single-decree Paxosdecree::DecreeSingle decreesingle_decree
Multi-PaxosColocatedNodeMulti-Paxosmulti_paxos, quickstart, journal_calls
Leader handoffColocatedNode::relinquish_toMulti-Paxosleader_handoff
Matchmaker PaxosMatchmaker, MatchmakerReconfigurerMatchmakermatchmaker, reconfiguration
Proxy leadersProxyLeaderCompartmentalizedproxy_leader
Batchersbatcher::Batcher, batcher::UnbatcherCompartmentalizednone yet
ReplicasReplicaNodeCompartmentalizedreplica_tier
Leaderless readsquorum_read::QuorumReadsCompartmentalizedquorum_read
Grid quorumsmembership::QuorumSystemQuorumsacceptor_grid

Three layers

The crate has three layers, and each layer uses only the layers below it. A role never uses a deployment, and a deployment never uses another deployment. CI checks this withscripts/check-core-layers.sh.

A role knows only what the caller gives it. The proposer builds no message, the acceptor never reads the chosen prefix, and the replica never sees a ballot tally. Each quorum question goes through membership (has_phase1_quorum,has_phase2_quorum), so a new quorum system is a new QuorumSystemvariant and no tally changes.

The log is a journal

The log of ColocatedNode carries a journal: a Write appends records at a position, SetLeader names the client that may write, and Truncate drops a prefix. The core judges no command at propose. Each node judges a command when its slot is applied, in slot order, so each node gives the same Outcome. A write on a journal with no writer is chosen by Paxos and refused by the journal.

The pages

  1. The driver loopInput in, one Ready out: persist, then send, then learn. Be the driver of three nodes.
  2. The deploymentsThe colocated node, the proxy leader, the replica and the matchmaker: what each runs, and when to use it.
  3. How it is checkedA TLA+ model for each flavor, each walk checked against its model, faults on, every probe reached, mutants caught.

In paros

  • crates/lib/paros-consensus/README.md: the entry point, with the driver loop and the examples.
  • src/lib.rs: the crate root. Its quick start is a doc test with three nodes.
  • AGENTS.md: the map of the modules and the rules for a change.
  • examples/: seven examples that drive the deployments, and four lessons that drive the roles by hand.