From dbbd2c183f96662195eb2e89ffa1066eaad3bb09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 12 Feb 2026 12:14:42 -0300 Subject: [PATCH] fix: encode topic len as LE in compute_message_id According to the spec, the message ID should encode the topic len in little-endian. Encoding it as big-endian doesn't make a practical difference, but it's better to follow the spec. --- crates/net/p2p/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/net/p2p/src/lib.rs b/crates/net/p2p/src/lib.rs index 7524499..b83196f 100644 --- a/crates/net/p2p/src/lib.rs +++ b/crates/net/p2p/src/lib.rs @@ -506,7 +506,7 @@ fn compute_message_id(message: &libp2p::gossipsub::Message) -> libp2p::gossipsub Err(_) => (MESSAGE_DOMAIN_INVALID_SNAPPY, &message.data), }; let topic = message.topic.as_str().as_bytes(); - let topic_len = (topic.len() as u64).to_be_bytes(); + let topic_len = (topic.len() as u64).to_le_bytes(); hasher.update(domain); hasher.update(topic_len); hasher.update(topic);