Chapter 09 · ~16 min
How we know it works
Six rungs from a smoke test to the chaos rig — and why consensus ships test-first.
What you’ll walk away with
- Why consensus must be test-first: the ladder of who can fix it ends with “nobody, quickly”
- The layer model: six rungs, each with a focus and a deliberate blind spot — and the rule that keeps a case at the lowest rung that can express it
- Why determinism (chapter 6’s trick) is what makes the exhaustive layers affordable
- The chaos rig, properly: a fuzzer for operational reality — it discovers, it never gates, and every finding gets pinned below
The ladder of who can fix it
Think about what a serious bug costs, in three worlds.
World one: the single sequencer. You ship a bug and the chain halts. That’s sad — users notice, a postmortem is owed — but the fix is a hotfix: one binary, one machine, one operator, minutes. You own the box.
World two: you run a fleet of external nodes. The bug crash-loops all of them. Sadder — more machines, more angry dashboards — but they’re still your machines. Your deploy pipeline, your ssh keys, your rollback. An expensive evening.
World three: a committee. N validators, run by independent operators — different companies, different time zones, different change-management processes. A bug halts the chain, and now the “hotfix” is a coordinated, multi-organization deployment, negotiated over a bridge call, while the chain is down and every user watches. There is no ssh that works everywhere. Nobody can fix it alone — that was the point of the committee, remember: no single party can change what the chain does. The property you bought for safety prices your incident response.
When the deployment is decentralized, the fix path is the slow path — so the only acceptable time to find a consensus bug is before it ships.
That’s the sentence this chapter stands on, and it explains a discipline you’ll see enforced rather than aspired to: consensus code without a test demonstrating it is not reviewable here. The harness isn’t quality assurance after the fact; it’s part of the feature. What follows is how that discipline is organized — not a tour of every test, but the shape: what each layer is for, what it deliberately ignores, and why so many layers earn their keep for this one subsystem.
One rule, six rungs
Every layer below answers one question: what class of bug is this the cheapest place to catch? Each rung sees more of reality than the one below it — and pays for that sight in speed, precision, and reproducibility. Which is why one sorting rule governs the whole ladder:
If a case can be expressed at a lower layer, it must be. An integration test that could have been a simulation scenario is a review finding — not because integration tests are bad, but because the lower rung runs it faster, replays it exactly, and never flakes.
Click through the ladder. For each rung, read the “deliberately cannot see” line — then look one rung up: every blind spot is the next layer’s job.
The floor, and the cheap seats
The bottom rung answers an embarrassingly basic question that deserves a permanent answer: does the library even turn? The smoke test wires commonware’s raw simplex engine — no marshal, no blocks, no node, payloads that are just hashes — and proves four things: the pinned version runs in this workspace at all; the engine can be wired end-to-end (scheme, elector, channels, journals, the integration traits); five validators finalize with no forks and no evidence; and the deterministic runtime is bit-exact per seed. When a monthly library upgrade lands, this is the first thing that either turns or doesn’t.
One rung up, plain unit tests hold the pure logic: validity-rule tables, the startup-guard matrices, overlay bookkeeping — and the golden fixtures, which deserve a special mention because they invert your intuition about severity. “Certificate bytes changed after an upgrade” sounds like a five-alarm incident; the goldens make it a forty-line test failing on the first pull request, before anything runs. The cheapest rung catches some of the scariest bugs. Severity and layer are different axes.
The main surface: committees in a bottle
Here the pyramid inverts from the usual shape: the primary testing surface for consensus is not unit tests and not integration tests — it’s deterministic simulation: entire committees of the production stack (real engine, real marshal, real journals, real backfill) over the seeded runtime and a scripted network. You already hold the key idea from chapter 6 — same code, two universes, twin fingerprints — so just add scale: a corpus of scenarios organized by capability (steady state, crashes and restarts, partitions, byzantine peers of both flavors, late joiners, migrations, epoch changes), each run across seeds, each seed run twice with audit fingerprints compared, so nondeterminism fails loudly instead of becoming a flaky test.
Three properties make this rung the workhorse:
- Edge cases are modeled, not awaited. A crash between a vote and its broadcast, a partition healing one message too late — injected at exact virtual-time points. Nothing sleeps and hopes.
- State, not just blocks. The real VM runs in simulation over in-memory state, so scenarios assert that every validator’s state is identical — semantic divergence is a simulation-reachable bug, not a staging surprise.
- A red seed is a gift. A failure prints its scenario and seed; rerunning replays it exactly, message for message. There is no “flaky, retried, green” lane. Pull requests run each scenario’s own seed set; a nightly job sweeps the corpus at depth.
Real boxes: the wiring layer
Simulation deliberately cannot see sockets, disks, processes, or configuration — so one rung up, the integration suite boots real nodes: RocksDB, real consensus networking, a local L1. Its territory is wiring truths: does it boot, does configuration parse and migrate, does a restart over real storage recover, do the RPC surfaces serve, does settlement settle — and the drills: chain migration, committee changes, settlement failover. Its discipline is telling: assertions use generous poll-until bounds, never timing-tuned sleeps (timing-sensitive integration tests are flaky by construction), and it refuses to test byzantine behavior or partitions — those are expressible below, so the rule sends them below.
The chaos rig: a fuzzer for operational reality
Everything so far shares one quiet limitation: it tests the failure space someone modeled. Deterministic simulation is exhaustive about the interleavings you thought to script; integration checks the wiring you knew to check. The last rung exists for the rest of it. The chaos rig is best understood as a fuzzer whose input space is operational reality: a containerized committee built from the production image, a seeded schedule of faults — kill, graceful stop, freeze, partition, packet loss and delay — running for hours or days of real wall-clock time, under real transaction load funded through real L1 deposits.
Random abuse alone would be noise. Two design choices make it an instrument:
- The driver journals what it broke — before breaking it. Every fault is preceded by a journal entry stating the expected consequence, including the deliberate quorum outages (“liveness expected: no”). The rig never takes the committee below quorum by accident; it takes it there on the record.
- The watcher checks reality against the journal, continuously. Identical hashes across validators, finality and height monotonicity, progress exactly when the journal says to expect it, zero byzantine evidence, every process death accounted for, and a log oracle for novel errors. The journal is what makes “the driver took quorum away” distinguishable from “the chain stalled unexplained” — without it, every injected outage would look like a finding.
And two ground rules define its place in the ladder. Telescope, not gate: the rig never runs in CI, because its findings are probabilistic and its runs are hours long — it’s pointed at the system by a human, like an instrument. And a finding freezes the scene: on the first violated expectation the rig stops healing, captures the journal, the findings, and every container’s logs, and exits nonzero — because a healed-away anomaly is an anomaly you can’t study. What it reliably catches is exactly what no other rung can see: teardown races that need thousands of genuine process deaths to fire, rate-and-drift interactions that need real elapsed time to accumulate, recovery paths that only exist once a chain has actually aged, leaks. Each finding is then reproduced, understood, and pinned as a deterministic regression at the lowest layer that can express it. The rig discovers; the lower rungs pin; tomorrow’s corpus is smarter. (Even the library-upgrade procedure ends with a soak — the one rung that catches what a changed runtime does to timing and teardown, which is precisely the shape of change a runtime release carries.)
Step through one soak below — the committee strip, the driver’s journal, and the watcher’s verdicts. Missions:
- Step the clean run end to end. At the sanctioned outage, read the watcher’s verdict carefully: no progress, and no finding — because the journal said so.
- Now press the villain button and rerun. Same schedule — but this time a validator dies with no journal entry covering it. Watch what changes, and watch what the rig does next: nothing heals anymore. The scene is evidence.
- Read the last narration twice: the finding’s afterlife is a deterministic regression at a lower rung. The rig’s output is not green dashboards — it’s better lower rungs.
Your turn: file it at the right layer
You now know the ladder well enough to use it the way reviewers here use it: as a sorting question. Six bug shapes below — for each, commit to the lowest rung that can catch it before you reveal the answer. Missions:
- Sort all six. Two will land at unit — notice how scary one of them sounds.
- For both chaos bugs, read the “pinned at” line: the rig never keeps its own catches.
- Whichever you misfile, ask why you over- or under-shot: too high usually means “I forgot the lower rung could model that”; too low usually means “I forgot what that rung deliberately cannot see”.
The four things to keep
- Decentralization prices your incident response: with N independent operators, the fix path is a negotiation — so consensus bugs must be found before they ship, and the harness is part of the feature.
- Six rungs, one rule: every case lives at the lowest layer that can express it; each rung’s deliberate blind spot is the next rung’s job.
- The primary surface is deterministic simulation — whole committees, modeled edge cases, twin-run fingerprints, red seeds as perfect reproducers.
- The chaos rig is a fuzzer for the space nobody modeled: expectation-journaled faults, a watcher that knows injected from real, findings that freeze the scene — and every catch pinned as a deterministic test below. Telescope, not gate.
Where this lives in our stack
- The strategy in the maintainers’ own words — the five enforced principles, the layer table, the rig’s contract — is docs/src/consensus/testing.md. This chapter is its intuition layer; that page is the reference.
- The rungs, bottom to top: lib/consensus/core/tests/simplex_smoke.rs (its module doc lists exactly the four things it proves); lib/wire/tests/ (the goldens); lib/consensus/sim/ with the scenario corpus in its tests/ directory — each file’s header explains what its group pins; integration-tests/src/multi_node.rs (the real-committee harness); and tools/chaos/, whose README.md opens with the ground rules you just stepped through.
- The nightly depth sweep is .github/workflows/nightly-consensus.yml — the same corpus, many more seeds.
Next: the last chapter has no widgets — it has a terminal. You’ll bring up a real committee on your machine, kill validators, break quorum on purpose — and point the very rig you just met at a chain you built, expecting (and getting) zero findings. Everything this guide taught you, held to receipts.