diff --git a/prdoc/pr_7005.prdoc b/prdoc/pr_7005.prdoc new file mode 100644 index 000000000000..a61f7c5b9b71 --- /dev/null +++ b/prdoc/pr_7005.prdoc @@ -0,0 +1,7 @@ +title: Log peerset set ID -> protocol name mapping +doc: +- audience: Node Dev + description: To simplify debugging of peerset related issues like https://github.com/paritytech/polkadot-sdk/issues/6573#issuecomment-2563091343. +crates: +- name: sc-network + bump: patch diff --git a/substrate/client/network/src/protocol.rs b/substrate/client/network/src/protocol.rs index 6da1d601b34f..81e1848adefa 100644 --- a/substrate/client/network/src/protocol.rs +++ b/substrate/client/network/src/protocol.rs @@ -34,7 +34,7 @@ use libp2p::{ }, Multiaddr, PeerId, }; -use log::warn; +use log::{debug, warn}; use codec::DecodeAll; use sc_network_common::role::Roles; @@ -53,6 +53,9 @@ mod notifications; pub mod message; +// Log target for this file. +const LOG_TARGET: &str = "sub-libp2p"; + /// Maximum size used for notifications in the block announce and transaction protocols. // Must be equal to `max(MAX_BLOCK_ANNOUNCE_SIZE, MAX_TRANSACTIONS_SIZE)`. pub(crate) const BLOCK_ANNOUNCES_TRANSACTIONS_SUBSTREAM_SIZE: u64 = MAX_RESPONSE_SIZE; @@ -124,6 +127,10 @@ impl Protocol { handle.set_metrics(notification_metrics.clone()); }); + protocol_configs.iter().enumerate().for_each(|(i, (p, _, _))| { + debug!(target: LOG_TARGET, "Notifications protocol {:?}: {}", SetId::from(i), p.name); + }); + ( Notifications::new( protocol_controller_handles, @@ -164,7 +171,7 @@ impl Protocol { { self.behaviour.disconnect_peer(peer_id, SetId::from(position)); } else { - warn!(target: "sub-libp2p", "disconnect_peer() with invalid protocol name") + warn!(target: LOG_TARGET, "disconnect_peer() with invalid protocol name") } }