Liking cljdoc? Tell your friends :D

urd.consensus.algorithms.scp

Stellar Consensus Protocol -- Federated Byzantine Agreement -- as a pure state machine on urd.consensus.node.

The sixth algorithm in the library, and the first with no global validator set. Raft, Tendermint, round-robin and Snowman all start from "here are the n validators"; Nakamoto starts from "anyone with hashpower". SCP starts from neither. Each node names its own quorum slices, and whether a set of peers is decisive is a question only that node can answer -- from data it may not have yet.

Source of truth

stellar-core/src/scp/ (checkout of 2017; SCP's core has been frozen since 2015, so it is authoritative). File/line references below point there. The IETF draft draft-mazieres-dinrg-scp-05 is the same algorithm in prose.

Two deliberate divergences, both marked at their definitions:

  • update-round-leaders ACCUMULATES leaders across nomination rounds. The 2017 checkout clears the set each round (NominationProtocol.cpp:203); current stellar-core keeps them, and the growing-leader-set argument is what makes nomination converge. We implement the convergent version.
  • The attempt* rules scan candidate ballots from ALL known statements rather than from the hint statement that triggered them. stellar-core's hint is an optimisation to bound the scan; taking the union over every possible hint is a superset, and a superset cannot cause an unsafe accept because each candidate still has to clear federated voting on its own.

The four things this file exists to test

Membership's tri-state quorum? and node/fixpoint were designed for SCP and, until this file, never exercised by anything. The verdicts are recorded at each definition.

Quorum-ness is a greatest fixpoint, not a cardinality

A set U is a quorum iff every member of U has one of its own slices contained in U. That is self-referential, so it is computed as a greatest fixpoint (LocalNode.cpp:252-290): start from all candidates, repeatedly discard anyone whose advertised quorum set is not satisfied by the survivors, stop when stable, then ask whether the survivors contain a slice of MINE.

v-blocking? (LocalNode.cpp:194-220) is the cardinality DUAL and is purely LOCAL -- it reads only my own quorum set and never anybody else's. The asymmetry is the point: quorum is transitive, v-blocking is not.

Why the answer can be :unknown

Every statement carries the HASH of its sender's quorum set, not the set itself. A node routinely holds a statement whose quorum set it has never seen, and then it genuinely cannot evaluate the fixpoint.

stellar-core sidesteps this by refusing to process such an envelope at all -- Herder's ItemFetcher parks it until the quorum set arrives -- and inside isQuorum an unresolvable quorum set simply excludes its node (LocalNode.cpp:266-274), which is a safe UNDER-approximation. We do better, because the protocol offers a third value and it is worth finding out whether it carries its weight: quorum-tri computes BOTH bounds. Dropping the unknown-quorum-set nodes is the lower bound; treating them as unconditionally satisfied is the upper bound. Then

lower = true -> true (no arriving data can retract it) upper = false -> false (no arriving data can establish it) otherwise -> :unknown

so :unknown means precisely this answer will change once I fetch something, which is exactly the condition under which fetching is worth doing. false means decided with respect to arriving QUORUM SETS -- an arriving STATEMENT enlarges the node set being tested and can still flip it, which is harmless because the answer is recomputed on every pass, but it is not the stronger claim -- decided regardless of what arrives -- that this used to make.

Monotonicity is what makes those bounds sound. Learning a quorum set can only ADD survivors to the fixpoint, and more survivors can only satisfy more slices, so the answer moves in one direction only.

Fetching a missing quorum set needs no new effect

§4 of the design doc proposed a [:request-qset] effect and a :qset-received event. Neither is necessary and we did not add them: a missing quorum set has to come from a peer, so it is a unicast request and a unicast reply -- send-to and message-received, which already exist. See the PR; hiding a network round trip behind a bespoke effect would have made its failure modes invisible.

Replies are content-addressed and VERIFIED: (= hash (qset-hash qset)) before the cache is touched, so a Byzantine peer cannot answer a fetch with a quorum set of its choosing and thereby manufacture a quorum for us.

Purity

.cljc, no host interop except one character-code helper (the same reader conditional raft uses), no clock, no RNG. Nomination leader election is a portable hash of (slot, previous value, round, node), which is the role stellar-core gives SHA-256; see content-hash for why the obvious portable hash was not good enough, and for what a real deployment should use instead.

Stellar Consensus Protocol -- Federated Byzantine Agreement -- as a pure
state machine on `urd.consensus.node`.

The sixth algorithm in the library, and the first with **no global validator
set**. Raft, Tendermint, round-robin and Snowman all start from "here are the
n validators"; Nakamoto starts from "anyone with hashpower". SCP starts from
neither. Each node names its own *quorum slices*, and whether a set of peers
is decisive is a question only that node can answer -- from data it may not
have yet.

## Source of truth

`stellar-core/src/scp/` (checkout of 2017; SCP's core has been frozen since
2015, so it is authoritative). File/line references below point there. The
IETF draft `draft-mazieres-dinrg-scp-05` is the same algorithm in prose.

Two deliberate divergences, both marked at their definitions:

- `update-round-leaders` ACCUMULATES leaders across nomination rounds. The
  2017 checkout clears the set each round (`NominationProtocol.cpp:203`);
  current stellar-core keeps them, and the growing-leader-set argument is what
  makes nomination converge. We implement the convergent version.
- The `attempt*` rules scan candidate ballots from ALL known statements rather
  than from the `hint` statement that triggered them. stellar-core's hint is
  an optimisation to bound the scan; taking the union over every possible hint
  is a superset, and a superset cannot cause an unsafe accept because each
  candidate still has to clear federated voting on its own.

## The four things this file exists to test

`Membership`'s tri-state `quorum?` and `node/fixpoint` were designed for SCP
and, until this file, never exercised by anything. The verdicts are recorded
at each definition.

## Quorum-ness is a greatest fixpoint, not a cardinality

A set U is a *quorum* iff every member of U has one of its own slices
contained in U. That is self-referential, so it is computed as a greatest
fixpoint (`LocalNode.cpp:252-290`): start from all candidates, repeatedly
discard anyone whose advertised quorum set is not satisfied by the survivors,
stop when stable, then ask whether the survivors contain a slice of MINE.

`v-blocking?` (`LocalNode.cpp:194-220`) is the cardinality DUAL and is purely
LOCAL -- it reads only my own quorum set and never anybody else's. The
asymmetry is the point: quorum is transitive, v-blocking is not.

## Why the answer can be `:unknown`

Every statement carries the HASH of its sender's quorum set, not the set
itself. A node routinely holds a statement whose quorum set it has never seen,
and then it genuinely cannot evaluate the fixpoint.

stellar-core sidesteps this by refusing to process such an envelope at all --
`Herder`'s `ItemFetcher` parks it until the quorum set arrives -- and inside
`isQuorum` an unresolvable quorum set simply excludes its node
(`LocalNode.cpp:266-274`), which is a safe UNDER-approximation. We do better,
because the protocol offers a third value and it is worth finding out whether
it carries its weight: `quorum-tri` computes BOTH bounds. Dropping the
unknown-quorum-set nodes is the lower bound; treating them as unconditionally
satisfied is the upper bound. Then

  lower  = true   ->  true    (no arriving data can retract it)
  upper  = false  ->  false   (no arriving data can establish it)
  otherwise       ->  :unknown

so `:unknown` means precisely *this answer will change once I fetch something*,
which is exactly the condition under which fetching is worth doing. `false`
means decided with respect to arriving QUORUM SETS -- an arriving STATEMENT
enlarges the node set being tested and can still flip it, which is harmless
because the answer is recomputed on every pass, but it is not the stronger
claim -- decided regardless of what arrives -- that this used to make.

Monotonicity is what makes those bounds sound. Learning a quorum set can only
ADD survivors to the fixpoint, and more survivors can only satisfy more
slices, so the answer moves in one direction only.

## Fetching a missing quorum set needs no new effect

§4 of the design doc proposed a `[:request-qset]` effect and a
`:qset-received` event. Neither is necessary and we did not add them: a
missing quorum set has to come from a peer, so it is a unicast request and a
unicast reply -- `send-to` and `message-received`, which already exist. See
the PR; hiding a network round trip behind a bespoke effect would have made
its failure modes invisible.

Replies are content-addressed and VERIFIED: `(= hash (qset-hash qset))` before
the cache is touched, so a Byzantine peer cannot answer a fetch with a quorum
set of its choosing and thereby manufacture a quorum for us.

## Purity

`.cljc`, no host interop except one character-code helper (the same reader
conditional `raft` uses), no clock, no RNG. Nomination leader election is a
portable hash of (slot, previous value, round, node), which is the role
stellar-core gives SHA-256; see `content-hash` for why the obvious portable
hash was not good enough, and for what a real deployment should use instead.
raw docstring

ballotclj/s

(ballot counter value)
source

ballot-stateclj/s

(ballot-state st)

[b p p' h c] -- the five ballot variables, for assertions and traces.

`[b p p' h c]` -- the five ballot variables, for assertions and traces.
sourceraw docstring

bump-stateclj/s

(bump-state st value n-or-force)

bumpState(value, n): move to counter n, keeping h's value if we have one.

Keeping h's value is the rule that makes counter bumps safe: once we have confirmed a ballot prepared we may raise the counter forever but may never change the value underneath it.

`bumpState(value, n)`: move to counter `n`, keeping h's value if we have one.

Keeping `h`'s value is the rule that makes counter bumps safe: once we have
confirmed a ballot prepared we may raise the counter forever but may never
change the value underneath it.
sourceraw docstring

candidatesclj/s

(candidates st)
source

check-invariantsclj/s

(check-invariants st)

BallotProtocol::checkInvariants (BallotProtocol.cpp:624-656), throwing.

stellar-core runs this on every state change under dbgAssert. It is a SELF-CHECK on the ballot state rather than a protocol rule -- nothing here is reachable from a well-behaved transition, which is exactly why it is worth running: it catches the transition that is not well-behaved, at the point it happens rather than three rounds later when the externalized value is wrong.

dbgAssert compiles out of stellar's release builds. This does not, because the cost is six comparisons on a state machine that already runs a fixpoint of eleven rules, and because a check compiled out of the build that matters is a check you do not have.

`BallotProtocol::checkInvariants` (`BallotProtocol.cpp:624-656`), throwing.

stellar-core runs this on every state change under `dbgAssert`. It is a
SELF-CHECK on the ballot state rather than a protocol rule -- nothing here is
reachable from a well-behaved transition, which is exactly why it is worth
running: it catches the transition that is not well-behaved, at the point it
happens rather than three rounds later when the externalized value is wrong.

`dbgAssert` compiles out of stellar's release builds. This does not, because
the cost is six comparisons on a state machine that already runs a fixpoint of
eleven rules, and because a check compiled out of the build that matters is a
check you do not have.
sourceraw docstring

compare-ballotsclj/s

(compare-ballots b1 b2)

Total order on ballots, nil lowest.

Values are compared through canonical so the order is identical on both platforms; a deployment with structured values should supply comparable ids.

Total order on ballots, nil lowest.

Values are compared through `canonical` so the order is identical on both
platforms; a deployment with structured values should supply comparable ids.
sourceraw docstring

compatible?clj/s

(compatible? b1 b2)

Same value. Ballot ordering is by counter first, so two ballots can be ordered and still be about different values -- which is the whole reason p and p' both exist.

Same value. Ballot ordering is by counter first, so two ballots can be
ordered and still be about different values -- which is the whole reason `p`
and `p'` both exist.
sourceraw docstring

content-hashclj/s

(content-hash s)

A 32-bit hash with real avalanche, portable and exact on both platforms.

Per character: one djb2 step, h = (33h + c) mod (2^32 - 5), then one xorshift32 permutation. Neither half is enough alone, and finding that out was worth the trouble:

  • PLAIN djb2 (raft/string-hash) has no avalanche at all. Measured: the nomination priorities of peers :a :b :c :d came out 870040764 / 870040797 / 870040830 / 870040863 -- consecutive multiples of 33, the djb2 multiplier -- so the highest node id won EVERY round of EVERY slot. The simulation still reached consensus, which is exactly why it was worth catching: a broken leader lottery looks like a working one right up until its permanent leader is partitioned away.
  • djb2 THEN xorshift, the composition raft uses, is not enough either. xorshift32 is GF(2)-linear, so it maps a small, structured seed difference to a small, structured output difference; the four priorities stayed within 3% of each other and their order barely moved between rounds.

Interleaving them fixes it, because the multiply is nonlinear over GF(2) and the shifts are nonlinear over the integers, so neither structure survives the other. Measured over 400 nomination rounds the four peers now win 99 / 103 / 109 / 89 times.

The arithmetic stays exact: h is under 2^32 after the mix, so the largest intermediate is 33*2^32 + 65535, about 1.4e11, comfortably inside the 2^53 where a ClojureScript double is still an integer. A 32-bit FNV-1a would not be -- its multiply reaches 7.2e16.

Emphatically not cryptographic. It is used for two things: content-addressing quorum sets, where a collision costs an attacker a preimage search that a real deployment should make expensive by using SHA-256 over the XDR encoding; and the nomination lottery, which has no safety obligation at all.

A 32-bit hash with real avalanche, portable and exact on both platforms.

Per character: one djb2 step, `h = (33h + c) mod (2^32 - 5)`, then one
xorshift32 permutation. Neither half is enough alone, and finding that out was
worth the trouble:

- PLAIN djb2 (`raft/string-hash`) has no avalanche at all. Measured: the
  nomination priorities of peers :a :b :c :d came out
  870040764 / 870040797 / 870040830 / 870040863 -- consecutive multiples of
  33, the djb2 multiplier -- so the highest node id won EVERY round of EVERY
  slot. The simulation still reached consensus, which is exactly why it was
  worth catching: a broken leader lottery looks like a working one right up
  until its permanent leader is partitioned away.
- djb2 THEN xorshift, the composition `raft` uses, is not enough either.
  xorshift32 is GF(2)-linear, so it maps a small, structured seed difference
  to a small, structured output difference; the four priorities stayed within
  3% of each other and their order barely moved between rounds.

Interleaving them fixes it, because the multiply is nonlinear over GF(2) and
the shifts are nonlinear over the integers, so neither structure survives the
other. Measured over 400 nomination rounds the four peers now win 99 / 103 /
109 / 89 times.

The arithmetic stays exact: `h` is under 2^32 after the mix, so the largest
intermediate is 33*2^32 + 65535, about 1.4e11, comfortably inside the 2^53
where a ClojureScript double is still an integer. A 32-bit FNV-1a would not
be -- its multiply reaches 7.2e16.

Emphatically not cryptographic. It is used for two things: content-addressing
quorum sets, where a collision costs an attacker a preimage search that a
real deployment should make expensive by using SHA-256 over the XDR encoding;
and the nomination lottery, which has no safety obligation at all.
sourceraw docstring

default-configclj/s

source

externalizedclj/s

(externalized st)

The value this node externalized, or nil.

The value this node externalized, or nil.
sourceraw docstring

federated-acceptclj/s

(federated-accept state statements voted? accepted?)

accept(a): a v-blocking set already accepts a, OR a quorum containing me has each voted-or-accepted a.

The first clause is the one that makes federated voting work at all. A node that voted AGAINST a can still accept it, because a v-blocking set of its own slices has accepted -- a plain quorum rule can never switch such a node, and the protocol would deadlock.

Note the v-blocking clause is local and therefore always decidable, so a node that cannot resolve anybody's quorum set can still be dragged forward by its own slices.

`accept(a)`: a v-blocking set already accepts `a`, OR a quorum containing me
has each voted-or-accepted `a`.

The first clause is the one that makes federated voting work at all. A node
that voted AGAINST `a` can still accept it, because a v-blocking set of its
own slices has accepted -- a plain quorum rule can never switch such a node,
and the protocol would deadlock.

Note the v-blocking clause is local and therefore always decidable, so a node
that cannot resolve anybody's quorum set can still be dragged forward by its
own slices.
sourceraw docstring

federated-ratifyclj/s

(federated-ratify state statements accepted?)

confirm(a): a quorum containing me has each ACCEPTED a.

`confirm(a)`: a quorum containing me has each ACCEPTED `a`.
sourceraw docstring

intertwined?clj/s

(intertwined? qsets)
(intertwined? qsets faulty)

Small-network oracle for quorum intersection. With faulty supplied, every pair of quorums must share a node outside that set. Returns false when no quorum exists. Enumeration is exponential and limited to sixteen nodes.

Small-network oracle for quorum intersection. With `faulty` supplied, every
pair of quorums must share a node outside that set. Returns false when no
quorum exists. Enumeration is exponential and limited to sixteen nodes.
sourceraw docstring

makeclj/s

(make)
source

max-nomination-valuesclj/s

A hard cap on the values one nomination statement may carry, in the same spirit as max-qset-nodes and for the same reason.

nomination-rule runs federated-accept ONCE PER DISTINCT VALUE, and each of those is two greatest fixpoints over survivors plus a v-blocking? walk. The sanity check required only that a statement carry SOME value, so a single message with a million of them bought a million fixpoints, inside step, on the event loop -- and the whole thing sits inside settle's own 200-iteration fixpoint.

Generous against any honest node: a nomination set grows by at most one value per nominating peer per round, so this is far above what a real slot produces, and a statement above it is refused rather than truncated. Dropping values would silently change which of them federated voting could accept, which is a correctness change smuggled in as a resource bound.

A hard cap on the values one nomination statement may carry, in the same
spirit as `max-qset-nodes` and for the same reason.

`nomination-rule` runs `federated-accept` ONCE PER DISTINCT VALUE, and each
of those is two greatest fixpoints over `survivors` plus a `v-blocking?`
walk. The sanity check required only that a statement carry SOME value, so a
single message with a million of them bought a million fixpoints, inside
`step`, on the event loop -- and the whole thing sits inside `settle`'s own
200-iteration fixpoint.

Generous against any honest node: a nomination set grows by at most one value
per nominating peer per round, so this is far above what a real slot
produces, and a statement above it is refused rather than truncated. Dropping
values would silently change which of them federated voting could accept,
which is a correctness change smuggled in as a resource bound.
sourceraw docstring

max-qset-nodesclj/s

QuorumSetUtils.cpp:64 -- a hard cap so a single advertised set cannot make survivors' fixpoint arbitrarily expensive.

`QuorumSetUtils.cpp:64` -- a hard cap so a single advertised set cannot make
`survivors`' fixpoint arbitrarily expensive.
sourceraw docstring

membershipclj/s

source

missing-qset-hashesclj/s

(missing-qset-hashes state statements)

The quorum-set hashes referenced by statements that we cannot resolve.

This exists because Membership/quorum? can say :unknown but cannot say what it is waiting for.

The quorum-set hashes referenced by `statements` that we cannot resolve.

This exists because `Membership/quorum?` can say `:unknown` but cannot say
what it is waiting for.
sourceraw docstring

newer-ballot-statement?clj/s

(newer-ballot-statement? old new)

The total order of BallotProtocol.cpp:54-131: kind first, then (b,p,p',h).

Keeping only the newest per sender is not an optimisation. A Byzantine node that could get an OLD statement counted alongside its newest one would be voting twice, which is the federated equivalent of the duplicate-sender bug node/distinct-voters exists to prevent.

The total order of `BallotProtocol.cpp:54-131`: kind first, then (b,p,p',h).

Keeping only the newest per sender is not an optimisation. A Byzantine node
that could get an OLD statement counted alongside its newest one would be
voting twice, which is the federated equivalent of the duplicate-sender bug
`node/distinct-voters` exists to prevent.
sourceraw docstring

newer-nomination?clj/s

(newer-nomination? old new)

NominationProtocol.cpp:82-101: newer iff both sets grew (or stayed) and one strictly grew. A nomination statement is monotone by construction, so a shrinking one is a lie.

`NominationProtocol.cpp:82-101`: newer iff both sets grew (or stayed) and one
strictly grew. A nomination statement is monotone by construction, so a
shrinking one is a lie.
sourceraw docstring

node-weight-fractionclj/s

(node-weight-fraction node qset)

[num den]: this node's share of qset, or nil if it is not in the tree.

LocalNode.cpp:100-140 returns UINT64_MAX * n/d and multiplies fractions down the tree. Kept as an exact rational instead, because the products stay tiny and a double would round differently in the browser. Used ONLY for nomination leader election -- SCP's quorums are not weighted at all, which is why Membership/weight sits so awkwardly here.

`[num den]`: this node's share of `qset`, or nil if it is not in the tree.

`LocalNode.cpp:100-140` returns `UINT64_MAX * n/d` and multiplies fractions
down the tree. Kept as an exact rational instead, because the products stay
tiny and a double would round differently in the browser. Used ONLY for
nomination leader election -- SCP's quorums are not weighted at all, which is
why `Membership/weight` sits so awkwardly here.
sourceraw docstring

phaseclj/s

(phase st)
source

qset-hashclj/s

(qset-hash qset)

The content hash a statement carries in place of the quorum set itself.

This is what makes the tri-state real: peers advertise a digest, and a node that has never seen the preimage cannot evaluate a fixpoint through them.

CRYPTOGRAPHIC, unlike content-hash. handle-message :qset accepts a quorum set from any peer on the strength of (= (:hash msg) (qset-hash (:qset msg))) alone, and a forged set is then trusted by survivors -- which is the manufacture-a-quorum-from-nothing break the whole content-addressing scheme exists to prevent. At 32 bits a preimage search costs seconds, so content-hash was not a hash function here, it was a formality. hasch/uuid is SHA-512-derived, synchronous on both platforms, and is already what Bullshark content-addresses certificates with.

A STRING, never a raw UUID: the JVM compares a UUID's two 64-bit halves as SIGNED longs while ClojureScript compares the printed form, and these values are sorted -- see the note in bullshark. content-hash keeps the nomination lottery, which has no safety obligation at all.

The content hash a statement carries in place of the quorum set itself.

This is what makes the tri-state real: peers advertise a digest, and a node
that has never seen the preimage cannot evaluate a fixpoint through them.

CRYPTOGRAPHIC, unlike `content-hash`. `handle-message :qset` accepts a quorum
set from any peer on the strength of `(= (:hash msg) (qset-hash (:qset msg)))`
alone, and a forged set is then trusted by `survivors` -- which is the
manufacture-a-quorum-from-nothing break the whole content-addressing scheme
exists to prevent. At 32 bits a preimage search costs seconds, so
`content-hash` was not a hash function here, it was a formality. `hasch/uuid`
is SHA-512-derived, synchronous on both platforms, and is already what
Bullshark content-addresses certificates with.

A STRING, never a raw UUID: the JVM compares a UUID's two 64-bit halves as
SIGNED longs while ClojureScript compares the printed form, and these values
are sorted -- see the note in `bullshark`. `content-hash` keeps the nomination
lottery, which has no safety obligation at all.
sourceraw docstring

qset-nodesclj/s

(qset-nodes qset)

Every node id appearing anywhere in the tree.

Every node id appearing anywhere in the tree.
sourceraw docstring

quorum-slice?clj/s

(quorum-slice? qset node-set)

Does node-set contain one of qset's slices? (LocalNode.cpp:141-170)

Recursive: an inner set counts as one member once it is itself satisfied.

Does `node-set` contain one of `qset`'s slices? (`LocalNode.cpp:141-170`)

Recursive: an inner set counts as one member once it is itself satisfied.
sourceraw docstring

quorum-triclj/s

(quorum-tri my-qset candidates qset-of)

true / false / :unknown -- is there a quorum containing me inside candidates?

"Containing me" is not decoration. A quorum that excludes me proves nothing about MY safety, and SCP's whole guarantee is per-node. It is expressed the way stellar-core expresses it: the surviving set has to contain one of my own slices, and my slices implicitly include me.

`true` / `false` / `:unknown` -- is there a quorum containing me inside
`candidates`?

"Containing me" is not decoration. A quorum that excludes me proves nothing
about MY safety, and SCP's whole guarantee is per-node. It is expressed the
way stellar-core expresses it: the surviving set has to contain one of my own
slices, and my slices implicitly include me.
sourceraw docstring

rule-passesclj/s

(rule-passes st)

How many rule applications this node has run in total.

The gap across one step is how many transitions that single event unlocked. A one-transition-per-event machine can only ever move it by one.

How many rule applications this node has run in total.

The gap across one `step` is how many transitions that single event unlocked.
A one-transition-per-event machine can only ever move it by one.
sourceraw docstring

statement-qset-hashclj/s

(statement-qset-hash stmt)
source

statement-sane?clj/s

(statement-sane? st)

BallotProtocol.cpp:249-311 / NominationProtocol.cpp:102-113.

A Byzantine peer can send anything; a malformed statement must be dropped before it reaches the voting rules, not asserted against.

`BallotProtocol.cpp:249-311` / `NominationProtocol.cpp:102-113`.

A Byzantine peer can send anything; a malformed statement must be dropped
before it reaches the voting rules, not asserted against.
sourceraw docstring

survivorsclj/s

(survivors candidates qset-of unknown-survives?)

The greatest fixpoint of "everyone here is satisfied by everyone here".

qset-of maps a node to its advertised quorum set, or nil when we have never fetched it. unknown-survives? picks which bound we are computing:

false -- an unresolvable node is discarded (lower bound, stellar-core's) true -- an unresolvable node is assumed satisfied (upper bound)

Terminates because the set only ever shrinks.

The greatest fixpoint of "everyone here is satisfied by everyone here".

`qset-of` maps a node to its advertised quorum set, or nil when we have never
fetched it. `unknown-survives?` picks which bound we are computing:

  false -- an unresolvable node is discarded (lower bound, stellar-core's)
  true  -- an unresolvable node is assumed satisfied (upper bound)

Terminates because the set only ever shrinks.
sourceraw docstring

v-blocking?clj/s

(v-blocking? qset node-set)

Does node-set intersect EVERY slice of qset? (LocalNode.cpp:194-220)

Equivalently: the complement can no longer reach the threshold. This is the cardinality dual of quorum-slice? -- n - threshold + 1 members instead of threshold -- and it is why a node whose whole quorum set has moved on can be dragged forward even though nothing resembling a quorum has spoken.

Purely LOCAL: it reads one quorum set, mine, and consults no other node's advertised trust. That is the asymmetry §4 of the design doc calls out, and it is the reason v-blocking? is always decidable while quorum? is not.

Does `node-set` intersect EVERY slice of `qset`? (`LocalNode.cpp:194-220`)

Equivalently: the complement can no longer reach the threshold. This is the
cardinality dual of `quorum-slice?` -- `n - threshold + 1` members instead of
`threshold` -- and it is why a node whose whole quorum set has moved on can be
dragged forward even though nothing resembling a quorum has spoken.

Purely LOCAL: it reads one quorum set, mine, and consults no other node's
advertised trust. That is the asymmetry §4 of the design doc calls out, and it
is the reason `v-blocking?` is always decidable while `quorum?` is not.
sourceraw docstring

valid-qset?clj/s

(valid-qset? qset)
(valid-qset? {:keys [threshold validators inner-sets] :as qset} depth)

Structural sanity, in the spirit of QuorumSetUtils.cpp.

A threshold of zero would make the empty set a slice, i.e. would make every set a quorum -- the same class of silent safety failure as node's missing :validators guard, and worth refusing for the same reason. Depth is capped at 2 as stellar-core does.

Uniqueness is checked GLOBALLY across the tree, not per list. QuorumSetSanityChecker carries mKnownNodes across the whole recursion (QuorumSetUtils.cpp:68-76) and rejects any node named twice. Checking only within one list accepted, for instance,

{:threshold 2 :validators [:a] :inner-sets [{:threshold 1 :validators [:a]}]}

where quorum-slice? counts the single node :a twice toward a threshold of two -- so a peer can advertise a set that a single accomplice satisfies, and survivors will believe it.

Structural sanity, in the spirit of `QuorumSetUtils.cpp`.

A threshold of zero would make the empty set a slice, i.e. would make every
set a quorum -- the same class of silent safety failure as `node`'s missing
`:validators` guard, and worth refusing for the same reason. Depth is capped
at 2 as stellar-core does.

Uniqueness is checked GLOBALLY across the tree, not per list.
`QuorumSetSanityChecker` carries `mKnownNodes` across the whole recursion
(`QuorumSetUtils.cpp:68-76`) and rejects any node named twice. Checking only
within one list accepted, for instance,

    {:threshold 2 :validators [:a] :inner-sets [{:threshold 1 :validators [:a]}]}

where `quorum-slice?` counts the single node `:a` twice toward a threshold of
two -- so a peer can advertise a set that a single accomplice satisfies, and
`survivors` will believe it.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close