Skip to content

Commit da003b0

Browse files
authored
fix(gossipsub): change message to message_id in trace
I was trying to parse the tracing logs for a simulator and I noticed that fields were duplicated. this PR changes the message field to message_id which makes it more coherent as well. ![Screenshot 2025-04-05 at 4 26 34 PM](https://github.com/user-attachments/assets/79edffa6-1551-4381-86d3-d0cc4676eb0c) (3rd line) - [x] I have performed a self-review of my own code - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] A changelog entry has been made in the appropriate crates Pull-Request: #5972.
1 parent f4322c5 commit da003b0

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

protocols/gossipsub/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## 0.49.0
2+
- Improve log messaging by renaming `message` to `message_id`. This change makes it log coherent to
3+
the field and also improve duplication of `message` field.
4+
See [PR 5972](https://github.com/libp2p/rust-libp2p/pull/5972)
25

36
- Fix a race condition for messages published which are already in the network.
47
See [PR 5928](https://github.com/libp2p/rust-libp2p/pull/5928)

protocols/gossipsub/src/behaviour.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,13 @@ where
614614
// This message has already been seen. We don't re-publish messages that have already
615615
// been published on the network.
616616
tracing::warn!(
617-
message=%msg_id,
617+
message_id=%msg_id,
618618
"Not publishing a message that has already been published"
619619
);
620620
return Err(PublishError::Duplicate);
621621
}
622622

623-
tracing::trace!(message=%msg_id, "Publishing message");
623+
tracing::trace!(message_id=%msg_id, "Publishing message");
624624

625625
let topic_hash = raw_message.topic.clone();
626626

@@ -773,7 +773,7 @@ where
773773
self.send_idontwant(&raw_message, &msg_id, raw_message.source.as_ref());
774774
}
775775

776-
tracing::debug!(message=%msg_id, "Published message");
776+
tracing::debug!(message_id=%msg_id, "Published message");
777777

778778
if let Some(metrics) = self.metrics.as_mut() {
779779
metrics.register_published_message(&topic_hash);
@@ -815,7 +815,7 @@ where
815815
}
816816
None => {
817817
tracing::warn!(
818-
message=%msg_id,
818+
message_id=%msg_id,
819819
"Message not in cache. Ignoring forwarding"
820820
);
821821
if let Some(metrics) = self.metrics.as_mut() {
@@ -861,7 +861,7 @@ where
861861
}
862862
true
863863
} else {
864-
tracing::warn!(message=%msg_id, "Rejected message not in cache");
864+
tracing::warn!(message_id=%msg_id, "Rejected message not in cache");
865865
false
866866
}
867867
}
@@ -1344,13 +1344,13 @@ where
13441344
if count > self.config.gossip_retransimission() {
13451345
tracing::debug!(
13461346
peer=%peer_id,
1347-
message=%id,
1347+
message_id=%id,
13481348
"IWANT: Peer has asked for message too many times; ignoring request"
13491349
);
13501350
} else {
13511351
if let Some(peer) = self.connected_peers.get_mut(peer_id) {
13521352
if peer.dont_send.contains_key(&id) {
1353-
tracing::debug!(%peer_id, message=%id, "Peer already sent IDONTWANT for this message");
1353+
tracing::debug!(%peer_id, message_id=%id, "Peer already sent IDONTWANT for this message");
13541354
continue;
13551355
}
13561356
}
@@ -1662,7 +1662,7 @@ where
16621662
) -> bool {
16631663
tracing::debug!(
16641664
peer=%propagation_source,
1665-
message=%msg_id,
1665+
message_id=%msg_id,
16661666
"Handling message from peer"
16671667
);
16681668

@@ -1721,7 +1721,7 @@ where
17211721

17221722
if self_published {
17231723
tracing::debug!(
1724-
message=%msg_id,
1724+
message_id=%msg_id,
17251725
source=%propagation_source,
17261726
"Dropping message claiming to be from self but forwarded from source"
17271727
);
@@ -1782,7 +1782,7 @@ where
17821782
}
17831783

17841784
if !self.duplicate_cache.insert(msg_id.clone()) {
1785-
tracing::debug!(message=%msg_id, "Message already received, ignoring");
1785+
tracing::debug!(message_id=%msg_id, "Message already received, ignoring");
17861786
if let Some((peer_score, ..)) = &mut self.peer_score {
17871787
peer_score.duplicated_message(propagation_source, &msg_id, &message.topic);
17881788
}
@@ -1791,7 +1791,7 @@ where
17911791
}
17921792

17931793
tracing::debug!(
1794-
message=%msg_id,
1794+
message_id=%msg_id,
17951795
"Put message in duplicate_cache and resolve promises"
17961796
);
17971797

@@ -1837,7 +1837,7 @@ where
18371837
Some(propagation_source),
18381838
HashSet::new(),
18391839
);
1840-
tracing::debug!(message=%msg_id, "Completed message handling for message");
1840+
tracing::debug!(message_id=%msg_id, "Completed message handling for message");
18411841
}
18421842
}
18431843

@@ -2672,7 +2672,7 @@ where
26722672
}
26732673
}
26742674

2675-
tracing::debug!(message=%msg_id, "Forwarding message");
2675+
tracing::debug!(message_id=%msg_id, "Forwarding message");
26762676
let mut recipient_peers = HashSet::new();
26772677

26782678
// Populate the recipient peers mapping
@@ -2715,11 +2715,11 @@ where
27152715
for peer_id in recipient_peers.iter() {
27162716
if let Some(peer) = self.connected_peers.get_mut(peer_id) {
27172717
if peer.dont_send.contains_key(msg_id) {
2718-
tracing::debug!(%peer_id, message=%msg_id, "Peer doesn't want message");
2718+
tracing::debug!(%peer_id, message_id=%msg_id, "Peer doesn't want message");
27192719
continue;
27202720
}
27212721

2722-
tracing::debug!(%peer_id, message=%msg_id, "Sending message to peer");
2722+
tracing::debug!(%peer_id, message_id=%msg_id, "Sending message to peer");
27232723

27242724
self.send_message(
27252725
*peer_id,

0 commit comments

Comments
 (0)