Network performance tuning (#2608)

There is a pretty significant tradeoff between bandwidth and speed of gossipsub messages. 

We can reduce our bandwidth usage considerably at the cost of minimally delaying gossipsub messages. The impact of delaying messages has not been analyzed thoroughly yet, however this PR in conjunction with some gossipsub updates show considerable bandwidth reduction. 

This PR allows the user to set a CLI value (`network-load`) which is an integer in the range of 1 of 5 depending on their bandwidth appetite. 1 represents the least bandwidth but slowest message recieving and 5 represents the most bandwidth and fastest received message time. 

For low-bandwidth users it is likely to be more efficient to use a lower value. The default is set to 3, which currently represents a reduced bandwidth usage compared to previous version of this PR. The previous lighthouse versions are equivalent to setting the `network-load` CLI to 4.

This PR is awaiting a few gossipsub updates before we can get it into lighthouse.
This commit is contained in:
Age Manning
2022-01-14 05:42:47 +00:00
parent db95255aeb
commit 6f4102aab6
8 changed files with 120 additions and 29 deletions

View File

@@ -2,7 +2,7 @@ use crate::behaviour::gossipsub_scoring_parameters::{
lighthouse_gossip_thresholds, PeerScoreSettings,
};
use crate::config::gossipsub_config;
use crate::discovery::{subnet_predicate, Discovery, DiscoveryEvent, TARGET_SUBNET_PEERS};
use crate::discovery::{subnet_predicate, Discovery, DiscoveryEvent};
use crate::peer_manager::{
config::Config as PeerManagerCfg, peerdb::score::PeerAction, peerdb::score::ReportSource,
ConnectionDirection, PeerManager, PeerManagerEvent,
@@ -52,6 +52,9 @@ use types::{
pub mod gossipsub_scoring_parameters;
/// The number of peers we target per subnet for discovery queries.
pub const TARGET_SUBNET_PEERS: usize = 2;
const MAX_IDENTIFY_ADDRESSES: usize = 10;
/// Identifier of requests sent by a peer.
@@ -227,7 +230,7 @@ impl<TSpec: EthSpec> Behaviour<TSpec> {
max_subscriptions_per_request: 150, // 148 in theory = (64 attestation + 4 sync committee + 6 core topics) * 2
};
config.gs_config = gossipsub_config(ctx.fork_context.clone());
config.gs_config = gossipsub_config(config.network_load, ctx.fork_context.clone());
// If metrics are enabled for gossipsub build the configuration
let gossipsub_metrics = ctx