From 83c78c80024ac9ae3d95153fb383b01d74bf8ea9 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Tue, 8 Nov 2022 23:53:02 +0100 Subject: [PATCH] use mainnet as default config (#4302) Without this, tools like `ncli_db` require command line parameter to process mainnet blocks, which is a regression since the merge - this is a subset of #4147. --- beacon_chain/networking/network_metadata.nim | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/beacon_chain/networking/network_metadata.nim b/beacon_chain/networking/network_metadata.nim index 6e537f189..f699133b0 100644 --- a/beacon_chain/networking/network_metadata.nim +++ b/beacon_chain/networking/network_metadata.nim @@ -258,8 +258,27 @@ proc getMetadataForNetwork*( metadata + proc getRuntimeConfig*( eth2Network: Option[string]): RuntimeConfig {.raises: [Defect, IOError].} = + ## Returns the run-time config for a network specified on the command line + ## If the network is not explicitly specified, the function will act as the + ## regular Nimbus binary, returning the mainnet config. + ## + ## TODO the assumption that the input variable is a CLI config option is not + ## quite appropriate in such as low-level function. The "assume mainnet by + ## default" behavior is something that should be handled closer to the `conf` + ## layer. if eth2Network.isSome: return getMetadataForNetwork(eth2Network.get).cfg - defaultRuntimeConfig + + when const_preset == "mainnet": + when defined(gnosisChainBinary): + gnosisMetadata.cfg + else: + mainnetMetadata.cfg + else: + # This is a non-standard build (i.e. minimal), and the function was most + # likely executed in a test. The best we can do is return a fully default + # config: + defaultRuntimeConfig