2023-01-19 08:33:11 +00:00
|
|
|
# Nimbus
|
2024-02-28 17:31:45 +00:00
|
|
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
2023-01-19 08:33:11 +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-31 12:38:08 +00:00
|
|
|
{.push raises: [].}
|
2023-01-19 08:33:11 +00:00
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
import std/os, json_serialization/std/net, beacon_chain/light_client, beacon_chain/conf
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
export net, conf
|
|
|
|
|
2023-09-15 14:21:00 +00:00
|
|
|
proc defaultDataDir*(): string =
|
2024-02-28 17:31:45 +00:00
|
|
|
let dataDir =
|
|
|
|
when defined(windows):
|
|
|
|
"AppData" / "Roaming" / "FluffyBeaconLCBridge"
|
|
|
|
elif defined(macosx):
|
|
|
|
"Library" / "Application Support" / "FluffyBeaconLCBridge"
|
|
|
|
else:
|
|
|
|
".cache" / "fluffy-beacon-lc-bridge"
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
getHomeDir() / dataDir
|
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
const defaultDataDirDesc* = defaultDataDir()
|
2023-01-19 08:33:11 +00:00
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
type BeaconBridgeConf* = object # Config
|
|
|
|
configFile* {.desc: "Loads the configuration from a TOML file", name: "config-file".}:
|
|
|
|
Option[InputFile]
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
# Logging
|
2024-02-28 17:31:45 +00:00
|
|
|
logLevel* {.desc: "Sets the log level", defaultValue: "INFO", name: "log-level".}:
|
|
|
|
string
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
logStdout* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
hidden,
|
|
|
|
desc:
|
|
|
|
"Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json)",
|
|
|
|
defaultValueDesc: "auto",
|
|
|
|
defaultValue: StdoutLogKind.Auto,
|
|
|
|
name: "log-format"
|
|
|
|
.}: StdoutLogKind
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
# Storage
|
|
|
|
dataDir* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "The directory where beacon_lc_bridge will store all data",
|
|
|
|
defaultValue: defaultDataDir(),
|
|
|
|
defaultValueDesc: $defaultDataDirDesc,
|
|
|
|
abbr: "d",
|
|
|
|
name: "data-dir"
|
|
|
|
.}: OutDir
|
2023-01-19 08:33:11 +00:00
|
|
|
|
2023-03-28 13:50:23 +00:00
|
|
|
# Portal JSON-RPC API server to connect to
|
|
|
|
rpcAddress* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "Listening address of the Portal JSON-RPC server",
|
|
|
|
defaultValue: "127.0.0.1",
|
|
|
|
name: "rpc-address"
|
|
|
|
.}: string
|
2023-03-28 13:50:23 +00:00
|
|
|
|
|
|
|
rpcPort* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "Listening port of the Portal JSON-RPC server",
|
|
|
|
defaultValue: 8545,
|
|
|
|
name: "rpc-port"
|
|
|
|
.}: Port
|
2023-03-28 13:50:23 +00:00
|
|
|
|
|
|
|
## Bridge options
|
2023-03-23 07:49:16 +00:00
|
|
|
beaconLightClient* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "Enable beacon light client content bridging",
|
|
|
|
defaultValue: false,
|
|
|
|
name: "beacon-light-client"
|
|
|
|
.}: bool
|
2023-03-23 07:49:16 +00:00
|
|
|
|
2023-03-28 13:50:23 +00:00
|
|
|
## Beacon chain light client specific options
|
2023-01-19 08:33:11 +00:00
|
|
|
|
2023-03-28 13:50:23 +00:00
|
|
|
# For Consensus light sync - No default - Needs to be provided by the user
|
2023-01-19 08:33:11 +00:00
|
|
|
trustedBlockRoot* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc:
|
|
|
|
"Recent trusted finalized block root to initialize the consensus light client from",
|
|
|
|
name: "trusted-block-root"
|
|
|
|
.}: Eth2Digest
|
2023-01-19 08:33:11 +00:00
|
|
|
|
2023-03-28 13:50:23 +00:00
|
|
|
# Network
|
|
|
|
eth2Network* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "The Eth2 network to join", defaultValueDesc: "mainnet", name: "network"
|
|
|
|
.}: Option[string]
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
# Libp2p
|
|
|
|
bootstrapNodes* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "Specifies one or more bootstrap nodes to use when connecting to the network",
|
|
|
|
abbr: "b",
|
|
|
|
name: "bootstrap-node"
|
|
|
|
.}: seq[string]
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
bootstrapNodesFile* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "Specifies a line-delimited file of bootstrap Ethereum network addresses",
|
|
|
|
defaultValue: "",
|
|
|
|
name: "bootstrap-file"
|
|
|
|
.}: InputFile
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
listenAddress* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "Listening address for the Ethereum LibP2P and Discovery v5 traffic",
|
2024-05-15 03:07:59 +00:00
|
|
|
defaultValueDesc: "*",
|
2024-02-28 17:31:45 +00:00
|
|
|
name: "listen-address"
|
2024-05-15 03:07:59 +00:00
|
|
|
.}: Option[IpAddress]
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
tcpPort* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "Listening TCP port for Ethereum LibP2P traffic",
|
|
|
|
defaultValue: defaultEth2TcpPort,
|
|
|
|
defaultValueDesc: $defaultEth2TcpPortDesc,
|
|
|
|
name: "tcp-port"
|
|
|
|
.}: Port
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
udpPort* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "Listening UDP port for node discovery",
|
|
|
|
defaultValue: defaultEth2TcpPort,
|
|
|
|
defaultValueDesc: $defaultEth2TcpPortDesc,
|
|
|
|
name: "udp-port"
|
|
|
|
.}: Port
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
# TODO: Select a lower amount of peers.
|
|
|
|
maxPeers* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "The target number of peers to connect to",
|
|
|
|
defaultValue: 160, # 5 (fanout) * 64 (subnets) / 2 (subs) for a healthy mesh
|
|
|
|
name: "max-peers"
|
|
|
|
.}: int
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
hardMaxPeers* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "The maximum number of peers to connect to. Defaults to maxPeers * 1.5",
|
|
|
|
name: "hard-max-peers"
|
|
|
|
.}: Option[int]
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
nat* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc:
|
|
|
|
"Specify method to use for determining public address. " &
|
|
|
|
"Must be one of: any, none, upnp, pmp, extip:<IP>",
|
|
|
|
defaultValue: NatConfig(hasExtIp: false, nat: NatAny),
|
|
|
|
defaultValueDesc: "any",
|
|
|
|
name: "nat"
|
|
|
|
.}: NatConfig
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
enrAutoUpdate* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
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",
|
|
|
|
defaultValue: false,
|
|
|
|
name: "enr-auto-update"
|
|
|
|
.}: bool
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
agentString* {.
|
|
|
|
defaultValue: "nimbus",
|
2024-02-28 17:31:45 +00:00
|
|
|
desc: "Node agent string which is used as identifier in the LibP2P network",
|
|
|
|
name: "agent-string"
|
|
|
|
.}: string
|
2023-01-19 08:33:11 +00:00
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
discv5Enabled* {.desc: "Enable Discovery v5", defaultValue: true, name: "discv5".}:
|
|
|
|
bool
|
2023-01-19 08:33:11 +00:00
|
|
|
|
|
|
|
directPeers* {.
|
2024-02-28 17:31:45 +00:00
|
|
|
desc:
|
|
|
|
"The list of priviledged, secure and known peers to connect and" &
|
|
|
|
"maintain the connection to, this requires a not random netkey-file." &
|
|
|
|
"In the complete multiaddress format like:" &
|
|
|
|
"/ip4/<address>/tcp/<port>/p2p/<peerId-public-key>." &
|
|
|
|
"Peering agreements are established out of band and must be reciprocal",
|
|
|
|
name: "direct-peer"
|
|
|
|
.}: seq[string]
|
|
|
|
|
2023-01-19 08:33:11 +00:00
|
|
|
func asLightClientConf*(pc: BeaconBridgeConf): LightClientConf =
|
|
|
|
return LightClientConf(
|
|
|
|
configFile: pc.configFile,
|
|
|
|
logLevel: pc.logLevel,
|
|
|
|
logStdout: pc.logStdout,
|
|
|
|
logFile: none(OutFile),
|
|
|
|
dataDir: pc.dataDir,
|
|
|
|
eth2Network: pc.eth2Network,
|
|
|
|
bootstrapNodes: pc.bootstrapNodes,
|
|
|
|
bootstrapNodesFile: pc.bootstrapNodesFile,
|
|
|
|
listenAddress: pc.listenAddress,
|
|
|
|
tcpPort: pc.tcpPort,
|
|
|
|
udpPort: pc.udpPort,
|
|
|
|
maxPeers: pc.maxPeers,
|
|
|
|
hardMaxPeers: pc.hardMaxPeers,
|
|
|
|
nat: pc.nat,
|
|
|
|
enrAutoUpdate: pc.enrAutoUpdate,
|
|
|
|
agentString: pc.agentString,
|
|
|
|
discv5Enabled: pc.discv5Enabled,
|
|
|
|
directPeers: pc.directPeers,
|
|
|
|
trustedBlockRoot: pc.trustedBlockRoot,
|
|
|
|
web3Urls: @[],
|
2023-03-09 23:40:55 +00:00
|
|
|
jwtSecret: none(InputFile),
|
2024-02-28 17:31:45 +00:00
|
|
|
stopAtEpoch: 0,
|
2023-01-19 08:33:11 +00:00
|
|
|
)
|