aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-19 16:13:53 +0000
committertv <tv@krebsco.de>2026-11-19 17:35:42 +0100
commit866c6a402e65f9102e63cebdf5a50c0a3f526260 (patch)
tree8e3051bdebb3f136dee5bbcda1ad6de723b2f171 /src/transport
parent180e5ad1d1d144f5e9f9168094a0ec0417b64a61 (diff)
wire: a peer on another version is named older or newer, with what to upgrade
A node meeting messages of a wire version it doesn't speak logged `Peer speaks another wire version (another build)`, with the versions as fields only. It says now, in the message, which build is the newer and which node to upgrade: this one, where the peer's is newer (`upgrade this node to talk with it`), else the peer's (`upgrade that node`), with the peer's version and the ones this build speaks. Its fields are the peer's version and the oldest and newest this build speaks.
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/wire.rs47
1 files changed, 42 insertions, 5 deletions
diff --git a/src/transport/wire.rs b/src/transport/wire.rs
index abaa408..0b661dd 100644
--- a/src/transport/wire.rs
+++ b/src/transport/wire.rs
@@ -135,9 +135,9 @@ pub(crate) fn encode(message: &ParsedMessage) -> Result<Vec<u8>, WireError> {
const MAX_OTHER_VERSIONS: usize = 1024;
/// Senders whose messages are of another wire version (`WireError::Version`): each
-/// logged once, at warn level, so two builds that don't speak to each other say so,
-/// instead of silently retrying their HELLOs for good. Bounded: anyone can send us
-/// anything.
+/// logged once, at warn level, so two builds that don't speak to each other say so, and
+/// which of them to upgrade, instead of silently retrying their HELLOs for good. Bounded:
+/// anyone can send us anything.
#[derive(Default)]
pub(crate) struct OtherVersions(std::sync::Mutex<std::collections::HashSet<String>>);
@@ -155,13 +155,36 @@ impl OtherVersions {
tracing::warn!(
from = %super::Addressed(scheme, &sender),
version,
- ours = VERSION,
- "Peer speaks another wire version (another build); ignoring its messages"
+ oldest = OLDEST,
+ newest = VERSION,
+ "Peer speaks another wire version: {}; ignoring its messages",
+ other_build(version)
);
}
}
}
+/// Of a peer whose messages are of wire `version`, which this build doesn't speak, what
+/// an operator does: upgrade this node where the peer's build is newer, the peer's where
+/// it is older.
+fn other_build(version: u8) -> String {
+ let ours = if OLDEST == VERSION {
+ VERSION.to_string()
+ } else {
+ format!("{OLDEST} to {VERSION}")
+ };
+ if version > VERSION {
+ format!(
+ "a newer build (wire version {version}; this one speaks {ours}): upgrade this node \
+ to talk with it"
+ )
+ } else {
+ format!(
+ "an older build (wire version {version}; this one speaks {ours}): upgrade that node"
+ )
+ }
+}
+
pub(crate) fn decode(payload: &[u8]) -> Result<ParsedMessage, WireError> {
let (&version, payload) = payload.split_first().ok_or(WireError::Empty)?;
if version == SPEAKS {
@@ -616,6 +639,20 @@ mod tests {
assert!(other.0.lock().unwrap().len() <= MAX_OTHER_VERSIONS);
}
+ /// The warning says which build is the older, the one to upgrade, and both versions.
+ #[test]
+ fn the_older_build_is_named() {
+ let newer = other_build(VERSION + 1);
+ assert!(newer.contains("upgrade this node"), "{newer}");
+ assert!(
+ newer.contains(&format!("wire version {}", VERSION + 1)),
+ "{newer}"
+ );
+ assert!(newer.contains(&format!("speaks {VERSION}")), "{newer}");
+ let older = other_build(OLDEST - 1);
+ assert!(older.contains("upgrade that node"), "{older}");
+ }
+
/// Every kind decodes to what was encoded: re-encoded, the same bytes.
#[test]
fn every_kind_round_trips() {