aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-19 14:09:05 +0000
committertv <tv@krebsco.de>2026-11-19 15:18:42 +0100
commitf85298c40c2528ee801c14a10a7db8920b50fdf8 (patch)
tree1eef6e26be145d819b5280142f9a6aa277ec4b3f
parent59d8d6f9c4f539ac9392872026d99a93f66102ee (diff)
vote: the version that moved the store counts not toward the next checkpoint
`--store-propose-versions` counted the versions since the checkpoint's version, the one current at its heads. The version that moved the store there is written after its heads, so it counted: with 1, a node proposed a checkpoint again as soon as it backed one (`--store-back-after` after the move), and the next one, and so on, every ten minutes for good. It counts the versions written since that change more than moving to a checkpoint now (`State::changed_since_checkpoint`): with 1, one checkpoint after every other version, and none after a checkpoint. The test goes on past the move.
-rw-r--r--docs/example.toml6
-rw-r--r--docs/guides/federation/checkpoints.md3
-rw-r--r--docs/guides/federation/voting-by-itself.md16
-rw-r--r--src/config/mod.rs2
-rw-r--r--src/federation/fold.rs18
-rw-r--r--src/federation/vote.rs14
6 files changed, 41 insertions, 18 deletions
diff --git a/docs/example.toml b/docs/example.toml
index 4078017..ce1ea83 100644
--- a/docs/example.toml
+++ b/docs/example.toml
@@ -154,9 +154,9 @@ htpasswd = "/etc/continuum/htpasswd"
# hand only through it (POST /admin/events/vote). It follows the `true` of the parties
# named (by default only on versions that only move to a checkpoint), votes `false` on a
# checkpoint proposed beside one it backs, if told, and proposes a checkpoint once it
-# holds so many events beyond its checkpoint, so many versions were written since, or so
-# long after it moved there; it backs and proposes none sooner than store-back-after
-# after a move or its start.
+# holds so many events beyond its checkpoint, so many versions changing more than moving
+# to a checkpoint were written since, or so long after it moved there; it backs and
+# proposes none sooner than store-back-after after a move or its start.
# store-vote-key = "/var/lib/continuum/party.key"
# store-vote-record = "/var/lib/continuum/party-record.json"
# store-follow = ["lass"]
diff --git a/docs/guides/federation/checkpoints.md b/docs/guides/federation/checkpoints.md
index ad468f8..c929d89 100644
--- a/docs/guides/federation/checkpoints.md
+++ b/docs/guides/federation/checkpoints.md
@@ -36,7 +36,8 @@ nothing that can still pass is proposed on the current version.
A node voting for its party by itself proposes checkpoints by its operator's rules: once
it holds so many events beyond its checkpoint (`--store-propose-events`), so many
-versions were written since it (`--store-propose-versions`, after every version with 1),
+versions changing more than moving to a checkpoint were written since it
+(`--store-propose-versions`, after every such version with 1),
or so long after its store moved there (`--store-propose-every`), at the heads it holds,
no more than an event may name (64, which it merges first under a revision with merge
events), where no proposal holds it back ([`voting-by-itself.md`](voting-by-itself.md),
diff --git a/docs/guides/federation/voting-by-itself.md b/docs/guides/federation/voting-by-itself.md
index 2209389..b01bfd3 100644
--- a/docs/guides/federation/voting-by-itself.md
+++ b/docs/guides/federation/voting-by-itself.md
@@ -50,19 +50,19 @@ or `POST /admin/events/vote` with `{"proposal": "8d02…", "yes": true}`.
just started, it holds nothing for a while yet.
* **Proposing checkpoints** (`--store-propose-events COUNT`, `--store-propose-versions
COUNT`, `--store-propose-every DURATION`): once it holds so many events beyond its
- checkpoint, so many versions were written since it, or so long after its store moved
- there by its own clock, it proposes a version that only moves to a checkpoint, at the
+ checkpoint, so many versions changing more than moving to a checkpoint were written
+ since it, or so long after its store moved there by its own clock, it proposes a
+ version that only moves to a checkpoint, at the
heads it holds, no more than an event may name (64, which it merges first under a
revision with merge events), where no proposal on the current version holds it back: one
it would back that can still pass; one that can still pass that a third of the parties
back, someone but its proposer among them; or one held for less than a while
(`--store-held-for`, ten minutes unless set) whose proposer has none older on the
- version. It
- backs what it proposes, so that the nodes following its party back it too. With
- `--store-propose-versions 1`, it proposes one after every version: after a close vote,
- one key voting twice can pass a rival version at a history from before it, any time
- later, which nodes lagging behind or joining from the root may take; a checkpoint above
- that version ends that.
+ version. It backs what it proposes, so that the nodes following its party back it too.
+ With `--store-propose-versions 1`, it proposes one after every version that changes
+ more: after a close vote, one key voting twice can pass a rival version at a history
+ from before it, any time later, which nodes lagging behind or joining from the root may
+ take; a checkpoint above that version ends that.
* **`false` beside** (`--store-nay-beside`): where it backs a proposal that can still
pass, it votes `false` on every other version only moving to a checkpoint, so that of
two checkpoints proposed at once the other dies, and its backers are free.
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 3b8d305..caecb49 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -310,7 +310,7 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[
Kind::Integer,
"COUNT",
None,
- "With store-vote-key: propose a checkpoint, as store-propose-events, once this many versions were written since its store's checkpoint: with 1, after every version, so that what keys voting twice could grow beside it at a history from before ends there.",
+ "With store-vote-key: propose a checkpoint, as store-propose-events, once this many versions changing more than moving to a checkpoint were written since its store's checkpoint: with 1, after every such version, so that what keys voting twice could grow beside it at a history from before ends there.",
),
#[cfg(feature = "federation")]
option(
diff --git a/src/federation/fold.rs b/src/federation/fold.rs
index d832976..46dad27 100644
--- a/src/federation/fold.rs
+++ b/src/federation/fold.rs
@@ -350,9 +350,21 @@ impl State {
ballots
}
- /// The checkpoint's version: the one current where the store moved there, or started.
- pub(crate) fn checkpoint_version(&self) -> &Version {
- &self.versions[&self.checkpoint]
+ /// How many versions were written since the checkpoint's that change more than moving
+ /// to a checkpoint: the one that moved the store there counts not.
+ pub(crate) fn changed_since_checkpoint(&self) -> u64 {
+ let mut count = 0;
+ let mut version = self.current();
+ while version.hash != self.checkpoint {
+ let Some(before) = version.changes.and_then(|hash| self.versions.get(&hash)) else {
+ break;
+ };
+ if !version.only_moves_on(before) {
+ count += 1;
+ }
+ version = before;
+ }
+ count
}
/// The version the proposal of hash `proposal` proposes, as JSON, where it holds one:
diff --git a/src/federation/vote.rs b/src/federation/vote.rs
index 4ba2e8f..7000b40 100644
--- a/src/federation/vote.rs
+++ b/src/federation/vote.rs
@@ -49,7 +49,8 @@ pub(crate) struct Rules {
pub(crate) propose_events: Option<usize>,
/// ...or so long after the store moved to it, by its own clock...
pub(crate) propose_every: Option<Duration>,
- /// ...or once so many versions were written since the one it holds.
+ /// ...or once so many versions were written since the one it holds, of those changing
+ /// more than moving to a checkpoint.
pub(crate) propose_versions: Option<u64>,
/// How long it holds an event before it holds it for a while: the voters' rule, and how
/// long a new proposal holds back a checkpoint.
@@ -421,7 +422,7 @@ pub(crate) fn by_hand(
/// what is written after does.
fn checkpoint(seen: &Seen<'_>, rules: &Rules, current: &Version, all: &[Proposed]) -> Option<Json> {
let store = seen.store;
- let since = current.number - store.state().checkpoint_version().number;
+ let since = store.state().changed_since_checkpoint();
let due = rules
.propose_events
.is_some_and(|events| store.taken().len() >= events)
@@ -836,6 +837,15 @@ mod tests {
let version = Version::read(json).unwrap();
assert_eq!(version.checkpoint, Some(vec![written]));
assert_eq!(version.changes, Some(next.hash()));
+ // Once the store moved there, the version that moved it counts not: none again.
+ let on = next.hash();
+ let proposal = taken(&mut store, tv.propose(&[written], json));
+ let votes = [&tv, &lass]
+ .map(|party| taken(&mut store, party.vote(&[proposal], on, version.hash, true)));
+ taken(&mut store, harness::version_event(&votes, version.hash));
+ assert_eq!(store.state().current().hash, version.hash);
+ assert_eq!(store.state().changed_since_checkpoint(), 0);
+ assert!(decide(&seen(&store, &long), &rules, &record).is_empty());
}
/// A node proposes a checkpoint at the heads its store holds, the one it took a moment