From 055e09b3410040e4300238ac5d0a53fdc2726e40 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 Nov 2026 12:43:51 +0000 Subject: federation: a node casts no true its own store refuses A node recorded each vote, saved the record, offered the vote to its store, and didn't look at the answer. A party freed by nays cast after a checkpoint's heads were named, with its earlier true in their history, votes on that checkpoint on its proposal alone, as a checkpoint's vote leaves the nays out: there the earlier proposal isn't dead, and every store refuses the vote. Recorded all the same, it bound the party by a vote no node held; and deciding on it each round, the node proposed no checkpoint of its own. The fold's rule for a party's second true is State::may_back now, which a node asks at the history its vote would build on (vote::builds_on), as it decides, by itself or by hand, and as it signs: a vote refused at its own history counts nowhere, so none is cast, and none recorded. --- src/federation/fold.rs | 53 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 21 deletions(-) (limited to 'src/federation/fold.rs') diff --git a/src/federation/fold.rs b/src/federation/fold.rs index b96cf1f..b590f07 100644 --- a/src/federation/fold.rs +++ b/src/federation/fold.rs @@ -559,33 +559,44 @@ impl State { return Err(Refused::new("its proposal isn't proposed on that version")); } if *yes { - let backed: BTreeSet = self - .signed() - .filter_map(|(_, other, _)| match &other.does { - Does::Vote { - on: voted_on, - proposal: voted, - yes: true, - } if other.party == signed.party - && voted_on == on - && voted != proposal => - { - Some(*voted) - } - _ => None, - }) - .collect(); - if backed.iter().any(|other| !self.tally(current, other).dead) { - return Err(Refused::new( - "its party backs another proposal on that version, not dead", - )); - } + self.may_back(&signed.party, proposal, current)?; } Ok(()) } } } + /// Whether a `true` of `party` on the proposal of hash `proposal` on `current` is + /// taken here, as far as its party's other votes go: none of its `true`s on another + /// proposal on that version but on one dead here. A node asks it at the history its + /// vote would build on (`Store::state_at`), before it casts one. + pub(crate) fn may_back( + &self, + party: &str, + proposal: &Id, + current: &Version, + ) -> Result<(), Refused> { + let backed: BTreeSet = self + .signed() + .filter_map(|(_, other, _)| match &other.does { + Does::Vote { + on, + proposal: voted, + yes: true, + } if other.party == party && *on == current.hash && voted != proposal => { + Some(*voted) + } + _ => None, + }) + .collect(); + if backed.iter().any(|other| !self.tally(current, other).dead) { + return Err(Refused::new( + "its party backs another proposal on that version, not dead", + )); + } + Ok(()) + } + /// Whether a version event is taken here, at its history, `current` the version current /// there. One whose proposal passed but doesn't read as a version, it doesn't refuse: /// a later continuum may read it (`Fold::stops`). -- cgit v1.3.1