Snowman: leaderless consensus by repeated sampling, on urd's core protocol.
This exists to stress the OPPOSITE corner of the protocol from Raft. Where Raft is leader-based, log-structured, quorum-decided and absolutely final, Snowman is leaderless, chain-structured, SAMPLE-decided and only probabilistically final. If one protocol expresses both cleanly, the generality claim has evidence; if not, we learn where it breaks.
There is no quorum. A node repeatedly samples k peers, asks each for its current preference, and feeds the tally into a Snowball instance. Confidence accumulates only on CONSECUTIVE successful polls, so a network that keeps flip-flopping never finalizes -- and one that has tipped past the metastable point converges fast. Safety is probabilistic, parameterised by k, alpha, beta and the Byzantine fraction; it is not enforced by the code, and this implementation does not pretend otherwise.
One instance per PARENT, arbitrating among its children. This is
snowman_block.go:22-44, where the instance is a field of the block and
AddChild adds each new child as one of its choices; topological.go:517
votes into parentBlock.sb.
What that instance IS, is the next section. This one is about the PLACEMENT, which is the part that was a safety bug.
It is worth stating why, because the obvious alternative -- one instance per
candidate block, keyed by and voting for itself -- looks equivalent and is
not. Snowflake's entire safety argument is that confidence counts CONSECUTIVE
successes, enforced by nnary_snowflake.go:66-68: a poll whose winner differs
from the current preference zeroes confidence before incrementing. That flip
is only visible to an instance that can see both siblings. Give each block its
own instance and the flip never happens, no instance ever holds more than one
choice, and confidence in a losing sibling is never cleared -- so two honest
nodes seeing the alternating tallies X, Y, X, Y, X and Y, X, Y, X, Y both
reach beta and accept CONFLICTING blocks. Alternating tallies are the expected
outcome of a split preference, not a contrived one. The consecutive-poll
invariant this namespace advertises has to be enforced at the layer that
accepts blocks, or it is not enforced at all.
Two consequences follow from getting the PLACEMENT right:
topological.go:362-427 does this with a Kahn
sort; the path walk below is the same relation computed per chit).topological.go:296-311), rather than leaving preference
at the child of the last accepted block -- which would cap the chain at one
block per round.:variant selects it and defaults to :tree, which is what a running node
uses: chains/manager.go:933 and :1358 build Topological{Factory: SnowflakeFactory}, and snowman_block.go:39 hands that factory to
snowball.NewTree.
:tree NewTree(SnowflakeFactory) -- production
:flat-snowflake NewFlat(SnowflakeFactory)
:flat-snowball NewFlat(SnowballFactory) -- the published algorithm
The flat variants are kept because the papers are stated in Snowball's terms
and a library covering this family should be able to express them. Neither is
what any chain runs; NewFlat has no non-test caller anywhere in avalanchego.
The Tree is not an optimization of the flat form, which is how the design doc
had it filed. Flat.RecordPoll feeds one n-ary instance the PLURALITY choice
and its count; the Tree feeds each of its nodes every vote that reached it, so
votes for two siblings combine at every node above the bit where their ids
diverge. Three children where two share a leading bit the third lacks: a
split between the two still eliminates the third, on evidence the flat form
discards as a sub-alpha plurality. See snowtree.
Block ids stay whatever the application calls them. The Tree needs
fixed-width bits, so choice-key derives them with hasch/uuid rather than
constraining the vertex contract.
Membership does NOT apply. Snowman never asks "is this set a quorum of
the validators?" -- it asks "did alpha of my k SAMPLED peers agree?". The
Membership protocol is therefore optional, not universal, and a runtime
must not require it. Documented in the design as a correction.
:sample returning a BAG is load-bearing, and would have been easy to get
wrong. Weight is drawn without replacement, so one peer can appear several
times and its multiplicity IS its vote weight. The multiplicity belongs to
the REQUEST, not to the peer: several polls are in flight at once and a
peer's weight differs between them, so storing it in one global map lets
one poll's tally exceed k.
Probabilistic finality still maps onto :commit without :revert.
Preference flips freely BEFORE finalization, but a finalized decision is
never revoked -- so Snowman needs the revocable API less than Raft does,
which is a pleasing inversion of the usual intuition.
Snowman: leaderless consensus by repeated sampling, on urd's core protocol.
This exists to stress the OPPOSITE corner of the protocol from Raft. Where
Raft is leader-based, log-structured, quorum-decided and absolutely final,
Snowman is leaderless, chain-structured, SAMPLE-decided and only
probabilistically final. If one protocol expresses both cleanly, the
generality claim has evidence; if not, we learn where it breaks.
## How it decides
There is no quorum. A node repeatedly samples k peers, asks each for its
current preference, and feeds the tally into a Snowball instance. Confidence
accumulates only on CONSECUTIVE successful polls, so a network that keeps
flip-flopping never finalizes -- and one that has tipped past the metastable
point converges fast. Safety is probabilistic, parameterised by k, alpha, beta
and the Byzantine fraction; it is not enforced by the code, and this
implementation does not pretend otherwise.
## Where the instances live, and why it matters
**One instance per PARENT, arbitrating among its children.** This is
`snowman_block.go:22-44`, where the instance is a field of the block and
`AddChild` adds each new child as one of its choices; `topological.go:517`
votes into `parentBlock.sb`.
What that instance IS, is the next section. This one is about the PLACEMENT,
which is the part that was a safety bug.
It is worth stating why, because the obvious alternative -- one instance per
candidate block, keyed by and voting for itself -- looks equivalent and is
not. Snowflake's entire safety argument is that confidence counts CONSECUTIVE
successes, enforced by `nnary_snowflake.go:66-68`: a poll whose winner differs
from the current preference zeroes confidence before incrementing. That flip
is only visible to an instance that can see both siblings. Give each block its
own instance and the flip never happens, no instance ever holds more than one
choice, and confidence in a losing sibling is never cleared -- so two honest
nodes seeing the alternating tallies X, Y, X, Y, X and Y, X, Y, X, Y both
reach beta and accept CONFLICTING blocks. Alternating tallies are the expected
outcome of a split preference, not a contrived one. The consecutive-poll
invariant this namespace advertises has to be enforced at the layer that
accepts blocks, or it is not enforced at all.
Two consequences follow from getting the PLACEMENT right:
- **Vote bubbling is transitive.** A chit for a deep block is a vote for every
block on the path from the last accepted block down to it, each counted in
its own parent's instance (`topological.go:362-427` does this with a Kahn
sort; the path walk below is the same relation computed per chit).
- **Preference is the TIP.** After recording a poll we walk down the preferred
branch to a leaf (`topological.go:296-311`), rather than leaving preference
at the child of the last accepted block -- which would cap the chain at one
block per round.
## Which instance, of the three avalanchego has
`:variant` selects it and defaults to `:tree`, which is what a running node
uses: `chains/manager.go:933` and `:1358` build `Topological{Factory:
SnowflakeFactory}`, and `snowman_block.go:39` hands that factory to
`snowball.NewTree`.
:tree NewTree(SnowflakeFactory) -- production
:flat-snowflake NewFlat(SnowflakeFactory)
:flat-snowball NewFlat(SnowballFactory) -- the published algorithm
The flat variants are kept because the papers are stated in Snowball's terms
and a library covering this family should be able to express them. Neither is
what any chain runs; `NewFlat` has no non-test caller anywhere in avalanchego.
The Tree is not an optimization of the flat form, which is how the design doc
had it filed. `Flat.RecordPoll` feeds one n-ary instance the PLURALITY choice
and its count; the Tree feeds each of its nodes every vote that reached it, so
votes for two siblings combine at every node above the bit where their ids
diverge. Three children where two share a leading bit the third lacks: a
split between the two still eliminates the third, on evidence the flat form
discards as a sub-alpha plurality. See `snowtree`.
Block ids stay whatever the application calls them. The Tree needs
fixed-width bits, so `choice-key` derives them with `hasch/uuid` rather than
constraining the vertex contract.
## What it revealed about the core protocol
1. `Membership` does NOT apply. Snowman never asks "is this set a quorum of
the validators?" -- it asks "did alpha of my k SAMPLED peers agree?". The
`Membership` protocol is therefore optional, not universal, and a runtime
must not require it. Documented in the design as a correction.
2. `:sample` returning a BAG is load-bearing, and would have been easy to get
wrong. Weight is drawn without replacement, so one peer can appear several
times and its multiplicity IS its vote weight. The multiplicity belongs to
the REQUEST, not to the peer: several polls are in flight at once and a
peer's weight differs between them, so storing it in one global map lets
one poll's tally exceed k.
3. Probabilistic finality still maps onto `:commit` without `:revert`.
Preference flips freely BEFORE finalization, but a finalized decision is
never revoked -- so Snowman needs the revocable API less than Raft does,
which is a pleasing inversion of the usual intuition.(block-id block)SHA-256 of the canonical CBOR block fields excluding :id. This is the default identity check for blocks fetched from other validators.
SHA-256 of the canonical CBOR block fields excluding :id. This is the default identity check for blocks fetched from other validators.
(choice-key choice)The bit key the Tree indexes a choice by.
Block ids here are whatever the application calls them -- a keyword in the
tests, a hash in a deployment -- and the Tree needs fixed-width bits. So the
key is derived rather than required: hasch/uuid is content-addressed,
synchronous on both platforms, and already how Bullshark identifies
certificates. 32 hex characters, 128 bits.
A caller therefore keeps its own ids and never sees a digest, and no constraint leaks into the vertex contract to buy this.
The bit key the Tree indexes a choice by. Block ids here are whatever the application calls them -- a keyword in the tests, a hash in a deployment -- and the Tree needs fixed-width bits. So the key is derived rather than required: `hasch/uuid` is content-addressed, synchronous on both platforms, and already how Bullshark identifies certificates. 32 hex characters, 128 bits. A caller therefore keeps its own ids and never sees a digest, and no constraint leaks into the vertex contract to buy this.
(create)Create a Snowman node. A :verify-block predicate validates application IDs and content. Configure :params {:tree-key-mode :avalanche} to traverse 32-byte hexadecimal IDs in AvalancheGo byte/bit order. Without a verifier, fetched blocks use block-id and locally supplied vertices come from the application VM. :powers sets positive voting weights for all validators (unit weight by default).
Supply the application's durable :delivered-through cursor for suffix replay. An application migrating older decisions can supply its trusted :accepted-frontier block and matching cursor.
Create a Snowman node. A :verify-block predicate validates application IDs
and content. Configure :params {:tree-key-mode :avalanche} to traverse
32-byte hexadecimal IDs in AvalancheGo byte/bit order. Without a verifier, fetched blocks use block-id and locally supplied
vertices come from the application VM. :powers sets positive voting weights
for all validators (unit weight by default).
Supply the application's durable :delivered-through cursor for suffix replay.
An application migrating older decisions can supply its trusted
:accepted-frontier block and matching cursor.Ticks a poll waits for its chits before being abandoned.
A poll that loses one chit must not hang forever: :outstanding would grow
without bound and the node would simply stop polling into its instances.
On expiry the poll is COMPLETED from the chits that did arrive, not discarded. The previous behaviour recorded nothing, and its docstring justified that as matching avalanchego -- "avalanchego likewise drops a poll it cannot complete rather than tallying a partial result. Tallying the partial would under-count, fail alpha, and clear confidence, so a lossy network could never finalize anything." Both sentences are contradicted by the source.
avalanchego never leaves a poll incomplete. Every outstanding query ends in
Chits or QueryFailed (voter.go:47,49), and both reach polls.Vote or
polls.Drop. Drop removes the peer from polled
(early_term_traversal.go:154-156) -- it does not invalidate the poll -- and
Finished case 1 is remaining == 0, i.e. everyone either voted OR was
dropped (:167-176). The partial does not mechanically fail alpha either,
precisely because the dropped peer leaves polled: alpha is measured against
votes RECEIVED, so a poll clears it with up to k - alphaPreference
non-responses -- five of twenty at production parameters.
Discarding instead is a permanent halt, not a slowdown. With k near n --
avalanchego's own default is K=20 on subnets of about that size -- a single
unresponsive validator lands in every sample, so every poll expires and
records nothing, forever. Measured: five validators, k=4, one crashed, and
the four healthy nodes finalize NOTHING in 600 ticks.
It is also a safety-argument gap. A round in which the network genuinely
disagreed (sub-alpha) was erased rather than registering as a failed poll, so
beta counted "polls where everyone happened to answer" rather than
consecutive successful polls.
Ticks a poll waits for its chits before being abandoned. A poll that loses one chit must not hang forever: `:outstanding` would grow without bound and the node would simply stop polling into its instances. On expiry the poll is COMPLETED from the chits that did arrive, not discarded. The previous behaviour recorded nothing, and its docstring justified that as matching avalanchego -- "avalanchego likewise drops a poll it cannot complete rather than tallying a partial result. Tallying the partial would under-count, fail alpha, and clear confidence, so a lossy network could never finalize anything." Both sentences are contradicted by the source. avalanchego never leaves a poll incomplete. Every outstanding query ends in `Chits` or `QueryFailed` (`voter.go:47,49`), and both reach `polls.Vote` or `polls.Drop`. `Drop` removes the peer from `polled` (`early_term_traversal.go:154-156`) -- it does not invalidate the poll -- and `Finished` case 1 is `remaining == 0`, i.e. everyone either voted OR was dropped (`:167-176`). The partial does not mechanically fail alpha either, precisely because the dropped peer leaves `polled`: alpha is measured against votes RECEIVED, so a poll clears it with up to `k - alphaPreference` non-responses -- five of twenty at production parameters. Discarding instead is a permanent halt, not a slowdown. With `k` near `n` -- avalanchego's own default is K=20 on subnets of about that size -- a single unresponsive validator lands in every sample, so every poll expires and records nothing, forever. Measured: five validators, k=4, one crashed, and the four healthy nodes finalize NOTHING in 600 ticks. It is also a safety-argument gap. A round in which the network genuinely disagreed (sub-alpha) was erased rather than registering as a failed poll, so `beta` counted "polls where everyone happened to answer" rather than consecutive successful polls.
The three shapes, and the only accepted values of :variant.
The three shapes, and the only accepted values of `:variant`.
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 |