Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit peers #5333

Merged
merged 5 commits into from
Mar 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(beacon_node): add explicit peers to GossipSub, mark as trusted
  • Loading branch information
Jonas Bostoen committed Feb 29, 2024
commit a2b5de40423ff9cba7c64e395d0d45fcc92103e4
26 changes: 21 additions & 5 deletions beacon_node/lighthouse_network/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
// initialise the node's ID
let local_keypair = utils::load_private_key(&config, &log);

let mut trusted_peers: Vec<PeerId> = config
.trusted_peers
.iter()
.map(|x| PeerId::from(x.clone()))
.collect();

// Explicit peers should also be marked as trusted since they are exempt from peer scoring.
// Cfr. https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#explicit-peering-agreements
trusted_peers.extend(
config
.explicit_peers
.iter()
.map(|x| PeerId::from(x.clone())),
);

// set up a collection of variables accessible outside of the network crate
let network_globals = {
// Create an ENR or load from disk if appropriate
Expand All @@ -158,11 +173,7 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
let globals = NetworkGlobals::new(
enr,
meta_data,
config
.trusted_peers
.iter()
.map(|x| PeerId::from(x.clone()))
.collect(),
trusted_peers,
config.disable_peer_scoring,
&log,
);
Expand Down Expand Up @@ -275,6 +286,11 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
.with_peer_score(params, thresholds)
.expect("Valid score params and thresholds");

// Add explicit peers to GossipSub
for explicit_peer in config.explicit_peers.iter() {
gossipsub.add_explicit_peer(&PeerId::from(explicit_peer.clone()));
}

(gossipsub, update_gossipsub_scores)
};

Expand Down