Skip to content

Commit

Permalink
fix: allow to disable peer discovery / discv5 (#7144)
Browse files Browse the repository at this point in the history
* fix: allow to disable peer discovery / discv5

* Explicitly check for false
  • Loading branch information
nflaig authored Oct 10, 2024
1 parent d44c409 commit 489accb
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/cli/src/cmds/beacon/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,6 @@ export async function beaconHandlerInit(args: BeaconArgs & GlobalArgs) {
// Add detailed version string for API node/version endpoint
beaconNodeOptions.set({api: {commit, version}});

// Combine bootnodes from different sources
const bootnodes = (beaconNodeOptions.get().network?.discv5?.bootEnrs ?? []).concat(
args.bootnodesFile ? readBootnodes(args.bootnodesFile) : [],
isKnownNetworkName(network) ? await getNetworkBootnodes(network) : []
);
// Deduplicate and set combined bootnodes
beaconNodeOptions.set({network: {discv5: {bootEnrs: [...new Set(bootnodes)]}}});

// Set known depositContractDeployBlock
if (isKnownNetworkName(network)) {
const {depositContractDeployBlock} = getNetworkData(network);
Expand All @@ -191,8 +183,19 @@ export async function beaconHandlerInit(args: BeaconArgs & GlobalArgs) {

const logger = initLogger(args, beaconPaths.dataDir, config);
const {peerId, enr} = await initPeerIdAndEnr(args, beaconPaths.beaconDir, logger);
// Inject ENR to beacon options
beaconNodeOptions.set({network: {discv5: {enr: enr.encodeTxt(), config: {enrUpdate: !enr.ip && !enr.ip6}}}});

if (args.discv5 !== false) {
// Inject ENR to beacon options
beaconNodeOptions.set({network: {discv5: {enr: enr.encodeTxt(), config: {enrUpdate: !enr.ip && !enr.ip6}}}});

// Combine bootnodes from different sources
const bootnodes = (beaconNodeOptions.get().network?.discv5?.bootEnrs ?? []).concat(
args.bootnodesFile ? readBootnodes(args.bootnodesFile) : [],
isKnownNetworkName(network) ? await getNetworkBootnodes(network) : []
);
// Deduplicate and set combined bootnodes
beaconNodeOptions.set({network: {discv5: {bootEnrs: [...new Set(bootnodes)]}}});
}

if (args.disableLightClientServer) {
beaconNodeOptions.set({chain: {disableLightClientServer: true}});
Expand Down

0 comments on commit 489accb

Please sign in to comment.