This commit is contained in:
tersec 2023-12-16 16:30:46 +00:00 committed by GitHub
parent 9c6ba7d142
commit 06ba2286c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 16 deletions

View File

@ -8,7 +8,7 @@
{.push raises: [].} {.push raises: [].}
import import
std/[strutils, os, options, unicode, uri], std/[options, unicode, uri],
metrics, metrics,
chronicles, chronicles/options as chroniclesOptions, chronicles, chronicles/options as chroniclesOptions,
@ -29,6 +29,8 @@ import
./el/el_conf, ./el/el_conf,
./filepath ./filepath
from std/os import getHomeDir, parentDir, `/`
from std/strutils import parseBiggestUInt, replace
from fork_choice/fork_choice_types from fork_choice/fork_choice_types
import ForkChoiceVersion import ForkChoiceVersion
from consensus_object_pools/block_pools_types_light_client from consensus_object_pools/block_pools_types_light_client
@ -56,7 +58,7 @@ const
defaultListenAddressDesc* = $defaultListenAddress defaultListenAddressDesc* = $defaultListenAddress
defaultAdminListenAddressDesc* = $defaultAdminListenAddress defaultAdminListenAddressDesc* = $defaultAdminListenAddress
defaultBeaconNodeDesc* = $defaultBeaconNode defaultBeaconNodeDesc = $defaultBeaconNode
when defined(windows): when defined(windows):
{.pragma: windowsOnly.} {.pragma: windowsOnly.}
@ -1433,7 +1435,7 @@ func defaultFeeRecipient*(conf: AnyConf): Opt[Eth1Address] =
# https://github.com/nim-lang/Nim/issues/19802 # https://github.com/nim-lang/Nim/issues/19802
(static(Opt.none Eth1Address)) (static(Opt.none Eth1Address))
proc loadJwtSecret*( proc loadJwtSecret(
rng: var HmacDrbgContext, rng: var HmacDrbgContext,
dataDir: string, dataDir: string,
jwtSecret: Opt[InputFile], jwtSecret: Opt[InputFile],
@ -1468,7 +1470,7 @@ proc engineApiUrls*(config: BeaconNodeConf): seq[EngineApiUrl] =
let elUrls = if config.noEl: let elUrls = if config.noEl:
return newSeq[EngineApiUrl]() return newSeq[EngineApiUrl]()
elif config.elUrls.len == 0 and config.web3Urls.len == 0: elif config.elUrls.len == 0 and config.web3Urls.len == 0:
@[defaultEngineApiUrl] @[getDefaultEngineApiUrl(config.jwtSecret)]
else: else:
config.elUrls config.elUrls

View File

@ -170,7 +170,7 @@ proc engineApiUrls*(config: LightClientConf): seq[EngineApiUrl] =
let elUrls = if config.noEl: let elUrls = if config.noEl:
return newSeq[EngineApiUrl]() return newSeq[EngineApiUrl]()
elif config.elUrls.len == 0 and config.web3Urls.len == 0: elif config.elUrls.len == 0 and config.web3Urls.len == 0:
@[defaultEngineApiUrl] @[getDefaultEngineApiUrl(config.jwtSecret)]
else: else:
config.elUrls config.elUrls

View File

@ -6,7 +6,7 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
import import
std/[options, strutils, uri], std/[options, uri],
stew/results, chronicles, confutils, stew/results, chronicles, confutils,
confutils/toml/defs as confTomlDefs, confutils/toml/defs as confTomlDefs,
confutils/toml/std/net as confTomlNet, confutils/toml/std/net as confTomlNet,
@ -15,6 +15,8 @@ import
toml_serialization, toml_serialization/lexer, toml_serialization, toml_serialization/lexer,
../spec/engine_authentication ../spec/engine_authentication
from std/strutils import toLowerAscii, split, startsWith
export export
toml_serialization, confTomlDefs, confTomlNet, confTomlUri toml_serialization, confTomlDefs, confTomlNet, confTomlUri
@ -41,11 +43,7 @@ const
defaultEngineApiRoles* = { DepositSyncing, BlockValidation, BlockProduction } defaultEngineApiRoles* = { DepositSyncing, BlockValidation, BlockProduction }
# https://github.com/ethereum/execution-apis/pull/302 # https://github.com/ethereum/execution-apis/pull/302
defaultJwtSecret* = "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" defaultJwtSecret = "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
defaultEngineApiUrl* = EngineApiUrlConfigValue(
url: "http://127.0.0.1:8551",
jwtSecret: some defaultJwtSecret)
chronicles.formatIt EngineApiUrl: chronicles.formatIt EngineApiUrl:
it.url it.url
@ -156,6 +154,19 @@ proc fixupWeb3Urls*(web3Url: var string) =
warn "The Web3 URL does not specify a protocol. Assuming a WebSocket server", web3Url warn "The Web3 URL does not specify a protocol. Assuming a WebSocket server", web3Url
web3Url = "ws://" & web3Url web3Url = "ws://" & web3Url
func getDefaultEngineApiUrl*(x: Option[InputFile]): EngineApiUrlConfigValue =
EngineApiUrlConfigValue(
url: "http://127.0.0.1:8551",
jwtSecret:
if x.isSome:
# Provided by toFinalUrl() and toFinalEngineApiUrls(); otherwise, if
# defaultJwtSecret is specified here, no-EL-URL-specified cases when
# JWT secret is specified get stuck with defaultJwtSecret regardless
# of being otherwise overridden.
none string
else:
some defaultJwtSecret)
proc toFinalUrl*(confValue: EngineApiUrlConfigValue, proc toFinalUrl*(confValue: EngineApiUrlConfigValue,
confJwtSecret: Opt[seq[byte]]): Result[EngineApiUrl, cstring] = confJwtSecret: Opt[seq[byte]]): Result[EngineApiUrl, cstring] =
if confValue.jwtSecret.isSome and confValue.jwtSecretFile.isSome: if confValue.jwtSecret.isSome and confValue.jwtSecretFile.isSome:

View File

@ -10,22 +10,22 @@
import import
std/[json, options], std/[json, options],
chronos, bearssl/rand, chronicles, confutils, stint, json_serialization, chronos, bearssl/rand, chronicles, confutils, stint, json_serialization,
web3, web3/confutils_defs, eth/keys, eth/p2p/discoveryv5/random2, web3, eth/keys, eth/p2p/discoveryv5/random2,
stew/[io2, byteutils], json_rpc/jsonmarshal, stew/[io2, byteutils], json_rpc/jsonmarshal,
../beacon_chain/[conf, filepath], ../beacon_chain/conf,
../beacon_chain/el/el_manager, ../beacon_chain/el/el_manager,
../beacon_chain/networking/eth2_network, ../beacon_chain/networking/eth2_network,
../beacon_chain/spec/[beaconstate, eth2_merkleization], ../beacon_chain/spec/eth2_merkleization,
../beacon_chain/spec/datatypes/base, ../beacon_chain/spec/datatypes/base,
../beacon_chain/spec/eth2_apis/eth2_rest_serialization, ../beacon_chain/spec/eth2_apis/eth2_rest_serialization,
../beacon_chain/validators/keystore_management, ../beacon_chain/validators/keystore_management,
../tests/mocking/mock_genesis,
./logtrace ./logtrace
from std/os import changeFileExt, fileExists from std/os import changeFileExt, fileExists
from std/sequtils import mapIt, toSeq from std/sequtils import mapIt, toSeq
from std/terminal import readPasswordFromStdin
from std/times import toUnix from std/times import toUnix
from ../beacon_chain/spec/beaconstate import initialize_beacon_state_from_eth1
from ../tests/mocking/mock_genesis import mockEth1BlockHash
# Compiled version of /scripts/depositContract.v.py in this repo # Compiled version of /scripts/depositContract.v.py in this repo
# The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler. # The contract was compiled in Remix (https://remix.ethereum.org/) with vyper (remote) compiler.
@ -583,6 +583,12 @@ proc sendDeposits(deposits: seq[LaunchPadDeposit],
{.pop.} # TODO confutils.nim(775, 17) Error: can raise an unlisted exception: ref IOError {.pop.} # TODO confutils.nim(775, 17) Error: can raise an unlisted exception: ref IOError
when isMainModule: when isMainModule:
import
web3/confutils_defs,
../beacon_chain/filepath
from std/terminal import readPasswordFromStdin
proc main() {.async.} = proc main() {.async.} =
var conf = try: CliConfig.load() var conf = try: CliConfig.load()
except CatchableError as exc: except CatchableError as exc: