Skip to content

Commit 7728d5e

Browse files
committed
feat: display hotkeys in P2P gossipsub logs
1 parent 25f0c0c commit 7728d5e

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

crates/p2p-consensus/src/network.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,8 +943,14 @@ impl P2PNetwork {
943943
..
944944
})) => match self.handle_gossipsub_message(propagation_source, &message.data) {
945945
Ok(msg) => {
946+
let hotkey = self
947+
.peer_mapping
948+
.get_hotkey(&propagation_source)
949+
.map(|h| h.to_ss58())
950+
.unwrap_or_else(|| "unknown".to_string());
946951
debug!(
947952
source = %propagation_source,
953+
hotkey = %hotkey,
948954
msg_type = %msg.type_name(),
949955
"Received gossipsub message"
950956
);
@@ -960,8 +966,14 @@ impl P2PNetwork {
960966
}
961967
}
962968
Err(e) => {
969+
// Try to extract hotkey from message for debugging
970+
let hotkey = bincode::deserialize::<SignedP2PMessage>(&message.data)
971+
.ok()
972+
.map(|m| m.signer.to_ss58())
973+
.unwrap_or_else(|| "unknown".to_string());
963974
debug!(
964975
source = %propagation_source,
976+
hotkey = %hotkey,
965977
error = %e,
966978
"Failed to process gossipsub message"
967979
);
@@ -971,7 +983,12 @@ impl P2PNetwork {
971983
peer_id,
972984
topic,
973985
})) => {
974-
info!(peer = %peer_id, topic = %topic, "Peer subscribed to topic");
986+
let hotkey = self
987+
.peer_mapping
988+
.get_hotkey(&peer_id)
989+
.map(|h| h.to_ss58())
990+
.unwrap_or_else(|| "unknown".to_string());
991+
info!(peer = %peer_id, hotkey = %hotkey, topic = %topic, "Peer subscribed to topic");
975992
}
976993
SwarmEvent::Behaviour(CombinedEvent::Kademlia(kad::Event::RoutingUpdated {
977994
peer,
@@ -1309,8 +1326,15 @@ impl NetworkRunner {
13091326
.handle_gossipsub_message(propagation_source, &message.data)
13101327
{
13111328
Ok(msg) => {
1329+
let hotkey = self
1330+
.network
1331+
.peer_mapping
1332+
.get_hotkey(&propagation_source)
1333+
.map(|h| h.to_ss58())
1334+
.unwrap_or_else(|| "unknown".to_string());
13121335
debug!(
13131336
source = %propagation_source,
1337+
hotkey = %hotkey,
13141338
msg_type = %msg.type_name(),
13151339
"Received gossipsub message"
13161340
);
@@ -1326,8 +1350,14 @@ impl NetworkRunner {
13261350
}
13271351
}
13281352
Err(e) => {
1353+
// Try to extract hotkey from message for debugging
1354+
let hotkey = bincode::deserialize::<SignedP2PMessage>(&message.data)
1355+
.ok()
1356+
.map(|m| m.signer.to_ss58())
1357+
.unwrap_or_else(|| "unknown".to_string());
13291358
warn!(
13301359
source = %propagation_source,
1360+
hotkey = %hotkey,
13311361
error = %e,
13321362
"Failed to process gossipsub message"
13331363
);

0 commit comments

Comments
 (0)