mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 14:26:26 +00:00
Merge pull request #1428 from status-im/devel
Merge more commits affecting the user experience in master
This commit is contained in:
commit
543cbdfc6b
7
Makefile
7
Makefile
@ -144,7 +144,6 @@ clean_eth2_network_simulation_all:
|
||||
rm -rf tests/simulation/{data,validators}
|
||||
|
||||
GOERLI_TESTNETS_PARAMS := \
|
||||
--dump \
|
||||
--web3-url=$(GOERLI_WEB3_URL) \
|
||||
--tcp-port=$$(( $(BASE_PORT) + $(NODE_ID) )) \
|
||||
--udp-port=$$(( $(BASE_PORT) + $(NODE_ID) )) \
|
||||
@ -201,7 +200,7 @@ medalla-dev: | beacon_node
|
||||
--network=medalla \
|
||||
--log-level="DEBUG; TRACE:discv5,networking; REQUIRED:none; DISABLED:none" \
|
||||
--data-dir=build/data/shared_medalla_$(NODE_ID) \
|
||||
$(GOERLI_TESTNETS_PARAMS) $(NODE_PARAMS)
|
||||
$(GOERLI_TESTNETS_PARAMS) --dump $(NODE_PARAMS)
|
||||
|
||||
medalla-deposit-data: | beacon_node deposit_contract
|
||||
build/beacon_node deposits create \
|
||||
@ -262,13 +261,13 @@ altona-dev: | beacon_node
|
||||
--network=altona \
|
||||
--log-level="DEBUG; TRACE:discv5,networking; REQUIRED:none; DISABLED:none" \
|
||||
--data-dir=build/data/shared_altona_$(NODE_ID) \
|
||||
$(GOERLI_TESTNETS_PARAMS) $(NODE_PARAMS)
|
||||
$(GOERLI_TESTNETS_PARAMS) --dump $(NODE_PARAMS)
|
||||
|
||||
altona-deposit: | beacon_node deposit_contract
|
||||
build/beacon_node deposits create \
|
||||
--network=altona \
|
||||
--out-deposits-file=nbc-altona-deposits.json \
|
||||
--new-wallet-file=build/data/shared_algona_$(NODE_ID)/wallet.json \
|
||||
--new-wallet-file=build/data/shared_altona_$(NODE_ID)/wallet.json \
|
||||
--out-deposits-dir=build/data/shared_altona_$(NODE_ID)/validators \
|
||||
--out-secrets-dir=build/data/shared_altona_$(NODE_ID)/secrets \
|
||||
--count=$(VALIDATORS)
|
||||
|
@ -72,7 +72,7 @@ logScope: topics = "beacnde"
|
||||
|
||||
proc onBeaconBlock(node: BeaconNode, signedBlock: SignedBeaconBlock) {.gcsafe.}
|
||||
|
||||
proc getStateFromSnapshot(conf: BeaconNodeConf): NilableBeaconStateRef =
|
||||
proc getStateFromSnapshot(conf: BeaconNodeConf, stateSnapshotContents: ref string): NilableBeaconStateRef =
|
||||
var
|
||||
genesisPath = conf.dataDir/genesisFile
|
||||
snapshotContents: TaintedString
|
||||
@ -105,8 +105,8 @@ proc getStateFromSnapshot(conf: BeaconNodeConf): NilableBeaconStateRef =
|
||||
except CatchableError as err:
|
||||
error "Failed to read genesis file", err = err.msg
|
||||
quit 1
|
||||
elif conf.stateSnapshotContents != nil:
|
||||
swap(snapshotContents, TaintedString conf.stateSnapshotContents[])
|
||||
elif stateSnapshotContents != nil:
|
||||
swap(snapshotContents, TaintedString stateSnapshotContents[])
|
||||
else:
|
||||
# No snapshot was provided. We should wait for genesis.
|
||||
return nil
|
||||
@ -140,7 +140,8 @@ func enrForkIdFromState(state: BeaconState): ENRForkID =
|
||||
|
||||
proc init*(T: type BeaconNode,
|
||||
rng: ref BrHmacDrbgContext,
|
||||
conf: BeaconNodeConf): Future[BeaconNode] {.async.} =
|
||||
conf: BeaconNodeConf,
|
||||
stateSnapshotContents: ref string): Future[BeaconNode] {.async.} =
|
||||
let
|
||||
netKeys = getPersistentNetKeys(rng[], conf)
|
||||
nickname = if conf.nodeName == "auto": shortForm(netKeys)
|
||||
@ -151,7 +152,7 @@ proc init*(T: type BeaconNode,
|
||||
|
||||
if not ChainDAGRef.isInitialized(db):
|
||||
# Fresh start - need to load a genesis state from somewhere
|
||||
var genesisState = conf.getStateFromSnapshot()
|
||||
var genesisState = conf.getStateFromSnapshot(stateSnapshotContents)
|
||||
|
||||
# Try file from command line first
|
||||
if genesisState.isNil:
|
||||
@ -220,9 +221,9 @@ proc init*(T: type BeaconNode,
|
||||
error "Failed to initialize database", err = e.msg
|
||||
quit 1
|
||||
|
||||
if conf.stateSnapshotContents != nil:
|
||||
if stateSnapshotContents != nil:
|
||||
# The memory for the initial snapshot won't be needed anymore
|
||||
conf.stateSnapshotContents[] = ""
|
||||
stateSnapshotContents[] = ""
|
||||
|
||||
# TODO check that genesis given on command line (if any) matches database
|
||||
let
|
||||
@ -1036,7 +1037,10 @@ when hasPrompt:
|
||||
# createThread(t, processPromptCommands, addr p)
|
||||
|
||||
programMain:
|
||||
var config = makeBannerAndConfig(clientId, BeaconNodeConf)
|
||||
var
|
||||
config = makeBannerAndConfig(clientId, BeaconNodeConf)
|
||||
# This is ref so we can mutate it (to erase it) after the initial loading.
|
||||
stateSnapshotContents: ref string
|
||||
|
||||
setupLogging(config.logLevel, config.logFile)
|
||||
|
||||
@ -1077,7 +1081,7 @@ programMain:
|
||||
config.bootstrapNodes.add node
|
||||
|
||||
if config.stateSnapshot.isNone and metadata.genesisData.len > 0:
|
||||
config.stateSnapshotContents = newClone metadata.genesisData
|
||||
stateSnapshotContents = newClone metadata.genesisData
|
||||
|
||||
template checkForIncompatibleOption(flagName, fieldName) =
|
||||
# TODO: This will have to be reworked slightly when we introduce config files.
|
||||
@ -1166,7 +1170,7 @@ programMain:
|
||||
|
||||
config.createDumpDirs()
|
||||
|
||||
var node = waitFor BeaconNode.init(rng, config)
|
||||
var node = waitFor BeaconNode.init(rng, config, stateSnapshotContents)
|
||||
|
||||
## Ctrl+C handling
|
||||
proc controlCHandler() {.noconv.} =
|
||||
|
@ -14,6 +14,7 @@ proc fromJson*(n: JsonNode, argName: string, result: var ValidatorPubKey) =
|
||||
result = ValidatorPubKey.fromHex(n.getStr()).tryGet()
|
||||
|
||||
proc `%`*(pubkey: ValidatorPubKey): JsonNode =
|
||||
unsafePromote(pubkey.unsafeAddr)
|
||||
result = newJString($pubkey)
|
||||
|
||||
proc fromJson*(n: JsonNode, argName: string, result: var List) =
|
||||
@ -31,6 +32,7 @@ proc fromJson*(n: JsonNode, argName: string, result: var ValidatorSig) =
|
||||
result = ValidatorSig.fromHex(n.getStr()).tryGet()
|
||||
|
||||
proc `%`*(value: ValidatorSig): JsonNode =
|
||||
unsafePromote(value.unsafeAddr)
|
||||
result = newJString($value)
|
||||
|
||||
proc fromJson*(n: JsonNode, argName: string, result: var Version) =
|
||||
|
@ -228,7 +228,7 @@ proc importKeystoresFromDir*(rng: var BrHmacDrbgContext,
|
||||
let keystore = try:
|
||||
Json.loadFile(file, Keystore)
|
||||
except SerializationError as e:
|
||||
warn "Invalid keystore", err = e.formatMsg(file)
|
||||
trace "Invalid keystore", err = e.formatMsg(file)
|
||||
continue
|
||||
except IOError as e:
|
||||
warn "Failed to read keystore file", file, err = e.msg
|
||||
|
Loading…
x
Reference in New Issue
Block a user