From 03744437a5ffc36fbb5e973a0ddfd6b91945b212 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 01:48:57 +0000 Subject: federation: votes on the events proposing a checkpoint above its heads Anyone could propose a checkpoint's version again, by an event beside its heads. A node voting by itself, and a party's client, built a vote on every event proposing what it voted on, so every vote was beside the heads, and no version event written on them was taken: the checkpoint could never move the store. And the voters' rule refused it once that event was held for a while, as the heads left it out. They vote on the events proposing it that are above the heads it names (`State::proposing`), which `GET /events/counts` lists as `proposals`; where there are none, `none` says so, the node casts nothing and the client says why. The voters' rule leaves proposals and votes aside, as they lapse with the move. Row 70 is tested (`federation_attack_70`). --- src/federation/fold.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/federation/fold.rs') diff --git a/src/federation/fold.rs b/src/federation/fold.rs index 2e3fc56..7986a13 100644 --- a/src/federation/fold.rs +++ b/src/federation/fold.rs @@ -354,6 +354,33 @@ impl State { self.proposed.get(proposal) } + /// Of the events proposing the proposal of hash `proposal` on `on`, those a vote on it + /// may build on: where its version names a checkpoint, those above its heads, so that + /// a version event written on the votes is above them too. One proposing it again, + /// beside them, a vote doesn't build on. + pub(crate) fn proposing(&self, on: &Id, proposal: &Id) -> Vec { + let proposals = self + .ballots(on) + .remove(proposal) + .map(|ballot| ballot.proposals) + .unwrap_or_default(); + let heads = self + .proposed + .get(proposal) + .and_then(|json| Version::read(json).ok()) + .and_then(|version| version.checkpoint); + match heads { + None => proposals, + Some(heads) => { + let above = self.above(&heads.into_iter().collect()); + proposals + .into_iter() + .filter(|id| above.contains(id)) + .collect() + } + } + } + /// The version event writing the proposal of hash `proposal` on the current version, /// where it passed here: on the `true` votes of the first parties by name that pass it, /// each party's of the lowest ID, so that nodes holding those votes write the same. -- cgit v1.3.1