Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions execution_chain/common.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2022 Status Research & Development GmbH
# Copyright (c) 2022-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
Expand All @@ -10,9 +10,9 @@
import
./common/common,
./common/genesis,
./common/context
./common/manager

export
common,
genesis,
context
manager
82 changes: 0 additions & 82 deletions execution_chain/common/context.nim

This file was deleted.

5 changes: 1 addition & 4 deletions execution_chain/common/manager.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2021-2024 Status Research & Development GmbH
# Copyright (c) 2021-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
Expand Down Expand Up @@ -27,9 +27,6 @@ type
AccountsManager* = object
accounts: Table[Address, NimbusAccount]

proc init*(_: type AccountsManager): AccountsManager =
discard

proc loadKeystores*(am: var AccountsManager, path: string):
Result[void, string] =
try:
Expand Down
59 changes: 6 additions & 53 deletions execution_chain/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,8 @@ import

export net, defs, jsdefs, jsnet, nimbus_binary_common

const
# e.g.: Copyright (c) 2018-2025 Status Research & Development GmbH
NimbusCopyright* = "Copyright (c) 2018-" &
CompileDate.split('-')[0] &
" Status Research & Development GmbH"

# e.g.:
# nimbus_execution_client/v0.1.0-abcdef/os-cpu/nim-a.b.c/emvc
# Copyright (c) 2018-2025 Status Research & Development GmbH
NimbusBuild* = "$#\p$#" % [
ClientId,
NimbusCopyright,
]

NimbusHeader* = "$#\p\pNim version $#" % [
NimbusBuild,
nimBanner()
]
const NimbusCopyright* =
"Copyright (c) 2018-" & compileYear & " Status Research & Development GmbH"

func getLogLevels(): string =
var logLevels: seq[string]
Expand Down Expand Up @@ -196,16 +180,6 @@ type
defaultValue: StdoutLogKind.Auto
name: "log-format" .}: StdoutLogKind

logMetricsEnabled* {.
desc: "Enable metrics logging"
defaultValue: false
name: "log-metrics" .}: bool

logMetricsInterval* {.
desc: "Interval at which to log metrics, in seconds"
defaultValue: 10
name: "log-metrics-interval" .}: int

metricsEnabled* {.
desc: "Enable the built-in metrics HTTP server"
defaultValue: false
Expand Down Expand Up @@ -320,7 +294,7 @@ type
separator: "\pPERFORMANCE OPTIONS",
defaultValue: 0,
desc: "Number of worker threads (\"0\" = use as many threads as there are CPU cores available)"
name: "num-threads" .}: uint
name: "num-threads" .}: int

persistBatchSize* {.
hidden
Expand Down Expand Up @@ -802,31 +776,10 @@ func dbOptions*(conf: NimbusConf, noKeyCache = false): DbOptions =
# Constructor
#-------------------------------------------------------------------

proc makeConfig*(cmdLine = commandLineParams()): NimbusConf =
proc makeConfig*(cmdLine = commandLineParams(), ignoreUnknown = false): NimbusConf =
## Note: this function is not gc-safe
try:
result = NimbusConf.load(
cmdLine,
version = NimbusBuild,
copyrightBanner = NimbusHeader,
secondarySources = proc (
conf: NimbusConf, sources: ref SecondarySources
) {.raises: [ConfigurationError].} =
if conf.configFile.isSome:
sources.addConfigFile(Toml, conf.configFile.get)
)
except CatchableError as err:
if err[] of ConfigurationError and err.parent != nil:
if err.parent[] of TomlFieldReadingError:
let fieldName = ((ref TomlFieldReadingError)(err.parent)).field
echo "Error when parsing ", fieldName, ": ", err.msg
elif err.parent[] of TomlReaderError:
type TT = ref TomlReaderError
echo TT(err).formatMsg("")
else:
echo "Error when parsing config file: ", err.msg
else:
echo "Error when parsing command line params: ", err.msg
result = NimbusConf.loadWithBanners(ClientId, NimbusCopyright, [], ignoreUnknown, cmdLine).valueOr:
writePanicLine error # Logging not yet set up
quit QuitFailure

processNetworkParamsAndNetworkId(result)
Expand Down
52 changes: 52 additions & 0 deletions execution_chain/networking/netkeys.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Nimbus
# Copyright (c) 2021-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
# at your option.
# This file may not be copied, modified, or distributed except according to
# those terms.

{.push raises: [].}

import std/[strutils, os], stew/[io2, byteutils], results, eth/common/keys

proc containsOnlyHexDigits(hex: string): bool =
const HexDigitsX = HexDigits + {'x'}
for c in hex:
if c notin HexDigitsX:
return false
true

proc getNetKeys*(rng: var HmacDrbgContext, netKey: string): Result[KeyPair, string] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

portal client has code with a similar goal but obviously differently implemented 😅 : https://github.com/status-im/nimbus-eth1/blob/master/portal/common/common_utils.nim#L81

Probably something we want to also make common in another iteration (and potentially with rework of nimbus-eth2 keystore to also use that...)

let privateKey =
if netKey.len == 0 or netKey == "random":
PrivateKey.random(rng)
elif netKey.len in {64, 66} and netKey.containsOnlyHexDigits:
PrivateKey.fromHex(netKey).valueOr:
return err($error)
else:
# TODO: should we secure the private key with
# keystore encryption?
if fileAccessible(netKey, {AccessFlags.Find}):
try:
let lines = netKey.readLines(1)
if lines.len == 0:
return err("empty network key file")
PrivateKey.fromHex(lines[0]).valueOr:
return err($error)
except IOError as e:
return err("cannot open network key file: " & e.msg)
else:
let privateKey = PrivateKey.random(rng)

try:
createDir(netKey.splitFile.dir)
netKey.writeFile(privateKey.toRaw.to0xHex)
except OSError as e:
return err("could not create network key file: " & e.msg)
except IOError as e:
return err("could not write network key file: " & e.msg)

privateKey
ok privateKey.toKeyPair()
6 changes: 2 additions & 4 deletions execution_chain/nimbus_desc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ type
httpServer*: NimbusHttpServerRef
engineApiServer*: NimbusHttpServerRef
ethNode*: EthereumNode
ctx*: EthContext
fc*: ForkedChainRef
txPool*: TxPoolRef
peerManager*: PeerManagerRef
beaconSyncRef*: BeaconSyncRef
beaconEngine*: BeaconEngineRef
metricsServer*: MetricsHttpServerRef
wire*: EthWireRef
accountsManager*: ref AccountsManager
rng*: ref HmacDrbgContext

proc closeWait*(nimbus: NimbusNode) {.async.} =
trace "Graceful shutdown"
Expand All @@ -67,8 +67,6 @@ proc closeWait*(nimbus: NimbusNode) {.async.} =
waitedFutures.add nimbus.peerManager.stop()
if nimbus.beaconSyncRef.isNil.not:
waitedFutures.add nimbus.beaconSyncRef.stop()
if nimbus.metricsServer.isNil.not:
waitedFutures.add nimbus.metricsServer.stop()
if nimbus.wire.isNil.not:
waitedFutures.add nimbus.wire.stop()

Expand Down
Loading
Loading