aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/fold.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-25 12:43:51 +0000
committertv <tv@krebsco.de>2026-11-25 12:43:51 +0000
commit055e09b3410040e4300238ac5d0a53fdc2726e40 (patch)
tree76bc574f812b683a20cc34833a3fd3481845c3c7 /src/federation/fold.rs
parent2085f8fa1b7f4d5c5011479cbf1f3d6fac6545a2 (diff)
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.
Diffstat (limited to 'src/federation/fold.rs')
-rw-r--r--src/federation/fold.rs53
1 files changed, 32 insertions, 21 deletions
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<Id> = 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<Id> = 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`).