@chainsafe/lodestar 1.35.0-dev.e9dd48f165 → 1.35.0-dev.fcf8d024ea
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.git-data.json +1 -1
- package/bin/lodestar.js +3 -0
- package/bin/lodestar.ts +3 -0
- package/lib/applyPreset.d.ts.map +1 -0
- package/lib/cli.d.ts +3 -3
- package/lib/cli.d.ts.map +1 -0
- package/lib/cli.js +1 -1
- package/lib/cli.js.map +1 -1
- package/lib/cmds/beacon/handler.d.ts +1 -1
- package/lib/cmds/beacon/handler.d.ts.map +1 -0
- package/lib/cmds/beacon/handler.js +1 -1
- package/lib/cmds/beacon/handler.js.map +1 -1
- package/lib/cmds/beacon/index.d.ts.map +1 -0
- package/lib/cmds/beacon/initBeaconState.d.ts.map +1 -0
- package/lib/cmds/beacon/initBeaconState.js.map +1 -1
- package/lib/cmds/beacon/initPeerIdAndEnr.d.ts +2 -2
- package/lib/cmds/beacon/initPeerIdAndEnr.d.ts.map +1 -0
- package/lib/cmds/beacon/initPeerIdAndEnr.js +1 -1
- package/lib/cmds/beacon/initPeerIdAndEnr.js.map +1 -1
- package/lib/cmds/beacon/options.d.ts.map +1 -0
- package/lib/cmds/beacon/paths.d.ts.map +1 -0
- package/lib/cmds/bootnode/handler.d.ts +13 -8
- package/lib/cmds/bootnode/handler.d.ts.map +1 -0
- package/lib/cmds/bootnode/handler.js +2 -2
- package/lib/cmds/bootnode/handler.js.map +1 -1
- package/lib/cmds/bootnode/index.d.ts.map +1 -0
- package/lib/cmds/bootnode/options.d.ts.map +1 -0
- package/lib/cmds/bootnode/options.js +2 -1
- package/lib/cmds/bootnode/options.js.map +1 -1
- package/lib/cmds/dev/files.d.ts.map +1 -0
- package/lib/cmds/dev/handler.d.ts.map +1 -0
- package/lib/cmds/dev/handler.js +1 -1
- package/lib/cmds/dev/handler.js.map +1 -1
- package/lib/cmds/dev/index.d.ts.map +1 -0
- package/lib/cmds/dev/options.d.ts.map +1 -0
- package/lib/cmds/index.d.ts.map +1 -0
- package/lib/cmds/lightclient/handler.d.ts.map +1 -0
- package/lib/cmds/lightclient/index.d.ts.map +1 -0
- package/lib/cmds/lightclient/options.d.ts.map +1 -0
- package/lib/cmds/validator/blsToExecutionChange.d.ts.map +1 -0
- package/lib/cmds/validator/blsToExecutionChange.js.map +1 -1
- package/lib/cmds/validator/handler.d.ts.map +1 -0
- package/lib/cmds/validator/handler.js +3 -5
- package/lib/cmds/validator/handler.js.map +1 -1
- package/lib/cmds/validator/import.d.ts.map +1 -0
- package/lib/cmds/validator/index.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/index.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/poolSize.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/threadPool.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/threadPool.js +4 -1
- package/lib/cmds/validator/keymanager/decryptKeystores/threadPool.js.map +1 -1
- package/lib/cmds/validator/keymanager/decryptKeystores/types.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/worker.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/impl.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/impl.js +4 -0
- package/lib/cmds/validator/keymanager/impl.js.map +1 -1
- package/lib/cmds/validator/keymanager/interface.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/keystoreCache.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/persistedKeys.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/persistedKeys.js +1 -0
- package/lib/cmds/validator/keymanager/persistedKeys.js.map +1 -1
- package/lib/cmds/validator/keymanager/server.d.ts.map +1 -0
- package/lib/cmds/validator/keymanager/server.js +2 -0
- package/lib/cmds/validator/keymanager/server.js.map +1 -1
- package/lib/cmds/validator/list.d.ts.map +1 -0
- package/lib/cmds/validator/options.d.ts.map +1 -0
- package/lib/cmds/validator/paths.d.ts.map +1 -0
- package/lib/cmds/validator/signers/importExternalKeystores.d.ts.map +1 -0
- package/lib/cmds/validator/signers/index.d.ts.map +1 -0
- package/lib/cmds/validator/signers/logSigners.d.ts.map +1 -0
- package/lib/cmds/validator/slashingProtection/export.d.ts.map +1 -0
- package/lib/cmds/validator/slashingProtection/import.d.ts.map +1 -0
- package/lib/cmds/validator/slashingProtection/index.d.ts.map +1 -0
- package/lib/cmds/validator/slashingProtection/options.d.ts.map +1 -0
- package/lib/cmds/validator/slashingProtection/utils.d.ts.map +1 -0
- package/lib/cmds/validator/slashingProtection/utils.js +1 -1
- package/lib/cmds/validator/slashingProtection/utils.js.map +1 -1
- package/lib/cmds/validator/voluntaryExit.d.ts.map +1 -0
- package/lib/cmds/validator/voluntaryExit.js +1 -1
- package/lib/cmds/validator/voluntaryExit.js.map +1 -1
- package/lib/config/beaconNodeOptions.d.ts.map +1 -0
- package/lib/config/beaconNodeOptions.js +2 -1
- package/lib/config/beaconNodeOptions.js.map +1 -1
- package/lib/config/beaconParams.d.ts.map +1 -0
- package/lib/config/index.d.ts.map +1 -0
- package/lib/config/peerId.d.ts.map +1 -0
- package/lib/config/types.d.ts.map +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js.map +1 -1
- package/lib/migrations/index.d.ts +1 -0
- package/lib/migrations/index.d.ts.map +1 -0
- package/lib/migrations/index.js +1 -1
- package/lib/networks/chiado.d.ts.map +1 -0
- package/lib/networks/dev.d.ts.map +1 -0
- package/lib/networks/ephemery.d.ts.map +1 -0
- package/lib/networks/gnosis.d.ts.map +1 -0
- package/lib/networks/holesky.d.ts.map +1 -0
- package/lib/networks/hoodi.d.ts.map +1 -0
- package/lib/networks/index.d.ts.map +1 -0
- package/lib/networks/index.js +1 -2
- package/lib/networks/index.js.map +1 -1
- package/lib/networks/mainnet.d.ts.map +1 -0
- package/lib/networks/sepolia.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/api.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/builder.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/chain.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/eth1.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/execution.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/index.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/metrics.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/monitoring.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/network.d.ts +1 -0
- package/lib/options/beaconNodeOptions/network.d.ts.map +1 -0
- package/lib/options/beaconNodeOptions/network.js +6 -3
- package/lib/options/beaconNodeOptions/network.js.map +1 -1
- package/lib/options/beaconNodeOptions/sync.d.ts.map +1 -0
- package/lib/options/globalOptions.d.ts.map +1 -0
- package/lib/options/index.d.ts.map +1 -0
- package/lib/options/logOptions.d.ts.map +1 -0
- package/lib/options/paramsOptions.d.ts.map +1 -0
- package/lib/paths/global.d.ts.map +1 -0
- package/lib/paths/rootDir.d.ts.map +1 -0
- package/lib/util/errors.d.ts.map +1 -0
- package/lib/util/ethers.d.ts.map +1 -0
- package/lib/util/feeRecipient.d.ts.map +1 -0
- package/lib/util/file.d.ts.map +1 -0
- package/lib/util/file.js +1 -1
- package/lib/util/file.js.map +1 -1
- package/lib/util/format.d.ts.map +1 -0
- package/lib/util/fs.d.ts.map +1 -0
- package/lib/util/gitData/gitDataPath.d.ts.map +1 -0
- package/lib/util/gitData/index.d.ts.map +1 -0
- package/lib/util/gitData/index.js.map +1 -1
- package/lib/util/gitData/writeGitData.d.ts.map +1 -0
- package/lib/util/index.d.ts +3 -3
- package/lib/util/index.d.ts.map +1 -0
- package/lib/util/index.js +3 -3
- package/lib/util/index.js.map +1 -1
- package/lib/util/jwt.d.ts.map +1 -0
- package/lib/util/lockfile.d.ts.map +1 -0
- package/lib/util/logger.d.ts.map +1 -0
- package/lib/util/object.d.ts.map +1 -0
- package/lib/util/object.js.map +1 -1
- package/lib/util/passphrase.d.ts.map +1 -0
- package/lib/util/process.d.ts.map +1 -0
- package/lib/util/progress.d.ts.map +1 -0
- package/lib/util/proposerConfig.d.ts.map +1 -0
- package/lib/util/proposerConfig.js.map +1 -1
- package/lib/util/pruneOldFilesInDir.d.ts.map +1 -0
- package/lib/util/sleep.d.ts.map +1 -0
- package/lib/util/stripOffNewlines.d.ts.map +1 -0
- package/lib/util/types.d.ts.map +1 -0
- package/lib/util/version.d.ts.map +1 -0
- package/package.json +20 -19
- package/src/applyPreset.ts +91 -0
- package/src/cli.ts +56 -0
- package/src/cmds/beacon/handler.ts +267 -0
- package/src/cmds/beacon/index.ts +18 -0
- package/src/cmds/beacon/initBeaconState.ts +275 -0
- package/src/cmds/beacon/initPeerIdAndEnr.ts +199 -0
- package/src/cmds/beacon/options.ts +214 -0
- package/src/cmds/beacon/paths.ts +62 -0
- package/src/cmds/bootnode/handler.ts +203 -0
- package/src/cmds/bootnode/index.ts +13 -0
- package/src/cmds/bootnode/options.ts +109 -0
- package/src/cmds/dev/files.ts +52 -0
- package/src/cmds/dev/handler.ts +86 -0
- package/src/cmds/dev/index.ts +18 -0
- package/src/cmds/dev/options.ts +110 -0
- package/src/cmds/index.ts +15 -0
- package/src/cmds/lightclient/handler.ts +36 -0
- package/src/cmds/lightclient/index.ts +18 -0
- package/src/cmds/lightclient/options.ts +21 -0
- package/src/cmds/validator/blsToExecutionChange.ts +91 -0
- package/src/cmds/validator/handler.ts +300 -0
- package/src/cmds/validator/import.ts +111 -0
- package/src/cmds/validator/index.ts +28 -0
- package/src/cmds/validator/keymanager/decryptKeystoreDefinitions.ts +189 -0
- package/src/cmds/validator/keymanager/decryptKeystores/index.ts +1 -0
- package/src/cmds/validator/keymanager/decryptKeystores/poolSize.ts +16 -0
- package/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts +75 -0
- package/src/cmds/validator/keymanager/decryptKeystores/types.ts +12 -0
- package/src/cmds/validator/keymanager/decryptKeystores/worker.ts +24 -0
- package/src/cmds/validator/keymanager/impl.ts +425 -0
- package/src/cmds/validator/keymanager/interface.ts +35 -0
- package/src/cmds/validator/keymanager/keystoreCache.ts +91 -0
- package/src/cmds/validator/keymanager/persistedKeys.ts +268 -0
- package/src/cmds/validator/keymanager/server.ts +86 -0
- package/src/cmds/validator/list.ts +35 -0
- package/src/cmds/validator/options.ts +461 -0
- package/src/cmds/validator/paths.ts +95 -0
- package/src/cmds/validator/signers/importExternalKeystores.ts +69 -0
- package/src/cmds/validator/signers/index.ts +176 -0
- package/src/cmds/validator/signers/logSigners.ts +81 -0
- package/src/cmds/validator/slashingProtection/export.ts +110 -0
- package/src/cmds/validator/slashingProtection/import.ts +70 -0
- package/src/cmds/validator/slashingProtection/index.ts +12 -0
- package/src/cmds/validator/slashingProtection/options.ts +15 -0
- package/src/cmds/validator/slashingProtection/utils.ts +56 -0
- package/src/cmds/validator/voluntaryExit.ts +232 -0
- package/src/config/beaconNodeOptions.ts +68 -0
- package/src/config/beaconParams.ts +87 -0
- package/src/config/index.ts +3 -0
- package/src/config/peerId.ts +50 -0
- package/src/config/types.ts +3 -0
- package/src/index.ts +28 -0
- package/src/migrations/index.ts +0 -0
- package/src/networks/chiado.ts +20 -0
- package/src/networks/dev.ts +27 -0
- package/src/networks/ephemery.ts +9 -0
- package/src/networks/gnosis.ts +18 -0
- package/src/networks/holesky.ts +17 -0
- package/src/networks/hoodi.ts +16 -0
- package/src/networks/index.ts +236 -0
- package/src/networks/mainnet.ts +34 -0
- package/src/networks/sepolia.ts +17 -0
- package/src/options/beaconNodeOptions/api.ts +110 -0
- package/src/options/beaconNodeOptions/builder.ts +63 -0
- package/src/options/beaconNodeOptions/chain.ts +326 -0
- package/src/options/beaconNodeOptions/eth1.ts +95 -0
- package/src/options/beaconNodeOptions/execution.ts +92 -0
- package/src/options/beaconNodeOptions/index.ts +50 -0
- package/src/options/beaconNodeOptions/metrics.ts +39 -0
- package/src/options/beaconNodeOptions/monitoring.ts +61 -0
- package/src/options/beaconNodeOptions/network.ts +401 -0
- package/src/options/beaconNodeOptions/sync.ts +65 -0
- package/src/options/globalOptions.ts +72 -0
- package/src/options/index.ts +3 -0
- package/src/options/logOptions.ts +70 -0
- package/src/options/paramsOptions.ts +72 -0
- package/src/paths/global.ts +24 -0
- package/src/paths/rootDir.ts +11 -0
- package/src/util/errors.ts +20 -0
- package/src/util/ethers.ts +44 -0
- package/src/util/feeRecipient.ts +6 -0
- package/src/util/file.ts +167 -0
- package/src/util/format.ts +76 -0
- package/src/util/fs.ts +59 -0
- package/src/util/gitData/gitDataPath.ts +48 -0
- package/src/util/gitData/index.ts +70 -0
- package/src/util/gitData/writeGitData.ts +10 -0
- package/src/util/index.ts +17 -0
- package/src/util/jwt.ts +10 -0
- package/src/util/lockfile.ts +45 -0
- package/src/util/logger.ts +105 -0
- package/src/util/object.ts +15 -0
- package/src/util/passphrase.ts +25 -0
- package/src/util/process.ts +25 -0
- package/src/util/progress.ts +58 -0
- package/src/util/proposerConfig.ts +136 -0
- package/src/util/pruneOldFilesInDir.ts +27 -0
- package/src/util/sleep.ts +3 -0
- package/src/util/stripOffNewlines.ts +6 -0
- package/src/util/types.ts +8 -0
- package/src/util/version.ts +74 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import {multiaddr} from "@multiformats/multiaddr";
|
|
2
|
+
import {ENR} from "@chainsafe/enr";
|
|
3
|
+
import {IBeaconNodeOptions, defaultOptions} from "@lodestar/beacon-node";
|
|
4
|
+
import {CliCommandOptions} from "@lodestar/utils";
|
|
5
|
+
import {YargsError} from "../../util/index.js";
|
|
6
|
+
|
|
7
|
+
export const defaultListenAddress = "0.0.0.0";
|
|
8
|
+
export const defaultListenAddress6 = "::";
|
|
9
|
+
export const defaultP2pPort = 9000;
|
|
10
|
+
|
|
11
|
+
export type NetworkArgs = {
|
|
12
|
+
discv5?: boolean;
|
|
13
|
+
listenAddress?: string;
|
|
14
|
+
port?: number;
|
|
15
|
+
discoveryPort?: number;
|
|
16
|
+
listenAddress6?: string;
|
|
17
|
+
port6?: number;
|
|
18
|
+
discoveryPort6?: number;
|
|
19
|
+
bootnodes?: string[];
|
|
20
|
+
targetPeers?: number;
|
|
21
|
+
subscribeAllSubnets?: boolean;
|
|
22
|
+
slotsToSubscribeBeforeAggregatorDuty?: number;
|
|
23
|
+
disablePeerScoring?: boolean;
|
|
24
|
+
mdns?: boolean;
|
|
25
|
+
"network.maxPeers"?: number;
|
|
26
|
+
"network.connectToDiscv5Bootnodes"?: boolean;
|
|
27
|
+
"network.discv5FirstQueryDelayMs"?: number;
|
|
28
|
+
"network.dontSendGossipAttestationsToForkchoice"?: boolean;
|
|
29
|
+
"network.allowPublishToZeroPeers"?: boolean;
|
|
30
|
+
"network.gossipsubD"?: number;
|
|
31
|
+
"network.gossipsubDLow"?: number;
|
|
32
|
+
"network.gossipsubDHigh"?: number;
|
|
33
|
+
"network.gossipsubAwaitHandler"?: boolean;
|
|
34
|
+
"network.disableFloodPublish"?: boolean;
|
|
35
|
+
"network.rateLimitMultiplier"?: number;
|
|
36
|
+
"network.maxGossipTopicConcurrency"?: number;
|
|
37
|
+
"network.useWorker"?: boolean;
|
|
38
|
+
"network.maxYoungGenerationSizeMb"?: number;
|
|
39
|
+
"network.targetGroupPeers"?: number;
|
|
40
|
+
|
|
41
|
+
/** @deprecated This option is deprecated and should be removed in next major release. */
|
|
42
|
+
"network.requestCountPeerLimit"?: number;
|
|
43
|
+
/** @deprecated This option is deprecated and should be removed in next major release. */
|
|
44
|
+
"network.blockCountTotalLimit"?: number;
|
|
45
|
+
/** @deprecated This option is deprecated and should be removed in next major release. */
|
|
46
|
+
"network.blockCountPeerLimit"?: number;
|
|
47
|
+
/** @deprecated This option is deprecated and should be removed in next major release. */
|
|
48
|
+
"network.rateTrackerTimeoutMs"?: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function validateMultiaddrArg<T extends Record<string, string | undefined>>(args: T, key: keyof T): void {
|
|
52
|
+
if (args[key]) {
|
|
53
|
+
try {
|
|
54
|
+
multiaddr(args[key]);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
throw new YargsError(`Invalid ${key as string}: ${(e as Error).message}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function parseListenArgs(args: NetworkArgs) {
|
|
62
|
+
// If listenAddress is explicitly set, use it
|
|
63
|
+
// If listenAddress6 is not set, use defaultListenAddress
|
|
64
|
+
const listenAddress = args.listenAddress ?? (args.listenAddress6 ? undefined : defaultListenAddress);
|
|
65
|
+
const port = listenAddress ? (args.port ?? defaultP2pPort) : undefined;
|
|
66
|
+
const discoveryPort = listenAddress ? (args.discoveryPort ?? args.port ?? defaultP2pPort) : undefined;
|
|
67
|
+
|
|
68
|
+
// If listenAddress6 is explicitly set, use it
|
|
69
|
+
// If listenAddress is not set, use defaultListenAddress6
|
|
70
|
+
const listenAddress6 = args.listenAddress6 ?? (args.listenAddress ? undefined : defaultListenAddress6);
|
|
71
|
+
const port6 = listenAddress6 ? (args.port6 ?? defaultP2pPort) : undefined;
|
|
72
|
+
const discoveryPort6 = listenAddress6 ? (args.discoveryPort6 ?? args.port6 ?? defaultP2pPort) : undefined;
|
|
73
|
+
|
|
74
|
+
return {listenAddress, port, discoveryPort, listenAddress6, port6, discoveryPort6};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function parseArgs(args: NetworkArgs): IBeaconNodeOptions["network"] {
|
|
78
|
+
const {listenAddress, port, discoveryPort, listenAddress6, port6, discoveryPort6} = parseListenArgs(args);
|
|
79
|
+
// validate ip, ip6, ports
|
|
80
|
+
const muArgs = {
|
|
81
|
+
listenAddress: listenAddress ? `/ip4/${listenAddress}` : undefined,
|
|
82
|
+
port: listenAddress ? `/tcp/${port}` : undefined,
|
|
83
|
+
discoveryPort: listenAddress ? `/udp/${discoveryPort}` : undefined,
|
|
84
|
+
listenAddress6: listenAddress6 ? `/ip6/${listenAddress6}` : undefined,
|
|
85
|
+
port6: listenAddress6 ? `/tcp/${port6}` : undefined,
|
|
86
|
+
discoveryPort6: listenAddress6 ? `/udp/${discoveryPort6}` : undefined,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
for (const key of [
|
|
90
|
+
"listenAddress",
|
|
91
|
+
"port",
|
|
92
|
+
"discoveryPort",
|
|
93
|
+
"listenAddress6",
|
|
94
|
+
"port6",
|
|
95
|
+
"discoveryPort6",
|
|
96
|
+
] as (keyof typeof muArgs)[]) {
|
|
97
|
+
validateMultiaddrArg(muArgs, key);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const bindMu = listenAddress ? `${muArgs.listenAddress}${muArgs.discoveryPort}` : undefined;
|
|
101
|
+
const localMu = listenAddress ? `${muArgs.listenAddress}${muArgs.port}` : undefined;
|
|
102
|
+
const bindMu6 = listenAddress6 ? `${muArgs.listenAddress6}${muArgs.discoveryPort6}` : undefined;
|
|
103
|
+
const localMu6 = listenAddress6 ? `${muArgs.listenAddress6}${muArgs.port6}` : undefined;
|
|
104
|
+
|
|
105
|
+
const targetPeers = args.targetPeers;
|
|
106
|
+
const maxPeers = args["network.maxPeers"] ?? (targetPeers !== undefined ? Math.floor(targetPeers * 1.1) : undefined);
|
|
107
|
+
if (targetPeers != null && maxPeers != null && targetPeers > maxPeers) {
|
|
108
|
+
throw new YargsError("network.maxPeers must be greater than or equal to targetPeers");
|
|
109
|
+
}
|
|
110
|
+
// Set discv5 opts to null to disable only if explicitly disabled
|
|
111
|
+
const enableDiscv5 = args.discv5 ?? true;
|
|
112
|
+
|
|
113
|
+
// TODO: Okay to set to empty array?
|
|
114
|
+
const bootEnrs = args.bootnodes ?? [];
|
|
115
|
+
// throw if user-provided enrs are invalid
|
|
116
|
+
for (const enrStr of bootEnrs) {
|
|
117
|
+
try {
|
|
118
|
+
ENR.decodeTxt(enrStr);
|
|
119
|
+
} catch (_e) {
|
|
120
|
+
throw new YargsError(`Provided ENR in bootnodes is invalid:\n ${enrStr}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
discv5: enableDiscv5
|
|
126
|
+
? {
|
|
127
|
+
config: {},
|
|
128
|
+
bindAddrs: {
|
|
129
|
+
ip4: bindMu as string,
|
|
130
|
+
ip6: bindMu6,
|
|
131
|
+
},
|
|
132
|
+
bootEnrs,
|
|
133
|
+
// biome-ignore lint/suspicious/noExplicitAny: We need to use `any` type here
|
|
134
|
+
enr: undefined as any,
|
|
135
|
+
}
|
|
136
|
+
: null,
|
|
137
|
+
maxPeers: maxPeers ?? defaultOptions.network.maxPeers,
|
|
138
|
+
targetPeers: targetPeers ?? defaultOptions.network.targetPeers,
|
|
139
|
+
localMultiaddrs: [localMu, localMu6].filter(Boolean) as string[],
|
|
140
|
+
subscribeAllSubnets: args.subscribeAllSubnets,
|
|
141
|
+
slotsToSubscribeBeforeAggregatorDuty:
|
|
142
|
+
args.slotsToSubscribeBeforeAggregatorDuty ?? defaultOptions.network.slotsToSubscribeBeforeAggregatorDuty,
|
|
143
|
+
disablePeerScoring: args.disablePeerScoring,
|
|
144
|
+
connectToDiscv5Bootnodes: args["network.connectToDiscv5Bootnodes"],
|
|
145
|
+
discv5FirstQueryDelayMs: args["network.discv5FirstQueryDelayMs"],
|
|
146
|
+
dontSendGossipAttestationsToForkchoice: args["network.dontSendGossipAttestationsToForkchoice"],
|
|
147
|
+
allowPublishToZeroPeers: args["network.allowPublishToZeroPeers"],
|
|
148
|
+
gossipsubD: args["network.gossipsubD"],
|
|
149
|
+
gossipsubDLow: args["network.gossipsubDLow"],
|
|
150
|
+
gossipsubDHigh: args["network.gossipsubDHigh"],
|
|
151
|
+
gossipsubAwaitHandler: args["network.gossipsubAwaitHandler"],
|
|
152
|
+
disableFloodPublish: args["network.disableFloodPublish"],
|
|
153
|
+
mdns: args.mdns,
|
|
154
|
+
rateLimitMultiplier: args["network.rateLimitMultiplier"],
|
|
155
|
+
maxGossipTopicConcurrency: args["network.maxGossipTopicConcurrency"],
|
|
156
|
+
useWorker: args["network.useWorker"],
|
|
157
|
+
maxYoungGenerationSizeMb: args["network.maxYoungGenerationSizeMb"],
|
|
158
|
+
targetGroupPeers: args["network.targetGroupPeers"] ?? defaultOptions.network.targetGroupPeers,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const options: CliCommandOptions<NetworkArgs> = {
|
|
163
|
+
discv5: {
|
|
164
|
+
type: "boolean",
|
|
165
|
+
// TODO: Add `network.discv5.enabled` to the `IDiscv5DiscoveryInputOptions` type
|
|
166
|
+
description: "Enable discv5",
|
|
167
|
+
defaultDescription: String(true),
|
|
168
|
+
group: "network",
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
listenAddress: {
|
|
172
|
+
type: "string",
|
|
173
|
+
description: "The IPv4 address to listen for p2p UDP and TCP connections",
|
|
174
|
+
defaultDescription: defaultListenAddress,
|
|
175
|
+
group: "network",
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
port: {
|
|
179
|
+
description: "The TCP/UDP port to listen on. The UDP port can be modified by the --discoveryPort flag.",
|
|
180
|
+
type: "number",
|
|
181
|
+
// TODO: Derive from BeaconNode defaults
|
|
182
|
+
defaultDescription: String(defaultP2pPort),
|
|
183
|
+
group: "network",
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
discoveryPort: {
|
|
187
|
+
description: "The UDP port that discovery will listen on. Defaults to `port`",
|
|
188
|
+
type: "number",
|
|
189
|
+
defaultDescription: "`port`",
|
|
190
|
+
group: "network",
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
listenAddress6: {
|
|
194
|
+
type: "string",
|
|
195
|
+
description: "The IPv6 address to listen for p2p UDP and TCP connections",
|
|
196
|
+
defaultDescription: defaultListenAddress6,
|
|
197
|
+
group: "network",
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
port6: {
|
|
201
|
+
description: "The TCP/UDP port to listen on. The UDP port can be modified by the --discoveryPort6 flag.",
|
|
202
|
+
type: "number",
|
|
203
|
+
// TODO: Derive from BeaconNode defaults
|
|
204
|
+
defaultDescription: String(defaultP2pPort),
|
|
205
|
+
group: "network",
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
discoveryPort6: {
|
|
209
|
+
description: "The UDP port that discovery will listen on. Defaults to `port6`",
|
|
210
|
+
type: "number",
|
|
211
|
+
defaultDescription: "`port6`",
|
|
212
|
+
group: "network",
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
bootnodes: {
|
|
216
|
+
type: "array",
|
|
217
|
+
description: "Bootnodes for discv5 discovery",
|
|
218
|
+
defaultDescription: JSON.stringify(defaultOptions.network.discv5?.bootEnrs || []),
|
|
219
|
+
group: "network",
|
|
220
|
+
// Each bootnode entry could be comma separated, just deserialize it into a single array
|
|
221
|
+
// as comma separated entries are generally most friendly in ansible kind of setups, i.e.
|
|
222
|
+
// [ "en1", "en2,en3" ] => [ 'en1', 'en2', 'en3' ]
|
|
223
|
+
coerce: (args: string[]) => args.flatMap((item) => item.split(",")),
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
targetPeers: {
|
|
227
|
+
type: "number",
|
|
228
|
+
description: "The target connected peers. Above this number peers will be disconnected",
|
|
229
|
+
defaultDescription: String(defaultOptions.network.targetPeers),
|
|
230
|
+
group: "network",
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
subscribeAllSubnets: {
|
|
234
|
+
type: "boolean",
|
|
235
|
+
description: "Subscribe to all subnets regardless of validator count",
|
|
236
|
+
defaultDescription: String(defaultOptions.network.subscribeAllSubnets === true),
|
|
237
|
+
group: "network",
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
slotsToSubscribeBeforeAggregatorDuty: {
|
|
241
|
+
hidden: true,
|
|
242
|
+
type: "number",
|
|
243
|
+
description: "Number of slots before an aggregator duty to subscribe to subnets",
|
|
244
|
+
defaultDescription: String(defaultOptions.network.slotsToSubscribeBeforeAggregatorDuty),
|
|
245
|
+
group: "network",
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
disablePeerScoring: {
|
|
249
|
+
type: "boolean",
|
|
250
|
+
description: "Disable peer scoring, used for testing on devnets",
|
|
251
|
+
defaultDescription: String(defaultOptions.network.disablePeerScoring === true),
|
|
252
|
+
group: "network",
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
mdns: {
|
|
256
|
+
type: "boolean",
|
|
257
|
+
description: "Enable mdns local peer discovery",
|
|
258
|
+
defaultDescription: String(defaultOptions.network.mdns === true),
|
|
259
|
+
group: "network",
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
"network.maxPeers": {
|
|
263
|
+
hidden: true,
|
|
264
|
+
type: "number",
|
|
265
|
+
description: "The maximum number of connections allowed",
|
|
266
|
+
defaultDescription: String(defaultOptions.network.maxPeers),
|
|
267
|
+
group: "network",
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
"network.connectToDiscv5Bootnodes": {
|
|
271
|
+
type: "boolean",
|
|
272
|
+
description: "Attempt direct libp2p peer connection to discv5 bootnodes",
|
|
273
|
+
hidden: true,
|
|
274
|
+
defaultDescription: String(defaultOptions.network.connectToDiscv5Bootnodes === true),
|
|
275
|
+
group: "network",
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
"network.discv5FirstQueryDelayMs": {
|
|
279
|
+
type: "number",
|
|
280
|
+
description: "Delay the 1st heart beat of Peer Manager after starting Discv5",
|
|
281
|
+
hidden: true,
|
|
282
|
+
defaultDescription: String(defaultOptions.network.discv5FirstQueryDelayMs),
|
|
283
|
+
group: "network",
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
"network.requestCountPeerLimit": {
|
|
287
|
+
type: "number",
|
|
288
|
+
description: "Max block req/resp requests per peer per rateTrackerTimeoutMs",
|
|
289
|
+
hidden: true,
|
|
290
|
+
group: "network",
|
|
291
|
+
deprecated: true,
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
"network.blockCountTotalLimit": {
|
|
295
|
+
type: "number",
|
|
296
|
+
description: "Max block count requested per rateTrackerTimeoutMs",
|
|
297
|
+
hidden: true,
|
|
298
|
+
group: "network",
|
|
299
|
+
deprecated: true,
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
"network.blockCountPeerLimit": {
|
|
303
|
+
type: "number",
|
|
304
|
+
description: "Max block count requested per peer per rateTrackerTimeoutMs",
|
|
305
|
+
hidden: true,
|
|
306
|
+
group: "network",
|
|
307
|
+
deprecated: true,
|
|
308
|
+
},
|
|
309
|
+
|
|
310
|
+
"network.rateTrackerTimeoutMs": {
|
|
311
|
+
type: "number",
|
|
312
|
+
description: "Time window to track rate limit in milliseconds",
|
|
313
|
+
hidden: true,
|
|
314
|
+
group: "network",
|
|
315
|
+
deprecated: true,
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
"network.dontSendGossipAttestationsToForkchoice": {
|
|
319
|
+
hidden: true,
|
|
320
|
+
type: "boolean",
|
|
321
|
+
description: "Pass gossip attestations to forkchoice or not",
|
|
322
|
+
group: "network",
|
|
323
|
+
},
|
|
324
|
+
|
|
325
|
+
"network.allowPublishToZeroPeers": {
|
|
326
|
+
hidden: true,
|
|
327
|
+
type: "boolean",
|
|
328
|
+
description: "Don't error when publishing to zero peers",
|
|
329
|
+
group: "network",
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
"network.gossipsubD": {
|
|
333
|
+
hidden: true,
|
|
334
|
+
type: "number",
|
|
335
|
+
description: "Gossipsub D param",
|
|
336
|
+
group: "network",
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
"network.gossipsubDLow": {
|
|
340
|
+
hidden: true,
|
|
341
|
+
type: "number",
|
|
342
|
+
description: "Gossipsub D param low",
|
|
343
|
+
group: "network",
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
"network.gossipsubDHigh": {
|
|
347
|
+
hidden: true,
|
|
348
|
+
type: "number",
|
|
349
|
+
description: "Gossipsub D param high",
|
|
350
|
+
group: "network",
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
"network.gossipsubAwaitHandler": {
|
|
354
|
+
hidden: true,
|
|
355
|
+
type: "boolean",
|
|
356
|
+
group: "network",
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
"network.disableFloodPublish": {
|
|
360
|
+
hidden: true,
|
|
361
|
+
description: "Disable gossipsub flood publish",
|
|
362
|
+
type: "boolean",
|
|
363
|
+
group: "network",
|
|
364
|
+
},
|
|
365
|
+
|
|
366
|
+
"network.rateLimitMultiplier": {
|
|
367
|
+
type: "number",
|
|
368
|
+
description: "The multiplier to increase the rate limits. Set to zero to disable rate limiting.",
|
|
369
|
+
hidden: true,
|
|
370
|
+
defaultDescription: String(defaultOptions.network.rateLimitMultiplier),
|
|
371
|
+
group: "network",
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
"network.maxGossipTopicConcurrency": {
|
|
375
|
+
type: "number",
|
|
376
|
+
hidden: true,
|
|
377
|
+
group: "network",
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
"network.useWorker": {
|
|
381
|
+
type: "boolean",
|
|
382
|
+
hidden: true,
|
|
383
|
+
group: "network",
|
|
384
|
+
},
|
|
385
|
+
|
|
386
|
+
"network.maxYoungGenerationSizeMb": {
|
|
387
|
+
type: "number",
|
|
388
|
+
hidden: true,
|
|
389
|
+
group: "network",
|
|
390
|
+
description: "Max size of young generation in megabytes. Defaults to 152mb",
|
|
391
|
+
defaultDescription: String(defaultOptions.network.maxYoungGenerationSizeMb),
|
|
392
|
+
},
|
|
393
|
+
|
|
394
|
+
"network.targetGroupPeers": {
|
|
395
|
+
type: "number",
|
|
396
|
+
hidden: true,
|
|
397
|
+
group: "network",
|
|
398
|
+
description: "Target number of peers per sampling group",
|
|
399
|
+
defaultDescription: String(defaultOptions.network.targetGroupPeers),
|
|
400
|
+
},
|
|
401
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {IBeaconNodeOptions, defaultOptions} from "@lodestar/beacon-node";
|
|
2
|
+
import {CliCommandOptions} from "@lodestar/utils";
|
|
3
|
+
|
|
4
|
+
export type SyncArgs = {
|
|
5
|
+
"sync.isSingleNode"?: boolean;
|
|
6
|
+
"sync.disableProcessAsChainSegment"?: boolean;
|
|
7
|
+
"sync.disableRangeSync"?: boolean;
|
|
8
|
+
"sync.backfillBatchSize"?: number;
|
|
9
|
+
"sync.slotImportTolerance"?: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function parseArgs(args: SyncArgs): IBeaconNodeOptions["sync"] {
|
|
13
|
+
return {
|
|
14
|
+
isSingleNode: args["sync.isSingleNode"],
|
|
15
|
+
disableProcessAsChainSegment: args["sync.disableProcessAsChainSegment"],
|
|
16
|
+
backfillBatchSize: args["sync.backfillBatchSize"] ?? defaultOptions.sync.backfillBatchSize,
|
|
17
|
+
disableRangeSync: args["sync.disableRangeSync"],
|
|
18
|
+
slotImportTolerance: args["sync.slotImportTolerance"] ?? defaultOptions.sync.slotImportTolerance,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const options: CliCommandOptions<SyncArgs> = {
|
|
23
|
+
"sync.isSingleNode": {
|
|
24
|
+
hidden: true,
|
|
25
|
+
type: "boolean",
|
|
26
|
+
description:
|
|
27
|
+
"Allow node to consider itself synced without being connected to a peer. \
|
|
28
|
+
Use only for local networks with a single node, can be dangerous in regular networks.",
|
|
29
|
+
defaultDescription: String(defaultOptions.sync.isSingleNode),
|
|
30
|
+
group: "sync",
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
"sync.disableRangeSync": {
|
|
34
|
+
hidden: true,
|
|
35
|
+
type: "boolean",
|
|
36
|
+
description: "Disable range sync completely. Should only be used for debugging or testing.",
|
|
37
|
+
defaultDescription: String(defaultOptions.sync.disableRangeSync),
|
|
38
|
+
group: "sync",
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
"sync.slotImportTolerance": {
|
|
42
|
+
hidden: true,
|
|
43
|
+
type: "number",
|
|
44
|
+
description: "Number of slot tolerance to trigger range sync and to measure if node is synced.",
|
|
45
|
+
defaultDescription: String(defaultOptions.sync.slotImportTolerance),
|
|
46
|
+
group: "sync",
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
"sync.disableProcessAsChainSegment": {
|
|
50
|
+
hidden: true,
|
|
51
|
+
type: "boolean",
|
|
52
|
+
description:
|
|
53
|
+
"For RangeSync disable processing batches of blocks at once. Should only be used for debugging or testing.",
|
|
54
|
+
defaultDescription: String(defaultOptions.sync.disableProcessAsChainSegment),
|
|
55
|
+
group: "sync",
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
"sync.backfillBatchSize": {
|
|
59
|
+
hidden: true,
|
|
60
|
+
type: "number",
|
|
61
|
+
description: "Batch size for backfill sync to sync/process blocks, set non zero to enable backfill sync",
|
|
62
|
+
defaultDescription: String(defaultOptions.sync.backfillBatchSize),
|
|
63
|
+
group: "sync",
|
|
64
|
+
},
|
|
65
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {ACTIVE_PRESET} from "@lodestar/params";
|
|
2
|
+
import {CliCommandOptions} from "@lodestar/utils";
|
|
3
|
+
import {NetworkName, networkNames} from "../networks/index.js";
|
|
4
|
+
import {readFile} from "../util/index.js";
|
|
5
|
+
import {IParamsArgs, paramsOptions} from "./paramsOptions.js";
|
|
6
|
+
|
|
7
|
+
type GlobalSingleArgs = {
|
|
8
|
+
dataDir?: string;
|
|
9
|
+
network?: NetworkName;
|
|
10
|
+
paramsFile?: string;
|
|
11
|
+
preset: string;
|
|
12
|
+
presetFile?: string;
|
|
13
|
+
rcConfig?: string;
|
|
14
|
+
supernode?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const defaultNetwork: NetworkName = "mainnet";
|
|
18
|
+
|
|
19
|
+
const globalSingleOptions: CliCommandOptions<GlobalSingleArgs> = {
|
|
20
|
+
dataDir: {
|
|
21
|
+
description: "Lodestar root data directory",
|
|
22
|
+
type: "string",
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
network: {
|
|
26
|
+
description: "Name of the Ethereum Consensus chain network to join",
|
|
27
|
+
type: "string",
|
|
28
|
+
defaultDescription: defaultNetwork,
|
|
29
|
+
choices: networkNames,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
paramsFile: {
|
|
33
|
+
description: "Network configuration file",
|
|
34
|
+
type: "string",
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// hidden option to allow for LODESTAR_PRESET to be set
|
|
38
|
+
preset: {
|
|
39
|
+
hidden: true,
|
|
40
|
+
type: "string",
|
|
41
|
+
default: ACTIVE_PRESET,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
presetFile: {
|
|
45
|
+
hidden: true,
|
|
46
|
+
description: "Preset configuration file to override the active preset with custom values",
|
|
47
|
+
type: "string",
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
rcConfig: {
|
|
51
|
+
description: "RC file to supplement command line args, accepted formats: .yml, .yaml, .json",
|
|
52
|
+
type: "string",
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
supernode: {
|
|
56
|
+
description: "Subscribe to and custody all data column sidecar subnets",
|
|
57
|
+
type: "boolean",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const rcConfigOption: [string, string, (configPath: string) => Record<string, unknown>] = [
|
|
62
|
+
"rcConfig",
|
|
63
|
+
globalSingleOptions.rcConfig.description as string,
|
|
64
|
+
(configPath: string): Record<string, unknown> => readFile(configPath, ["json", "yml", "yaml"]),
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
export type GlobalArgs = GlobalSingleArgs & IParamsArgs;
|
|
68
|
+
|
|
69
|
+
export const globalOptions = {
|
|
70
|
+
...globalSingleOptions,
|
|
71
|
+
...paramsOptions,
|
|
72
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {LogLevel, logFormats} from "@lodestar/logger";
|
|
2
|
+
import {CliCommandOptions, LogLevels} from "@lodestar/utils";
|
|
3
|
+
import {LOG_FILE_DISABLE_KEYWORD} from "../util/logger.js";
|
|
4
|
+
|
|
5
|
+
export type LogArgs = {
|
|
6
|
+
logLevel: LogLevel;
|
|
7
|
+
logFile?: string;
|
|
8
|
+
logFileLevel: LogLevel;
|
|
9
|
+
logFileDailyRotate: number;
|
|
10
|
+
logFormatGenesisTime?: number;
|
|
11
|
+
logPrefix?: string;
|
|
12
|
+
logFormat?: string;
|
|
13
|
+
logLevelModule?: string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const logOptions: CliCommandOptions<LogArgs> = {
|
|
17
|
+
logLevel: {
|
|
18
|
+
choices: LogLevels,
|
|
19
|
+
description: "Logging verbosity level for emitting logs to terminal",
|
|
20
|
+
default: LogLevel.info,
|
|
21
|
+
type: "string",
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
logFile: {
|
|
25
|
+
description: `Path to output all logs to a persistent log file, use '${LOG_FILE_DISABLE_KEYWORD}' to disable`,
|
|
26
|
+
type: "string",
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
logFileLevel: {
|
|
30
|
+
choices: LogLevels,
|
|
31
|
+
description: "Logging verbosity level for emitting logs to file",
|
|
32
|
+
default: LogLevel.debug,
|
|
33
|
+
type: "string",
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
logFileDailyRotate: {
|
|
37
|
+
description:
|
|
38
|
+
"Daily rotate log files, set to an integer to limit the file count, set to 0 (zero) to disable rotation",
|
|
39
|
+
default: 5,
|
|
40
|
+
type: "number",
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
logFormatGenesisTime: {
|
|
44
|
+
hidden: true,
|
|
45
|
+
description:
|
|
46
|
+
"Use epoch slot timestamp format, instead or regular timestamp. Must provide genesisTime to compute relative time",
|
|
47
|
+
type: "number",
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
logPrefix: {
|
|
51
|
+
hidden: true,
|
|
52
|
+
description: "Logger prefix module field with a string ID",
|
|
53
|
+
type: "string",
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
logFormat: {
|
|
57
|
+
hidden: true,
|
|
58
|
+
description: "Log format used when emitting logs to the terminal and / or file",
|
|
59
|
+
choices: logFormats,
|
|
60
|
+
type: "string",
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
logLevelModule: {
|
|
64
|
+
hidden: true,
|
|
65
|
+
description: "Set log level for a specific module by name: 'chain=debug' or 'network=debug,chain=debug'",
|
|
66
|
+
type: "array",
|
|
67
|
+
string: true,
|
|
68
|
+
coerce: (args: string[]) => args.flatMap((item) => item.split(",")),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {ChainConfig, chainConfigTypes} from "@lodestar/config";
|
|
2
|
+
import {CliCommandOptions, CliOptionDefinition} from "@lodestar/utils";
|
|
3
|
+
import {IBeaconParamsUnparsed} from "../config/types.js";
|
|
4
|
+
import {ObjectKeys} from "../util/index.js";
|
|
5
|
+
|
|
6
|
+
// No options are statically declared
|
|
7
|
+
// If an arbitrary key notation is used, it removes type safety on most of this CLI arg parsing code.
|
|
8
|
+
// Params will be parsed from an args object assuming to contain the required keys
|
|
9
|
+
|
|
10
|
+
export type ITerminalPowArgs = {
|
|
11
|
+
"terminal-total-difficulty-override"?: string;
|
|
12
|
+
"terminal-block-hash-override"?: string;
|
|
13
|
+
"terminal-block-hash-epoch-override"?: string;
|
|
14
|
+
};
|
|
15
|
+
export type IParamsArgs = Record<never, never> & ITerminalPowArgs;
|
|
16
|
+
|
|
17
|
+
const getArgKey = (key: keyof IBeaconParamsUnparsed): string => `params.${key}`;
|
|
18
|
+
|
|
19
|
+
export function parseBeaconParamsArgs(args: Record<string, string | number>): IBeaconParamsUnparsed {
|
|
20
|
+
return ObjectKeys(chainConfigTypes).reduce((beaconParams: Partial<IBeaconParamsUnparsed>, key) => {
|
|
21
|
+
const value = args[getArgKey(key)];
|
|
22
|
+
if (value != null) beaconParams[key] = value;
|
|
23
|
+
return beaconParams;
|
|
24
|
+
}, {});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const paramsOptionsByName = ObjectKeys(chainConfigTypes).reduce(
|
|
28
|
+
(options: Record<string, CliOptionDefinition>, key): Record<string, CliOptionDefinition> => {
|
|
29
|
+
options[getArgKey(key)] = {
|
|
30
|
+
hidden: true,
|
|
31
|
+
type: "string",
|
|
32
|
+
group: "params",
|
|
33
|
+
};
|
|
34
|
+
return options;
|
|
35
|
+
},
|
|
36
|
+
{}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const terminalArgsToParamsMap: {[K in keyof ITerminalPowArgs]: keyof ChainConfig} = {
|
|
40
|
+
"terminal-total-difficulty-override": "TERMINAL_TOTAL_DIFFICULTY",
|
|
41
|
+
"terminal-block-hash-override": "TERMINAL_BLOCK_HASH",
|
|
42
|
+
"terminal-block-hash-epoch-override": "TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export function parseTerminalPowArgs(args: ITerminalPowArgs): IBeaconParamsUnparsed {
|
|
46
|
+
const parsedArgs = ObjectKeys(terminalArgsToParamsMap).reduce((beaconParams: Partial<IBeaconParamsUnparsed>, key) => {
|
|
47
|
+
const paramOption = terminalArgsToParamsMap[key];
|
|
48
|
+
const value = args[key];
|
|
49
|
+
if (paramOption != null && value != null) beaconParams[paramOption] = value;
|
|
50
|
+
return beaconParams;
|
|
51
|
+
}, {});
|
|
52
|
+
return parsedArgs;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const paramsOptions: CliCommandOptions<IParamsArgs> = {
|
|
56
|
+
...paramsOptionsByName,
|
|
57
|
+
|
|
58
|
+
"terminal-total-difficulty-override": {
|
|
59
|
+
description: "Terminal PoW block TTD override",
|
|
60
|
+
type: "string",
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
"terminal-block-hash-override": {
|
|
64
|
+
description: "Terminal PoW block hash override",
|
|
65
|
+
type: "string",
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
"terminal-block-hash-epoch-override": {
|
|
69
|
+
description: "Terminal PoW block hash override activation epoch",
|
|
70
|
+
type: "string",
|
|
71
|
+
},
|
|
72
|
+
};
|