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/vote.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/federation/vote.rs') diff --git a/src/federation/vote.rs b/src/federation/vote.rs index d4968be..1b4de16 100644 --- a/src/federation/vote.rs +++ b/src/federation/vote.rs @@ -144,7 +144,7 @@ fn proposed(seen: &Seen<'_>, current: &Version) -> Vec { /// Whether the node backs `version`, proposed `proposed_held` ago, by the voters' rule: one /// naming a checkpoint only where it changes nothing of `current` but its number, what it /// changes and its checkpoint, and its heads leave out nothing the node held for a while -/// before it was proposed. +/// before it was proposed, proposals and votes aside, which lapse with the move. pub(crate) fn backs_checkpoint( seen: &Seen<'_>, rules: &Rules, @@ -161,11 +161,21 @@ pub(crate) fn backs_checkpoint( ); } let before = proposed_held + rules.held_for; + // Proposals and votes lapse with the move: they count no more on the version after. + let lapsing = |id: &Id| { + matches!( + seen.store.get(id).and_then(Event::read_taken), + Some(Event::Signed(Signed { + does: Does::Proposal { .. } | Does::Vote { .. }, + .. + })) + ) + }; let held: Vec = seen .store .taken() .iter() - .filter(|id| (seen.held)(id).is_some_and(|held| held >= before)) + .filter(|id| (seen.held)(id).is_some_and(|held| held >= before) && !lapsing(id)) .copied() .collect(); let left_out = seen.store.left_out(heads, &held); -- cgit v1.3.1