diff options
| author | tv <tv@krebsco.de> | 2026-11-18 18:49:50 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-18 20:29:41 +0100 |
| commit | c64fcc05d8c53bee99ab039bd709039afb730cdd (patch) | |
| tree | 45baad78d7b92de42283be2954fc3f9b4dd6129d /src/api | |
| parent | 598366b03679eac9d04f32d9194f3ba4ba9c3da8 (diff) | |
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.
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/events.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/api/events.rs b/src/api/events.rs index 04dc77e..bd6db70 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -81,16 +81,21 @@ fn why(refusal: &Refusal) -> String { } /// `GET /events`: the store's ID, its checkpoint's, its heads, how many events it took -/// after its checkpoint, the node's party, and whether the node votes for it by itself. +/// after its checkpoint, the event it stopped at, if any, the node's party, and whether +/// the node votes for it by itself. async fn summary(State(state): State<AppState>) -> Response { let party = state.holding.party().map(str::to_owned); let votes = state.holding.votes_by_itself(); with_store(&state, |store| { + let stopped = store + .stopped() + .map(|(id, why, held)| json!({"id": id.to_string(), "why": why, "heldBack": held})); json!({ "store": store.id().to_string(), "checkpoint": Id::of(store.checkpoint()).to_string(), "heads": ids(store.heads()), "taken": store.taken().len(), + "stopped": stopped, "party": party, "votesByItself": votes, }) @@ -218,7 +223,7 @@ async fn refused(State(state): State<AppState>) -> Response { /// `POST /events`: puts an event, the request's body, whoever signed it: offered to the /// store, and written into the document at its ID unless the store refuses it. Taken, -/// held already, or waiting for what it builds on. +/// held already, waiting for what it builds on, or held back, the store stopped. async fn put( State(state): State<AppState>, Extension(AuthenticatedUser(user)): Extension<AuthenticatedUser>, @@ -238,6 +243,7 @@ async fn put( Some(Offered::Taken(_)) => "taken", Some(Offered::Held) => "held", Some(Offered::Waiting) => "waiting", + Some(Offered::Stopped) => "stopped", }; match crate::federation::held::write(&state, Some(user), bytes).await { Ok(()) => Json(json!({"id": id.to_string(), "event": became})).into_response(), @@ -359,10 +365,10 @@ async fn check_fork(State(state): State<AppState>, body: Bytes) -> Response { } } -/// `POST /admin/events/drop`: drops events the store took after its checkpoint, with -/// everything built on them, as the operator has the node do: it refuses them from then -/// on, from whoever brings them, and keeps so across restarts (`--store-file`). What it -/// dropped, in the order taken. +/// `POST /admin/events/drop`: drops events the store took after its checkpoint, or the +/// one it stopped at, with everything built on them, as the operator has the node do: it +/// refuses them from then on, from whoever brings them, and keeps so across restarts +/// (`--store-file`). What it dropped, in the order taken, then the one it stopped at. async fn drop_taken(State(state): State<AppState>, Json(named): Json<Named>) -> Response { let named = match named.ids() { Ok(ids) => ids, |
