Skip to content

Commit

Permalink
correctly set the enr with custody subnet info
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed May 22, 2024
1 parent 3c36b23 commit 8745339
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/cli/src/cmds/beacon/initPeerIdAndEnr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {Multiaddr} from "@multiformats/multiaddr";
import {createPrivateKeyFromPeerId, SignableENR} from "@chainsafe/enr";
import {Logger, fromHex} from "@lodestar/utils";
import {ChainForkConfig} from "@lodestar/config";
import {ssz} from "@lodestar/types";

import {exportToJSON, readPeerId} from "../../config/index.js";
import {writeFile600Perm} from "../../util/file.js";
Expand Down Expand Up @@ -69,7 +70,7 @@ function maybeUpdateEnr<T extends "ip" | "tcp" | "udp" | "ip6" | "tcp6" | "udp6"
}

export function overwriteEnrWithCliArgs(
_config: ChainForkConfig,
config: ChainForkConfig,
enr: SignableENR,
args: BeaconArgs,
logger: Logger,
Expand All @@ -78,7 +79,6 @@ export function overwriteEnrWithCliArgs(
const preSeq = enr.seq;
const {port, discoveryPort, port6, discoveryPort6} = parseListenArgs(args);
// TODO remove the hardcoding serialize count
(enr as unknown as {custody_subnet_count: string}).custody_subnet_count = "0x1000000000000000";
maybeUpdateEnr(enr, "ip", args["enr.ip"] ?? enr.ip);
maybeUpdateEnr(enr, "ip6", args["enr.ip6"] ?? enr.ip6);
maybeUpdateEnr(enr, "udp", args["enr.udp"] ?? discoveryPort ?? enr.udp);
Expand All @@ -87,6 +87,7 @@ export function overwriteEnrWithCliArgs(
maybeUpdateEnr(enr, "tcp", args["enr.tcp"] ?? port ?? enr.tcp);
maybeUpdateEnr(enr, "tcp6", args["enr.tcp6"] ?? port6 ?? enr.tcp6);
}
enr.set("custody_subnet_count", ssz.UintNum64.serialize(config.CUSTODY_REQUIREMENT));

function testMultiaddrForLocal(mu: Multiaddr, ip4: boolean): void {
const isLocal = isLocalMultiAddr(mu);
Expand Down

0 comments on commit 8745339

Please sign in to comment.