Use the mesh_n value from NetworkLoad for PeerScoreSettings (#5013)

* Build `gs_config` and use the `mesh_n` config for `PeerScoreSettings`

* Remove unused imports

* Merge branch 'unstable' into peer-score-settings

# Conflicts:
#	beacon_node/lighthouse_network/src/config.rs
#	beacon_node/lighthouse_network/src/service/gossipsub_scoring_parameters.rs
#	beacon_node/lighthouse_network/src/service/mod.rs
This commit is contained in:
Jimmy Chen
2024-04-12 06:14:15 +10:00
committed by GitHub
parent 7e49f82726
commit d30ba976a1
4 changed files with 19 additions and 40 deletions

View File

@@ -140,7 +140,7 @@ impl<AppReqId: ReqId, E: EthSpec> Network<AppReqId, E> {
) -> error::Result<(Self, Arc<NetworkGlobals<E>>)> {
let log = log.new(o!("service"=> "libp2p"));
let mut config = ctx.config.clone();
let config = ctx.config.clone();
trace!(log, "Libp2p Service starting");
// initialise the node's ID
let local_keypair = utils::load_private_key(&config, &log);
@@ -180,7 +180,19 @@ impl<AppReqId: ReqId, E: EthSpec> Network<AppReqId, E> {
.eth2()
.expect("Local ENR must have a fork id");
let score_settings = PeerScoreSettings::new(ctx.chain_spec, &config.gs_config);
let gossipsub_config_params = GossipsubConfigParams {
message_domain_valid_snappy: ctx.chain_spec.message_domain_valid_snappy,
gossip_max_size: ctx.chain_spec.gossip_max_size as usize,
};
let gs_config = gossipsub_config(
config.network_load,
ctx.fork_context.clone(),
gossipsub_config_params,
ctx.chain_spec.seconds_per_slot,
E::slots_per_epoch(),
);
let score_settings = PeerScoreSettings::new(ctx.chain_spec, gs_config.mesh_n());
let gossip_cache = {
let slot_duration = std::time::Duration::from_secs(ctx.chain_spec.seconds_per_slot);
@@ -248,18 +260,6 @@ impl<AppReqId: ReqId, E: EthSpec> Network<AppReqId, E> {
max_subscriptions_per_request: max_topics * 2,
};
let gossipsub_config_params = GossipsubConfigParams {
message_domain_valid_snappy: ctx.chain_spec.message_domain_valid_snappy,
gossip_max_size: ctx.chain_spec.gossip_max_size as usize,
};
config.gs_config = gossipsub_config(
config.network_load,
ctx.fork_context.clone(),
gossipsub_config_params,
ctx.chain_spec.seconds_per_slot,
E::slots_per_epoch(),
);
// If metrics are enabled for libp2p build the configuration
let gossipsub_metrics = ctx.libp2p_registry.as_mut().map(|registry| {
(
@@ -268,10 +268,10 @@ impl<AppReqId: ReqId, E: EthSpec> Network<AppReqId, E> {
)
});
let snappy_transform = SnappyTransform::new(config.gs_config.max_transmit_size());
let snappy_transform = SnappyTransform::new(gs_config.max_transmit_size());
let mut gossipsub = Gossipsub::new_with_subscription_filter_and_transform(
MessageAuthenticity::Anonymous,
config.gs_config.clone(),
gs_config.clone(),
gossipsub_metrics,
filter,
snappy_transform,