From 95b17137a80aba28fc9f85e824d7ca83d5cd51e5 Mon Sep 17 00:00:00 2001 From: Age Manning Date: Tue, 14 Sep 2021 08:28:35 +0000 Subject: [PATCH] Reduce network debug noise (#2593) The identify network debug logs can get quite noisy and are unnecessary to print on every request/response. This PR reduces debug noise by only printing messages for identify messages that offer some new information. --- beacon_node/eth2_libp2p/src/behaviour/mod.rs | 8 -------- beacon_node/eth2_libp2p/src/peer_manager/mod.rs | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/beacon_node/eth2_libp2p/src/behaviour/mod.rs b/beacon_node/eth2_libp2p/src/behaviour/mod.rs index 316917ac5..8d0c9ee5b 100644 --- a/beacon_node/eth2_libp2p/src/behaviour/mod.rs +++ b/beacon_node/eth2_libp2p/src/behaviour/mod.rs @@ -1004,14 +1004,6 @@ impl NetworkBehaviourEventProcess for Behaviour %peer_id, - "protocol_version" => info.protocol_version, - "agent_version" => info.agent_version, - "listening_ addresses" => ?info.listen_addrs, - "observed_address" => ?info.observed_addr, - "protocols" => ?info.protocols - ); } IdentifyEvent::Sent { .. } => {} IdentifyEvent::Error { .. } => {} diff --git a/beacon_node/eth2_libp2p/src/peer_manager/mod.rs b/beacon_node/eth2_libp2p/src/peer_manager/mod.rs index 34ba564d6..7b3a85908 100644 --- a/beacon_node/eth2_libp2p/src/peer_manager/mod.rs +++ b/beacon_node/eth2_libp2p/src/peer_manager/mod.rs @@ -483,10 +483,23 @@ impl PeerManager { pub fn identify(&mut self, peer_id: &PeerId, info: &IdentifyInfo) { if let Some(peer_info) = self.network_globals.peers.write().peer_info_mut(peer_id) { let previous_kind = peer_info.client.kind.clone(); + let previous_listening_addresses = std::mem::replace( + &mut peer_info.listening_addresses, + info.listen_addrs.clone(), + ); peer_info.client = client::Client::from_identify_info(info); - peer_info.listening_addresses = info.listen_addrs.clone(); - if previous_kind != peer_info.client.kind { + if previous_kind != peer_info.client.kind + || peer_info.listening_addresses != previous_listening_addresses + { + debug!(self.log, "Identified Peer"; "peer" => %peer_id, + "protocol_version" => &info.protocol_version, + "agent_version" => &info.agent_version, + "listening_ addresses" => ?info.listen_addrs, + "observed_address" => ?info.observed_addr, + "protocols" => ?info.protocols + ); + // update the peer client kind metric if let Some(v) = metrics::get_int_gauge( &metrics::PEERS_PER_CLIENT,