The Ignorant Protocol
One Raft crate, from a browser tab you can break to seven bare-metal boards

A real Raft, live in your browser: raft.umbertogotti.dev. Here is how it got there.
The protocol has no idea where it is running.
That is not a limitation. It is the entire point.
Prologue
Most distributed systems are born married to their deployment.
The consensus code reads the clock. It opens the socket. It decides when to fsync. It spawns the thread. Five years later, that marriage is the architecture: you cannot test the protocol without the network, you cannot move it without rewriting it, and you cannot prove it without deploying it.
This is about a Raft implementation that refused the marriage.
It has never read a clock. It has never opened a socket. It has never spawned a thread.
It runs in a single test thread, in a browser tab, in OS processes, in Kubernetes pods, in an emulated Cortex-M4, and on seven bare-metal boards on an Ethernet switch — two different chips, one Raft cluster.
The same protocol crate, everywhere.
What Is an Ignorant Protocol?
A function.
(context, event) -> actions
Events come in: a peer's message, a timer firing, a client's request. Actions come out: send this, persist that, arm this timer, answer that client. Everything else is pushed behind a trait:
| The protocol never touches | It asks an adapter instead |
|---|---|
| sockets | transport |
| disks, flash, databases | storage |
| clocks | timers it arms, events it is handed |
| randomness | an injected entropy source |
| HTTP, gRPC, a web page | the client interface |
| logs, metrics | an observer |
It never asks what time is it? It asks to be woken up later. It never asks how much memory is there? It counts entries; the deployment decides what an entry may cost. It never draws a random number; it is handed one, and on a microcontroller that number comes from the chip's hardware generator.
And it is held to that. Every change type-checks the protocol crates for a bare-metal Cortex-M target (thumbv7em-none-eabihf, no_std) before a single test runs. Grep them for tokio, quinn, wasm, embassy or stm32: zero hits. Grep them for Instant::now or SystemTime: zero hits.
Here, ignorance is enforced by the build.
The idea itself is old. It has a name, sans-IO, and a lineage: etcd's raft library has long been a pure state machine that leaves the network and storage to its caller, quinn-proto does the same for QUIC, and FoundationDB and TigerBeetle built their testing on deterministic simulation; TigerBeetle even runs its simulator in a browser. What this post adds is distance: one no_std crate with no deployment-specific code, across ten configurations, down to a cluster of two different chips with no operating system, and kept that way by the build.
Rung Zero: A Single Thread
The bottom of the ladder is one thread.
A cluster of fully wired Raft nodes lives in a Vec. A message is a value moved between queues. A timer fires when the test fires it, and not a microsecond before.
That sounds like a toy, but it is the most dangerous tier in the repository: when nothing is nondeterministic, everything can be made adversarial. Seeded schedules of losses, delays, reorderings, crashes, restarts, snapshots and membership changes, with Raft's safety properties checked after every single step of every node. 256 schedules on every commit, roughly 10,000 on every soak run, every failure printed with its seed and shrunk to the smallest schedule that still fails.
The literature's famous counter-examples run here as tests: Figure 8 of the Raft paper, Figures 4.6 and 4.7 of the dissertation, and the 2015 single-server membership bug with all three of its conditions — each shown failing the moment the rule that prevents it is removed.
The same thread keeps the protocol's costs honest. Under 11 load profiles, from an idle cluster to a snapshot install and a healed partition, a budget tool checks 987 memory, storage and network measurements on every commit. Each has a recorded limit, and a commit that goes over any of them fails unless it re-records the budget and explains why.
Rung One: The Laboratory
The protocol escaped the single thread — into a browser tab.
Same nodes, same protocol, compiled to WebAssembly, up to 32 of them in one page, inside a world built around them: every link with its own delay, jitter, loss, duplication and reordering; servers added and removed while the cluster runs; time from a thousandth of real time to four times it.
It is live: raft.umbertogotti.dev. No install, no sign-up. Three experiments, a minute each:
- Partition it. Press Start, wait for the cluster to elect a leader, then drag a line across the map. The network is cut in two. The side without a majority turns yellow — its servers stand for elections they can never win — while the majority elects a leader and carries on. Press Heal everything, and the stragglers rejoin without deposing anyone.
- Kill the leader. Right-click the leader (the red node) and choose Crash. Within an election timeout another server turns red. Restart the old leader: it comes back a follower and catches up.
- Watch it think. Press Pause, then step: Next delivery hands over one message, Next timer fires the next timeout. Every vote, heartbeat and append, one at a time.
Every run is seeded, and every random draw is an integer from that seed, so a run plays out the same way in the browser and natively. Export run, and it replays with a fingerprint check that says reproduced or tells you exactly where it diverged.
A bug report is not a paragraph. It is a file.
Rung Two: Processes
One OS process per node: its own address space, its own crash domain, its own durable storage (sled), its own wall-clock timers, real gRPC between them, and a real scheduler interleaving everything in ways no test author chose.
Changes to the protocol core to get there: 0. 296 process-level tests confirm it on every commit.
Rung Three: Kubernetes
Every node a pod. Pods find each other by DNS name and talk QUIC with mutual TLS, under a certificate authority minted for that one run. Storage is redb on a volume claim of its own, mounted again by a restarted pod. The whole cluster runs inside a KVM guest the test suite boots for the occasion: 81 scenarios.
Kubernetes has its own physics, and it showed them. A pod restarted at a new address was handed a message queued for the old one. A pod deleted with force kept running for half a second and accepted a write it was supposed to miss. A stale append reached a follower that had just installed a snapshot.
Two of those were the deployment's to absorb. The third was a genuine protocol bug.
The append had been sent before the follower crashed. It arrived after the restarted follower had caught up from a snapshot covering entries 1 to 3, and the follower re-added entries 1 and 2, which the snapshot already covered. Its log now claimed less than it had already committed: it reported a log ending at entry 2 with a commit index of 3.
Two invariants broke at once. A node's commit index can never pass the end of its own log: a node can only know an entry is committed if it holds that entry, in its log or in its snapshot. And a log must start right after its snapshot, so entries 1 and 2 should never have come back.
The bug was pinned where it is cheapest: a unit test in the protocol crate and a deterministic scenario on rung zero.
Reality finds the bug. The single thread keeps it found.
Rung Four: Bare Metal
Seven boards on an Ethernet switch, forming one Raft cluster: six STM32F767ZIs and an STM32H743ZI — a 216 MHz Cortex-M7 with 512 KB of RAM next to a 480 MHz Cortex-M7 with 1 MB. Clocks drifting against each other. No operating system at all.
The same protocol crate, compiled into firmware with Embassy, running as cooperative async tasks on a single core: one task for the node, others for the client interface, the network stack and the diagnostics.
How small is small?
- Seven complete Raft nodes fit on one board.
- Messages travel in 508-byte UDP payloads and are reassembled up to 2 KiB, so the deployment caps an append at ten entries — and the largest status message still fits a single datagram: 424 bytes of 508.
- Each board seeds its election timeouts from its own hardware random number generator.
- At boot, each board reports why it reset, whether it panicked on the way down, and how deep the previous run's stack went — the one measurement a wedged node cannot take for itself.
The hardware-in-the-loop validation flashes all seven, waits for them to discover each other, and drives the cluster from the host through the client interface alone — no third channel into the firmware. Over two hours it runs sixteen scenarios, from the first election to crash recovery of as many boards as the cluster can lose at once, the H743 among them.
Until this week it ran on five identical boards. Making the cluster heterogeneous took board support, probe wiring and a build per chip — and not a single line in the protocol crate.
It does not know it is on a microcontroller. It does not know the board next to it is a different chip.
It remains, gloriously, ignorant.
The Ladder, Itemised
| Deployment | Transport | Storage | Threading model |
|---|---|---|---|
| In-memory | in-memory queues, moved by the test | in-memory | one thread; invariants checked after every step |
| Seeded schedules & soak | in-memory, with seeded loss, delay and reordering | in-memory | one thread; 256 schedules per commit, ~10,000 per soak |
| Memory budget | in-memory | in-memory | one thread; 987 memory, storage and network measurements across 11 load profiles, checked against a budget on every commit |
| Browser | simulated network: per-link delay, jitter, loss, cuts | in-memory per node | single-threaded WebAssembly; up to 32 nodes in one tab |
| Process | gRPC, one stream per peer | sled | one OS process per node; a synchronous step loop beside Tokio runtimes for the network |
| Kubernetes | QUIC with mutual TLS | redb on a volume claim | one pod per node; a step-loop thread beside multi-threaded Tokio runtimes |
| Embassy, on the desktop | Embassy channels | in-memory | cooperative async tasks |
| QEMU (Cortex-M4) | Embassy channels, or UDP looped back | in-memory, flash, or semihosting | cooperative tasks on one core, no OS; seven nodes in one image |
| One board, seven nodes | Embassy channels, or UDP looped back | in-memory, flash, or semihosting | the same; seven node tasks on one chip |
| Seven-board cluster | UDP over Ethernet | flash | the same; one node task per board |
Ten configurations. Six transports. Five storage engines. Threading models from one thread, no clock to cooperative tasks on bare metal to multi-threaded runtimes inside pods inside a VM.
One protocol crate.
Next Up
- Rung Five: a Raspberry Pi Zero 2 W. Ten nodes on a single board.
- The same deal for IBFT and HotStuff. Two Byzantine fault-tolerant protocols, written as ignorant crates and taken up the same ladder.
Epilogue
Most systems still treat deployment as destiny. I think it is a detail — and the moment it becomes one, an absurd amount of optionality appears.
A new transport is an adapter. A new storage engine is an adapter. A new chip is an adapter. A new cloud is an adapter.
The protocol does not change. The world around it does.
That is the power of an ignorant protocol.
Break it yourself: raft.umbertogotti.dev. Find a bug, export the run, and email it to me. Here, a bug report is a file.
Find me here:
Comments
Post a Comment