From 11dd3eda0526030bd8f15167a10a2168accb8d93 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 21 Nov 2026 23:11:02 +0000 Subject: roots: a joiner shakes hands again with a seed that says it's ready A seed that named no root, joining itself, names it once ready, but only from this build on: a 0.0.1 seed never shakes hands again, and its joiner waited for ever. scripts/wire-check hit that, d of this tree joining through c of 0.0.1, their handshake 6 ms before c was ready. So the joiner does its half too: where a seed it still waits for named none, a STATUS saying the seed became ready has it shake hands with the seed again (seed_ready), which then names its root. --- CHANGELOG.md | 3 ++- docs/access.md | 4 +++- src/swarm/peer/keepalive.rs | 2 ++ src/swarm/roots.rs | 18 +++++++++++++++++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98e3bbb..f01a619 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ it from the release before ([`docs/operations.md`](docs/operations.md), * A node joining through a seed that is joining itself no longer waits for ever: a seed names the swarm's root once it has it, shaking hands again with each peer it named - none to ([`docs/access.md`](docs/access.md); [`src/swarm/roots.rs`](src/swarm/roots.rs)). + none to, and a joiner shaking hands again with a seed of any build once it says it is + ready ([`docs/access.md`](docs/access.md); [`src/swarm/roots.rs`](src/swarm/roots.rs)). * The feature `most` builds every transport, the dashboard and the federation at once, as development does throughout ([`docs/development.md`](docs/development.md); diff --git a/docs/access.md b/docs/access.md index 5153b16..f9375df 100644 --- a/docs/access.md +++ b/docs/access.md @@ -396,7 +396,9 @@ nor starts it. So without `--genesis-root`, the root is the one the seeds that a within that wait agree on, none while any peer names another: one seed hands a joiner another root only if it is all the joiner hears of its seeds by then; with `--genesis-root`, never. A seed joining itself names no root until it has one: once -ready, it shakes hands again with every peer it named none to. +ready, it shakes hands again with every peer it named none to; and a joining node shakes +hands again with a seed that named none once it says it is ready, as a seed of an older +build doesn't. What it doesn't do yet: diff --git a/src/swarm/peer/keepalive.rs b/src/swarm/peer/keepalive.rs index b4daf53..51ff14a 100644 --- a/src/swarm/peer/keepalive.rs +++ b/src/swarm/peer/keepalive.rs @@ -295,6 +295,8 @@ pub(super) async fn note_status(state: &AppState, peer: &str, remote: &transport // We may have left the opening to it while it wasn't ready, and nothing else // would make us look again. state.request_sync(peer); + // A seed that named no root, joining itself then, names it now. + crate::swarm::roots::seed_ready(state, peer); } } crate::swarm::source::reported(state, peer, remote.ready, Some(remote.syncs_with_you)); diff --git a/src/swarm/roots.rs b/src/swarm/roots.rs index c0aa4ea..1df0129 100644 --- a/src/swarm/roots.rs +++ b/src/swarm/roots.rs @@ -16,7 +16,8 @@ //! neither ends the wait nor starts its clock, only disputes. One seed hands a joiner //! another root only if it is all the joiner hears of its seeds within the wait. A //! seed naming none, joining itself, names it once ready, in a handshake again with -//! each peer it named none to (`named_to`, `unnamed`). +//! each peer it named none to (`named_to`, `unnamed`); and a joiner, with a seed +//! that named none, once it says it is ready (`seed_ready`), for older seeds. use std::collections::{HashMap, HashSet}; use std::time::Duration; @@ -194,6 +195,21 @@ pub(crate) fn seed_found(state: &AppState, node: &str) { } } +/// `peer` says it is ready now (a STATUS): where it is a seed this node still waits for, +/// and named no root in its handshake (joining itself then), a handshake again has it +/// name one. A seed whose build does so itself (`unnamed`) does it anyway: this is for +/// those that don't. +pub(crate) fn seed_ready(state: &AppState, peer: &str) { + let ask = { + let roots = state.roots.lock_or_recover(); + roots.awaiting.is_some() && roots.seeds.contains(peer) && !roots.named.contains_key(peer) + }; + if ask { + let (state, peer) = (state.clone(), peer.to_owned()); + tokio::spawn(async move { crate::swarm::peer::rehandshake(&state, &peer).await }); + } +} + /// Until when a joining node still waits for its seeds to name the swarm's root, if it /// waits on a clock (`await_seeds`): then `repin`. pub(crate) fn waiting_until(state: &AppState) -> Option { -- cgit v1.3.1