aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/vote.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-25 15:20:37 +0000
committertv <tv@krebsco.de>2026-11-25 15:20:37 +0000
commit46fc2ab070b5f8d3cd6c8bd0d6bd15c624a061e5 (patch)
tree880459c95224d1882ca847e0b607c8c78ef151b4 /src/federation/vote.rs
parent1656f73b41a3528048c33774457b0d68ed430934 (diff)
federation: a node votes false by no rule: --store-nay-beside is gone
A node following a party copies no false, so a followed key voting twice finds nobody to end the first of its two checkpoints. With --store-nay-beside its followers cast that false by rule: it showed each checkpoint to some of them, voted false on one itself, had them end it and move to the other, and passed the first with the rest. Two checkpoint versions on one, by one key, in a federation of any size. The rule was there for two checkpoints proposed at once, which a node's wait before it proposes makes rare. Where they stay proposed, neither with two thirds, their parties end one by hand: the checkpoints guide says how (Two proposed at once). Row 59 says so, and its simulation has the one two thirds back pass, with no false cast. An option that is gone is named so, with what to do (config::GONE), on the command line and in a configuration file, where "unknown option" would leave an operator guessing.
Diffstat (limited to 'src/federation/vote.rs')
-rw-r--r--src/federation/vote.rs137
1 files changed, 0 insertions, 137 deletions
diff --git a/src/federation/vote.rs b/src/federation/vote.rs
index baf8dd0..0bad500 100644
--- a/src/federation/vote.rs
+++ b/src/federation/vote.rs
@@ -55,8 +55,6 @@ pub(crate) struct Rules {
/// How long it holds an event before it holds it for a while: the voters' rule, and how
/// long a new proposal holds back a checkpoint.
pub(crate) held_for: Duration,
- /// Voting `false` on a checkpoint proposed beside one it backs.
- pub(crate) nay_beside: bool,
/// How long its store holds its checkpoint, or runs, before it backs or proposes a
/// later one.
pub(crate) back_after: Duration,
@@ -382,9 +380,6 @@ pub(crate) fn decide(seen: &Seen<'_>, rules: &Rules, record: &Record) -> Vec<Act
});
}
}
- if rules.nay_beside {
- acts.extend(beside(&current, &all, &acts, record, &nays));
- }
if !backed && let Some(version) = checkpoint(seen, rules, &current, &all) {
let hash = Id::of(&version.bytes());
if record
@@ -397,64 +392,6 @@ pub(crate) fn decide(seen: &Seen<'_>, rules: &Rules, record: &Record) -> Vec<Act
acts
}
-/// The votes `false` a node casts beside what it backs: where its party backs a proposal on
-/// `current` that can still pass, by its `record` or by `acts`, on every other proposal
-/// that only moves to a checkpoint and can still pass, but where it votes already.
-fn beside(
- current: &Version,
- all: &[Proposed],
- acts: &[Act],
- record: &Record,
- nays: &[Vec<u8>],
-) -> Vec<Act> {
- let voting: BTreeSet<Id> = acts
- .iter()
- .filter_map(|act| match act {
- Act::Vote { proposal, .. } => Some(*proposal),
- Act::Propose(_) => None,
- })
- .collect();
- let backs: BTreeSet<Id> = record
- .backs(&current.hash)
- .into_iter()
- .chain(acts.iter().filter_map(|act| match act {
- Act::Vote {
- proposal,
- yes: true,
- ..
- } => Some(*proposal),
- _ => None,
- }))
- .collect();
- let backing = all
- .iter()
- .any(|proposed| backs.contains(&proposed.hash) && alive(current, proposed));
- if !backing {
- return Vec::new();
- }
- all.iter()
- .filter(|proposed| {
- !backs.contains(&proposed.hash)
- && !voting.contains(&proposed.hash)
- && alive(current, proposed)
- && proposed
- .version
- .as_ref()
- .is_some_and(|version| version.only_moves_on(current))
- })
- .filter(|proposed| {
- record
- .may_vote(current, proposed.hash, &proposed.json, false, nays)
- .is_ok()
- })
- .map(|proposed| Act::Vote {
- proposal: proposed.hash,
- yes: false,
- nays: Vec::new(),
- })
- .collect()
-}
-
/// A vote by hand, cast through the node that votes for its party, which keeps its
/// party's one record: `yes` on the proposal of hash `proposal` on the current version, by
/// the record, and with a `true` by the voters' rule; or why not.
@@ -1180,78 +1117,4 @@ mod tests {
let record = super::tests::record(&apart, "tv");
assert!(decide(&seen(&apart, &held), &rules, &record).is_empty());
}
-
- /// Two checkpoints proposed at once: a node backing one votes `false` on the other by
- /// its rule, and on nothing else; without the rule, on nothing.
- #[test]
- fn a_node_votes_false_on_a_checkpoint_beside_the_one_it_backs() {
- let (tv, lass, _, first, mut store) = three();
- let root = store.id();
- let on = first.hash();
- let here = taken(
- &mut store,
- tv.write(&[root], "home/tv/a", harness::str("1")),
- );
- let there = taken(
- &mut store,
- lass.write(&[root], "home/lass/b", harness::str("1")),
- );
- let (mut one, mut two) = (first.after(on), first.after(on));
- one.checkpoint = Some(vec![here]);
- two.checkpoint = Some(vec![there]);
- let mut other = first.after(on);
- other.rules.push(("names/x".to_owned(), harness::str("tv")));
- let proposing = tv.propose(&[here], &one.json());
- let mut record = record(&store, "tv");
- record.signed(&proposing);
- let proposal = taken(&mut store, proposing);
- let by_lass = [
- taken(&mut store, lass.propose(&[there], &two.json())),
- taken(&mut store, lass.propose(&[root], &other.json())),
- ];
- // lass's, held since its proposals came, after tv proposed.
- let long = |id: &Id| {
- Some(if *id == there || by_lass.contains(id) {
- Duration::from_secs(60)
- } else {
- Duration::from_secs(3600)
- })
- };
- let rules = Rules {
- nay_beside: true,
- ..Rules::default()
- };
- // Backing its own, this round: `false` on the other checkpoint, not on the version
- // that changes more.
- let acts = decide(&seen(&store, &long), &rules, &record);
- assert_eq!(acts.len(), 2, "{acts:?}");
- assert!(acts.contains(&Act::Vote {
- proposal: one.hash(),
- yes: true,
- nays: Vec::new()
- }));
- assert!(acts.contains(&Act::Vote {
- proposal: two.hash(),
- yes: false,
- nays: Vec::new()
- }));
- let quiet = Rules::default();
- assert_eq!(decide(&seen(&store, &long), &quiet, &record).len(), 1);
- // Its `true` recorded and taken: `false` on the other, once.
- let yes = tv.vote(&[proposal], on, one.hash(), true);
- record.cast(store.state().current(), &yes, Vec::new());
- taken(&mut store, yes);
- let acts = decide(&seen(&store, &long), &rules, &record);
- assert_eq!(
- acts,
- vec![Act::Vote {
- proposal: two.hash(),
- yes: false,
- nays: Vec::new()
- }]
- );
- let no = tv.vote(&[proposal], on, two.hash(), false);
- record.cast(store.state().current(), &no, Vec::new());
- assert!(decide(&seen(&store, &long), &rules, &record).is_empty());
- }
}