From 33be6b959c9777c40ca2b16507e9f4f60d6d2d44 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 14:42:45 +0000 Subject: vote: a second `true` builds on the nays that freed its party The federation takes a party's `true` only where, at its history, every other proposal it backed on that version is dead. A party's client, and a node voting by itself, built a vote on the events proposing what it votes on alone. A proposal made while the party's first `true` was alive, at a history holding it, holds that `true` in its history, and not the nays that ended the first proposal later: the party's `true` on it was refused, though its record cast it. The compromise case: five back X, Y is proposed, X dies, its backers back Y. A vote now builds on one event proposing what it votes on, and on the nays that freed its party (`client::building`), so the first proposal is dead at its history too. One event proposing it is enough, so many proposing it again don't push a vote past the dependencies an event may name. A checkpoint's vote builds on its proposal alone: one of those nays in the history of its heads, named, would put the vote beside them. A party freed only after the heads were named backs that checkpoint not, and its client says so before casting; it backs one proposed after. Row 74 is tested (`federation_attack_74`); federation.md and the guides say so. --- src/federation/party.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/federation/party.rs') diff --git a/src/federation/party.rs b/src/federation/party.rs index f64746b..a544155 100644 --- a/src/federation/party.rs +++ b/src/federation/party.rs @@ -836,9 +836,23 @@ async fn vote( eprintln!("Warning: {why}"); } } - // On the events proposing it the node shows, those above the heads it names for a - // checkpoint, so a version event may be written on it. - let cast = signer.sign(&proposals, event::vote(current.hash, proposal, yes))?; + // On an event proposing it the node shows, of a checkpoint one above the heads it + // names, and on the nays that freed the party (`client::building`). + let checkpoint = Version::read(&proposed) + .ok() + .and_then(|version| version.checkpoint) + .is_some(); + if checkpoint && yes && !kept.is_empty() { + eprintln!( + "Warning: this `true` builds on {proposing} alone, not on the nays that freed \ + {party}: where they came after the heads it names, and {party}'s `true` they \ + ended is in the history of {proposing}, nodes refuse it; a checkpoint proposed \ + after them takes {party}'s `true`", + party = signer.party + ); + } + let on = client::building(proposing, checkpoint, &kept).map_err(|why| anyhow!(why))?; + let cast = signer.sign(&on, event::vote(current.hash, proposal, yes))?; record.cast(¤t, &cast, kept); record.save(path).map_err(|why| anyhow!(why))?; node.put(&cast).await -- cgit v1.3.1