From c64fcc05d8c53bee99ab039bd709039afb730cdd Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 18 Nov 2026 18:49:50 +0000 Subject: federation: a node stops at a version it doesn't read A version event writing a proposal passed on the version a node reads, which doesn't read as a version there (of a later federation, using what a later continuum takes, or none at all), the node can't judge: `Fold::stops`. The store stops at it: it takes nothing and refuses nothing from then on, holding back whatever comes, that event first (`Offered::Stopped`), and keeps none of it across a restart, where it stops there again. One beside the version the node reads is refused of its own, as any other. Its operator has it drop that event (`POST /admin/events/drop`), or one it builds on: it is refused as dropped, or as built on what was, any version event writing that version with it, kept in the store file; the node judges what it held back and goes on under the version before. Allowed again, it stops there once more. The node logs the stop and its end; `GET /events` names the event, why, and how many it holds back (`stopped`); a put answers `stopped`, written into the document all the same; a node voting by itself casts nothing while stopped. The test fold's eras tagged `new` stop a store. Row 39 is tested (`federation_attack_39`); of rows 9, 10 and 48, a node stops at the version event. --- src/federation/fold.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/federation/fold.rs') diff --git a/src/federation/fold.rs b/src/federation/fold.rs index f37c213..fddedc0 100644 --- a/src/federation/fold.rs +++ b/src/federation/fold.rs @@ -484,7 +484,8 @@ impl State { } /// Whether a version event is taken here, at its history, `current` the version current - /// there. + /// there. One whose proposal passed but doesn't read as a version, it doesn't refuse: + /// a later continuum may read it (`Fold::stops`). fn judge_version(&self, deps: &[Id], hash: &Id, current: &Version) -> Result<(), Refused> { if !self.proposed_on(hash, ¤t.hash) { return Err(Refused::new( @@ -494,8 +495,9 @@ impl State { if !self.tally(current, hash).passed { return Err(Refused::new("its proposal hasn't passed at its history")); } - let next = Version::read(&self.proposed[hash]) - .map_err(|why| Refused::new(format!("no version: {why}")))?; + let Ok(next) = Version::read(&self.proposed[hash]) else { + return Ok(()); + }; next.changes_validly(Some(current)) .map_err(|why| Refused::new(format!("no version: {why}")))?; if let Some(heads) = &next.checkpoint { @@ -627,6 +629,19 @@ impl Fold for Federation { state.events.insert(*id, Held { event, under }); } + /// A version event whose proposal passed at its history but doesn't read as a version + /// here, changing the version the node reads: one a later continuum may read + /// (`docs/federation.md`, Changing the federation). Beside the version the node reads, + /// it is refused as any other (`keeps`). + fn stops(at: &State, now: &State, _id: &Id, bytes: &[u8]) -> Option { + let Some(Event::Version { version, .. }) = Event::read_taken(bytes) else { + return None; + }; + let why = Version::read(at.proposed.get(&version)?).err()?; + (at.current().hash == now.current().hash) + .then(|| format!("version {version} passed, and doesn't read as one here: {why}")) + } + fn keeps(now: &State, _id: &Id, bytes: &[u8]) -> bool { match Event::read_taken(bytes) { Some(Event::Version { version, .. }) => { -- cgit v1.3.1