aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/peer
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-19 13:33:51 +0000
committertv <tv@krebsco.de>2026-11-19 14:39:52 +0100
commit7a5aeb02024ddff71ba60f40913555cd21a633ad (patch)
treed3d0f1bafd3d39dab02c89a902162c829d6c79f7 /src/swarm/peer
parent03105d40322dff9c18f0571872ab0f643aded0f7 (diff)
transport: SPEAKS, which wire versions a node speaks and what it knows
Before each HELLO and each HELLO_REPLY, a node sends SPEAKS: the oldest and the newest wire version it speaks, and the ID of the newest revision of the federation it knows. It stands outside the wire versions, its first byte 0, which no version is, laid out as no build changes: that byte, the oldest, the newest, then 32 bytes of the revision's ID where there is one; a reader takes those and leaves whatever follows, which a later build may add. So a peer on another build reads it too, and nodes on different builds can say what they run, which a rollout needs. A build from before it takes it for a message of another wire version and logs that once of the peer (version=0), reading the rest of the peer's messages as before: SPEAKS rolls out node by node, with no change of VERSION. The node keeps what each peer said last (`swarm::speaking`, at most 4096 peers). It counts as `hello` traffic. `OLDEST`, the oldest version this build reads, is `VERSION` for now: a range for a later build to widen. operations.md also says what is so of the other-version warning now: every transport logs it once per peer at warn, not Mycelium alone.
Diffstat (limited to 'src/swarm/peer')
-rw-r--r--src/swarm/peer/handshake.rs11
-rw-r--r--src/swarm/peer/inbound.rs8
2 files changed, 18 insertions, 1 deletions
diff --git a/src/swarm/peer/handshake.rs b/src/swarm/peer/handshake.rs
index 4cc0cf4..ef7d379 100644
--- a/src/swarm/peer/handshake.rs
+++ b/src/swarm/peer/handshake.rs
@@ -127,6 +127,7 @@ async fn transmit_hello(state: &AppState, peer: &str) -> Result<()> {
None => 0,
};
state.lock_rtt().hello_sent(peer, Instant::now());
+ say_what_we_speak(state, peer).await;
let result = state
.transport
.send_message(
@@ -169,6 +170,15 @@ async fn transmit_hello(state: &AppState, peer: &str) -> Result<()> {
}
}
+/// Tells `peer` what this build speaks and knows, with each handshake (SPEAKS,
+/// `swarm::speaking`): a build from before SPEAKS ignores it.
+async fn say_what_we_speak(state: &AppState, peer: &str) {
+ let speaks = ParsedMessage::Speaks(crate::swarm::speaking::own());
+ if let Err(error) = state.transport.send_message(peer, &speaks).await {
+ debug!(peer = %peer, error = %format!("{error:#}"), "SPEAKS not sent");
+ }
+}
+
pub(super) async fn ensure_handshake(state: &AppState, peer: &str) {
if let Err(error) = send_hello_once(state, peer).await {
warn!(peer = %peer, error = %format!("{error:#}"), "HELLO failed; will retry");
@@ -247,6 +257,7 @@ pub(super) async fn send_hello_reply(
};
debug!(to = %peer, ready, "Sending HELLO_REPLY");
+ say_what_we_speak(state, peer).await;
state
.transport
diff --git a/src/swarm/peer/inbound.rs b/src/swarm/peer/inbound.rs
index d266e5f..e23ec14 100644
--- a/src/swarm/peer/inbound.rs
+++ b/src/swarm/peer/inbound.rs
@@ -39,6 +39,11 @@ pub(crate) async fn handle_message(
note_alive(state, &peer, &message).await;
return Ok(());
}
+ // SPEAKS only says what the peer's build speaks and knows (`swarm::speaking`).
+ if let ParsedMessage::Speaks(speaks) = message {
+ state.speaking.heard(&peer, speaks);
+ return Ok(());
+ }
// WHO and ME end at the identity layer (`transport::identity`). A sync message names
// its epoch by a tag (`EpochTag`): ours, or the sender's as we know it; one naming
// neither is of an epoch we don't sync on, and says nothing we could record.
@@ -317,7 +322,8 @@ pub(crate) async fn handle_message(
transport::ParsedMessage::Who(_)
| transport::ParsedMessage::Me(_)
| transport::ParsedMessage::Ping(_)
- | transport::ParsedMessage::Pong { .. } => {}
+ | transport::ParsedMessage::Pong { .. }
+ | transport::ParsedMessage::Speaks(_) => {}
}
Ok(())