aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/fold.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-24 18:58:32 +0000
committertv <tv@krebsco.de>2026-11-24 18:58:32 +0000
commitfb54044c688e0252b4af54a057151b9c4d4ccf98 (patch)
tree10e2566a2302ed11e4ec6d96a52e0afde7ad4582 /src/federation/fold.rs
parentc105463a8f4d080c28f39fa07d170e47e8d1eb8e (diff)
federation: no true on a checkpoint at heads no version may name
A version event is refused where the heads its version names for a checkpoint have one in another's history, or aren't after the current checkpoint (may_move). Neither the voters' rule nor what a node tells clients asked that: votes on such a proposal are taken, no version event on them ever is, so nothing lapses, and every party that voted true stays bound until others' nays end it. A followed key proposing one bound all its followers; with two thirds of the parties so, nothing passed on that version again. may_move's part about the heads is may_name now, which backs_checkpoint asks before a true, and GET /events/counts says as none, so that a party's client backs no such proposal either.
Diffstat (limited to 'src/federation/fold.rs')
-rw-r--r--src/federation/fold.rs36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/federation/fold.rs b/src/federation/fold.rs
index c636a13..b96cf1f 100644
--- a/src/federation/fold.rs
+++ b/src/federation/fold.rs
@@ -610,9 +610,30 @@ impl State {
}
/// Whether a version event on `deps` may write a version naming `heads` for a
- /// checkpoint: after the checkpoint current at its history, at which that one is
- /// current too, none in another's history; and the version event above them.
+ /// checkpoint: heads a version may name (`may_name`), and the version event above
+ /// them.
fn may_move(&self, heads: &[Id], deps: &[Id]) -> Result<(), Refused> {
+ self.may_name(heads)?;
+ let named: BTreeSet<Id> = heads.iter().copied().collect();
+ let above = self.above(&named);
+ let is_above = deps
+ .iter()
+ .all(|dep| named.contains(dep) || above.contains(dep))
+ && (deps.iter().any(|dep| above.contains(dep))
+ || named.iter().all(|head| deps.contains(head)));
+ if !is_above {
+ return Err(Refused::new(
+ "not above the heads of the checkpoint it names",
+ ));
+ }
+ Ok(())
+ }
+
+ /// Whether a version written here may name `heads` for a checkpoint: after the
+ /// checkpoint current at its history, at which that one is current too, none in
+ /// another's history. Where not, no version event naming them is taken, whatever it
+ /// builds on: a `true` on such a version binds its party to what is never written.
+ pub(crate) fn may_name(&self, heads: &[Id]) -> Result<(), Refused> {
if heads
.iter()
.any(|a| heads.iter().any(|b| a != b && self.built_on(a, b)))
@@ -655,17 +676,6 @@ impl State {
"checkpoint heads not after the current checkpoint, or at which it isn't current",
));
}
- let above = self.above(&named);
- let is_above = deps
- .iter()
- .all(|dep| named.contains(dep) || above.contains(dep))
- && (deps.iter().any(|dep| above.contains(dep))
- || named.iter().all(|head| deps.contains(head)));
- if !is_above {
- return Err(Refused::new(
- "not above the heads of the checkpoint it names",
- ));
- }
Ok(())
}