From 7ab28c6a83cb190d12f3b9e2f74091eb2b0105e9 Mon Sep 17 00:00:00 2001 From: D-Nice Date: Tue, 4 Aug 2020 04:12:51 -0400 Subject: [PATCH 1/5] Fix Makefile dir typo (#1426) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8647eae13..d7ef3a156 100644 --- a/Makefile +++ b/Makefile @@ -268,7 +268,7 @@ 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) From 9522c611bc3c9e6d2c1c605f0c53973dfa60bda3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Tue, 4 Aug 2020 10:13:22 +0200 Subject: [PATCH 2/5] Makefile: move `--dump` to *-dev targets (#1423) --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d7ef3a156..0a300ac03 100644 --- a/Makefile +++ b/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,7 +261,7 @@ 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 \ From d7d1e072ba12648fcbec19693e110871362f6b91 Mon Sep 17 00:00:00 2001 From: Viktor Kirilov Date: Tue, 4 Aug 2020 11:15:26 +0300 Subject: [PATCH 3/5] fix for the BN/VC communication since the #1371 PR (#1416) --- beacon_chain/eth2_json_rpc_serialization.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/beacon_chain/eth2_json_rpc_serialization.nim b/beacon_chain/eth2_json_rpc_serialization.nim index 63212a7ee..f3b47ada5 100644 --- a/beacon_chain/eth2_json_rpc_serialization.nim +++ b/beacon_chain/eth2_json_rpc_serialization.nim @@ -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) = From d45ee66c218af98202b934daacfb0e5d2a1a1fcd Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Tue, 4 Aug 2020 12:17:06 +0300 Subject: [PATCH 4/5] Remove a confusing warning on Keystore import --- beacon_chain/keystore_management.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_chain/keystore_management.nim b/beacon_chain/keystore_management.nim index ff32a225f..bbc01c4b6 100644 --- a/beacon_chain/keystore_management.nim +++ b/beacon_chain/keystore_management.nim @@ -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 From a1d3532f49902fb8cfab17e25b7b050c4e29879b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Tue, 4 Aug 2020 12:35:20 +0200 Subject: [PATCH 5/5] move stateSnapshotContents from BeaconNodeConf (#1425) --- beacon_chain/beacon_node.nim | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index a89ac7a05..7d70456e9 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -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.} =