Skip to content

Commit

Permalink
Log peerset set ID -> protocol name mapping (paritytech#7005)
Browse files Browse the repository at this point in the history
To simplify debugging of peerset related issues like
paritytech#6573 (comment).

---------

Co-authored-by: command-bot <>
  • Loading branch information
dmitry-markin authored and dudo50 committed Jan 4, 2025
1 parent d9a0239 commit de60bf6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions prdoc/pr_7005.prdoc
Original file line number Diff line number Diff line change
@@ -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
11 changes: 9 additions & 2 deletions substrate/client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use libp2p::{
},
Multiaddr, PeerId,
};
use log::warn;
use log::{debug, warn};

use codec::DecodeAll;
use sc_network_common::role::Roles;
Expand All @@ -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;
Expand Down Expand Up @@ -124,6 +127,10 @@ impl<B: BlockT> Protocol<B> {
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,
Expand Down Expand Up @@ -164,7 +171,7 @@ impl<B: BlockT> Protocol<B> {
{
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")
}
}

Expand Down

0 comments on commit de60bf6

Please sign in to comment.