2020-04-22 05:53:02 +00:00
|
|
|
{.push raises: [Defect].}
|
|
|
|
|
2018-11-23 23:58:49 +00:00
|
|
|
import
|
2020-06-02 19:59:51 +00:00
|
|
|
os, options,
|
2020-07-02 15:14:11 +00:00
|
|
|
chronicles, chronicles/options as chroniclesOptions,
|
|
|
|
confutils, confutils/defs, confutils/std/net,
|
|
|
|
json_serialization, web3/ethtypes,
|
|
|
|
network_metadata, spec/[crypto, keystore, digest]
|
2018-12-19 12:58:53 +00:00
|
|
|
|
|
|
|
export
|
2020-07-02 15:14:11 +00:00
|
|
|
defs, enabledLogLevel, parseCmdArg, completeCmdArg,
|
|
|
|
network_metadata
|
2019-03-26 19:44:51 +00:00
|
|
|
|
2018-11-23 23:58:49 +00:00
|
|
|
type
|
2019-03-18 03:54:08 +00:00
|
|
|
ValidatorKeyPath* = TypedInputFile[ValidatorPrivKey, Txt, "privkey"]
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2020-05-22 17:04:52 +00:00
|
|
|
BNStartUpCmd* = enum
|
2018-12-19 12:58:53 +00:00
|
|
|
noCommand
|
2019-03-26 10:01:13 +00:00
|
|
|
createTestnet
|
2020-06-15 22:20:31 +00:00
|
|
|
deposits
|
2020-06-23 19:11:07 +00:00
|
|
|
wallets
|
2020-06-15 22:20:31 +00:00
|
|
|
|
2020-06-23 19:11:07 +00:00
|
|
|
WalletsCmd* {.pure.} = enum
|
|
|
|
create = "Creates a new EIP-2386 wallet"
|
|
|
|
restore = "Restores a wallet from cold storage"
|
|
|
|
list = "Lists details about all wallets"
|
2020-06-15 22:20:31 +00:00
|
|
|
|
2020-06-23 19:11:07 +00:00
|
|
|
DepositsCmd* {.pure.} = enum
|
|
|
|
create = "Creates validator keystores and deposits"
|
|
|
|
send = "Sends prepared deposits to the validator deposit contract"
|
|
|
|
status = "Displays status information about all deposits"
|
2019-11-01 09:53:06 +00:00
|
|
|
|
2020-05-22 17:04:52 +00:00
|
|
|
VCStartUpCmd* = enum
|
|
|
|
VCNoCommand
|
|
|
|
|
2020-07-02 15:14:11 +00:00
|
|
|
Web3Url* = distinct string
|
2019-10-28 23:04:52 +00:00
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
BeaconNodeConf* = object
|
2019-01-16 23:01:15 +00:00
|
|
|
logLevel* {.
|
2020-04-27 22:39:04 +00:00
|
|
|
defaultValue: "DEBUG"
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Sets the log level"
|
2020-04-27 22:39:04 +00:00
|
|
|
name: "log-level" }: string
|
2019-03-18 03:54:08 +00:00
|
|
|
|
2020-07-02 15:14:11 +00:00
|
|
|
eth2Network* {.
|
|
|
|
desc: "The Eth2 network to join"
|
|
|
|
name: "network" }: Option[string]
|
2019-03-19 17:22:17 +00:00
|
|
|
|
|
|
|
dataDir* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: config.defaultDataDir()
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "The directory where nimbus will store all blockchain data"
|
2019-11-11 14:43:12 +00:00
|
|
|
abbr: "d"
|
|
|
|
name: "data-dir" }: OutDir
|
2019-01-16 23:01:15 +00:00
|
|
|
|
2020-03-24 11:13:07 +00:00
|
|
|
web3Url* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: ""
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "URL of the Web3 server to observe Eth1"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "web3-url" }: string
|
2019-09-01 15:02:49 +00:00
|
|
|
|
|
|
|
depositContractAddress* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Address of the deposit contract"
|
2020-07-02 15:14:11 +00:00
|
|
|
name: "deposit-contract" }: Option[Eth1Address]
|
2019-10-03 01:51:44 +00:00
|
|
|
|
2020-06-19 17:42:28 +00:00
|
|
|
depositContractDeployedAt* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "The Eth1 block hash where the deposit contract has been deployed"
|
2020-06-19 17:42:28 +00:00
|
|
|
name: "deposit-contract-block" }: Option[Eth2Digest]
|
|
|
|
|
2020-06-01 19:48:20 +00:00
|
|
|
nonInteractive* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Do not display interative prompts. Quit on missing configuration"
|
2020-06-01 19:48:20 +00:00
|
|
|
name: "non-interactive" }: bool
|
|
|
|
|
2018-12-19 12:58:53 +00:00
|
|
|
case cmd* {.
|
|
|
|
command
|
2020-05-22 17:04:52 +00:00
|
|
|
defaultValue: noCommand }: BNStartUpCmd
|
2018-12-19 12:58:53 +00:00
|
|
|
|
|
|
|
of noCommand:
|
|
|
|
bootstrapNodes* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Specifies one or more bootstrap nodes to use when connecting to the network"
|
2019-11-11 14:43:12 +00:00
|
|
|
abbr: "b"
|
|
|
|
name: "bootstrap-node" }: seq[string]
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2018-12-19 12:58:53 +00:00
|
|
|
bootstrapNodesFile* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: ""
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Specifies a line-delimited file of bootstrap Ethereum network addresses"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "bootstrap-file" }: InputFile
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2020-03-18 19:36:22 +00:00
|
|
|
libp2pAddress* {.
|
|
|
|
defaultValue: defaultListenAddress(config)
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Listening address for the Ethereum LibP2P traffic"
|
2020-06-05 15:08:50 +00:00
|
|
|
name: "listen-address" }: ValidIpAddress
|
2020-03-18 19:36:22 +00:00
|
|
|
|
2018-12-19 12:58:53 +00:00
|
|
|
tcpPort* {.
|
2020-03-16 22:28:54 +00:00
|
|
|
defaultValue: defaultEth2TcpPort
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Listening TCP port for Ethereum LibP2P traffic"
|
2020-03-16 22:28:54 +00:00
|
|
|
name: "tcp-port" }: Port
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2018-12-19 12:58:53 +00:00
|
|
|
udpPort* {.
|
2020-03-16 22:28:54 +00:00
|
|
|
defaultValue: defaultEth2TcpPort
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Listening UDP port for node discovery"
|
2020-03-16 22:28:54 +00:00
|
|
|
name: "udp-port" }: Port
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2019-12-18 01:11:20 +00:00
|
|
|
maxPeers* {.
|
2020-06-05 20:25:01 +00:00
|
|
|
defaultValue: 79 # The Wall gets released
|
2019-12-18 01:11:20 +00:00
|
|
|
desc: "The maximum number of peers to connect to"
|
|
|
|
name: "max-peers" }: int
|
|
|
|
|
2019-03-19 03:57:19 +00:00
|
|
|
nat* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
desc: "Specify method to use for determining public address. " &
|
2020-06-23 19:11:07 +00:00
|
|
|
"Must be one of: any, none, upnp, pmp, extip:<IP>"
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: "any" }: string
|
2019-03-19 03:57:19 +00:00
|
|
|
|
2018-12-19 12:58:53 +00:00
|
|
|
validators* {.
|
|
|
|
required
|
2020-06-15 22:20:31 +00:00
|
|
|
desc: "Path to a validator keystore"
|
2019-11-11 14:43:12 +00:00
|
|
|
abbr: "v"
|
|
|
|
name: "validator" }: seq[ValidatorKeyPath]
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2020-06-03 11:52:36 +00:00
|
|
|
validatorsDirFlag* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "A directory containing validator keystores"
|
2020-06-01 19:48:20 +00:00
|
|
|
name: "validators-dir" }: Option[InputDir]
|
|
|
|
|
2020-06-03 11:52:36 +00:00
|
|
|
secretsDirFlag* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "A directory containing validator keystore passwords"
|
2020-06-01 19:48:20 +00:00
|
|
|
name: "secrets-dir" }: Option[InputDir]
|
|
|
|
|
2020-06-23 19:11:07 +00:00
|
|
|
walletsDirFlag* {.
|
|
|
|
desc: "A directory containing wallet files"
|
|
|
|
name: "wallets-dir" }: Option[InputDir]
|
|
|
|
|
2018-12-19 12:58:53 +00:00
|
|
|
stateSnapshot* {.
|
2020-07-02 15:52:48 +00:00
|
|
|
desc: "SSZ file specifying a recent state snapshot"
|
2019-11-11 14:43:12 +00:00
|
|
|
abbr: "s"
|
|
|
|
name: "state-snapshot" }: Option[InputFile]
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2020-07-02 15:52:48 +00:00
|
|
|
stateSnapshotContents* {.hidden.}: ref string
|
|
|
|
# This is ref so we can mutate it (to erase it) after the initial loading.
|
|
|
|
|
2019-10-28 23:04:52 +00:00
|
|
|
nodeName* {.
|
2019-11-11 14:43:12 +00:00
|
|
|
defaultValue: ""
|
2019-03-22 14:35:20 +00:00
|
|
|
desc: "A name for this node that will appear in the logs. " &
|
2020-06-23 19:11:07 +00:00
|
|
|
"If you set this to 'auto', a persistent automatically generated ID will be selected for each --data-dir folder"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "node-name" }: string
|
2019-03-22 14:35:20 +00:00
|
|
|
|
2020-02-17 18:24:14 +00:00
|
|
|
verifyFinalization* {.
|
|
|
|
defaultValue: false
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Specify whether to verify finalization occurs on schedule, for testing"
|
2020-02-17 18:24:14 +00:00
|
|
|
name: "verify-finalization" }: bool
|
|
|
|
|
2020-02-17 21:22:50 +00:00
|
|
|
stopAtEpoch* {.
|
2020-02-17 18:24:14 +00:00
|
|
|
defaultValue: 0
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "A positive epoch selects the epoch at which to stop"
|
2020-02-17 21:22:50 +00:00
|
|
|
name: "stop-at-epoch" }: uint64
|
2020-02-17 18:24:14 +00:00
|
|
|
|
2020-03-16 22:28:54 +00:00
|
|
|
metricsEnabled* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: false
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Enable the metrics server"
|
2020-03-16 22:28:54 +00:00
|
|
|
name: "metrics" }: bool
|
2019-09-07 17:48:05 +00:00
|
|
|
|
2020-03-16 22:28:54 +00:00
|
|
|
metricsAddress* {.
|
2020-03-18 19:36:22 +00:00
|
|
|
defaultValue: defaultAdminListenAddress(config)
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Listening address of the metrics server"
|
2020-06-05 15:08:50 +00:00
|
|
|
name: "metrics-address" }: ValidIpAddress
|
2019-09-07 17:48:05 +00:00
|
|
|
|
2020-03-16 22:28:54 +00:00
|
|
|
metricsPort* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: 8008
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Listening HTTP port of the metrics server"
|
2020-03-16 22:28:54 +00:00
|
|
|
name: "metrics-port" }: Port
|
2019-09-07 17:48:05 +00:00
|
|
|
|
2020-03-18 19:36:22 +00:00
|
|
|
statusBarEnabled* {.
|
|
|
|
defaultValue: true
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Display a status bar at the bottom of the terminal screen"
|
2020-03-18 19:36:22 +00:00
|
|
|
name: "status-bar" }: bool
|
|
|
|
|
|
|
|
statusBarContents* {.
|
2020-06-08 16:04:11 +00:00
|
|
|
defaultValue: "peers: $connected_peers;" &
|
|
|
|
"finalized: $finalized_root:$finalized_epoch;" &
|
|
|
|
"head: $head_root:$head_epoch:$head_epoch_slot;" &
|
|
|
|
"time: $epoch:$epoch_slot ($slot)|" &
|
2020-03-18 19:36:22 +00:00
|
|
|
"ETH: $attached_validators_balance"
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Textual template for the contents of the status bar"
|
2020-03-18 19:36:22 +00:00
|
|
|
name: "status-bar-contents" }: string
|
|
|
|
|
|
|
|
rpcEnabled* {.
|
|
|
|
defaultValue: false
|
|
|
|
desc: "Enable the JSON-RPC server"
|
|
|
|
name: "rpc" }: bool
|
|
|
|
|
|
|
|
rpcPort* {.
|
|
|
|
defaultValue: defaultEth2RpcPort
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "HTTP port for the JSON-RPC service"
|
2020-03-18 19:36:22 +00:00
|
|
|
name: "rpc-port" }: Port
|
|
|
|
|
|
|
|
rpcAddress* {.
|
|
|
|
defaultValue: defaultAdminListenAddress(config)
|
|
|
|
desc: "Listening address of the RPC server"
|
2020-06-05 15:08:50 +00:00
|
|
|
name: "rpc-address" }: ValidIpAddress
|
2020-03-18 19:36:22 +00:00
|
|
|
|
|
|
|
dumpEnabled* {.
|
2019-12-03 11:32:27 +00:00
|
|
|
defaultValue: false
|
|
|
|
desc: "Write SSZ dumps of blocks, attestations and states to data dir"
|
2020-03-18 19:36:22 +00:00
|
|
|
name: "dump" }: bool
|
2019-12-03 11:32:27 +00:00
|
|
|
|
2019-03-19 17:22:17 +00:00
|
|
|
of createTestnet:
|
2020-06-01 19:48:20 +00:00
|
|
|
testnetDepositsDir* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Directory containing validator keystores"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "validators-dir" }: InputDir
|
2019-03-07 13:59:28 +00:00
|
|
|
|
2019-03-27 12:06:06 +00:00
|
|
|
totalValidators* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "The number of validator deposits in the newly created chain"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "total-validators" }: uint64
|
2019-03-07 13:59:28 +00:00
|
|
|
|
|
|
|
firstValidator* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: 0
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Index of first validator to add to validator list"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "first-validator" }: uint64
|
2019-03-19 17:22:17 +00:00
|
|
|
|
2019-03-27 12:06:06 +00:00
|
|
|
lastUserValidator* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: config.totalValidators - 1,
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "The last validator index that will free for taking from a testnet participant"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "last-user-validator" }: uint64
|
2019-03-19 17:22:17 +00:00
|
|
|
|
|
|
|
bootstrapAddress* {.
|
2020-06-05 15:08:50 +00:00
|
|
|
defaultValue: ValidIpAddress.init("127.0.0.1")
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "The public IP address that will be advertised as a bootstrap node for the testnet"
|
2020-06-05 15:08:50 +00:00
|
|
|
name: "bootstrap-address" }: ValidIpAddress
|
2019-03-19 17:22:17 +00:00
|
|
|
|
|
|
|
bootstrapPort* {.
|
2020-03-16 22:28:54 +00:00
|
|
|
defaultValue: defaultEth2TcpPort
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "The TCP/UDP port that will be used by the bootstrap node"
|
2020-03-16 22:28:54 +00:00
|
|
|
name: "bootstrap-port" }: Port
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2019-02-15 16:33:32 +00:00
|
|
|
genesisOffset* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: 5
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Seconds from now to add to genesis time"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "genesis-offset" }: int
|
2019-02-15 16:33:32 +00:00
|
|
|
|
2019-03-19 17:22:17 +00:00
|
|
|
outputGenesis* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Output file where to write the initial state snapshot"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "output-genesis" }: OutFile
|
2019-03-18 03:54:08 +00:00
|
|
|
|
2019-09-10 21:55:58 +00:00
|
|
|
withGenesisRoot* {.
|
2019-10-28 23:04:52 +00:00
|
|
|
defaultValue: false
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Include a genesis root in 'network.json'"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "with-genesis-root" }: bool
|
2019-09-10 21:55:58 +00:00
|
|
|
|
2019-10-28 23:04:52 +00:00
|
|
|
outputBootstrapFile* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Output file with list of bootstrap nodes for the network"
|
2019-11-11 14:43:12 +00:00
|
|
|
name: "output-bootstrap-file" }: OutFile
|
2019-09-10 22:13:27 +00:00
|
|
|
|
2020-06-23 19:11:07 +00:00
|
|
|
of wallets:
|
|
|
|
case walletsCmd* {.command.}: WalletsCmd
|
|
|
|
of WalletsCmd.create:
|
|
|
|
createdWalletName* {.
|
|
|
|
desc: "An easy-to-remember name for the wallet of your choice"
|
|
|
|
name: "name"}: Option[WalletName]
|
|
|
|
|
|
|
|
nextAccount* {.
|
|
|
|
desc: "Initial value for the 'nextaccount' property of the wallet"
|
|
|
|
name: "next-account" }: Option[Natural]
|
|
|
|
|
|
|
|
createdWalletFile* {.
|
|
|
|
desc: "Output wallet file"
|
|
|
|
name: "out" }: Option[OutFile]
|
|
|
|
|
|
|
|
of WalletsCmd.restore:
|
|
|
|
restoredWalletName* {.
|
|
|
|
desc: "An easy-to-remember name for the wallet of your choice"
|
|
|
|
name: "name"}: Option[WalletName]
|
|
|
|
|
|
|
|
restoredDepositsCount* {.
|
|
|
|
desc: "Expected number of deposits to recover. If not specified, " &
|
|
|
|
"Nimbus will try to guess the number by inspecting the latest " &
|
|
|
|
"beacon state"
|
|
|
|
name: "deposits".}: Option[Natural]
|
|
|
|
|
|
|
|
restoredWalletFile* {.
|
|
|
|
desc: "Output wallet file"
|
|
|
|
name: "out" }: Option[OutFile]
|
|
|
|
|
|
|
|
of WalletsCmd.list:
|
|
|
|
discard
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2020-06-15 22:20:31 +00:00
|
|
|
of deposits:
|
2020-06-24 13:57:09 +00:00
|
|
|
depositPrivateKey* {.
|
|
|
|
defaultValue: ""
|
|
|
|
desc: "Private key of the controlling (sending) account",
|
|
|
|
name: "deposit-private-key" }: string
|
|
|
|
|
2020-06-16 18:38:51 +00:00
|
|
|
case depositsCmd* {.command.}: DepositsCmd
|
2020-06-23 19:11:07 +00:00
|
|
|
of DepositsCmd.create:
|
2020-06-15 22:20:31 +00:00
|
|
|
totalDeposits* {.
|
|
|
|
defaultValue: 1
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Number of deposits to generate"
|
2020-06-15 22:20:31 +00:00
|
|
|
name: "count" }: int
|
|
|
|
|
2020-06-23 19:11:07 +00:00
|
|
|
existingWalletId* {.
|
|
|
|
desc: "An existing wallet ID. If not specified, a new wallet will be created"
|
|
|
|
name: "wallet" }: Option[WalletName]
|
|
|
|
|
2020-06-15 22:20:31 +00:00
|
|
|
outValidatorsDir* {.
|
|
|
|
defaultValue: "validators"
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Output folder for validator keystores and deposits"
|
2020-06-16 18:38:51 +00:00
|
|
|
name: "out-deposits-dir" }: string
|
2020-06-15 22:20:31 +00:00
|
|
|
|
|
|
|
outSecretsDir* {.
|
|
|
|
defaultValue: "secrets"
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Output folder for randomly generated keystore passphrases"
|
2020-06-15 22:20:31 +00:00
|
|
|
name: "out-secrets-dir" }: string
|
|
|
|
|
|
|
|
dontSend* {.
|
|
|
|
defaultValue: false,
|
|
|
|
desc: "By default, all created deposits are also immediately sent " &
|
|
|
|
"to the validator deposit contract. You can use this option to " &
|
|
|
|
"prevent this behavior. Use the `deposits send` command to send " &
|
2020-06-23 19:11:07 +00:00
|
|
|
"the deposit transactions at your convenience later"
|
2020-06-15 22:20:31 +00:00
|
|
|
name: "dont-send" .}: bool
|
|
|
|
|
2020-06-23 19:11:07 +00:00
|
|
|
of DepositsCmd.send:
|
2020-06-15 22:20:31 +00:00
|
|
|
depositsDir* {.
|
|
|
|
defaultValue: "validators"
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "A folder with validator metadata created by the `deposits create` command"
|
2020-06-16 18:38:51 +00:00
|
|
|
name: "deposits-dir" }: string
|
2020-06-15 22:20:31 +00:00
|
|
|
|
|
|
|
minDelay* {.
|
|
|
|
defaultValue: 0.0
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Minimum possible delay between making two deposits (in seconds)"
|
2020-06-15 22:20:31 +00:00
|
|
|
name: "min-delay" }: float
|
|
|
|
|
|
|
|
maxDelay* {.
|
|
|
|
defaultValue: 0.0
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Maximum possible delay between making two deposits (in seconds)"
|
2020-06-15 22:20:31 +00:00
|
|
|
name: "max-delay" }: float
|
2020-06-16 18:38:51 +00:00
|
|
|
|
2020-06-23 19:11:07 +00:00
|
|
|
of DepositsCmd.status:
|
|
|
|
discard
|
|
|
|
|
2020-05-22 17:04:52 +00:00
|
|
|
ValidatorClientConf* = object
|
|
|
|
logLevel* {.
|
|
|
|
defaultValue: "DEBUG"
|
|
|
|
desc: "Sets the log level."
|
|
|
|
name: "log-level" }: string
|
|
|
|
|
|
|
|
dataDir* {.
|
|
|
|
defaultValue: config.defaultDataDir()
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "The directory where nimbus will store all blockchain data"
|
2020-05-22 17:04:52 +00:00
|
|
|
abbr: "d"
|
|
|
|
name: "data-dir" }: OutDir
|
|
|
|
|
2020-06-01 19:48:20 +00:00
|
|
|
nonInteractive* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Do not display interative prompts. Quit on missing configuration"
|
2020-06-01 19:48:20 +00:00
|
|
|
name: "non-interactive" }: bool
|
|
|
|
|
2020-05-22 17:04:52 +00:00
|
|
|
case cmd* {.
|
|
|
|
command
|
|
|
|
defaultValue: VCNoCommand }: VCStartUpCmd
|
|
|
|
|
|
|
|
of VCNoCommand:
|
|
|
|
rpcPort* {.
|
|
|
|
defaultValue: defaultEth2RpcPort
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "HTTP port of the server to connect to for RPC"
|
2020-05-22 17:04:52 +00:00
|
|
|
name: "rpc-port" }: Port
|
|
|
|
|
|
|
|
rpcAddress* {.
|
|
|
|
defaultValue: defaultAdminListenAddress(config)
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Address of the server to connect to for RPC"
|
2020-06-05 15:08:50 +00:00
|
|
|
name: "rpc-address" }: ValidIpAddress
|
2020-05-22 17:04:52 +00:00
|
|
|
|
|
|
|
validators* {.
|
|
|
|
required
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "Attach a validator by supplying a keystore path"
|
2020-05-22 17:04:52 +00:00
|
|
|
abbr: "v"
|
|
|
|
name: "validator" }: seq[ValidatorKeyPath]
|
|
|
|
|
2020-06-03 13:16:39 +00:00
|
|
|
validatorsDirFlag* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "A directory containing validator keystores"
|
2020-06-01 19:48:20 +00:00
|
|
|
name: "validators-dir" }: Option[InputDir]
|
|
|
|
|
2020-06-03 13:16:39 +00:00
|
|
|
secretsDirFlag* {.
|
2020-06-23 19:11:07 +00:00
|
|
|
desc: "A directory containing validator keystore passwords"
|
2020-06-01 19:48:20 +00:00
|
|
|
name: "secrets-dir" }: Option[InputDir]
|
|
|
|
|
2020-05-22 17:04:52 +00:00
|
|
|
proc defaultDataDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
|
2019-03-19 17:22:17 +00:00
|
|
|
let dataDir = when defined(windows):
|
|
|
|
"AppData" / "Roaming" / "Nimbus"
|
|
|
|
elif defined(macosx):
|
|
|
|
"Library" / "Application Support" / "Nimbus"
|
|
|
|
else:
|
|
|
|
".cache" / "nimbus"
|
2018-12-09 08:25:02 +00:00
|
|
|
|
2019-10-28 23:04:52 +00:00
|
|
|
getHomeDir() / dataDir / "BeaconNode"
|
2018-11-29 01:08:34 +00:00
|
|
|
|
2020-05-22 17:04:52 +00:00
|
|
|
func dumpDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
|
2019-12-03 11:32:27 +00:00
|
|
|
conf.dataDir / "dump"
|
2019-12-10 14:20:40 +00:00
|
|
|
|
2020-06-16 08:49:32 +00:00
|
|
|
func dumpDirInvalid*(conf: BeaconNodeConf|ValidatorClientConf): string =
|
|
|
|
conf.dumpDir / "invalid" # things that failed validation
|
|
|
|
|
|
|
|
func dumpDirIncoming*(conf: BeaconNodeConf|ValidatorClientConf): string =
|
|
|
|
conf.dumpDir / "incoming" # things that couldn't be validated (missingparent etc)
|
|
|
|
|
|
|
|
func dumpDirOutgoing*(conf: BeaconNodeConf|ValidatorClientConf): string =
|
|
|
|
conf.dumpDir / "outgoing" # things we produced
|
|
|
|
|
|
|
|
proc createDumpDirs*(conf: BeaconNodeConf) =
|
|
|
|
if conf.dumpEnabled:
|
|
|
|
try:
|
|
|
|
createDir(conf.dumpDirInvalid)
|
|
|
|
createDir(conf.dumpDirIncoming)
|
|
|
|
createDir(conf.dumpDirOutgoing)
|
|
|
|
except CatchableError as err:
|
|
|
|
# Dumping is mainly a debugging feature, so ignore these..
|
|
|
|
warn "Cannot create dump directories", msg = err.msg
|
|
|
|
|
2020-07-02 15:14:11 +00:00
|
|
|
func parseCmdArg*(T: type Eth1Address, input: TaintedString): T
|
|
|
|
{.raises: [ValueError, Defect].} =
|
|
|
|
fromHex(T, string input)
|
|
|
|
|
|
|
|
func completeCmdArg*(T: type Eth1Address, input: TaintedString): seq[string] =
|
|
|
|
return @[]
|
|
|
|
|
2020-06-19 17:42:28 +00:00
|
|
|
func parseCmdArg*(T: type Eth2Digest, input: TaintedString): T
|
|
|
|
{.raises: [ValueError, Defect].} =
|
|
|
|
fromHex(T, string input)
|
|
|
|
|
|
|
|
func completeCmdArg*(T: type Eth2Digest, input: TaintedString): seq[string] =
|
|
|
|
return @[]
|
|
|
|
|
2020-06-23 19:11:07 +00:00
|
|
|
func parseCmdArg*(T: type WalletName, input: TaintedString): T
|
|
|
|
{.raises: [ValueError, Defect].} =
|
|
|
|
if input.len == 0:
|
|
|
|
raise newException(ValueError, "The wallet name should not be empty")
|
|
|
|
if input[0] == '_':
|
|
|
|
raise newException(ValueError, "The wallet name should not start with an underscore")
|
|
|
|
return T(input)
|
|
|
|
|
|
|
|
func completeCmdArg*(T: type WalletName, input: TaintedString): seq[string] =
|
|
|
|
return @[]
|
|
|
|
|
2020-06-03 11:52:36 +00:00
|
|
|
func validatorsDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
|
|
|
|
string conf.validatorsDirFlag.get(InputDir(conf.dataDir / "validators"))
|
|
|
|
|
|
|
|
func secretsDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
|
|
|
|
string conf.secretsDirFlag.get(InputDir(conf.dataDir / "secrets"))
|
2019-12-10 14:20:40 +00:00
|
|
|
|
2020-06-23 19:11:07 +00:00
|
|
|
func walletsDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
|
|
|
|
string conf.walletsDirFlag.get(InputDir(conf.dataDir / "wallets"))
|
|
|
|
|
2020-05-22 17:04:52 +00:00
|
|
|
func databaseDir*(conf: BeaconNodeConf|ValidatorClientConf): string =
|
2019-12-10 14:20:40 +00:00
|
|
|
conf.dataDir / "db"
|
|
|
|
|
2020-06-05 15:08:50 +00:00
|
|
|
func defaultListenAddress*(conf: BeaconNodeConf|ValidatorClientConf): ValidIpAddress =
|
2020-03-16 22:28:54 +00:00
|
|
|
# TODO: How should we select between IPv4 and IPv6
|
|
|
|
# Maybe there should be a config option for this.
|
2020-06-05 15:08:50 +00:00
|
|
|
(static ValidIpAddress.init("0.0.0.0"))
|
2020-03-16 22:28:54 +00:00
|
|
|
|
2020-06-05 15:08:50 +00:00
|
|
|
func defaultAdminListenAddress*(conf: BeaconNodeConf|ValidatorClientConf): ValidIpAddress =
|
|
|
|
(static ValidIpAddress.init("127.0.0.1"))
|
2020-03-18 19:36:22 +00:00
|
|
|
|
2020-02-11 17:35:42 +00:00
|
|
|
template writeValue*(writer: var JsonWriter,
|
|
|
|
value: TypedInputFile|InputFile|InputDir|OutPath|OutDir|OutFile) =
|
|
|
|
writer.writeValue(string value)
|
2020-07-02 15:14:11 +00:00
|
|
|
|