Skip to content

Commit 1a8f96f

Browse files
committed
Gossipsub fast message id change (#3755)
For improved consistency, this mixes in the topic into our fast message id for more consistent tracking of messages across topics.
1 parent 6b325d4 commit 1a8f96f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

beacon_node/lighthouse_network/src/config.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,11 @@ impl From<u8> for NetworkLoad {
288288
/// Return a Lighthouse specific `GossipsubConfig` where the `message_id_fn` depends on the current fork.
289289
pub fn gossipsub_config(network_load: u8, fork_context: Arc<ForkContext>) -> GossipsubConfig {
290290
// The function used to generate a gossipsub message id
291-
// We use the first 8 bytes of SHA256(data) for content addressing
292-
let fast_gossip_message_id =
293-
|message: &RawGossipsubMessage| FastMessageId::from(&Sha256::digest(&message.data)[..8]);
291+
// We use the first 8 bytes of SHA256(topic, data) for content addressing
292+
let fast_gossip_message_id = |message: &RawGossipsubMessage| {
293+
let data = [message.topic.as_str().as_bytes(), &message.data].concat();
294+
FastMessageId::from(&Sha256::digest(data)[..8])
295+
};
294296
fn prefix(
295297
prefix: [u8; 4],
296298
message: &GossipsubMessage,

0 commit comments

Comments
 (0)