From fb54044c688e0252b4af54a057151b9c4d4ccf98 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 24 Nov 2026 18:58:32 +0000 Subject: 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. --- src/federation/fold.rs | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/federation/fold.rs') 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 = 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(()) } -- cgit v1.3.1