import {CliCommandOptions, CliOptionDefinition} from "@lodestar/utils"; import {NetworkName} from "../../networks/index.js"; import {beaconNodeOptions, globalOptions} from "../../options/index.js"; import {parseRange} from "../../util/format.js"; import {BeaconArgs, beaconOptions} from "../beacon/options.js"; import {IValidatorCliArgs, validatorOptions} from "../validator/options.js"; type IDevOwnArgs = { genesisEth1Hash?: string; genesisValidators: number; startValidators?: number[]; genesisTime?: number; reset?: boolean; dumpTestnetFiles?: string; }; const devOwnOptions: CliCommandOptions = { genesisEth1Hash: { description: "If present it will create genesis with this eth1 hash.", type: "string", group: "dev", }, genesisValidators: { alias: ["c"], description: "If present it will create genesis with interop validators and start chain.", default: 8, type: "number", group: "dev", }, startValidators: { description: "Start interop validators in inclusive range(s) with notation '0..7'", type: "array", coerce: (indexes: string[]): number[] => // Parse ["11..13,15..17"] to ["11..13", "15..17"] indexes .flatMap((item) => item.split(",")) .flatMap(parseRange), group: "dev", }, genesisTime: { description: "genesis_time to initialize interop genesis state", defaultDescription: "now", type: "number", group: "dev", }, reset: { description: "To delete chain and validator directories", alias: ["r"], type: "boolean", group: "dev", }, dumpTestnetFiles: { description: "Dump testnet files and exit", type: "string", group: "dev", }, }; /** * Add custom defaults different than the ones in `beaconOptions`: * - In dev command we don't wanna connect to other peers, * - but we do wanna get out of syncing (min peers) * - and have api enabled by default (as it's used by validator) * Note: use beaconNodeOptions and globalOptions to make sure option key is correct */ const externalOptionsOverrides: Partial> = { // Custom paths different than regular beacon, validator paths // network="dev" will store all data in separate dir than other networks network: { ...globalOptions.network, default: "dev" as NetworkName, }, "sync.isSingleNode": { ...beaconNodeOptions["sync.isSingleNode"], defaultDescription: undefined, default: true, }, "network.allowPublishToZeroPeers": { ...beaconNodeOptions["network.allowPublishToZeroPeers"], defaultDescription: undefined, default: true, }, rest: { ...beaconNodeOptions.rest, defaultDescription: undefined, default: true, }, "rest.stacktraces": { ...beaconNodeOptions["rest.stacktraces"], default: true, }, "rest.swaggerUI": { ...beaconNodeOptions["rest.swaggerUI"], default: true, }, "execution.engineMock": { ...beaconNodeOptions["execution.engineMock"], default: true, }, }; export const devOptions = { ...beaconOptions, ...validatorOptions, ...externalOptionsOverrides, ...devOwnOptions, }; export type IDevArgs = BeaconArgs & IValidatorCliArgs & IDevOwnArgs;