mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 06:46:10 +00:00
parent
9c6ba7d142
commit
06ba2286c0
@ -8,7 +8,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import
|
||||
std/[strutils, os, options, unicode, uri],
|
||||
std/[options, unicode, uri],
|
||||
metrics,
|
||||
|
||||
chronicles, chronicles/options as chroniclesOptions,
|
||||
@ -29,6 +29,8 @@ import
|
||||
./el/el_conf,
|
||||
./filepath
|
||||
|
||||
from std/os import getHomeDir, parentDir, `/`
|
||||
from std/strutils import parseBiggestUInt, replace
|
||||
from fork_choice/fork_choice_types
|
||||
import ForkChoiceVersion
|
||||
from consensus_object_pools/block_pools_types_light_client
|
||||
@ -56,7 +58,7 @@ const
|
||||
|
||||
defaultListenAddressDesc* = $defaultListenAddress
|
||||
defaultAdminListenAddressDesc* = $defaultAdminListenAddress
|
||||
defaultBeaconNodeDesc* = $defaultBeaconNode
|
||||
defaultBeaconNodeDesc = $defaultBeaconNode
|
||||
|
||||
when defined(windows):
|
||||
{.pragma: windowsOnly.}
|
||||
@ -1433,7 +1435,7 @@ func defaultFeeRecipient*(conf: AnyConf): Opt[Eth1Address] =
|
||||
# https://github.com/nim-lang/Nim/issues/19802
|
||||
(static(Opt.none Eth1Address))
|
||||
|
||||
proc loadJwtSecret*(
|
||||
proc loadJwtSecret(
|
||||
rng: var HmacDrbgContext,
|
||||
dataDir: string,
|
||||
jwtSecret: Opt[InputFile],
|
||||
@ -1468,7 +1470,7 @@ proc engineApiUrls*(config: BeaconNodeConf): seq[EngineApiUrl] =
|
||||
let elUrls = if config.noEl:
|
||||
return newSeq[EngineApiUrl]()
|
||||
elif config.elUrls.len == 0 and config.web3Urls.len == 0:
|
||||
@[defaultEngineApiUrl]
|
||||
@[getDefaultEngineApiUrl(config.jwtSecret)]
|
||||
else:
|
||||
config.elUrls
|
||||
|
||||
|
@ -170,7 +170,7 @@ proc engineApiUrls*(config: LightClientConf): seq[EngineApiUrl] =
|
||||
let elUrls = if config.noEl:
|
||||
return newSeq[EngineApiUrl]()
|
||||
elif config.elUrls.len == 0 and config.web3Urls.len == 0:
|
||||
@[defaultEngineApiUrl]
|
||||
@[getDefaultEngineApiUrl(config.jwtSecret)]
|
||||
else:
|
||||
config.elUrls
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
std/[options, strutils, uri],
|
||||
std/[options, uri],
|
||||
stew/results, chronicles, confutils,
|
||||
confutils/toml/defs as confTomlDefs,
|
||||
confutils/toml/std/net as confTomlNet,
|
||||
@ -15,6 +15,8 @@ import
|
||||
toml_serialization, toml_serialization/lexer,
|
||||
../spec/engine_authentication
|
||||
|
||||
from std/strutils import toLowerAscii, split, startsWith
|
||||
|
||||
export
|
||||
toml_serialization, confTomlDefs, confTomlNet, confTomlUri
|
||||
|
||||
@ -41,11 +43,7 @@ const
|
||||
defaultEngineApiRoles* = { DepositSyncing, BlockValidation, BlockProduction }
|
||||
|
||||
# https://github.com/ethereum/execution-apis/pull/302
|
||||
defaultJwtSecret* = "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
|
||||
|
||||
defaultEngineApiUrl* = EngineApiUrlConfigValue(
|
||||
url: "http://127.0.0.1:8551",
|
||||
jwtSecret: some defaultJwtSecret)
|
||||
defaultJwtSecret = "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
|
||||
|
||||
chronicles.formatIt EngineApiUrl:
|
||||
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
|
||||
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,
|
||||
confJwtSecret: Opt[seq[byte]]): Result[EngineApiUrl, cstring] =
|
||||
if confValue.jwtSecret.isSome and confValue.jwtSecretFile.isSome:
|
||||
|
@ -10,22 +10,22 @@
|
||||
import
|
||||
std/[json, options],
|
||||
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,
|
||||
../beacon_chain/[conf, filepath],
|
||||
../beacon_chain/conf,
|
||||
../beacon_chain/el/el_manager,
|
||||
../beacon_chain/networking/eth2_network,
|
||||
../beacon_chain/spec/[beaconstate, eth2_merkleization],
|
||||
../beacon_chain/spec/eth2_merkleization,
|
||||
../beacon_chain/spec/datatypes/base,
|
||||
../beacon_chain/spec/eth2_apis/eth2_rest_serialization,
|
||||
../beacon_chain/validators/keystore_management,
|
||||
../tests/mocking/mock_genesis,
|
||||
./logtrace
|
||||
|
||||
from std/os import changeFileExt, fileExists
|
||||
from std/sequtils import mapIt, toSeq
|
||||
from std/terminal import readPasswordFromStdin
|
||||
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
|
||||
# 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
|
||||
|
||||
when isMainModule:
|
||||
import
|
||||
web3/confutils_defs,
|
||||
../beacon_chain/filepath
|
||||
|
||||
from std/terminal import readPasswordFromStdin
|
||||
|
||||
proc main() {.async.} =
|
||||
var conf = try: CliConfig.load()
|
||||
except CatchableError as exc:
|
||||
|
Loading…
x
Reference in New Issue
Block a user