Skip to content

Commit

Permalink
make deployment phase configurable (#4231)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
etan-status authored Oct 12, 2022
1 parent 2b531b6 commit 10215db
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
13 changes: 13 additions & 0 deletions beacon_chain/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 0 additions & 9 deletions beacon_chain/networking/network_metadata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 10215db

Please sign in to comment.