make deployment phase configurable (#4231)

Allow config of deployment phase via config instead of attempting to
derive from genesis content (when running relevant testnets), so that
we don't have to keep maintaining the list inside the binary.
This commit is contained in:
Etan Kissling 2022-10-12 17:58:36 -05:00 committed by GitHub
parent 2b531b6653
commit 10215dbc14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View File

@ -113,6 +113,12 @@ type
# migrateAll = "Export and remove the whole validator slashing protection DB."
# migrate = "Export and remove specified validators from Nimbus."
DeploymentPhase* {.pure.} = enum
Devnet = "devnet"
Testnet = "testnet"
Mainnet = "mainnet"
None = "none"
BeaconNodeConf* = object
configFile* {.
desc: "Loads the configuration from a TOML file"
@ -515,6 +521,13 @@ type
defaultValueDesc: "50"
name: "sync-horizon" .}: uint64
deploymentPhase* {.
hidden
desc: "Configures the deployment phase"
defaultValue: DeploymentPhase.Mainnet
defaultValueDesc: $DeploymentPhase.Mainnet
name: "deployment-phase" .}: DeploymentPhase
# TODO nim-confutils on 32-bit platforms overflows decoding integers
# requiring 64-bit representations and doesn't build when specifying
# UInt256 directly, so pass this through for decoding elsewhere.

View File

@ -79,15 +79,6 @@ type
else:
incompatibilityDesc*: string
type DeploymentPhase* {.pure.} = enum
None,
Devnet,
Testnet,
Mainnet
func deploymentPhase*(genesisData: string): DeploymentPhase =
DeploymentPhase.Devnet
const
eth2NetworksDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor/eth2-networks"
mergeTestnetsDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor/merge-testnets"

View File

@ -624,7 +624,7 @@ proc init*(T: type BeaconNode,
dag = loadChainDag(
config, cfg, db, eventBus,
validatorMonitor, networkGenesisValidatorsRoot,
genesisStateContents.deploymentPhase <= DeploymentPhase.Testnet)
config.deploymentPhase <= DeploymentPhase.Testnet)
genesisTime = getStateField(dag.headState, genesis_time)
beaconClock = BeaconClock.init(genesisTime)
getBeaconTime = beaconClock.getBeaconTimeFn()