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/vote.rs | 99 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) (limited to 'src/federation/vote.rs') diff --git a/src/federation/vote.rs b/src/federation/vote.rs index e96cb22..baf8dd0 100644 --- a/src/federation/vote.rs +++ b/src/federation/vote.rs @@ -236,6 +236,47 @@ pub(crate) fn backs_checkpoint( } } +/// What a vote of `party` on the proposal of hash `proposal` builds on in `store`: an +/// event proposing it, of a checkpoint one above the heads it names, so that a version +/// event may be written on the vote; and, but for a checkpoint, the nays that freed its +/// party (`client::building`). Why not, where there is none, or where the store refuses a +/// `true` built so: the party backs another proposal that isn't dead at that history, its +/// nays cast beside a checkpoint's heads, say. Such a vote counts nowhere, so a node +/// casts and records none. +pub(crate) fn builds_on( + store: &Store, + party: &str, + proposal: &Id, + yes: bool, + nays: &[Vec], +) -> Result, String> { + let state = store.state(); + let current = state.current(); + let proposing = state + .proposing(¤t.hash, proposal) + .first() + .copied() + .ok_or_else(|| { + format!( + "no event proposing {proposal} is above the heads it names: no version \ + event is written on a vote on it" + ) + })?; + let checkpoint = state + .proposal(proposal) + .and_then(|json| Version::read(json).ok()) + .and_then(|version| version.checkpoint) + .is_some(); + let on = super::client::building(proposing, checkpoint, nays)?; + if yes { + store + .state_at(&on) + .may_back(party, proposal, current) + .map_err(|why| format!("no store takes that vote: {}", why.0))?; + } + Ok(on) +} + /// Whether a proposal can still pass: not dead by the votes cast. fn alive(current: &Version, proposed: &Proposed) -> bool { let parties = current.parties.len(); @@ -330,7 +371,9 @@ pub(crate) fn decide(seen: &Seen<'_>, rules: &Rules, record: &Record) -> Vec