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

fix: allow to disable peer discovery / discv5 #7144

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
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
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
Loading