2021-03-26 06:52:01 +00:00
# beacon_chain
2024-01-06 14:26:56 +00:00
# Copyright (c) 2018-2024 Status Research & Development GmbH
2021-03-26 06:52:01 +00:00
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
2023-01-20 14:14:37 +00:00
{. push raises : [ ] . }
2022-07-29 10:53:42 +00:00
2018-11-23 23:58:49 +00:00
import
2023-12-16 16:30:46 +00:00
std / [ options , unicode , uri ] ,
2022-02-11 20:40:49 +00:00
metrics ,
2021-05-19 06:38:13 +00:00
2020-07-02 15:14:11 +00:00
chronicles , chronicles / options as chroniclesOptions ,
2022-03-05 02:33:15 +00:00
confutils , confutils / defs , confutils / std / net ,
confutils / toml / defs as confTomlDefs ,
confutils / toml / std / net as confTomlNet ,
confutils / toml / std / uri as confTomlUri ,
2024-01-20 16:42:19 +00:00
serialization / errors ,
2021-05-19 06:38:13 +00:00
stew / [ io2 , byteutils ] , unicodedb / properties , normalize ,
2021-02-16 20:35:10 +00:00
eth / common / eth_types as commonEthTypes , eth / net / nat ,
2020-11-24 23:23:28 +00:00
eth / p2p / discoveryv5 / enr ,
2023-12-12 15:15:00 +00:00
json_serialization , web3 / [ primitives , confutils_defs ] ,
2023-05-11 08:52:44 +00:00
kzg4844 / kzg_ex ,
2022-07-12 10:08:52 +00:00
. / spec / [ engine_authentication , keystore , network , crypto ] ,
2021-06-21 08:35:24 +00:00
. / spec / datatypes / base ,
2021-03-05 13:12:00 +00:00
. / networking / network_metadata ,
2021-05-19 06:38:13 +00:00
. / validators / slashing_protection_common ,
2023-05-15 05:05:12 +00:00
. / el / el_conf ,
2021-05-19 06:38:13 +00:00
. / filepath
2018-12-19 12:58:53 +00:00
2023-12-16 16:30:46 +00:00
from std / os import getHomeDir , parentDir , ` / `
from std / strutils import parseBiggestUInt , replace
2023-09-12 07:52:51 +00:00
from fork_choice / fork_choice_types
import ForkChoiceVersion
2022-03-11 20:28:10 +00:00
from consensus_object_pools / block_pools_types_light_client
2022-06-14 09:03:39 +00:00
import LightClientDataImportMode
2022-03-11 20:28:10 +00:00
2018-12-19 12:58:53 +00:00
export
2022-02-11 20:40:49 +00:00
uri , nat , enr ,
2023-11-01 07:33:00 +00:00
defaultEth2TcpPort , enabledLogLevel ,
2021-12-22 12:37:31 +00:00
defs , parseCmdArg , completeCmdArg , network_metadata ,
2023-03-05 01:40:21 +00:00
el_conf , network , BlockHashOrNumber ,
2023-09-04 19:14:58 +00:00
confTomlDefs , confTomlNet , confTomlUri ,
LightClientDataImportMode
2022-02-11 20:40:49 +00:00
declareGauge network_name , " network name " , [ " name " ]
2019-03-26 19:44:51 +00:00
2021-04-01 12:28:57 +00:00
const
# TODO: How should we select between IPv4 and IPv6
# Maybe there should be a config option for this.
2023-11-01 07:33:00 +00:00
defaultListenAddress * = ( static parseIpAddress ( " 0.0.0.0 " ) )
defaultAdminListenAddress * = ( static parseIpAddress ( " 127.0.0.1 " ) )
2021-11-30 01:20:21 +00:00
defaultSigningNodeRequestTimeout * = 60
2022-07-20 18:17:21 +00:00
defaultBeaconNode * = " http://127.0.0.1: " & $ defaultEth2RestPort
2022-09-29 07:57:14 +00:00
defaultBeaconNodeUri * = parseUri ( defaultBeaconNode )
2023-02-15 15:10:31 +00:00
defaultGasLimit * = 30_000_000
2022-07-20 18:17:21 +00:00
defaultListenAddressDesc * = $ defaultListenAddress
defaultAdminListenAddressDesc * = $ defaultAdminListenAddress
2023-12-16 16:30:46 +00:00
defaultBeaconNodeDesc = $ defaultBeaconNode
2021-04-01 12:28:57 +00:00
2022-02-27 11:02:45 +00:00
when defined ( windows ) :
{. pragma : windowsOnly . }
2022-03-14 09:19:50 +00:00
{. pragma : posixOnly , hidden . }
2022-02-27 11:02:45 +00:00
else :
{. pragma : windowsOnly , hidden . }
2022-03-14 09:19:50 +00:00
{. pragma : posixOnly . }
2022-02-27 11:02:45 +00:00
2018-11-23 23:58:49 +00:00
type
2022-01-17 09:27:08 +00:00
BNStartUpCmd * {. pure . } = enum
2018-12-19 12:58:53 +00:00
noCommand
2020-06-15 22:20:31 +00:00
deposits
2020-06-23 19:11:07 +00:00
wallets
2020-11-24 23:23:28 +00:00
record
2020-12-04 16:28:42 +00:00
web3
2021-05-19 06:38:13 +00:00
slashingdb
2022-01-17 09:27:08 +00:00
trustedNodeSync
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
2021-04-08 11:35:58 +00:00
createTestnetDeposits = " Creates validator keystores and deposits for testnet usage "
2020-08-02 17:26:57 +00:00
` import ` = " Imports password-protected keystores interactively "
2020-11-27 19:48:33 +00:00
# status = "Displays status information about all deposits"
exit = " Submits a validator voluntary exit "
2019-11-01 09:53:06 +00:00
2021-11-30 01:20:21 +00:00
SNStartUpCmd * = enum
SNNoCommand
2020-11-24 23:23:28 +00:00
RecordCmd * {. pure . } = enum
create = " Create a new ENR "
print = " Print the content of a given ENR "
2020-12-04 16:28:42 +00:00
Web3Cmd * {. pure . } = enum
test = " Test a web3 provider "
2021-02-19 18:39:18 +00:00
SlashingDbKind * {. pure . } = enum
v1
v2
both
2021-11-02 17:06:36 +00:00
StdoutLogKind * {. pure . } = enum
Auto = " auto "
Colors = " colors "
NoColors = " nocolors "
Json = " json "
None = " none "
History pruning (fixes #4419) (#4445)
Introduce (optional) pruning of historical data - a pruned node will
continue to answer queries for historical data up to
`MIN_EPOCHS_FOR_BLOCK_REQUESTS` epochs, or roughly 5 months, capping
typical database usage at around 60-70gb.
To enable pruning, add `--history=prune` to the command line - on the
first start, old data will be cleared (which may take a while) - after
that, data is pruned continuously.
When pruning an existing database, the database will not shrink -
instead, the freed space is recycled as the node continues to run - to
free up space, perform a trusted node sync with a fresh database.
When switching on archive mode in a pruned node, history is retained
from that point onwards.
History pruning is scheduled to be enabled by default in a future
release.
In this PR, `minimal` mode from #4419 is not implemented meaning
retention periods for states and blocks are always the same - depending
on user demand, a future PR may implement `minimal` as well.
2023-01-07 10:02:15 +00:00
HistoryMode * {. pure . } = enum
Archive = " archive "
Prune = " prune "
2021-05-19 06:38:13 +00:00
SlashProtCmd * = enum
` import ` = " Import a EIP-3076 slashing protection interchange file "
` export ` = " Export a EIP-3076 slashing protection interchange file "
# migrateAll = "Export and remove the whole validator slashing protection DB."
# migrate = "Export and remove specified validators from Nimbus."
2023-02-16 17:25:48 +00:00
ImportMethod * {. pure . } = enum
Normal = " normal "
SingleSalt = " single-salt "
2023-06-08 08:44:32 +00:00
BlockMonitoringType * {. pure . } = enum
Disabled = " disabled "
Poll = " poll "
Event = " event "
2023-10-13 12:42:00 +00:00
Web3SignerUrl * = object
url * : Uri
provenBlockProperties * : seq [ string ] # empty if this is not a verifying Web3Signer
2018-11-29 01:08:34 +00:00
BeaconNodeConf * = object
2022-03-05 02:33:15 +00:00
configFile * {.
desc : " Loads the configuration from a TOML file "
2022-06-15 18:04:07 +00:00
name : " config-file " . } : Option [ InputFile ]
2022-03-05 02:33:15 +00:00
2019-01-16 23:01:15 +00:00
logLevel * {.
2021-05-19 06:38:13 +00:00
desc : " Sets the log level for process and topics (e.g. \" DEBUG; TRACE:discv5,libp2p; REQUIRED:none; DISABLED:none \" ) "
2020-11-09 08:12:48 +00:00
defaultValue : " INFO "
2022-06-15 18:04:07 +00:00
name : " log-level " . } : string
2019-03-18 03:54:08 +00:00
2021-11-02 17:06:36 +00:00
logStdout * {.
2021-11-10 09:02:18 +00:00
hidden
2021-11-02 17:06:36 +00:00
desc : " Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json) "
defaultValueDesc : " auto "
defaultValue : StdoutLogKind . Auto
2022-06-15 18:04:07 +00:00
name : " log-format " . } : StdoutLogKind
2021-11-02 17:06:36 +00:00
2020-07-15 13:15:55 +00:00
logFile * {.
2023-04-12 17:01:29 +00:00
desc : " Specifies a path for the written JSON log file (deprecated) "
2022-06-15 18:04:07 +00:00
name : " log-file " . } : Option [ OutFile ]
2020-07-15 13:15:55 +00:00
2020-07-02 15:14:11 +00:00
eth2Network * {.
2021-05-19 06:38:13 +00:00
desc : " The Eth2 network to join "
defaultValueDesc : " mainnet "
2022-06-15 18:04:07 +00:00
name : " network " . } : Option [ string ]
2019-03-19 17:22:17 +00:00
dataDir * {.
2020-06-23 19:11:07 +00:00
desc : " The directory where nimbus will store all blockchain data "
2021-05-19 06:38:13 +00:00
defaultValue : config . defaultDataDir ( )
defaultValueDesc : " "
2019-11-11 14:43:12 +00:00
abbr : " d "
2022-06-15 18:04:07 +00:00
name : " data-dir " . } : OutDir
2019-01-16 23:01:15 +00:00
2020-08-01 18:32:41 +00:00
validatorsDirFlag * {.
desc : " A directory containing validator keystores "
2022-06-15 18:04:07 +00:00
name : " validators-dir " . } : Option [ InputDir ]
2020-08-01 18:32:41 +00:00
2023-10-13 12:42:00 +00:00
verifyingWeb3Signers * {.
desc : " Remote Web3Signer URL that will be used as a source of validators "
name : " verifying-web3-signer-url " . } : seq [ Uri ]
provenBlockProperties * {.
desc : " The field path of a block property that will be sent for verification to the verifying Web3Signer (for example \" .execution_payload.fee_recipient \" ) "
name : " proven-block-property " . } : seq [ string ]
web3Signers * {.
2023-08-31 12:16:15 +00:00
desc : " Remote Web3Signer URL that will be used as a source of validators "
2023-09-06 19:04:10 +00:00
name : " web3-signer-url " . } : seq [ Uri ]
2023-08-31 12:16:15 +00:00
2023-09-06 19:04:10 +00:00
web3signerUpdateInterval * {.
desc : " Number of seconds between validator list updates "
name : " web3-signer-update-interval "
defaultValue : 3600 . } : Natural
2023-09-04 19:14:58 +00:00
2020-08-02 17:26:57 +00:00
secretsDirFlag * {.
desc : " A directory containing validator keystore passwords "
2022-06-15 18:04:07 +00:00
name : " secrets-dir " . } : Option [ InputDir ]
2020-08-02 17:26:57 +00:00
2020-07-17 20:59:50 +00:00
walletsDirFlag * {.
desc : " A directory containing wallet files "
2022-06-15 18:04:07 +00:00
name : " wallets-dir " . } : Option [ InputDir ]
2020-07-17 20:59:50 +00:00
2022-07-21 11:07:19 +00:00
eraDirFlag * {.
hidden
desc : " A directory containing era files "
name : " era-dir " . } : Option [ InputDir ]
2023-03-14 16:54:15 +00:00
web3ForcePolling * {.
hidden
desc : " Force the use of polling when determining the head block of Eth1 (obsolete) "
name : " web3-force-polling " . } : Option [ bool ]
2021-04-06 21:42:59 +00:00
web3Urls * {.
2023-03-05 01:40:21 +00:00
desc : " One or more execution layer Engine API URLs "
name : " web3-url " . } : seq [ EngineApiUrlConfigValue ]
2019-09-01 15:02:49 +00:00
2023-03-05 01:40:21 +00:00
elUrls * {.
desc : " One or more execution layer Engine API URLs "
name : " el " . } : seq [ EngineApiUrlConfigValue ]
noEl * {.
2021-11-25 16:51:51 +00:00
defaultValue : false
2023-03-05 01:40:21 +00:00
desc : " Don ' t use an EL. The node will remain optimistically synced and won ' t be able to perform validator duties "
name : " no-el " . } : bool
2021-11-25 16:51:51 +00:00
2022-10-26 20:44:45 +00:00
optimistic * {.
2023-01-04 15:51:14 +00:00
hidden # deprecated > 22.12
desc : " Run the node in optimistic mode, allowing it to optimistically sync without an execution client (flag deprecated, always on) "
name : " optimistic " . } : Option [ bool ]
2022-10-26 20:44:45 +00:00
2022-08-22 19:44:40 +00:00
requireEngineAPI * {.
2022-09-19 21:47:46 +00:00
hidden # Deprecated > 22.9
2022-08-22 19:44:40 +00:00
desc : " Require Nimbus to be configured with an Engine API end-point after the Bellatrix fork epoch "
2022-09-19 21:47:46 +00:00
name : " require-engine-api-in-bellatrix " . } : Option [ bool ]
2022-08-22 19:44:40 +00:00
2020-06-01 19:48:20 +00:00
nonInteractive * {.
2023-04-12 17:01:29 +00:00
desc : " Do not display interactive prompts. Quit on missing configuration "
2022-06-15 18:04:07 +00:00
name : " non-interactive " . } : bool
2020-06-01 19:48:20 +00:00
2020-08-25 12:49:05 +00:00
netKeyFile * {.
desc : " Source of network (secp256k1) private key file " &
2021-05-19 06:38:13 +00:00
" (random|<path>) "
defaultValue : " random " ,
2022-06-15 18:04:07 +00:00
name : " netkey-file " . } : string
2020-08-25 12:49:05 +00:00
netKeyInsecurePassword * {.
2021-05-19 06:38:13 +00:00
desc : " Use pre-generated INSECURE password for network private key file "
2020-08-25 12:49:05 +00:00
defaultValue : false ,
2022-06-15 18:04:07 +00:00
name : " insecure-netkey-password " . } : bool
2020-08-25 12:49:05 +00:00
2020-11-28 07:00:36 +00:00
agentString * {.
defaultValue : " nimbus " ,
desc : " Node agent string which is used as identifier in network "
2022-06-15 18:04:07 +00:00
name : " agent-string " . } : string
2020-11-28 07:00:36 +00:00
2022-01-24 20:40:59 +00:00
subscribeAllSubnets * {.
defaultValue : false ,
2022-02-04 12:34:03 +00:00
desc : " Subscribe to all subnet topics when gossiping "
2022-06-15 18:04:07 +00:00
name : " subscribe-all-subnets " . } : bool
2021-01-12 12:43:15 +00:00
2021-02-19 18:39:18 +00:00
slashingDbKind * {.
2021-02-19 15:18:17 +00:00
hidden
2021-04-04 22:55:17 +00:00
defaultValue : SlashingDbKind . v2
2021-05-19 06:38:13 +00:00
desc : " The slashing DB flavour to use "
2022-06-15 18:04:07 +00:00
name : " slashing-db-kind " . } : SlashingDbKind
2021-02-19 15:18:17 +00:00
2021-09-17 00:13:52 +00:00
numThreads * {.
2022-03-19 07:59:10 +00:00
defaultValue : 0 ,
desc : " Number of worker threads ( \" 0 \" = use as many threads as there are CPU cores available) "
2022-06-15 18:04:07 +00:00
name : " num-threads " . } : int
2021-09-17 00:13:52 +00:00
2023-04-17 20:11:28 +00:00
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/authentication.md#key-distribution
2022-04-12 20:17:32 +00:00
jwtSecret * {.
2022-08-02 12:23:03 +00:00
desc : " A file containing the hex-encoded 256 bit secret key to be used for verifying/generating JWT tokens "
2023-03-05 01:40:21 +00:00
name : " jwt-secret " . } : Option [ InputFile ]
2022-04-12 20:17:32 +00:00
2018-12-19 12:58:53 +00:00
case cmd * {.
command
2022-06-15 18:04:07 +00:00
defaultValue : BNStartUpCmd . noCommand . } : BNStartUpCmd
2018-12-19 12:58:53 +00:00
2022-01-17 09:27:08 +00:00
of BNStartUpCmd . noCommand :
2022-02-27 11:02:45 +00:00
runAsServiceFlag * {.
windowsOnly
defaultValue : false ,
desc : " Run as a Windows service "
2022-06-15 18:04:07 +00:00
name : " run-as-service " . } : bool
2022-02-27 11:02:45 +00:00
2018-12-19 12:58:53 +00:00
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 "
2022-06-15 18:04:07 +00:00
name : " bootstrap-node " . } : seq [ string ]
2018-11-23 23:58:49 +00:00
2018-12-19 12:58:53 +00:00
bootstrapNodesFile * {.
2020-06-23 19:11:07 +00:00
desc : " Specifies a line-delimited file of bootstrap Ethereum network addresses "
2021-05-19 06:38:13 +00:00
defaultValue : " "
2022-06-15 18:04:07 +00:00
name : " bootstrap-file " . } : InputFile
2018-11-23 23:58:49 +00:00
2020-09-27 20:00:24 +00:00
listenAddress * {.
2021-05-19 06:38:13 +00:00
desc : " Listening address for the Ethereum LibP2P and Discovery v5 traffic "
2021-04-01 12:28:57 +00:00
defaultValue : defaultListenAddress
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultListenAddressDesc
2023-11-01 07:33:00 +00:00
name : " listen-address " . } : IpAddress
2020-03-18 19:36:22 +00:00
2018-12-19 12:58:53 +00:00
tcpPort * {.
2021-05-19 06:38:13 +00:00
desc : " Listening TCP port for Ethereum LibP2P traffic "
2020-03-16 22:28:54 +00:00
defaultValue : defaultEth2TcpPort
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultEth2TcpPortDesc
2022-06-15 18:04:07 +00:00
name : " tcp-port " . } : Port
2018-11-23 23:58:49 +00:00
2018-12-19 12:58:53 +00:00
udpPort * {.
2021-05-19 06:38:13 +00:00
desc : " Listening UDP port for node discovery "
2020-03-16 22:28:54 +00:00
defaultValue : defaultEth2TcpPort
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultEth2TcpPortDesc
2022-06-15 18:04:07 +00:00
name : " udp-port " . } : Port
2018-11-23 23:58:49 +00:00
2019-12-18 01:11:20 +00:00
maxPeers * {.
2022-03-11 10:51:53 +00:00
desc : " The target number of peers to connect to "
2020-11-29 13:43:41 +00:00
defaultValue : 160 # 5 (fanout) * 64 (subnets) / 2 (subs) for a heathy mesh
2022-06-15 18:04:07 +00:00
name : " max-peers " . } : int
2019-12-18 01:11:20 +00:00
2022-03-11 10:51:53 +00:00
hardMaxPeers * {.
desc : " The maximum number of peers to connect to. Defaults to maxPeers * 1.5 "
2022-06-15 18:04:07 +00:00
name : " hard-max-peers " . } : Option [ int ]
2022-03-11 10:51:53 +00:00
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> "
2021-02-16 20:35:10 +00:00
defaultValue : NatConfig ( hasExtIp : false , nat : NatAny )
2021-05-19 06:38:13 +00:00
defaultValueDesc : " any "
2021-02-16 20:35:10 +00:00
name : " nat " . } : NatConfig
2019-03-19 03:57:19 +00:00
2021-02-02 08:07:21 +00:00
enrAutoUpdate * {.
desc : " Discovery can automatically update its ENR with the IP address " &
" and UDP port as seen by other nodes it communicates with. " &
" This option allows to enable/disable this functionality "
2021-05-19 06:38:13 +00:00
defaultValue : false
2021-02-02 08:07:21 +00:00
name : " enr-auto-update " . } : bool
2023-06-23 07:16:30 +00:00
enableYamux * {.
hidden
desc : " Enable the Yamux multiplexer "
defaultValue : false
name : " enable-yamux " . } : bool
2020-09-22 20:42:42 +00:00
weakSubjectivityCheckpoint * {.
desc : " Weak subjectivity checkpoint in the format block_root:epoch_number "
2022-06-15 18:04:07 +00:00
name : " weak-subjectivity-checkpoint " . } : Option [ Checkpoint ]
2018-12-19 12:58:53 +00:00
2023-11-03 15:07:49 +00:00
externalBeaconApiUrl * {.
desc : " External beacon API to use for syncing (on empty database) "
name : " external-beacon-api-url " . } : Option [ string ]
2022-08-29 12:16:35 +00:00
syncLightClient * {.
2023-11-03 15:07:49 +00:00
desc : " Accelerate sync using light client "
2023-04-10 14:28:46 +00:00
defaultValue : true
2022-08-29 12:16:35 +00:00
name : " sync-light-client " . } : bool
2022-06-07 17:01:11 +00:00
2022-08-29 12:16:35 +00:00
trustedBlockRoot * {.
2023-11-03 15:07:49 +00:00
desc : " Recent trusted finalized block root to sync from external " &
" beacon API (with `--external-beacon-api-url`). " &
" Uses the light client sync protocol to obtain the latest " &
" finalized checkpoint (LC is initialized from trusted block root) "
2022-08-29 12:16:35 +00:00
name : " trusted-block-root " . } : Option [ Eth2Digest ]
2022-06-07 17:01:11 +00:00
2023-11-03 15:07:49 +00:00
trustedStateRoot * {.
desc : " Recent trusted finalized state root to sync from external " &
" beacon API (with `--external-beacon-api-url`) "
name : " trusted-state-root " . } : Option [ Eth2Digest ]
2020-09-22 20:42:42 +00:00
finalizedCheckpointState * {.
desc : " SSZ file specifying a recent finalized state "
2022-06-15 18:04:07 +00:00
name : " finalized-checkpoint-state " . } : Option [ InputFile ]
2020-09-22 20:42:42 +00:00
2023-09-08 10:09:21 +00:00
genesisState * {.
desc : " SSZ file specifying the genesis state of the network (for networks without a built-in genesis state) "
name : " genesis-state " . } : Option [ InputFile ]
genesisStateUrl * {.
desc : " URL for obtaining the genesis state of the network (for networks without a built-in genesis state) "
name : " genesis-state-url " . } : Option [ Uri ]
2023-02-23 02:10:07 +00:00
finalizedDepositTreeSnapshot * {.
desc : " SSZ file specifying a recent finalized EIP-4881 deposit tree snapshot "
name : " finalized-deposit-tree-snapshot " . } : Option [ InputFile ]
2020-09-22 20:42:42 +00:00
finalizedCheckpointBlock * {.
State-only checkpoint state startup (#4251)
Currently, we require genesis and a checkpoint block and state to start
from an arbitrary slot - this PR relaxes this requirement so that we can
start with a state alone.
The current trusted-node-sync algorithm works by first downloading
blocks until we find an epoch aligned non-empty slot, then downloads the
state via slot.
However, current
[proposals](https://github.com/ethereum/beacon-APIs/pull/226) for
checkpointing prefer finalized state as
the main reference - this allows more simple access control and caching
on the server side - in particular, this should help checkpoint-syncing
from sources that have a fast `finalized` state download (like infura
and teku) but are slow when accessing state via slot.
Earlier versions of Nimbus will not be able to read databases created
without a checkpoint block and genesis. In most cases, backfilling makes
the database compatible except where genesis is also missing (custom
networks).
* backfill checkpoint block from libp2p instead of checkpoint source,
when doing trusted node sync
* allow starting the client without genesis / checkpoint block
* perform epoch start slot lookahead when loading tail state, so as to
deal with the case where the epoch start slot does not have a block
* replace `--blockId` with `--state-id` in TNS command line
* when replaying, also look at the parent of the last-known-block (even
if we don't have the parent block data, we can still replay from a
"parent" state) - in particular, this clears the way for implementing
state pruning
* deprecate `--finalized-checkpoint-block` option (no longer needed)
2022-11-02 10:02:38 +00:00
hidden
2020-09-22 20:42:42 +00:00
desc : " SSZ file specifying a recent finalized block "
2022-06-15 18:04:07 +00:00
name : " finalized-checkpoint-block " . } : Option [ InputFile ]
2020-07-02 15:52:48 +00:00
2019-10-28 23:04:52 +00:00
nodeName * {.
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 "
2021-05-19 06:38:13 +00:00
defaultValue : " "
2022-06-15 18:04:07 +00:00
name : " node-name " . } : string
2019-03-22 14:35:20 +00:00
2020-06-29 17:30:19 +00:00
graffiti * {.
desc : " The graffiti value that will appear in proposed blocks. " &
2020-11-09 08:12:48 +00:00
" You can use a 0x-prefixed hex encoded string to specify raw bytes "
2022-06-15 18:04:07 +00:00
name : " graffiti " . } : Option [ GraffitiBytes ]
2020-06-29 17:30:19 +00:00
2022-07-13 13:48:09 +00:00
strictVerification * {.
2022-02-04 12:34:03 +00:00
hidden
desc : " Specify whether to verify finalization occurs on schedule (debug only) "
2021-05-19 06:38:13 +00:00
defaultValue : false
2022-06-15 18:04:07 +00:00
name : " verify-finalization " . } : bool
2020-02-17 18:24:14 +00:00
2020-02-17 21:22:50 +00:00
stopAtEpoch * {.
2022-03-04 17:38:01 +00:00
hidden
desc : " The wall-time epoch at which to exit the program. (for testing purposes) "
2021-05-19 06:38:13 +00:00
defaultValue : 0
2023-08-30 11:15:19 +00:00
name : " debug-stop-at-epoch " . } : uint64
2020-02-17 18:24:14 +00:00
2022-03-04 17:38:01 +00:00
stopAtSyncedEpoch * {.
hidden
desc : " The synced epoch at which to exit the program. (for testing purposes) "
defaultValue : 0
2022-06-15 18:04:07 +00:00
name : " stop-at-synced-epoch " . } : uint64
2022-03-04 17:38:01 +00:00
2020-03-16 22:28:54 +00:00
metricsEnabled * {.
2021-05-19 06:38:13 +00:00
desc : " Enable the metrics server "
2019-10-28 23:04:52 +00:00
defaultValue : false
2022-06-15 18:04:07 +00:00
name : " metrics " . } : bool
2019-09-07 17:48:05 +00:00
2020-03-16 22:28:54 +00:00
metricsAddress * {.
2021-05-19 06:38:13 +00:00
desc : " Listening address of the metrics server "
2021-04-01 12:28:57 +00:00
defaultValue : defaultAdminListenAddress
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultAdminListenAddressDesc
2023-11-01 07:33:00 +00:00
name : " metrics-address " . } : IpAddress
2019-09-07 17:48:05 +00:00
2020-03-16 22:28:54 +00:00
metricsPort * {.
2021-05-19 06:38:13 +00:00
desc : " Listening HTTP port of the metrics server "
2019-10-28 23:04:52 +00:00
defaultValue : 8008
2022-06-15 18:04:07 +00:00
name : " metrics-port " . } : Port
2019-09-07 17:48:05 +00:00
2020-03-18 19:36:22 +00:00
statusBarEnabled * {.
2022-03-14 09:19:50 +00:00
posixOnly
2020-06-23 19:11:07 +00:00
desc : " Display a status bar at the bottom of the terminal screen "
2021-05-19 06:38:13 +00:00
defaultValue : true
2022-06-15 18:04:07 +00:00
name : " status-bar " . } : bool
2020-03-18 19:36:22 +00:00
statusBarContents * {.
2022-03-14 09:19:50 +00:00
posixOnly
2021-05-19 06:38:13 +00:00
desc : " Textual template for the contents of the status bar "
2020-06-08 16:04:11 +00:00
defaultValue : " peers: $connected_peers ; " &
" finalized: $finalized_root : $finalized_epoch ; " &
2024-01-15 16:48:03 +00:00
" head: $head_root : $head_epoch : $head_epoch_slot $next_consensus_fork ; " &
2020-09-11 12:46:01 +00:00
" time: $epoch : $epoch_slot ( $slot ); " &
2020-11-28 18:53:51 +00:00
" sync: $sync_status | " &
" ETH: $attached_validators_balance "
2021-05-19 06:38:13 +00:00
defaultValueDesc : " "
2022-06-15 18:04:07 +00:00
name : " status-bar-contents " . } : string
2020-03-18 19:36:22 +00:00
rpcEnabled * {.
2022-09-29 06:29:49 +00:00
# Deprecated > 1.7.0
2022-05-24 07:23:48 +00:00
hidden
2022-09-29 06:29:49 +00:00
desc : " Deprecated for removal "
name : " rpc " . } : Option [ bool ]
2020-03-18 19:36:22 +00:00
rpcPort * {.
2022-09-29 06:29:49 +00:00
# Deprecated > 1.7.0
2022-05-24 07:23:48 +00:00
hidden
2022-09-29 06:29:49 +00:00
desc : " Deprecated for removal "
name : " rpc-port " . } : Option [ Port ]
2020-03-18 19:36:22 +00:00
rpcAddress * {.
2022-09-29 06:29:49 +00:00
# Deprecated > 1.7.0
2022-05-24 07:23:48 +00:00
hidden
2022-09-29 06:29:49 +00:00
desc : " Deprecated for removal "
2023-11-01 07:33:00 +00:00
name : " rpc-address " . } : Option [ IpAddress ]
2020-03-18 19:36:22 +00:00
2021-03-17 18:46:45 +00:00
restEnabled * {.
2021-10-21 08:24:22 +00:00
desc : " Enable the REST server "
2021-03-17 18:46:45 +00:00
defaultValue : false
2022-06-15 18:04:07 +00:00
name : " rest " . } : bool
2021-03-17 18:46:45 +00:00
restPort * {.
2021-10-21 08:24:22 +00:00
desc : " Port for the REST server "
2022-07-20 18:17:21 +00:00
defaultValue : defaultEth2RestPort
defaultValueDesc : $ defaultEth2RestPortDesc
2022-06-15 18:04:07 +00:00
name : " rest-port " . } : Port
2021-03-17 18:46:45 +00:00
restAddress * {.
2021-10-21 08:24:22 +00:00
desc : " Listening address of the REST server "
2021-04-03 01:50:47 +00:00
defaultValue : defaultAdminListenAddress
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultAdminListenAddressDesc
2023-11-01 07:33:00 +00:00
name : " rest-address " . } : IpAddress
2021-03-17 18:46:45 +00:00
2022-02-11 22:33:30 +00:00
restAllowedOrigin * {.
desc : " Limit the access to the REST API to a particular hostname " &
" (for CORS-enabled clients such as browsers) "
2022-06-15 18:04:07 +00:00
name : " rest-allow-origin " . } : Option [ string ]
2022-02-11 22:33:30 +00:00
2022-01-05 14:49:10 +00:00
restCacheSize * {.
defaultValue : 3
desc : " The maximum number of recently accessed states that are kept in " &
" memory. Speeds up requests obtaining information for consecutive " &
" slots or epochs. "
2022-06-15 18:04:07 +00:00
name : " rest-statecache-size " . } : Natural
2022-01-05 14:49:10 +00:00
restCacheTtl * {.
defaultValue : 60
desc : " The number of seconds to keep recently accessed states in memory "
2022-06-15 18:04:07 +00:00
name : " rest-statecache-ttl " . } : Natural
2022-01-05 14:49:10 +00:00
2022-01-27 16:41:05 +00:00
restRequestTimeout * {.
defaultValue : 0
defaultValueDesc : " infinite "
desc : " The number of seconds to wait until complete REST request " &
" will be received "
2022-06-15 18:04:07 +00:00
name : " rest-request-timeout " . } : Natural
2022-01-27 16:41:05 +00:00
restMaxRequestBodySize * {.
defaultValue : 16_384
desc : " Maximum size of REST request body (kilobytes) "
2022-06-15 18:04:07 +00:00
name : " rest-max-body-size " . } : Natural
2022-01-27 16:41:05 +00:00
restMaxRequestHeadersSize * {.
2023-01-26 15:00:10 +00:00
defaultValue : 128
2022-01-27 16:41:05 +00:00
desc : " Maximum size of REST request headers (kilobytes) "
2022-06-15 18:04:07 +00:00
name : " rest-max-headers-size " . } : Natural
2023-01-26 15:00:10 +00:00
## NOTE: If you going to adjust this value please check value
## ``ClientMaximumValidatorIds`` and comments in
## `spec/eth2_apis/rest_types.nim`. This values depend on each other.
2022-01-27 16:41:05 +00:00
2021-12-22 12:37:31 +00:00
keymanagerEnabled * {.
2022-12-01 05:38:54 +00:00
desc : " Enable the REST keymanager API "
2021-12-22 12:37:31 +00:00
defaultValue : false
2022-06-15 18:04:07 +00:00
name : " keymanager " . } : bool
2021-12-22 12:37:31 +00:00
keymanagerPort * {.
desc : " Listening port for the REST keymanager API "
2022-07-20 18:17:21 +00:00
defaultValue : defaultEth2RestPort
defaultValueDesc : $ defaultEth2RestPortDesc
2022-06-15 18:04:07 +00:00
name : " keymanager-port " . } : Port
2021-12-22 12:37:31 +00:00
keymanagerAddress * {.
desc : " Listening port for the REST keymanager API "
defaultValue : defaultAdminListenAddress
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultAdminListenAddressDesc
2023-11-01 07:33:00 +00:00
name : " keymanager-address " . } : IpAddress
2021-12-22 12:37:31 +00:00
2022-02-11 22:33:30 +00:00
keymanagerAllowedOrigin * {.
desc : " Limit the access to the Keymanager API to a particular hostname " &
" (for CORS-enabled clients such as browsers) "
2022-06-15 18:04:07 +00:00
name : " keymanager-allow-origin " . } : Option [ string ]
2022-02-11 22:33:30 +00:00
2021-12-22 12:37:31 +00:00
keymanagerTokenFile * {.
2022-02-27 16:55:02 +00:00
desc : " A file specifying the authorization token required for accessing the keymanager API "
2022-06-15 18:04:07 +00:00
name : " keymanager-token-file " . } : Option [ InputFile ]
2021-10-04 19:08:31 +00:00
2022-06-14 09:03:39 +00:00
lightClientDataServe * {.
2022-07-29 08:45:39 +00:00
desc : " Serve data for enabling light clients to stay in sync with the network "
defaultValue : true
name : " light-client-data-serve " . } : bool
2022-03-11 20:28:10 +00:00
2022-06-14 09:03:39 +00:00
lightClientDataImportMode * {.
2022-07-29 08:45:39 +00:00
desc : " Which classes of light client data to import. " &
2022-03-11 20:28:10 +00:00
" Must be one of: none, only-new, full (slow startup), on-demand (may miss validator duties) "
2022-07-29 08:45:39 +00:00
defaultValue : LightClientDataImportMode . OnlyNew
2022-08-02 12:23:03 +00:00
defaultValueDesc : $ LightClientDataImportMode . OnlyNew
2022-07-29 08:45:39 +00:00
name : " light-client-data-import-mode " . } : LightClientDataImportMode
2022-03-11 20:28:10 +00:00
2022-06-27 11:24:38 +00:00
lightClientDataMaxPeriods * {.
2022-07-29 08:45:39 +00:00
desc : " Maximum number of sync committee periods to retain light client data "
2022-06-27 11:24:38 +00:00
name : " light-client-data-max-periods " . } : Option [ uint64 ]
2020-09-01 13:44:40 +00:00
inProcessValidators * {.
desc : " Disable the push model (the beacon node tells a signing process with the private keys of the validators what to sign and when) and load the validators in the beacon node itself "
2021-05-19 06:38:13 +00:00
defaultValue : true # the use of the nimbus_signing_process binary by default will be delayed until async I/O over stdin/stdout is developed for the child process.
2022-06-15 18:04:07 +00:00
name : " in-process-validators " . } : bool
2020-09-01 13:44:40 +00:00
2020-08-24 11:52:06 +00:00
discv5Enabled * {.
2021-05-19 06:38:13 +00:00
desc : " Enable Discovery v5 "
2020-08-24 11:52:06 +00:00
defaultValue : true
2022-06-15 18:04:07 +00:00
name : " discv5 " . } : bool
2020-08-24 11:52:06 +00:00
2020-03-18 19:36:22 +00:00
dumpEnabled * {.
2021-05-19 06:38:13 +00:00
desc : " Write SSZ dumps of blocks, attestations and states to data dir "
2019-12-03 11:32:27 +00:00
defaultValue : false
2022-06-15 18:04:07 +00:00
name : " dump " . } : bool
2019-12-03 11:32:27 +00:00
2021-03-23 06:10:17 +00:00
directPeers * {.
2023-09-15 18:45:55 +00:00
desc : " The list of privileged, secure and known peers to connect and maintain the connection to. This requires a not random netkey-file. In the multiaddress format like: /ip4/<address>/tcp/<port>/p2p/<peerId-public-key>, or enr format (enr:-xx). Peering agreements are established out of band and must be reciprocal "
2021-03-23 06:10:17 +00:00
name : " direct-peer " . } : seq [ string ]
2021-02-01 11:18:16 +00:00
doppelgangerDetection * {.
2021-06-03 09:20:42 +00:00
desc : " If enabled, the beacon node prudently listens for 2 epochs for attestations from a validator with the same index (a doppelganger), before sending an attestation itself. This protects against slashing (due to double-voting) but means you will miss two attestations when restarting. "
2021-02-03 17:11:42 +00:00
defaultValue : true
2022-06-15 18:04:07 +00:00
name : " doppelganger-detection " . } : bool
2020-10-27 17:21:35 +00:00
2021-11-18 19:35:26 +00:00
syncHorizon * {.
hidden
desc : " Number of empty slots to process before considering the client out of sync "
defaultValue : MaxEmptySlotCount
defaultValueDesc : " 50 "
2022-06-15 18:04:07 +00:00
name : " sync-horizon " . } : uint64
2021-11-18 19:35:26 +00:00
2021-11-25 10:53:31 +00:00
terminalTotalDifficultyOverride * {.
hidden
2022-10-24 20:32:52 +00:00
desc : " Deprecated for removal "
2022-06-15 18:04:07 +00:00
name : " terminal-total-difficulty-override " . } : Option [ string ]
2021-11-25 10:53:31 +00:00
2021-12-20 19:20:31 +00:00
validatorMonitorAuto * {.
2023-01-16 10:28:35 +00:00
desc : " Monitor validator activity automatically for validators active on this beacon node "
defaultValue : true
2022-06-15 18:04:07 +00:00
name : " validator-monitor-auto " . } : bool
2021-12-20 19:20:31 +00:00
validatorMonitorPubkeys * {.
2023-01-16 10:28:35 +00:00
desc : " One or more validators to monitor - works best when --subscribe-all-subnets is enabled "
2022-06-15 18:04:07 +00:00
name : " validator-monitor-pubkey " . } : seq [ ValidatorPubKey ]
2021-12-20 19:20:31 +00:00
2023-01-16 10:28:35 +00:00
validatorMonitorDetails * {.
desc : " Publish detailed metrics for each validator individually - may incur significant overhead with large numbers of validators "
2023-01-26 13:18:52 +00:00
defaultValue : false
2023-01-16 10:28:35 +00:00
name : " validator-monitor-details " . } : bool
2021-12-20 19:20:31 +00:00
validatorMonitorTotals * {.
2023-01-16 10:28:35 +00:00
hidden
desc : " Deprecated in favour of --validator-monitor-details "
name : " validator-monitor-totals " . } : Option [ bool ]
2021-12-20 19:20:31 +00:00
2022-02-15 13:54:37 +00:00
safeSlotsToImportOptimistically * {.
2022-09-29 06:29:49 +00:00
# Never unhidden or documented, and deprecated > 22.9.1
2022-02-15 13:54:37 +00:00
hidden
2022-09-29 06:29:49 +00:00
desc : " Deprecated for removal "
name : " safe-slots-to-import-optimistically " . } : Option [ uint16 ]
2022-02-15 13:54:37 +00:00
2022-04-14 20:15:34 +00:00
# Same option as appears in Lighthouse and Prysm
# https://lighthouse-book.sigmaprime.io/suggested-fee-recipient.html
# https://github.com/prysmaticlabs/prysm/pull/10312
suggestedFeeRecipient * {.
desc : " Suggested fee recipient "
name : " suggested-fee-recipient " . } : Option [ Address ]
2023-02-15 15:10:31 +00:00
suggestedGasLimit * {.
desc : " Suggested gas limit "
defaultValue : defaultGasLimit
name : " suggested-gas-limit " . } : uint64
2022-08-01 06:41:47 +00:00
payloadBuilderEnable * {.
desc : " Enable external payload builder "
defaultValue : false
2022-08-05 15:38:26 +00:00
name : " payload-builder " . } : bool
2022-08-01 06:41:47 +00:00
payloadBuilderUrl * {.
desc : " Payload builder URL "
defaultValue : " "
name : " payload-builder-url " . } : string
2023-04-23 19:10:34 +00:00
# Flag name and semantics borrowed from Prysm
# https://github.com/prysmaticlabs/prysm/pull/12227/files
localBlockValueBoost * {.
desc : " Increase execution layer block values for builder bid comparison by a percentage "
defaultValue : 0
name : " local-block-value-boost " . } : uint8
History pruning (fixes #4419) (#4445)
Introduce (optional) pruning of historical data - a pruned node will
continue to answer queries for historical data up to
`MIN_EPOCHS_FOR_BLOCK_REQUESTS` epochs, or roughly 5 months, capping
typical database usage at around 60-70gb.
To enable pruning, add `--history=prune` to the command line - on the
first start, old data will be cleared (which may take a while) - after
that, data is pruned continuously.
When pruning an existing database, the database will not shrink -
instead, the freed space is recycled as the node continues to run - to
free up space, perform a trusted node sync with a fresh database.
When switching on archive mode in a pruned node, history is retained
from that point onwards.
History pruning is scheduled to be enabled by default in a future
release.
In this PR, `minimal` mode from #4419 is not implemented meaning
retention periods for states and blocks are always the same - depending
on user demand, a future PR may implement `minimal` as well.
2023-01-07 10:02:15 +00:00
historyMode * {.
2023-02-22 13:09:38 +00:00
desc : " Retention strategy for historical data (archive/prune) "
2023-06-19 23:08:48 +00:00
defaultValue : HistoryMode . Prune
History pruning (fixes #4419) (#4445)
Introduce (optional) pruning of historical data - a pruned node will
continue to answer queries for historical data up to
`MIN_EPOCHS_FOR_BLOCK_REQUESTS` epochs, or roughly 5 months, capping
typical database usage at around 60-70gb.
To enable pruning, add `--history=prune` to the command line - on the
first start, old data will be cleared (which may take a while) - after
that, data is pruned continuously.
When pruning an existing database, the database will not shrink -
instead, the freed space is recycled as the node continues to run - to
free up space, perform a trusted node sync with a fresh database.
When switching on archive mode in a pruned node, history is retained
from that point onwards.
History pruning is scheduled to be enabled by default in a future
release.
In this PR, `minimal` mode from #4419 is not implemented meaning
retention periods for states and blocks are always the same - depending
on user demand, a future PR may implement `minimal` as well.
2023-01-07 10:02:15 +00:00
name : " history " . } : HistoryMode
2023-06-14 08:52:00 +00:00
# https://notes.ethereum.org/@bbusa/dencun-devnet-6
# "Please ensure that there is a way for us to specify the file through a
# runtime flag such as --trusted-setup-file (or similar)."
trustedSetupFile * {.
hidden
desc : " Experimental, debug option; could disappear at any time without warning "
name : " temporary-debug-trusted-setup-file " . } : Option [ string ]
2023-08-24 14:04:19 +00:00
bandwidthEstimate * {.
hidden
desc : " Bandwidth estimate for the node (bits per second) "
name : " debug-bandwidth-estimate " . } : Option [ Natural ]
2023-09-12 07:52:51 +00:00
forkChoiceVersion * {.
hidden
desc : " Forkchoice version to use. " &
" Must be one of: stable "
name : " debug-forkchoice-version " . } : Option [ ForkChoiceVersion ]
2022-01-17 09:27:08 +00:00
of BNStartUpCmd . wallets :
2020-06-23 19:11:07 +00:00
case walletsCmd * {. command . } : WalletsCmd
of WalletsCmd . create :
nextAccount * {.
desc : " Initial value for the ' nextaccount ' property of the wallet "
2022-06-15 18:04:07 +00:00
name : " next-account " . } : Option [ Natural ]
2020-06-23 19:11:07 +00:00
2020-07-17 20:59:50 +00:00
createdWalletNameFlag * {.
desc : " An easy-to-remember name for the wallet of your choice "
2022-06-15 18:04:07 +00:00
name : " name " . } : Option [ WalletName ]
2020-07-14 19:00:35 +00:00
2020-07-17 20:59:50 +00:00
createdWalletFileFlag * {.
2020-06-23 19:11:07 +00:00
desc : " Output wallet file "
2022-06-15 18:04:07 +00:00
name : " out " . } : Option [ OutFile ]
2020-06-23 19:11:07 +00:00
of WalletsCmd . restore :
2020-07-17 20:59:50 +00:00
restoredWalletNameFlag * {.
2020-06-23 19:11:07 +00:00
desc : " An easy-to-remember name for the wallet of your choice "
2022-06-15 18:04:07 +00:00
name : " name " . } : Option [ WalletName ]
2020-06-23 19:11:07 +00:00
2020-07-17 20:59:50 +00:00
restoredWalletFileFlag * {.
desc : " Output wallet file "
2022-06-15 18:04:07 +00:00
name : " out " . } : Option [ OutFile ]
2020-07-17 20:59:50 +00:00
2020-06-23 19:11:07 +00:00
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 ]
of WalletsCmd . list :
discard
2018-11-23 23:58:49 +00:00
2022-01-17 09:27:08 +00:00
of BNStartUpCmd . deposits :
2020-06-16 18:38:51 +00:00
case depositsCmd * {. command . } : DepositsCmd
2021-04-08 11:35:58 +00:00
of DepositsCmd . createTestnetDeposits :
2020-06-15 22:20:31 +00:00
totalDeposits * {.
2020-06-23 19:11:07 +00:00
desc : " Number of deposits to generate "
2021-05-19 06:38:13 +00:00
defaultValue : 1
2022-06-15 18:04:07 +00:00
name : " count " . } : int
2020-06-15 22:20:31 +00:00
2020-06-23 19:11:07 +00:00
existingWalletId * {.
desc : " An existing wallet ID. If not specified, a new wallet will be created "
2022-06-15 18:04:07 +00:00
name : " wallet " . } : Option [ WalletName ]
2020-06-23 19:11:07 +00:00
2020-06-15 22:20:31 +00:00
outValidatorsDir * {.
2020-08-01 18:32:41 +00:00
desc : " Output folder for validator keystores "
2021-05-19 06:38:13 +00:00
defaultValue : " validators "
2022-06-15 18:04:07 +00:00
name : " out-validators-dir " . } : string
2020-06-15 22:20:31 +00:00
outSecretsDir * {.
2020-06-23 19:11:07 +00:00
desc : " Output folder for randomly generated keystore passphrases "
2021-05-19 06:38:13 +00:00
defaultValue : " secrets "
2022-06-15 18:04:07 +00:00
name : " out-secrets-dir " . } : string
2020-06-15 22:20:31 +00:00
2020-07-17 20:59:50 +00:00
outDepositsFile * {.
desc : " The name of generated deposits file "
2022-06-15 18:04:07 +00:00
name : " out-deposits-file " . } : Option [ OutFile ]
2020-07-17 20:59:50 +00:00
newWalletNameFlag * {.
desc : " An easy-to-remember name for the wallet of your choice "
2022-06-15 18:04:07 +00:00
name : " new-wallet-name " . } : Option [ WalletName ]
2020-07-17 20:59:50 +00:00
newWalletFileFlag * {.
desc : " Output wallet file "
2022-06-15 18:04:07 +00:00
name : " new-wallet-file " . } : Option [ OutFile ]
2020-06-16 18:38:51 +00:00
2021-04-06 22:12:07 +00:00
#[
2020-11-27 19:48:33 +00:00
of DepositsCmd . status :
discard
2021-04-06 22:12:07 +00:00
] #
2020-11-27 19:48:33 +00:00
2020-08-02 17:26:57 +00:00
of DepositsCmd . ` import ` :
importedDepositsDir * {.
argument
2022-06-15 18:04:07 +00:00
desc : " A directory with keystores to import " . } : Option [ InputDir ]
2020-08-02 17:26:57 +00:00
2023-02-16 17:25:48 +00:00
importMethod * {.
desc : " Specifies which import method will be used ( " &
" normal, single-salt) "
defaultValue : ImportMethod . Normal
name : " method " . } : ImportMethod
2020-11-27 19:48:33 +00:00
of DepositsCmd . exit :
2023-04-25 06:44:01 +00:00
exitedValidators * {.
desc : " One or more validator index, public key or a keystore path of " &
" the exited validator(s) "
name : " validator " . } : seq [ string ]
exitAllValidatorsFlag * {.
desc : " Exit all validators in the specified data directory or validators directory "
defaultValue : false
name : " all " . } : bool
2020-11-27 19:48:33 +00:00
exitAtEpoch * {.
name : " epoch "
2023-04-25 06:44:01 +00:00
defaultValueDesc : " immediately "
2022-06-15 18:04:07 +00:00
desc : " The desired exit epoch " . } : Option [ uint64 ]
2020-06-23 19:11:07 +00:00
2022-01-25 10:07:15 +00:00
restUrlForExit * {.
desc : " URL of the beacon node REST service "
2022-06-01 10:47:52 +00:00
defaultValue : defaultBeaconNode
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultBeaconNodeDesc
2022-06-15 18:04:07 +00:00
name : " rest-url " . } : string
2022-01-31 11:57:16 +00:00
2023-03-20 11:58:54 +00:00
printData * {.
desc : " Print signed exit message instead of publishing it "
defaultValue : false
name : " print " . } : bool
2022-01-17 09:27:08 +00:00
of BNStartUpCmd . record :
2020-11-24 23:23:28 +00:00
case recordCmd * {. command . } : RecordCmd
of RecordCmd . create :
ipExt * {.
desc : " External IP address "
2023-11-01 07:33:00 +00:00
name : " ip " . } : IpAddress
2020-11-24 23:23:28 +00:00
tcpPortExt * {.
desc : " External TCP port "
name : " tcp-port " . } : Port
udpPortExt * {.
desc : " External UDP port "
name : " udp-port " . } : Port
seqNumber * {.
desc : " Record sequence number "
2021-05-19 06:38:13 +00:00
defaultValue : 1 ,
2020-11-24 23:23:28 +00:00
name : " seq-number " . } : uint
fields * {.
desc : " Additional record key pairs, provide as <string>:<bytes in hex> "
name : " field " . } : seq [ ( string ) ]
of RecordCmd . print :
recordPrint * {.
argument
desc : " ENR URI of the record to print "
name : " enr " . } : Record
2022-01-17 09:27:08 +00:00
of BNStartUpCmd . web3 :
2020-12-04 16:28:42 +00:00
case web3Cmd * {. command . } : Web3Cmd
of Web3Cmd . test :
web3TestUrl * {.
argument
desc : " The web3 provider URL to test "
2022-06-15 18:04:07 +00:00
name : " url " . } : Uri
2020-12-04 16:28:42 +00:00
2022-01-17 09:27:08 +00:00
of BNStartUpCmd . slashingdb :
2021-05-19 06:38:13 +00:00
case slashingdbCmd * {. command . } : SlashProtCmd
of SlashProtCmd . ` import ` :
importedInterchangeFile * {.
desc : " EIP-3076 slashing protection interchange file to import "
argument . } : InputFile
of SlashProtCmd . ` export ` :
exportedValidators * {.
desc : " Limit the export to specific validators " &
" (specified as numeric indices or public keys) "
abbr : " v "
2022-06-15 18:04:07 +00:00
name : " validator " . } : seq [ PubKey0x ]
2021-05-19 06:38:13 +00:00
exportedInterchangeFile * {.
desc : " EIP-3076 slashing protection interchange file to export "
2022-06-15 18:04:07 +00:00
argument . } : OutFile
2021-05-19 06:38:13 +00:00
2022-01-17 09:27:08 +00:00
of BNStartUpCmd . trustedNodeSync :
trustedNodeUrl * {.
desc : " URL of the REST API to sync from "
2022-06-01 10:47:52 +00:00
defaultValue : defaultBeaconNode
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultBeaconNodeDesc
2022-01-17 09:27:08 +00:00
name : " trusted-node-url "
. } : string
State-only checkpoint state startup (#4251)
Currently, we require genesis and a checkpoint block and state to start
from an arbitrary slot - this PR relaxes this requirement so that we can
start with a state alone.
The current trusted-node-sync algorithm works by first downloading
blocks until we find an epoch aligned non-empty slot, then downloads the
state via slot.
However, current
[proposals](https://github.com/ethereum/beacon-APIs/pull/226) for
checkpointing prefer finalized state as
the main reference - this allows more simple access control and caching
on the server side - in particular, this should help checkpoint-syncing
from sources that have a fast `finalized` state download (like infura
and teku) but are slow when accessing state via slot.
Earlier versions of Nimbus will not be able to read databases created
without a checkpoint block and genesis. In most cases, backfilling makes
the database compatible except where genesis is also missing (custom
networks).
* backfill checkpoint block from libp2p instead of checkpoint source,
when doing trusted node sync
* allow starting the client without genesis / checkpoint block
* perform epoch start slot lookahead when loading tail state, so as to
deal with the case where the epoch start slot does not have a block
* replace `--blockId` with `--state-id` in TNS command line
* when replaying, also look at the parent of the last-known-block (even
if we don't have the parent block data, we can still replay from a
"parent" state) - in particular, this clears the way for implementing
state pruning
* deprecate `--finalized-checkpoint-block` option (no longer needed)
2022-11-02 10:02:38 +00:00
stateId * {.
desc : " State id to sync to - this can be \" finalized \" , a slot number or state hash or \" head \" "
name : " state-id "
2023-04-16 06:07:07 +00:00
. } : Option [ string ]
2022-01-17 09:27:08 +00:00
State-only checkpoint state startup (#4251)
Currently, we require genesis and a checkpoint block and state to start
from an arbitrary slot - this PR relaxes this requirement so that we can
start with a state alone.
The current trusted-node-sync algorithm works by first downloading
blocks until we find an epoch aligned non-empty slot, then downloads the
state via slot.
However, current
[proposals](https://github.com/ethereum/beacon-APIs/pull/226) for
checkpointing prefer finalized state as
the main reference - this allows more simple access control and caching
on the server side - in particular, this should help checkpoint-syncing
from sources that have a fast `finalized` state download (like infura
and teku) but are slow when accessing state via slot.
Earlier versions of Nimbus will not be able to read databases created
without a checkpoint block and genesis. In most cases, backfilling makes
the database compatible except where genesis is also missing (custom
networks).
* backfill checkpoint block from libp2p instead of checkpoint source,
when doing trusted node sync
* allow starting the client without genesis / checkpoint block
* perform epoch start slot lookahead when loading tail state, so as to
deal with the case where the epoch start slot does not have a block
* replace `--blockId` with `--state-id` in TNS command line
* when replaying, also look at the parent of the last-known-block (even
if we don't have the parent block data, we can still replay from a
"parent" state) - in particular, this clears the way for implementing
state pruning
* deprecate `--finalized-checkpoint-block` option (no longer needed)
2022-11-02 10:02:38 +00:00
blockId * {.
hidden
desc : " Block id to sync to - this can be a block root, slot number, \" finalized \" or \" head \" (deprecated) "
. } : Option [ string ]
2023-04-16 06:07:07 +00:00
lcTrustedBlockRoot * {.
desc : " Recent trusted finalized block root to initialize light client from "
name : " trusted-block-root " . } : Option [ Eth2Digest ]
2022-01-17 09:27:08 +00:00
backfillBlocks * {.
desc : " Backfill blocks directly from REST server instead of fetching via API "
defaultValue : true
2022-06-15 18:04:07 +00:00
name : " backfill " . } : bool
2022-01-17 09:27:08 +00:00
2022-03-11 12:49:47 +00:00
reindex * {.
desc : " Recreate historical state index at end of backfill, allowing full history access (requires full backfill) "
2022-06-15 18:04:07 +00:00
defaultValue : false . } : bool
2022-03-11 12:49:47 +00:00
2022-12-07 10:24:51 +00:00
downloadDepositSnapshot * {.
desc : " Also try to download a snapshot of the deposit contract state "
defaultValue : false
name : " with-deposit-snapshot " . } : bool
2020-05-22 17:04:52 +00:00
ValidatorClientConf * = object
2022-03-05 02:33:15 +00:00
configFile * {.
desc : " Loads the configuration from a TOML file "
2022-06-15 18:04:07 +00:00
name : " config-file " . } : Option [ InputFile ]
2022-03-05 02:33:15 +00:00
2020-05-22 17:04:52 +00:00
logLevel * {.
2021-05-19 06:38:13 +00:00
desc : " Sets the log level "
2020-11-09 08:12:48 +00:00
defaultValue : " INFO "
2022-06-15 18:04:07 +00:00
name : " log-level " . } : string
2020-05-22 17:04:52 +00:00
2021-11-02 17:06:36 +00:00
logStdout * {.
2021-11-10 09:02:18 +00:00
hidden
2021-11-02 17:06:36 +00:00
desc : " Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json) "
defaultValueDesc : " auto "
defaultValue : StdoutLogKind . Auto
2022-06-15 18:04:07 +00:00
name : " log-format " . } : StdoutLogKind
2021-11-02 17:06:36 +00:00
2020-07-15 13:15:55 +00:00
logFile * {.
2023-04-12 17:01:29 +00:00
desc : " Specifies a path for the written JSON log file (deprecated) "
2022-06-15 18:04:07 +00:00
name : " log-file " . } : Option [ OutFile ]
2020-07-15 13:15:55 +00:00
2020-05-22 17:04:52 +00:00
dataDir * {.
2020-06-23 19:11:07 +00:00
desc : " The directory where nimbus will store all blockchain data "
2021-05-19 06:38:13 +00:00
defaultValue : config . defaultDataDir ( )
defaultValueDesc : " "
2020-05-22 17:04:52 +00:00
abbr : " d "
2022-06-15 18:04:07 +00:00
name : " data-dir " . } : OutDir
2020-05-22 17:04:52 +00:00
2022-07-21 16:54:07 +00:00
doppelgangerDetection * {.
# TODO This description is shared between the BN and the VC.
# Extract it in a constant (confutils fix may be needed).
desc : " If enabled, the validator client prudently listens for 2 epochs " &
" for attestations from a validator with the same index " &
" (a doppelganger), before sending an attestation itself. This " &
" protects against slashing (due to double-voting) but means you " &
" will miss two attestations when restarting. "
defaultValue : true
name : " doppelganger-detection " . } : bool
2020-06-01 19:48:20 +00:00
nonInteractive * {.
2023-04-12 17:01:29 +00:00
desc : " Do not display interactive prompts. Quit on missing configuration "
2022-06-15 18:04:07 +00:00
name : " non-interactive " . } : bool
2020-06-01 19:48:20 +00:00
2020-09-01 13:44:40 +00:00
validatorsDirFlag * {.
desc : " A directory containing validator keystores "
2022-06-15 18:04:07 +00:00
name : " validators-dir " . } : Option [ InputDir ]
2020-09-01 13:44:40 +00:00
2023-10-13 12:42:00 +00:00
verifyingWeb3Signers * {.
2023-08-31 12:16:15 +00:00
desc : " Remote Web3Signer URL that will be used as a source of validators "
2023-10-13 12:42:00 +00:00
name : " verifying-web3-signer-url " . } : seq [ Uri ]
provenBlockProperties * {.
desc : " The field path of a block property that will be sent for verification to the verifying Web3Signer (for example \" .execution_payload.fee_recipient \" ) "
name : " proven-block-property " . } : seq [ string ]
2023-08-31 12:16:15 +00:00
2023-09-06 19:04:10 +00:00
web3signerUpdateInterval * {.
desc : " Number of seconds between validator list updates "
name : " web3-signer-update-interval "
defaultValue : 3600 . } : Natural
2023-09-04 19:14:58 +00:00
2023-10-13 12:42:00 +00:00
web3Signers * {.
desc : " Remote Web3Signer URL that will be used as a source of validators "
name : " web3-signer-url " . } : seq [ Uri ]
2020-09-01 13:44:40 +00:00
secretsDirFlag * {.
desc : " A directory containing validator keystore passwords "
2022-06-15 18:04:07 +00:00
name : " secrets-dir " . } : Option [ InputDir ]
2020-09-01 13:44:40 +00:00
2022-08-19 10:30:07 +00:00
restRequestTimeout * {.
defaultValue : 0
defaultValueDesc : " infinite "
desc : " The number of seconds to wait until complete REST request " &
" will be received "
name : " rest-request-timeout " . } : Natural
restMaxRequestBodySize * {.
defaultValue : 16_384
desc : " Maximum size of REST request body (kilobytes) "
name : " rest-max-body-size " . } : Natural
restMaxRequestHeadersSize * {.
defaultValue : 64
desc : " Maximum size of REST request headers (kilobytes) "
name : " rest-max-headers-size " . } : Natural
# Same option as appears in Lighthouse and Prysm
# https://lighthouse-book.sigmaprime.io/suggested-fee-recipient.html
# https://github.com/prysmaticlabs/prysm/pull/10312
suggestedFeeRecipient * {.
desc : " Suggested fee recipient "
name : " suggested-fee-recipient " . } : Option [ Address ]
2023-02-15 15:10:31 +00:00
suggestedGasLimit * {.
desc : " Suggested gas limit "
2024-01-19 14:36:04 +00:00
defaultValue : defaultGasLimit
2023-02-15 15:10:31 +00:00
name : " suggested-gas-limit " . } : uint64
2021-12-22 12:37:31 +00:00
keymanagerEnabled * {.
2022-12-01 05:38:54 +00:00
desc : " Enable the REST keymanager API "
2021-12-22 12:37:31 +00:00
defaultValue : false
2022-06-15 18:04:07 +00:00
name : " keymanager " . } : bool
2021-12-22 12:37:31 +00:00
keymanagerPort * {.
desc : " Listening port for the REST keymanager API "
2022-07-20 18:17:21 +00:00
defaultValue : defaultEth2RestPort
defaultValueDesc : $ defaultEth2RestPortDesc
2022-06-15 18:04:07 +00:00
name : " keymanager-port " . } : Port
2021-12-22 12:37:31 +00:00
keymanagerAddress * {.
desc : " Listening port for the REST keymanager API "
defaultValue : defaultAdminListenAddress
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultAdminListenAddressDesc
2023-11-01 07:33:00 +00:00
name : " keymanager-address " . } : IpAddress
2021-12-22 12:37:31 +00:00
2022-08-19 10:30:07 +00:00
keymanagerAllowedOrigin * {.
desc : " Limit the access to the Keymanager API to a particular hostname " &
" (for CORS-enabled clients such as browsers) "
name : " keymanager-allow-origin " . } : Option [ string ]
2021-12-22 12:37:31 +00:00
keymanagerTokenFile * {.
desc : " A file specifying the authorizition token required for accessing the keymanager API "
2022-06-15 18:04:07 +00:00
name : " keymanager-token-file " . } : Option [ InputFile ]
2021-10-04 19:08:31 +00:00
2022-07-29 08:36:20 +00:00
metricsEnabled * {.
2022-12-01 05:38:54 +00:00
desc : " Enable the metrics server (BETA) "
2022-07-29 08:36:20 +00:00
defaultValue : false
name : " metrics " . } : bool
metricsAddress * {.
2022-12-01 05:38:54 +00:00
desc : " Listening address of the metrics server (BETA) "
2022-07-29 08:36:20 +00:00
defaultValue : defaultAdminListenAddress
defaultValueDesc : $ defaultAdminListenAddressDesc
2023-11-01 07:33:00 +00:00
name : " metrics-address " . } : IpAddress
2022-07-29 08:36:20 +00:00
metricsPort * {.
2022-12-01 05:38:54 +00:00
desc : " Listening HTTP port of the metrics server (BETA) "
2022-08-17 10:26:31 +00:00
defaultValue : 8108
2022-07-29 08:36:20 +00:00
name : " metrics-port " . } : Port
2022-02-27 11:02:45 +00:00
graffiti * {.
desc : " The graffiti value that will appear in proposed blocks. " &
" You can use a 0x-prefixed hex encoded string to specify " &
" raw bytes "
2022-06-15 18:04:07 +00:00
name : " graffiti " . } : Option [ GraffitiBytes ]
2020-10-27 11:04:17 +00:00
2022-02-27 11:02:45 +00:00
stopAtEpoch * {.
desc : " A positive epoch selects the epoch at which to stop "
defaultValue : 0
2023-08-30 11:15:19 +00:00
name : " debug-stop-at-epoch " . } : uint64
2020-09-01 13:38:34 +00:00
2022-10-29 09:00:51 +00:00
payloadBuilderEnable * {.
2022-12-01 05:38:54 +00:00
desc : " Enable usage of beacon node with external payload builder (BETA) "
2022-10-29 09:00:51 +00:00
defaultValue : false
name : " payload-builder " . } : bool
2023-11-08 12:03:51 +00:00
distributedEnabled * {.
desc : " Enable usage of Obol middleware (BETA) "
defaultValue : false
name : " distributed " . } : bool
2022-02-27 11:02:45 +00:00
beaconNodes * {.
2022-12-01 16:23:27 +00:00
desc : " URL addresses to one or more beacon node HTTP REST APIs " ,
2022-09-29 07:57:14 +00:00
defaultValue : @ [ defaultBeaconNodeUri ]
defaultValueDesc : $ defaultBeaconNodeUri
name : " beacon-node " . } : seq [ Uri ]
2020-06-01 19:48:20 +00:00
2023-06-08 08:44:32 +00:00
monitoringType * {.
desc : " Enable block monitoring which are seen by beacon node (BETA) "
defaultValue : BlockMonitoringType . Disabled
name : " block-monitor-type " . } : BlockMonitoringType
2021-11-30 01:20:21 +00:00
SigningNodeConf * = object
2022-03-05 02:33:15 +00:00
configFile * {.
desc : " Loads the configuration from a TOML file "
2022-06-15 18:04:07 +00:00
name : " config-file " . } : Option [ InputFile ]
2022-03-05 02:33:15 +00:00
2021-11-30 01:20:21 +00:00
logLevel * {.
desc : " Sets the log level "
defaultValue : " INFO "
2022-06-15 18:04:07 +00:00
name : " log-level " . } : string
2021-11-30 01:20:21 +00:00
logStdout * {.
desc : " Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json) "
defaultValueDesc : " auto "
defaultValue : StdoutLogKind . Auto
2022-06-15 18:04:07 +00:00
name : " log-stdout " . } : StdoutLogKind
2021-11-30 01:20:21 +00:00
logFile * {.
2023-04-12 17:01:29 +00:00
desc : " Specifies a path for the written JSON log file "
2022-06-15 18:04:07 +00:00
name : " log-file " . } : Option [ OutFile ]
2021-11-30 01:20:21 +00:00
nonInteractive * {.
2023-04-12 17:01:29 +00:00
desc : " Do not display interactive prompts. Quit on missing configuration "
2022-06-15 18:04:07 +00:00
name : " non-interactive " . } : bool
2021-11-30 01:20:21 +00:00
dataDir * {.
desc : " The directory where nimbus will store validator ' s keys "
defaultValue : config . defaultDataDir ( )
defaultValueDesc : " "
abbr : " d "
2022-06-15 18:04:07 +00:00
name : " data-dir " . } : OutDir
2021-11-30 01:20:21 +00:00
validatorsDirFlag * {.
desc : " A directory containing validator keystores "
2022-06-15 18:04:07 +00:00
name : " validators-dir " . } : Option [ InputDir ]
2021-11-30 01:20:21 +00:00
secretsDirFlag * {.
desc : " A directory containing validator keystore passwords "
2022-06-15 18:04:07 +00:00
name : " secrets-dir " . } : Option [ InputDir ]
2021-11-30 01:20:21 +00:00
2023-04-06 13:16:21 +00:00
expectedFeeRecipient * {.
desc : " Signatures for blocks will require proofs of the specified " &
" fee recipient "
name : " expected-fee-recipient " . } : Option [ Address ]
2021-11-30 01:20:21 +00:00
serverIdent * {.
desc : " Server identifier which will be used in HTTP Host header "
2022-06-15 18:04:07 +00:00
name : " server-ident " . } : Option [ string ]
2021-11-30 01:20:21 +00:00
requestTimeout * {.
desc : " Request timeout, maximum time that node will wait for remote " &
" client request (in seconds) "
defaultValue : defaultSigningNodeRequestTimeout
2022-06-15 18:04:07 +00:00
name : " request-timeout " . } : int
2021-11-30 01:20:21 +00:00
2022-02-27 11:02:45 +00:00
bindPort * {.
2022-12-01 05:38:54 +00:00
desc : " Port for the REST HTTP server "
2022-07-20 18:17:21 +00:00
defaultValue : defaultEth2RestPort
defaultValueDesc : $ defaultEth2RestPortDesc
2022-06-15 18:04:07 +00:00
name : " bind-port " . } : Port
2021-11-30 01:20:21 +00:00
2022-02-27 11:02:45 +00:00
bindAddress * {.
2022-12-01 05:38:54 +00:00
desc : " Listening address of the REST HTTP server "
2022-02-27 11:02:45 +00:00
defaultValue : defaultAdminListenAddress
2022-07-20 18:17:21 +00:00
defaultValueDesc : $ defaultAdminListenAddressDesc
2023-11-01 07:33:00 +00:00
name : " bind-address " . } : IpAddress
2021-11-30 01:20:21 +00:00
2022-02-27 11:02:45 +00:00
tlsEnabled * {.
2022-12-01 05:38:54 +00:00
desc : " Use secure TLS communication for REST server "
2022-02-27 11:02:45 +00:00
defaultValue : false
2022-06-15 18:04:07 +00:00
name : " tls " . } : bool
2021-11-30 01:20:21 +00:00
2022-02-27 11:02:45 +00:00
tlsCertificate * {.
desc : " Path to SSL certificate file "
2022-06-15 18:04:07 +00:00
name : " tls-cert " . } : Option [ InputFile ]
2021-11-30 01:20:21 +00:00
2022-02-27 11:02:45 +00:00
tlsPrivateKey * {.
desc : " Path to SSL ceritificate ' s private key "
2022-06-15 18:04:07 +00:00
name : " tls-key " . } : Option [ InputFile ]
2021-11-30 01:20:21 +00:00
AnyConf * = BeaconNodeConf | ValidatorClientConf | SigningNodeConf
2022-05-17 13:50:49 +00:00
proc defaultDataDir * [ Conf ] ( config : Conf ) : 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
2022-03-24 21:44:34 +00:00
func dumpDir ( config : AnyConf ) : string =
2021-02-22 16:17:48 +00:00
config . dataDir / " dump "
2019-12-10 14:20:40 +00:00
2021-11-30 01:20:21 +00:00
func dumpDirInvalid * ( config : AnyConf ) : string =
2021-02-22 16:17:48 +00:00
config . dumpDir / " invalid " # things that failed validation
2020-06-16 08:49:32 +00:00
2021-11-30 01:20:21 +00:00
func dumpDirIncoming * ( config : AnyConf ) : string =
2021-02-22 16:17:48 +00:00
config . dumpDir / " incoming " # things that couldn't be validated (missingparent etc)
2020-06-16 08:49:32 +00:00
2021-11-30 01:20:21 +00:00
func dumpDirOutgoing * ( config : AnyConf ) : string =
2021-02-22 16:17:48 +00:00
config . dumpDir / " outgoing " # things we produced
2020-06-16 08:49:32 +00:00
2021-02-22 16:17:48 +00:00
proc createDumpDirs * ( config : BeaconNodeConf ) =
2023-10-05 14:15:03 +00:00
proc fail {. noreturn . } =
raiseAssert " createDumpDirs should be used only in the right context "
case config . cmd
of BNStartUpCmd . noCommand :
if config . dumpEnabled :
if ( let res = secureCreatePath ( config . dumpDirInvalid ) ; res . isErr ) :
warn " Could not create dump directory " ,
path = config . dumpDirInvalid , err = ioErrorMsg ( res . error )
if ( let res = secureCreatePath ( config . dumpDirIncoming ) ; res . isErr ) :
warn " Could not create dump directory " ,
path = config . dumpDirIncoming , err = ioErrorMsg ( res . error )
if ( let res = secureCreatePath ( config . dumpDirOutgoing ) ; res . isErr ) :
warn " Could not create dump directory " ,
path = config . dumpDirOutgoing , err = ioErrorMsg ( res . error )
else : fail ( )
2020-06-16 08:49:32 +00:00
2022-06-07 17:01:11 +00:00
func parseCmdArg * ( T : type Eth2Digest , input : string ) : T
2023-08-25 09:29:07 +00:00
{. raises : [ ValueError ] . } =
2022-06-07 17:01:11 +00:00
Eth2Digest . fromHex ( input )
func completeCmdArg * ( T : type Eth2Digest , input : string ) : seq [ string ] =
return @ [ ]
2022-03-24 21:44:34 +00:00
func parseCmdArg * ( T : type GraffitiBytes , input : string ) : T
2023-08-25 09:29:07 +00:00
{. raises : [ ValueError ] . } =
2022-03-24 21:44:34 +00:00
GraffitiBytes . init ( input )
2020-06-29 17:30:19 +00:00
2022-03-24 21:44:34 +00:00
func completeCmdArg * ( T : type GraffitiBytes , input : string ) : seq [ string ] =
2020-06-29 17:30:19 +00:00
return @ [ ]
2022-03-24 21:44:34 +00:00
func parseCmdArg * ( T : type BlockHashOrNumber , input : string ) : T
2023-08-25 09:29:07 +00:00
{. raises : [ ValueError ] . } =
2022-03-24 21:44:34 +00:00
init ( BlockHashOrNumber , input )
2020-11-12 19:01:26 +00:00
2022-03-24 21:44:34 +00:00
func completeCmdArg * ( T : type BlockHashOrNumber , input : string ) : seq [ string ] =
2020-11-12 19:01:26 +00:00
return @ [ ]
2022-03-24 21:44:34 +00:00
func parseCmdArg * ( T : type Uri , input : string ) : T
2023-08-25 09:29:07 +00:00
{. raises : [ ValueError ] . } =
2022-03-24 21:44:34 +00:00
parseUri ( input )
2020-11-27 19:48:33 +00:00
2022-03-24 21:44:34 +00:00
func completeCmdArg * ( T : type Uri , input : string ) : seq [ string ] =
2020-11-27 19:48:33 +00:00
return @ [ ]
2022-03-24 21:44:34 +00:00
func parseCmdArg * ( T : type PubKey0x , input : string ) : T
2023-08-25 09:29:07 +00:00
{. raises : [ ValueError ] . } =
2022-03-24 21:44:34 +00:00
PubKey0x ( hexToPaddedByteArray [ RawPubKeySize ] ( input ) )
2021-05-19 06:38:13 +00:00
2022-03-24 21:44:34 +00:00
func parseCmdArg * ( T : type ValidatorPubKey , input : string ) : T
2023-08-25 09:29:07 +00:00
{. raises : [ ValueError ] . } =
2022-03-24 21:44:34 +00:00
let res = ValidatorPubKey . fromHex ( input )
2021-12-20 19:20:31 +00:00
if res . isErr ( ) : raise ( ref ValueError ) ( msg : $ res . error ( ) )
res . get ( )
2022-03-24 21:44:34 +00:00
func completeCmdArg * ( T : type PubKey0x , input : string ) : seq [ string ] =
2021-05-19 06:38:13 +00:00
return @ [ ]
2022-03-24 21:44:34 +00:00
func parseCmdArg * ( T : type Checkpoint , input : string ) : T
2023-08-25 09:29:07 +00:00
{. raises : [ ValueError ] . } =
2022-03-24 21:44:34 +00:00
let sepIdx = find ( input , ' : ' )
2022-06-17 11:55:03 +00:00
if sepIdx = = - 1 or sepIdx = = input . len - 1 :
2020-10-06 15:32:17 +00:00
raise newException ( ValueError ,
" The weak subjectivity checkpoint must be provided in the `block_root:epoch_number` format " )
2022-06-17 11:55:03 +00:00
var root : Eth2Digest
hexToByteArrayStrict ( input . toOpenArray ( 0 , sepIdx - 1 ) , root . data )
T ( root : root , epoch : parseBiggestUInt ( input [ sepIdx + 1 .. ^ 1 ] ) . Epoch )
2020-10-06 15:32:17 +00:00
2022-03-24 21:44:34 +00:00
func completeCmdArg * ( T : type Checkpoint , input : string ) : seq [ string ] =
2020-09-22 20:42:42 +00:00
return @ [ ]
2023-02-23 02:10:07 +00:00
func parseCmdArg * ( T : type Epoch , input : string ) : T
2023-08-25 09:29:07 +00:00
{. raises : [ ValueError ] . } =
2023-02-23 02:10:07 +00:00
Epoch parseBiggestUInt ( input )
func completeCmdArg * ( T : type Epoch , input : string ) : seq [ string ] =
return @ [ ]
2022-02-17 11:53:55 +00:00
func isPrintable ( rune : Rune ) : bool =
2020-10-02 14:48:27 +00:00
# This can be eventually replaced by the `unicodeplus` package, but a single
# proc does not justify the extra dependencies at the moment:
# https://github.com/nitely/nim-unicodeplus
# https://github.com/nitely/nim-segmentation
rune = = Rune ( 0x20 ) or unicodeCategory ( rune ) notin ctgC + ctgZ
2022-03-24 21:44:34 +00:00
func parseCmdArg * ( T : type WalletName , input : string ) : T
2023-08-25 09:29:07 +00:00
{. raises : [ ValueError ] . } =
2020-06-23 19:11:07 +00:00
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 " )
2022-03-24 21:44:34 +00:00
for rune in runes ( input ) :
2020-10-02 14:48:27 +00:00
if not rune . isPrintable :
raise newException ( ValueError , " The wallet name should consist only of printable characters " )
# From the Unicode Normalization FAQ (https://unicode.org/faq/normalization.html):
# NFKC is the preferred form for identifiers, especially where there are security concerns
# (see UTR #36 http://www.unicode.org/reports/tr36/)
return T ( toNFKC ( input ) )
2020-06-23 19:11:07 +00:00
2022-03-24 21:44:34 +00:00
func completeCmdArg * ( T : type WalletName , input : string ) : seq [ string ] =
2020-06-23 19:11:07 +00:00
return @ [ ]
2020-11-24 23:23:28 +00:00
2023-05-31 19:07:06 +00:00
proc parseCmdArg * ( T : type enr . Record , p : string ) : T {. raises : [ ValueError ] . } =
2020-11-24 23:23:28 +00:00
if not fromURI ( result , p ) :
2023-05-31 19:07:06 +00:00
raise newException ( ValueError , " Invalid ENR " )
2020-11-24 23:23:28 +00:00
2022-03-24 21:44:34 +00:00
func completeCmdArg * ( T : type enr . Record , val : string ) : seq [ string ] =
2020-11-24 23:23:28 +00:00
return @ [ ]
2020-06-23 19:11:07 +00:00
2022-05-17 13:50:49 +00:00
func validatorsDir * [ Conf ] ( config : Conf ) : string =
2021-02-22 16:17:48 +00:00
string config . validatorsDirFlag . get ( InputDir ( config . dataDir / " validators " ) )
2020-06-03 11:52:36 +00:00
2022-05-17 13:50:49 +00:00
func secretsDir * [ Conf ] ( config : Conf ) : string =
2021-02-22 16:17:48 +00:00
string config . secretsDirFlag . get ( InputDir ( config . dataDir / " secrets " ) )
2019-12-10 14:20:40 +00:00
2021-02-22 16:17:48 +00:00
func walletsDir * ( config : BeaconNodeConf ) : string =
2022-07-21 11:07:19 +00:00
string config . walletsDirFlag . get ( InputDir ( config . dataDir / " wallets " ) )
func eraDir * ( config : BeaconNodeConf ) : string =
# The era directory should be shared between networks of the same type..
string config . eraDirFlag . get ( InputDir ( config . dataDir / " era " ) )
2020-07-17 20:59:50 +00:00
2023-10-05 14:15:03 +00:00
{. push warning [ ProveField ] : off . } # https://github.com/nim-lang/Nim/issues/22791
2021-02-22 16:17:48 +00:00
func outWalletName * ( config : BeaconNodeConf ) : Option [ WalletName ] =
2022-02-16 22:24:44 +00:00
proc fail {. noreturn . } =
2020-07-17 20:59:50 +00:00
raiseAssert " outWalletName should be used only in the right context "
2021-02-22 16:17:48 +00:00
case config . cmd
2020-07-14 19:00:35 +00:00
of wallets :
2021-02-22 16:17:48 +00:00
case config . walletsCmd
of WalletsCmd . create : config . createdWalletNameFlag
of WalletsCmd . restore : config . restoredWalletNameFlag
2020-07-17 20:59:50 +00:00
of WalletsCmd . list : fail ( )
of deposits :
2021-04-06 22:12:07 +00:00
case config . depositsCmd
2021-04-08 11:35:58 +00:00
of DepositsCmd . createTestnetDeposits : config . newWalletNameFlag
2021-04-06 22:12:07 +00:00
else : fail ( )
2020-07-14 19:00:35 +00:00
else :
2020-07-17 20:59:50 +00:00
fail ( )
2023-10-05 14:15:03 +00:00
{. pop . }
2020-07-14 19:00:35 +00:00
2023-10-05 14:15:03 +00:00
{. push warning [ ProveField ] : off . } # https://github.com/nim-lang/Nim/issues/22791
2021-02-22 16:17:48 +00:00
func outWalletFile * ( config : BeaconNodeConf ) : Option [ OutFile ] =
2022-02-16 22:24:44 +00:00
proc fail {. noreturn . } =
2023-10-05 14:15:03 +00:00
raiseAssert " outWalletFile should be used only in the right context "
2020-07-17 20:59:50 +00:00
2021-02-22 16:17:48 +00:00
case config . cmd
2020-07-17 20:59:50 +00:00
of wallets :
2021-02-22 16:17:48 +00:00
case config . walletsCmd
of WalletsCmd . create : config . createdWalletFileFlag
of WalletsCmd . restore : config . restoredWalletFileFlag
2020-07-17 20:59:50 +00:00
of WalletsCmd . list : fail ( )
of deposits :
2021-04-06 22:12:07 +00:00
case config . depositsCmd
2021-04-08 11:35:58 +00:00
of DepositsCmd . createTestnetDeposits : config . newWalletFileFlag
2021-04-06 22:12:07 +00:00
else : fail ( )
2020-07-17 20:59:50 +00:00
else :
fail ( )
2023-10-05 14:15:03 +00:00
{. pop . }
2020-06-23 19:11:07 +00:00
2022-11-30 03:45:03 +00:00
func databaseDir * ( dataDir : OutDir ) : string =
dataDir / " db "
template databaseDir * ( config : AnyConf ) : string =
config . dataDir . databaseDir
2019-12-10 14:20:40 +00:00
2022-02-27 11:02:45 +00:00
func runAsService * ( config : BeaconNodeConf ) : bool =
2023-10-05 14:15:03 +00:00
case config . cmd
of noCommand :
config . runAsServiceFlag
else :
false
2022-02-27 11:02:45 +00:00
2023-10-13 12:42:00 +00:00
func web3SignerUrls * ( conf : AnyConf ) : seq [ Web3SignerUrl ] =
2023-12-05 21:08:18 +00:00
for url in conf . web3Signers :
2023-10-13 12:42:00 +00:00
result . add Web3SignerUrl ( url : url )
2023-12-05 21:08:18 +00:00
for url in conf . verifyingWeb3Signers :
2023-10-13 12:42:00 +00:00
result . add Web3SignerUrl ( url : url ,
provenBlockProperties : conf . provenBlockProperties )
2020-02-11 17:35:42 +00:00
template writeValue * ( writer : var JsonWriter ,
value : TypedInputFile | InputFile | InputDir | OutPath | OutDir | OutFile ) =
writer . writeValue ( string value )
2022-02-11 20:40:49 +00:00
2022-03-05 02:33:15 +00:00
template raiseUnexpectedValue ( r : var TomlReader , msg : string ) =
# TODO: We need to implement `raiseUnexpectedValue` for TOML,
# so the correct line and column information can be included
# in error messages:
raise newException ( SerializationError , msg )
proc readValue * ( r : var TomlReader , value : var Epoch )
2023-08-25 09:29:07 +00:00
{. raises : [ SerializationError , IOError ] . } =
2022-03-05 02:33:15 +00:00
value = Epoch r . parseInt ( uint64 )
proc readValue * ( r : var TomlReader , value : var GraffitiBytes )
2023-08-25 09:29:07 +00:00
{. raises : [ SerializationError , IOError ] . } =
2022-03-05 02:33:15 +00:00
try :
value = GraffitiBytes . init ( r . readValue ( string ) )
2023-07-15 16:30:52 +00:00
except ValueError :
2022-03-05 02:33:15 +00:00
r . raiseUnexpectedValue ( " A printable string or 0x-prefixed hex-encoded raw bytes expected " )
proc readValue * ( r : var TomlReader , val : var NatConfig )
2023-10-05 14:15:03 +00:00
{. raises : [ SerializationError ] . } =
2022-03-24 21:44:34 +00:00
val = try : parseCmdArg ( NatConfig , r . readValue ( string ) )
2022-03-05 02:33:15 +00:00
except CatchableError as err :
raise newException ( SerializationError , err . msg )
proc readValue * ( r : var TomlReader , a : var Eth2Digest )
2023-08-25 09:29:07 +00:00
{. raises : [ IOError , SerializationError ] . } =
2022-03-05 02:33:15 +00:00
try :
a = fromHex ( type ( a ) , r . readValue ( string ) )
except ValueError :
r . raiseUnexpectedValue ( " Hex string expected " )
proc readValue * ( reader : var TomlReader , value : var ValidatorPubKey )
2023-10-05 14:15:03 +00:00
{. raises : [ SerializationError ] . } =
2022-03-05 02:33:15 +00:00
let keyAsString = try :
reader . readValue ( string )
except CatchableError :
raiseUnexpectedValue ( reader , " A hex-encoded string expected " )
let key = ValidatorPubKey . fromHex ( keyAsString )
if key . isOk :
value = key . get
else :
# TODO: Can we provide better diagnostic?
raiseUnexpectedValue ( reader , " Valid hex-encoded public key expected " )
proc readValue * ( r : var TomlReader , a : var PubKey0x )
2023-10-05 14:15:03 +00:00
{. raises : [ SerializationError ] . } =
2022-03-05 02:33:15 +00:00
try :
2022-03-24 21:44:34 +00:00
a = parseCmdArg ( PubKey0x , r . readValue ( string ) )
2022-03-05 02:33:15 +00:00
except CatchableError :
r . raiseUnexpectedValue ( " a 0x-prefixed hex-encoded string expected " )
proc readValue * ( r : var TomlReader , a : var WalletName )
2023-10-05 14:15:03 +00:00
{. raises : [ SerializationError ] . } =
2022-03-05 02:33:15 +00:00
try :
2022-03-24 21:44:34 +00:00
a = parseCmdArg ( WalletName , r . readValue ( string ) )
2022-03-05 02:33:15 +00:00
except CatchableError :
r . raiseUnexpectedValue ( " string expected " )
2022-04-14 20:15:34 +00:00
proc readValue * ( r : var TomlReader , a : var Address )
2023-10-05 14:15:03 +00:00
{. raises : [ SerializationError ] . } =
2022-04-14 20:15:34 +00:00
try :
a = parseCmdArg ( Address , r . readValue ( string ) )
except CatchableError :
r . raiseUnexpectedValue ( " string expected " )
2023-09-22 21:45:24 +00:00
proc loadEth2Network * ( eth2Network : Option [ string ] ) : Eth2NetworkMetadata =
2022-09-19 09:25:41 +00:00
const defaultName =
2023-01-12 17:58:42 +00:00
when const_preset = = " gnosis " :
2022-09-19 09:25:41 +00:00
" gnosis "
elif const_preset = = " mainnet " :
" mainnet "
2022-02-11 20:40:49 +00:00
else :
2022-09-19 09:25:41 +00:00
" (unspecified) "
network_name . set ( 2 , labelValues = [ eth2Network . get ( otherwise = defaultName ) ] )
if eth2Network . isSome :
getMetadataForNetwork ( eth2Network . get )
2022-02-25 08:22:44 +00:00
else :
2023-01-12 17:58:42 +00:00
when const_preset = = " gnosis " :
2023-05-11 11:11:00 +00:00
getMetadataForNetwork ( " gnosis " )
2022-09-19 09:25:41 +00:00
elif const_preset = = " mainnet " :
2023-05-11 11:11:00 +00:00
getMetadataForNetwork ( " mainnet " )
2022-09-19 09:25:41 +00:00
else :
# Presumably other configurations can have other defaults, but for now
# this simplifies the flow
fatal " Must specify network on non-mainnet node "
quit 1
2022-05-31 10:45:37 +00:00
template loadEth2Network * ( config : BeaconNodeConf ) : Eth2NetworkMetadata =
loadEth2Network ( config . eth2Network )
2022-07-12 10:08:52 +00:00
2023-05-17 04:56:37 +00:00
func defaultFeeRecipient * ( conf : AnyConf ) : Opt [ Eth1Address ] =
2022-08-19 10:30:07 +00:00
if conf . suggestedFeeRecipient . isSome :
2023-05-17 04:56:37 +00:00
Opt . some conf . suggestedFeeRecipient . get
2022-08-19 10:30:07 +00:00
else :
# https://github.com/nim-lang/Nim/issues/19802
2023-05-17 04:56:37 +00:00
( static ( Opt . none Eth1Address ) )
2022-08-19 10:30:07 +00:00
2023-12-16 16:30:46 +00:00
proc loadJwtSecret (
2022-07-12 10:08:52 +00:00
rng : var HmacDrbgContext ,
dataDir : string ,
2023-11-27 14:48:29 +00:00
jwtSecret : Opt [ InputFile ] ,
allowCreate : bool ) : Opt [ seq [ byte ] ] =
2022-07-12 10:08:52 +00:00
# Some Web3 endpoints aren't compatible with JWT, but if explicitly chosen,
# use it regardless.
if jwtSecret . isSome or allowCreate :
let secret = rng . checkJwtSecret ( dataDir , jwtSecret )
if secret . isErr :
fatal " Specified a JWT secret file which couldn ' t be loaded " ,
err = secret . error
quit 1
2023-11-27 14:48:29 +00:00
Opt . some secret . get
2022-07-12 10:08:52 +00:00
else :
2023-11-27 14:48:29 +00:00
Opt . none seq [ byte ]
func configJwtSecretOpt * ( jwtSecret : Option [ InputFile ] ) : Opt [ InputFile ] =
if jwtSecret . isSome :
Opt . some jwtSecret . get
else :
Opt . none InputFile
2022-07-12 10:08:52 +00:00
2023-03-05 01:40:21 +00:00
proc loadJwtSecret * (
2022-07-12 10:08:52 +00:00
rng : var HmacDrbgContext ,
config : BeaconNodeConf ,
2023-11-27 14:48:29 +00:00
allowCreate : bool ) : Opt [ seq [ byte ] ] =
rng . loadJwtSecret (
string ( config . dataDir ) , config . jwtSecret . configJwtSecretOpt , allowCreate )
2023-03-05 01:40:21 +00:00
proc engineApiUrls * ( config : BeaconNodeConf ) : seq [ EngineApiUrl ] =
let elUrls = if config . noEl :
return newSeq [ EngineApiUrl ] ( )
elif config . elUrls . len = = 0 and config . web3Urls . len = = 0 :
2023-12-16 16:30:46 +00:00
@ [ getDefaultEngineApiUrl ( config . jwtSecret ) ]
2023-03-05 01:40:21 +00:00
else :
config . elUrls
2023-11-27 14:48:29 +00:00
( elUrls & config . web3Urls ) . toFinalEngineApiUrls (
config . jwtSecret . configJwtSecretOpt )
2023-05-11 08:52:44 +00:00
proc loadKzgTrustedSetup * ( ) : Result [ void , string ] =
2023-06-04 14:33:43 +00:00
const
vendorDir = currentSourcePath . parentDir . replace ( ' \\ ' , ' / ' ) & " /../vendor "
2023-10-19 05:14:02 +00:00
trustedSetup = staticRead (
vendorDir & " /nim-kzg4844/kzg4844/csources/src/trusted_setup.txt " )
2023-06-04 14:33:43 +00:00
2024-01-16 00:58:07 +00:00
static : doAssert const_preset in [ " mainnet " , " gnosis " , " minimal " ]
Kzg . loadTrustedSetupFromString ( trustedSetup )
2023-06-14 08:52:00 +00:00
proc loadKzgTrustedSetup * ( trustedSetupPath : string ) : Result [ void , string ] =
try :
Kzg . loadTrustedSetupFromString ( readFile ( trustedSetupPath ) )
except IOError as err :
err ( err . msg )