From ae96dab5d2134a36be5c83e7321b082328ad5b11 Mon Sep 17 00:00:00 2001 From: Age Manning Date: Fri, 23 Oct 2020 03:01:33 +0000 Subject: [PATCH] Increase UPnP logging and decrease batch sizes (#1812) ## Description This increases the logging of the underlying UPnP tasks to inform the user of UPnP error/success. This also decreases the batch syncing size to two epochs per batch. --- beacon_node/network/src/nat.rs | 39 +++++++++++-------- .../network/src/sync/range_sync/chain.rs | 2 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/beacon_node/network/src/nat.rs b/beacon_node/network/src/nat.rs index af19e2aa12..1b6520ef80 100644 --- a/beacon_node/network/src/nat.rs +++ b/beacon_node/network/src/nat.rs @@ -36,32 +36,39 @@ pub fn construct_upnp_mappings( network_send: mpsc::UnboundedSender>, log: slog::Logger, ) { - debug!(log, "UPnP Initialising routes"); + info!(log, "UPnP Attempting to initialise routes"); match igd::search_gateway(Default::default()) { - Err(e) => debug!(log, "UPnP not available"; "error" => %e), + Err(e) => info!(log, "UPnP not available"; "error" => %e), Ok(gateway) => { // Need to find the local listening address matched with the router subnet - let mut local_ip = None; let interfaces = match get_if_addrs() { Ok(v) => v, Err(e) => { - debug!(log, "UPnP failed to get local interfaces"; "error" => %e); + info!(log, "UPnP failed to get local interfaces"; "error" => %e); return; } }; - for interface in interfaces { - // Just use the first IP of the first interface that is not a loopback + let local_ip = interfaces.iter().find_map(|interface| { + // Just use the first IP of the first interface that is not a loopback and not an + // ipv6 address. if !interface.is_loopback() { - local_ip = Some(interface.ip()); + if let IpAddr::V4(_) = interface.ip() { + Some(interface.ip()) + } else { + None + } + } else { + None } - } + }); - if local_ip.is_none() { - debug!(log, "UPnP failed to find local IP address"); - return; - } - - let local_ip = local_ip.expect("IP exists"); + let local_ip = match local_ip { + None => { + info!(log, "UPnP failed to find local IP address"); + return; + } + Some(v) => v, + }; match local_ip { IpAddr::V4(address) => { @@ -79,7 +86,7 @@ pub fn construct_upnp_mappings( "lighthouse-tcp", ) { Err(e) => { - debug!(log, "UPnP could not construct libp2p port route"; "error" => %e); + info!(log, "UPnP TCP route not set"; "error" => %e); None } Ok(_) => { @@ -101,7 +108,7 @@ pub fn construct_upnp_mappings( "lighthouse-udp", ) { Err(e) => { - debug!(log, "UPnP could not construct discovery port route"; "error" => %e); + info!(log, "UPnP UDP route not set"; "error" => %e); None } Ok(_) => { diff --git a/beacon_node/network/src/sync/range_sync/chain.rs b/beacon_node/network/src/sync/range_sync/chain.rs index dacb12de1d..aace878c8e 100644 --- a/beacon_node/network/src/sync/range_sync/chain.rs +++ b/beacon_node/network/src/sync/range_sync/chain.rs @@ -18,7 +18,7 @@ use types::{Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot}; /// we will negatively report peers with poor bandwidth. This can be set arbitrarily high, in which /// case the responder will fill the response up to the max request size, assuming they have the /// bandwidth to do so. -pub const EPOCHS_PER_BATCH: u64 = 8; +pub const EPOCHS_PER_BATCH: u64 = 2; /// The maximum number of batches to queue before requesting more. const BATCH_BUFFER_SIZE: u8 = 5;