diff options
| author | tv <tv@krebsco.de> | 2026-11-19 14:42:45 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-19 15:53:14 +0100 |
| commit | 33be6b959c9777c40ca2b16507e9f4f60d6d2d44 (patch) | |
| tree | 9939a86e950edeeac619798f46a6c42c3bc9388b /src/federation/held.rs | |
| parent | a67c96469d2d06e85c4be69a725af7b93fb023a2 (diff) | |
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.
Diffstat (limited to 'src/federation/held.rs')
| -rw-r--r-- | src/federation/held.rs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/federation/held.rs b/src/federation/held.rs index 6e00e51..9c87995 100644 --- a/src/federation/held.rs +++ b/src/federation/held.rs @@ -29,7 +29,7 @@ use anyhow::{Context, Result, bail}; use serde::{Deserialize, Serialize}; use tracing::{error, info, warn}; -use super::client::Record; +use super::client::{self, Record}; use super::event::{self, Does, Event, Signed}; use super::fold::Federation; use super::revision::Feature; @@ -740,11 +740,14 @@ impl Holding { yes, nays, } => { - // On the events proposing it, those above the heads it names for a - // checkpoint, so a version event may be written on it, which the - // node's heads, holding what is beside them, may not be. - let proposing = store.state().proposing(¤t.hash, &proposal); - if proposing.is_empty() { + // On an event proposing it, of a checkpoint one above the heads it + // names, so a version event may be written on it, which the node's + // heads, holding what is beside them, may not be; and on the nays that + // freed its party (`client::building`). + let state = store.state(); + let Some(proposing) = + state.proposing(¤t.hash, &proposal).first().copied() + else { if hand.is_some() { return Err(format!( "no event proposing {proposal} is above the heads it names: \ @@ -752,12 +755,22 @@ impl Holding { )); } continue; - } + }; + let checkpoint = state + .proposal(&proposal) + .and_then(|json| Version::read(json).ok()) + .and_then(|version| version.checkpoint) + .is_some(); + let on = match client::building(proposing, checkpoint, &nays) { + Ok(on) => on, + Err(why) if hand.is_some() => return Err(why), + Err(_) => continue, + }; let cast = event::signed( &voter.key, party, &line, - &proposing, + &on, event::vote(current.hash, proposal, yes), ); record.cast(¤t, &cast, nays); |
