Skip to content

Commit

Permalink
Prevent logs and dialing quic multiaddrs when not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
AgeManning committed Jan 16, 2024
1 parent a68b701 commit 6f7b232
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub struct Config {
/// Configuration for the inbound rate limiter (requests received by this node).
pub inbound_rate_limiter_config: Option<InboundRateLimiterConfig>,

/// Whether to disable logging duplicate gossip messages as WARN. If set to true, duplicate
/// Whether to disable logging duplicate gossip messages as WARN. If set to true, duplicate
/// errors will be logged at DEBUG level.
pub disable_duplicate_warn_logs: bool,
}
Expand Down
3 changes: 3 additions & 0 deletions beacon_node/lighthouse_network/src/peer_manager/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct Config {
pub discovery_enabled: bool,
/// Whether metrics are enabled.
pub metrics_enabled: bool,
/// Whether quic is enabled.
pub quic_enabled: bool,
/// Target number of peers to connect to.
pub target_peer_count: usize,

Expand All @@ -37,6 +39,7 @@ impl Default for Config {
Config {
discovery_enabled: true,
metrics_enabled: false,
quic_enabled: true,
target_peer_count: DEFAULT_TARGET_PEERS,
status_interval: DEFAULT_STATUS_INTERVAL,
ping_interval_inbound: DEFAULT_PING_INTERVAL_INBOUND,
Expand Down
4 changes: 4 additions & 0 deletions beacon_node/lighthouse_network/src/peer_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ pub struct PeerManager<TSpec: EthSpec> {
discovery_enabled: bool,
/// Keeps track if the current instance is reporting metrics or not.
metrics_enabled: bool,
/// Keeps track of whether the QUIC protocol is enabled or not.
quic_enabled: bool,
/// The logger associated with the `PeerManager`.
log: slog::Logger,
}
Expand Down Expand Up @@ -149,6 +151,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
status_interval,
ping_interval_inbound,
ping_interval_outbound,
quic_enabled,
} = cfg;

// Set up the peer manager heartbeat interval
Expand All @@ -167,6 +170,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
heartbeat,
discovery_enabled,
metrics_enabled,
quic_enabled,
log: log.clone(),
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,16 @@ impl<TSpec: EthSpec> NetworkBehaviour for PeerManager<TSpec> {
if let Some(enr) = self.peers_to_dial.pop() {
let peer_id = enr.peer_id();
self.inject_peer_connection(&peer_id, ConnectingType::Dialing, Some(enr.clone()));
let quic_multiaddrs = enr.multiaddr_quic();
if !quic_multiaddrs.is_empty() {
debug!(self.log, "Dialing QUIC supported peer"; "peer_id"=> %peer_id, "quic_multiaddrs" => ?quic_multiaddrs);
}

let quic_multiaddrs = if self.quic_enabled {
let quic_multiaddrs = enr.multiaddr_quic();
if !quic_multiaddrs.is_empty() {
debug!(self.log, "Dialing QUIC supported peer"; "peer_id"=> %peer_id, "quic_multiaddrs" => ?quic_multiaddrs);
}
quic_multiaddrs
} else {
Vec::new()
};

// Prioritize Quic connections over Tcp ones.
let multiaddrs = quic_multiaddrs
Expand Down
1 change: 1 addition & 0 deletions beacon_node/lighthouse_network/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
let peer_manager = {
let peer_manager_cfg = PeerManagerCfg {
discovery_enabled: !config.disable_discovery,
quic_enabled: !config.disable_quic_support,
metrics_enabled: config.metrics_enabled,
target_peer_count: config.target_peers,
..Default::default()
Expand Down

0 comments on commit 6f7b232

Please sign in to comment.