Skip to content

Commit

Permalink
fix eth private network config validation for pow
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Jan 15, 2024
1 parent ba41728 commit bd998ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
2 changes: 0 additions & 2 deletions config/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ func (n *NetworkConfig) applyDefaults(defaults *NetworkConfig) error {
return nil
}

n.UpperCaseNetworkNames()

if defaults.SelectedNetworks != nil {
n.SelectedNetworks = defaults.SelectedNetworks
}
Expand Down
13 changes: 9 additions & 4 deletions docker/test_env/eth2_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@ func GetDefaultChainConfig() EthereumChainConfig {
return config
}

func (c *EthereumChainConfig) Validate(logger zerolog.Logger) error {
func (c *EthereumChainConfig) Validate(logger zerolog.Logger, consensusType ConsensusType) error {
if c.ChainID < 1 {
return fmt.Errorf("chain id must be >= 0")
}

if consensusType == ConsensusType_PoW {
return nil
}

if c.ValidatorCount < 4 {
return fmt.Errorf("validator count must be >= 4")
}
Expand All @@ -85,9 +93,6 @@ func (c *EthereumChainConfig) Validate(logger zerolog.Logger) error {
if c.GenesisDelay < 10 {
return fmt.Errorf("genesis delay must be >= 10")
}
if c.ChainID < 1 {
return fmt.Errorf("chain id must be >= 0")
}
if c.genesisTimestamp == 0 {
return fmt.Errorf("genesis timestamp must be generated by calling GenerateGenesisTimestamp()")
}
Expand Down
14 changes: 4 additions & 10 deletions docker/test_env/ethereum_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,11 @@ func (b *EthereumNetworkBuilder) validate() error {
}
}

err := b.ethereumChainConfig.Validate(logging.GetTestLogger(b.t))
if err != nil {
return err
if b.ethereumChainConfig == nil {
return errors.New("ethereum chain config is required")
}

return nil
return b.ethereumChainConfig.Validate(logging.GetTestLogger(nil), b.consensusType)
}

type EthereumNetwork struct {
Expand Down Expand Up @@ -543,12 +542,7 @@ func (en *EthereumNetwork) Validate() error {
return errors.New("ethereum chain config is required")
}

err := en.EthereumChainConfig.Validate(logging.GetTestLogger(nil))
if err != nil {
return err
}

return nil
return en.EthereumChainConfig.Validate(logging.GetTestLogger(nil), en.ConsensusType)
}

func (en *EthereumNetwork) ApplyOverrides(from *EthereumNetwork) error {
Expand Down

0 comments on commit bd998ea

Please sign in to comment.