Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
jxs committed Jan 22, 2024
1 parent 76d3963 commit adf2796
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions beacon_node/lighthouse_network/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
}
}

fn parse_upnp_event(&mut self, event: libp2p::upnp::Event) {
fn inject_upnp_event(&mut self, event: libp2p::upnp::Event) {
match event {
libp2p::upnp::Event::NewExternalAddr(addr) => {
info!(self.log, "UPnP route established"; "addr" => %addr);
Expand Down Expand Up @@ -1646,7 +1646,7 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
BehaviourEvent::Identify(ie) => self.inject_identify_event(ie),
BehaviourEvent::PeerManager(pe) => self.inject_pm_event(pe),
BehaviourEvent::Upnp(e) => {
self.parse_upnp_event(e);
self.inject_upnp_event(e);
None
}
BehaviourEvent::ConnectionLimits(le) => void::unreachable(le),
Expand Down
5 changes: 2 additions & 3 deletions beacon_node/lighthouse_network/src/service/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{GossipTopic, NetworkConfig};
use futures::future::Either;
use libp2p::core::{multiaddr::Multiaddr, muxing::StreamMuxerBox, transport::Boxed};
use libp2p::identity::{secp256k1, Keypair};
use libp2p::{core, gossipsub, noise, yamux, PeerId, Transport, TransportExt};
use libp2p::{core, gossipsub, noise, yamux, PeerId, Transport};
use prometheus_client::registry::Registry;
use slog::{debug, warn};
use ssz::Decode;
Expand Down Expand Up @@ -62,8 +62,7 @@ pub fn build_transport(
// Enables Quic
// The default quic configuration suits us for now.
let quic_config = libp2p::quic::Config::new(&local_private_key);
let (quic, quic_bandwidth) =
libp2p::quic::tokio::Transport::new(quic_config).with_bandwidth_logging();
let quic = libp2p::quic::tokio::Transport::new(quic_config);
let transport = tcp
.or_transport(quic)
.map(|either_output, _| match either_output {
Expand Down
7 changes: 5 additions & 2 deletions beacon_node/network/src/nat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ pub async fn construct_upnp_mappings(
};

if is_private {
bail!("Gateway's external address is a private address: {external_address}");
bail!(
"Gateway's external address is a private address: {}",
external_address
);
}

loop {
Expand All @@ -50,7 +53,7 @@ pub async fn construct_upnp_mappings(
"Lighthouse Discovery port",
)
.await
.context("Could not UPnP map port: {port} on the gateway")?;
.context("Could not UPnP map port: {} on the gateway", port)?;
debug!(log, "Discovery UPnP port mapped"; "port" => %port);
sleep(Duration::from_secs(MAPPING_TIMEOUT)).await;
}
Expand Down
6 changes: 5 additions & 1 deletion beacon_node/network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ impl<T: BeaconChainTypes> NetworkService<T> {
"Backfill is disabled. DO NOT RUN IN PRODUCTION"
);

if let (true, Some(v4)) = (config.upnp_enabled, config.listen_addrs().v4()) {
if let (true, false, Some(v4)) = (
config.upnp_enabled,
config.disable_discovery,
config.listen_addrs().v4(),
) {
let nw = network_log.clone();
let v4 = v4.clone();
tokio::spawn(async move {
Expand Down

0 comments on commit adf2796

Please sign in to comment.