The double-sign guard: the second durability barrier from the protocol design, kept deliberately separate from the write-ahead log.
CometBFT keeps FilePVLastSignState{Height,Round,Step} in an atomically
rewritten file distinct from the WAL (privval/file.go:74-83), because it is
the one thing that must survive even a WAL wipe. A validator that loses its
WAL can safely re-derive everything else; a validator that loses this file
can be slashed.
may-sign below is the function EMITTED by the ansatz proof in
proofs/may_sign.clj, which proves:
no-double-sign -- (may-sign h r s h r s) = false same-round-requires-a-later-step lower-height-is-never-signable lower-round-at-same-height-not-signable
Ansatz is JVM-only and urd is portable, so the proof is checked separately and the erased definition ships here. Do not edit one without the other.
CometBFT writes this rule as four clauses (spec/consensus/signing.md:216-223)
only because its wire encoding is not order-compatible: proposal is 0x20 = 32,
numerically ABOVE prevote = 1. Re-encoded in semantic order the four clauses
collapse to "lexicographically greater", and the whole property becomes
"a strict order has no repeats".
The double-sign guard: the second durability barrier from the protocol
design, kept deliberately separate from the write-ahead log.
CometBFT keeps `FilePVLastSignState{Height,Round,Step}` in an atomically
rewritten file distinct from the WAL (`privval/file.go:74-83`), because it is
the one thing that must survive even a WAL wipe. A validator that loses its
WAL can safely re-derive everything else; a validator that loses this file
can be slashed.
## The predicate is machine-checked
`may-sign` below is the function EMITTED by the ansatz proof in
`proofs/may_sign.clj`, which proves:
no-double-sign -- (may-sign h r s h r s) = false
same-round-requires-a-later-step
lower-height-is-never-signable
lower-round-at-same-height-not-signable
Ansatz is JVM-only and urd is portable, so the proof is checked separately
and the erased definition ships here. Do not edit one without the other.
CometBFT writes this rule as four clauses (`spec/consensus/signing.md:216-223`)
only because its wire encoding is not order-compatible: proposal is 0x20 = 32,
numerically ABOVE prevote = 1. Re-encoded in semantic order the four clauses
collapse to "lexicographically greater", and the whole property becomes
"a strict order has no repeats".The state before anything has ever been signed.
Height -1 rather than 0, because a validator must be able to sign a proposal (step rank 0) at height 0 round 0, and lexicographic strictness would forbid that against a last-signed of (0,0,0).
The state before anything has ever been signed. Height -1 rather than 0, because a validator must be able to sign a proposal (step rank 0) at height 0 round 0, and lexicographic strictness would forbid that against a last-signed of (0,0,0).
(may-sign h-new r-new s-new h-last r-last s-last)The verified predicate, in the arity the proof states it in.
True iff (h-new, r-new, s-new) is strictly lexicographically greater than (h-last, r-last, s-last).
The verified predicate, in the arity the proof states it in. True iff (h-new, r-new, s-new) is strictly lexicographically greater than (h-last, r-last, s-last).
(may-sign? candidate last-signed)Map-shaped wrapper: may we sign candidate given last-signed?
Both are {:height :round :step}. A nil last-signed means nothing has ever
been signed.
Map-shaped wrapper: may we sign `candidate` given `last-signed`?
Both are {:height :round :step}. A nil `last-signed` means nothing has ever
been signed.(rank s)The numeric rank of a step keyword, or a throw -- an unknown step must never be silently treated as rank 0, which would make it signable at any time.
The numeric rank of a step keyword, or a throw -- an unknown step must never be silently treated as rank 0, which would make it signable at any time.
Semantic order, NOT the wire encoding. See the namespace docstring.
Semantic order, NOT the wire encoding. See the namespace docstring.
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 |