diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 72039a61c..3df35e004 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -289,7 +289,7 @@ func NewBlockchain(s storage.Store, cfg config.Blockchain, log *zap.Logger) (*Bl cfg.Hardforks[hf.String()] = 0 } log.Info("Hardforks are not set, using default value") - } else { + } else if len(cfg.Hardforks) != 0 { // Explicitly set the height of all old omitted hardforks to 0 for proper // IsHardforkEnabled behaviour. for _, hf := range config.Hardforks { diff --git a/pkg/core/blockchain_core_test.go b/pkg/core/blockchain_core_test.go index dac7abee2..c431d508e 100644 --- a/pkg/core/blockchain_core_test.go +++ b/pkg/core/blockchain_core_test.go @@ -361,9 +361,9 @@ func TestBlockchain_IsRunning(t *testing.T) { } func TestNewBlockchain_InitHardforks(t *testing.T) { - t.Run("empty set", func(t *testing.T) { + t.Run("nil set", func(t *testing.T) { bc := newTestChainWithCustomCfg(t, func(c *config.Config) { - c.ProtocolConfiguration.Hardforks = map[string]uint32{} + c.ProtocolConfiguration.Hardforks = nil require.NoError(t, c.ProtocolConfiguration.Validate()) }) require.Equal(t, map[string]uint32{ @@ -372,6 +372,13 @@ func TestNewBlockchain_InitHardforks(t *testing.T) { config.HFCockatrice.String(): 0, }, bc.GetConfig().Hardforks) }) + t.Run("empty set", func(t *testing.T) { + bc := newTestChainWithCustomCfg(t, func(c *config.Config) { + c.ProtocolConfiguration.Hardforks = map[string]uint32{} + require.NoError(t, c.ProtocolConfiguration.Validate()) + }) + require.Equal(t, map[string]uint32{}, bc.GetConfig().Hardforks) + }) t.Run("missing old", func(t *testing.T) { bc := newTestChainWithCustomCfg(t, func(c *config.Config) { c.ProtocolConfiguration.Hardforks = map[string]uint32{config.HFBasilisk.String(): 5}