Skip to content

Commit

Permalink
Gossipsub fast message id change (sigp#3755)
Browse files Browse the repository at this point in the history
For improved consistency, this mixes in the topic into our fast message id for more consistent tracking of messages across topics.
  • Loading branch information
AgeManning committed Nov 28, 2022
1 parent c881b80 commit 2779017
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions beacon_node/lighthouse_network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,11 @@ impl From<u8> for NetworkLoad {
/// Return a Lighthouse specific `GossipsubConfig` where the `message_id_fn` depends on the current fork.
pub fn gossipsub_config(network_load: u8, fork_context: Arc<ForkContext>) -> GossipsubConfig {
// The function used to generate a gossipsub message id
// We use the first 8 bytes of SHA256(data) for content addressing
let fast_gossip_message_id =
|message: &RawGossipsubMessage| FastMessageId::from(&Sha256::digest(&message.data)[..8]);
// We use the first 8 bytes of SHA256(topic, data) for content addressing
let fast_gossip_message_id = |message: &RawGossipsubMessage| {
let data = [message.topic.as_str().as_bytes(), &message.data].concat();
FastMessageId::from(&Sha256::digest(data)[..8])
};
fn prefix(
prefix: [u8; 4],
message: &GossipsubMessage,
Expand Down

0 comments on commit 2779017

Please sign in to comment.