Seven consensus algorithms, one protocol, and a simulator that makes the hard failures cheap to test.
Urd implements Tendermint, Raft, Narwhal-Bullshark, Nakamoto, Snowman, SCP and
a round-robin reference as pure state machines behind a single protocol.
A node is (step state input) -> {:state _ :effects _}: no clock, no I/O, no
randomness. Everything a node wants done is a value, and something else does
it — which is why the same algorithm runs unchanged under a deterministic
simulator and under a real runtime with sockets and disks.
In Norse myth Urðr is the Norn of what has become, and Urðarbrunnr the well where the gods hold council. Consensus is the same question: what has become, and who agrees.
Portable Clojure and ClojureScript. Part of the replikativ stack.
Urd is experimental. The JVM, Node and real-network suites exercise the implementations, and the proof suite checks the signing order and quorum arithmetic. Each algorithm has its own deployment assumptions.
:id must verify that the ID binds the entire payload, including
any validator updates. Build a proposal with
(assoc payload :id (tm/content-id payload)) and configure every validator
with :valid-fn (every-pred tm/valid-content-id? application-valid?),
where tm names urd.consensus.algorithms.tendermint.Cryptography is real. urd.consensus.auth is Ed25519 over canonical CBOR and
the runtime verifies every inbound message; :auth is a required argument, and
opting out means typing :none. The toy attestation schemes in each algorithm
are labelled NOT CRYPTOGRAPHY in capitals, and urd.consensus.attest is the
real one.
org.replikativ/urd {:mvn/version "0.1.19"}
Four Tendermint nodes, in a deterministic simulator. No network, no store, no keys.
(require '[urd.consensus.sim :as sim]
'[urd.consensus.algorithms.tendermint :as tm])
(def peers [:a :b :c :d])
(defn cluster []
(sim/make {:seed 7
:nodes (zipmap peers (repeat (tm/make)))
:config {:value-fn (fn [_sim peer ctx]
{:id [:block peer (:height ctx)]})}}))
(def s (sim/run (cluster) 200))
(count (sim/committed s :a)) ;; => 21
(first (sim/committed s :a)) ;; => {:id [:block :a 0]}
(sim/agreement? s) ;; => true
sim/make needs only :nodes — it derives the validator set from the node
keys. :value-fn answers the :request-value effect; without one, every node
is handed {:payload :none}.
Now break it. A minority partition, then a crash and restart:
(-> (cluster) (sim/run 40)
(sim/partition-network [#{:a :b :c} #{:d}]) (sim/run 60)
sim/heal (sim/run 60)
sim/agreement?) ;; => true
(-> (cluster) (sim/run 40)
(sim/crash :b) (sim/run 40)
(sim/restart :b) (sim/run 80)
sim/agreement?) ;; => true
Every block above is executed by
test/urd/readme_test.clj on every run. This
README used to open with six calls to functions that had been deleted months
earlier; prose about code drifts silently, and a test does not.
One trap worth knowing. With round-robin, the value must carry
:snapshot-id— that is what identifies a proposal. A value without one has a nil id, every guard declines, and the cluster commits nothing, with no error and no log line. Tendermint has no such requirement. This is pinned by a test.
| faults | quorum | durable | set changes | maturity | |
|---|---|---|---|---|---|
| tendermint | Byzantine | 2f+1 by voting power | yes | yes, at height+1 | deployment candidate |
| raft | crash | majority, head count | yes | yes, joint consensus | deployment candidate (CFT) |
| round-robin | crash | majority, head count | yes | yes, next height | reference |
| bullshark | Byzantine | 2f+1 by stake | yes | refuses, loudly | reference-grade |
| scp | Byzantine, federated | quorum slices | yes | n/a | reference-grade |
| snowman | Byzantine, probabilistic | weighted sampling (k/α/β) | accepted chain | no | protocol stress test |
| nakamoto | open membership | cumulative work | yes | n/a | generality test |
snowtree and snowflake are not algorithms in this sense — they are the
Snowball trie and the Slush/Snowflake/Snowball primitives that Snowman uses.
Full detail, including each implementation's deliberate divergences from its reference, is in doc/algorithms.md.
step, effects,
the durability barrier, capability declarationsAPI documentation is on cljdoc.
clj -M:test # JVM unit and property tests
clj -M:integration # real sockets, real handshakes
clj -M:cljs-test && node target/cljs-test.js # portable tests under Node
clj -M:storage-sim # konserve's crash simulator
clj -M:proofs # theorems and implementation correspondence
bin/test-all # all of the above, sequentially
:integration is excluded from the default run on purpose: those tests stand
up real WebSocket servers and their outcome depends on machine load. A suite
whose result varies run to run cannot tell you whether a change was safe.
Effects are values. A node returns what it wants done; an interpreter does it. This is what makes two interpreters possible, and the second one is not a luxury — it found three bugs the simulator structurally could not, because the simulator has no wall clock, no core.async, and no orphaned timers.
Capabilities are declared and enforced. A node states which effects it emits and which topics it uses, and both interpreters refuse anything else. A typo cannot silently narrow what a node is allowed to do.
Refusing is a choice you have to make. :auth has no default. A node that
cannot verify its peers should refuse to start, not start and trust them.
Some things are proved, not tested. The double-sign guard and quorum
intersection are machine-checked in
ansatz — five theorems over Nat —
and clj -M:proofs re-checks them along with a differential test that the
shipped copies still match the verified definitions. Ansatz is not a runtime
dependency: it erases proofs and emits ordinary Clojure.
Every divergence is documented where it lives. Where this code departs from CometBFT, etcd-raft, narwhal or stellar-core, the docstring says so and says why — usually with the file and line of the reference it was read against, and sometimes with the measured failure that prompted it.
datahike · konserve · kabel · geheimnis · boring · skuld — a ledger built on urd
Tendermint: The latest gossip on BFT consensus · Raft: In Search of an Understandable Consensus Algorithm · Narwhal-Bullshark: Narwhal and Tusk, Bullshark · Avalanche: Snowflake to Avalanche · SCP: The Stellar Consensus Protocol · Bitcoin: Nakamoto
Copyright © 2026 Christian Weilbach. Distributed under the Apache License 2.0.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |