mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 05:47:59 -05:00
rebuild config index after loading dynamic config
This commit is contained in:
@@ -26,6 +26,15 @@ func BeaconConfig() *BeaconChainConfig {
|
||||
func OverrideBeaconConfig(c *BeaconChainConfig) {
|
||||
beaconConfigLock.Lock()
|
||||
defer beaconConfigLock.Unlock()
|
||||
c.InitializeForkSchedule()
|
||||
name, ok := reverseConfigNames[c.ConfigName]
|
||||
// if name collides with an existing config name, override it, because the fork versions probably conflict
|
||||
if !ok {
|
||||
// otherwise define it as the special "Dynamic" name, ie for a config loaded from a file at runtime
|
||||
name = Dynamic
|
||||
}
|
||||
KnownConfigs[name] = func() *BeaconChainConfig { return c }
|
||||
rebuildKnownForkVersions()
|
||||
beaconConfig = c
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,15 @@ func BeaconConfig() *BeaconChainConfig {
|
||||
// OverrideBeaconConfig(c). Any subsequent calls to params.BeaconConfig() will
|
||||
// return this new configuration.
|
||||
func OverrideBeaconConfig(c *BeaconChainConfig) {
|
||||
c.InitializeForkSchedule()
|
||||
name, ok := reverseConfigNames[c.ConfigName]
|
||||
// if name collides with an existing config name, override it, because the fork versions probably conflict
|
||||
if !ok {
|
||||
// otherwise define it as the special "Dynamic" name, ie for a config loaded from a file at runtime
|
||||
name = Dynamic
|
||||
}
|
||||
KnownConfigs[name] = func() *BeaconChainConfig { return c }
|
||||
rebuildKnownForkVersions()
|
||||
beaconConfig = c
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ func LoadChainConfigFile(chainConfigFileName string, conf *BeaconChainConfig) {
|
||||
// recompute SqrRootSlotsPerEpoch constant to handle non-standard values of SlotsPerEpoch
|
||||
conf.SqrRootSlotsPerEpoch = types.Slot(math.IntegerSquareRoot(uint64(conf.SlotsPerEpoch)))
|
||||
log.Debugf("Config file values: %+v", conf)
|
||||
conf.InitializeForkSchedule()
|
||||
OverrideBeaconConfig(conf)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ const (
|
||||
Pyrmont
|
||||
Prater
|
||||
EndToEndMainnet
|
||||
Dynamic
|
||||
)
|
||||
|
||||
// ConfigName enum describes the type of known network in use.
|
||||
@@ -36,7 +37,9 @@ var ConfigNames = map[ConfigName]string{
|
||||
Pyrmont: "pyrmont",
|
||||
Prater: "prater",
|
||||
EndToEndMainnet: "end-to-end-mainnet",
|
||||
Dynamic: "dynamic",
|
||||
}
|
||||
var reverseConfigNames map[string]ConfigName
|
||||
|
||||
// KnownConfigs provides an index of all known BeaconChainConfig values.
|
||||
var KnownConfigs = map[ConfigName]func() *BeaconChainConfig{
|
||||
@@ -63,6 +66,18 @@ func ConfigForVersion(version [fieldparams.VersionLength]byte) (*BeaconChainConf
|
||||
}
|
||||
|
||||
func init() {
|
||||
rebuildKnownForkVersions()
|
||||
buildReverseConfigName()
|
||||
}
|
||||
|
||||
func buildReverseConfigName() {
|
||||
reverseConfigNames = make(map[string]ConfigName)
|
||||
for cn, s := range ConfigNames {
|
||||
reverseConfigNames[s] = cn
|
||||
}
|
||||
}
|
||||
|
||||
func rebuildKnownForkVersions() {
|
||||
knownForkVersions = make(map[[fieldparams.VersionLength]byte]ConfigName)
|
||||
for n, cfunc := range KnownConfigs {
|
||||
cfg := cfunc()
|
||||
|
||||
Reference in New Issue
Block a user