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/attacks.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/federation/attacks.rs') diff --git a/src/federation/attacks.rs b/src/federation/attacks.rs index 316f5eb..db047c9 100644 --- a/src/federation/attacks.rs +++ b/src/federation/attacks.rs @@ -14,7 +14,7 @@ use super::store::{Fold, Id}; use super::version::Version; /// Rows whose tests wait: what a node or a party's client doesn't do yet, and flooding. -const LATER: &[u32] = &[30, 39, 63, 68]; +const LATER: &[u32] = &[30, 63, 68]; fn tv() -> Party { Party::new("tv", 1) @@ -71,6 +71,14 @@ impl Fed { assert!(matches!(why, Refusal::Judged(_)), "{why:?}"); } + /// An event the store stops at (`Fold::stops`), and its operator has it drop. + fn stops(&mut self, bytes: Vec) { + let id = Id::of(&bytes); + assert_eq!(self.store.offer(bytes), Offered::Stopped); + assert_eq!(self.store.stopped().map(|(at, ..)| *at), Some(id)); + assert_eq!(self.store.drop_taken(&[id]), Ok(vec![id])); + } + fn value(&self, path: &str) -> Option { self.store.state().value(path).cloned() } @@ -277,7 +285,8 @@ fn federation_attack_9() { let proposal = fed.take(tv.propose(&[root], &next.json())); let yes = fed.take(tv.vote(&[proposal], on, next.hash(), true)); let also = fed.take(lass.vote(&[proposal], on, next.hash(), true)); - fed.judged(harness::version_event(&[yes, also], next.hash())); + // None to this continuum, as one it doesn't know: it stops at it. + fed.stops(harness::version_event(&[yes, also], next.hash())); // Free the backers for the next one: nays make it dead. let no = fed.take(makefu().vote(&[proposal], on, next.hash(), false)); fed.take(tv.vote(&[no], on, next.hash(), false)); @@ -299,7 +308,7 @@ fn federation_attack_10() { let hash = Id::of(&unknown.bytes()); let yes = fed.take(tv.vote(&[proposal], on, hash, true)); let also = fed.take(lass.vote(&[proposal], on, hash, true)); - fed.judged(harness::version_event(&[yes, also], hash)); + fed.stops(harness::version_event(&[yes, also], hash)); } #[test] @@ -921,7 +930,7 @@ fn federation_attack_48() { let proposal = fed.take(tv.propose(&[root], &bad.json())); let yes = fed.take(tv.vote(&[proposal], on, bad.hash(), true)); let also = fed.take(lass.vote(&[proposal], on, bad.hash(), true)); - fed.judged(harness::version_event(&[yes, also], bad.hash())); + fed.stops(harness::version_event(&[yes, also], bad.hash())); // It can't die either: its backers are bound. let next = fed.first.after(on); let other = fed.take(makefu().propose(&[root], &next.json())); -- cgit v1.3.1