Skip to content

Commit f30884e

Browse files
AgeManningdanielrachi1
authored andcommitted
Prevent QUIC logs when quic is disabled (sigp#5071)
* Prevent logs and dialing quic multiaddrs when not supported * Merge latest unstable
1 parent 68b296a commit f30884e

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

beacon_node/lighthouse_network/src/peer_manager/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub struct Config {
1818
pub discovery_enabled: bool,
1919
/// Whether metrics are enabled.
2020
pub metrics_enabled: bool,
21+
/// Whether quic is enabled.
22+
pub quic_enabled: bool,
2123
/// Target number of peers to connect to.
2224
pub target_peer_count: usize,
2325

@@ -37,6 +39,7 @@ impl Default for Config {
3739
Config {
3840
discovery_enabled: true,
3941
metrics_enabled: false,
42+
quic_enabled: true,
4043
target_peer_count: DEFAULT_TARGET_PEERS,
4144
status_interval: DEFAULT_STATUS_INTERVAL,
4245
ping_interval_inbound: DEFAULT_PING_INTERVAL_INBOUND,

beacon_node/lighthouse_network/src/peer_manager/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ pub struct PeerManager<TSpec: EthSpec> {
104104
discovery_enabled: bool,
105105
/// Keeps track if the current instance is reporting metrics or not.
106106
metrics_enabled: bool,
107+
/// Keeps track of whether the QUIC protocol is enabled or not.
108+
quic_enabled: bool,
107109
/// The logger associated with the `PeerManager`.
108110
log: slog::Logger,
109111
}
@@ -149,6 +151,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
149151
status_interval,
150152
ping_interval_inbound,
151153
ping_interval_outbound,
154+
quic_enabled,
152155
} = cfg;
153156

154157
// Set up the peer manager heartbeat interval
@@ -167,6 +170,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
167170
heartbeat,
168171
discovery_enabled,
169172
metrics_enabled,
173+
quic_enabled,
170174
log: log.clone(),
171175
})
172176
}

beacon_node/lighthouse_network/src/peer_manager/network_behaviour.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,16 @@ impl<TSpec: EthSpec> NetworkBehaviour for PeerManager<TSpec> {
9696
if let Some(enr) = self.peers_to_dial.pop() {
9797
let peer_id = enr.peer_id();
9898
self.inject_peer_connection(&peer_id, ConnectingType::Dialing, Some(enr.clone()));
99-
let quic_multiaddrs = enr.multiaddr_quic();
100-
if !quic_multiaddrs.is_empty() {
101-
debug!(self.log, "Dialing QUIC supported peer"; "peer_id"=> %peer_id, "quic_multiaddrs" => ?quic_multiaddrs);
102-
}
99+
100+
let quic_multiaddrs = if self.quic_enabled {
101+
let quic_multiaddrs = enr.multiaddr_quic();
102+
if !quic_multiaddrs.is_empty() {
103+
debug!(self.log, "Dialing QUIC supported peer"; "peer_id"=> %peer_id, "quic_multiaddrs" => ?quic_multiaddrs);
104+
}
105+
quic_multiaddrs
106+
} else {
107+
Vec::new()
108+
};
103109

104110
// Prioritize Quic connections over Tcp ones.
105111
let multiaddrs = quic_multiaddrs

beacon_node/lighthouse_network/src/service/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
328328
let peer_manager = {
329329
let peer_manager_cfg = PeerManagerCfg {
330330
discovery_enabled: !config.disable_discovery,
331+
quic_enabled: !config.disable_quic_support,
331332
metrics_enabled: config.metrics_enabled,
332333
target_peer_count: config.target_peers,
333334
..Default::default()

0 commit comments

Comments
 (0)