diff --git a/params/precompile_config.go b/params/precompile_config.go index daa457b03b..71ea6ee2dc 100644 --- a/params/precompile_config.go +++ b/params/precompile_config.go @@ -129,7 +129,7 @@ func (c *ChainConfig) verifyPrecompileUpgrades() error { disabled bool ) // check the genesis chain config for any enabled upgrade - if config, ok := c.PrecompileUpgrade.getByKey(key); ok { + if config, ok := c.PrecompileUpgrade.getByKey(key); ok && config.Timestamp() != nil { if err := config.Verify(); err != nil { return err } diff --git a/params/precompile_config_test.go b/params/precompile_config_test.go index 55b138b65a..9802bf9648 100644 --- a/params/precompile_config_test.go +++ b/params/precompile_config_test.go @@ -59,6 +59,26 @@ func TestVerifyWithChainConfig(t *testing.T) { assert.ErrorContains(t, err, "disable should be [true]") } +func TestVerifyWithChainConfigAtNilTimestamp(t *testing.T) { + admins := []common.Address{{1}} + baseConfig := *SubnetEVMDefaultChainConfig + config := &baseConfig + config.PrecompileUpgrade = PrecompileUpgrade{ + // this does NOT enable the precompile, so it should be upgradeable. + TxAllowListConfig: precompile.NewTxAllowListConfig(nil, nil, nil), + } + require.False(t, config.IsTxAllowList(common.Big0)) // check the precompile is not enabled. + config.PrecompileUpgrades = []PrecompileUpgrade{ + { + // enable TxAllowList at timestamp 5 + TxAllowListConfig: precompile.NewTxAllowListConfig(big.NewInt(5), admins, nil), + }, + } + + // check this config is valid + require.NoError(t, config.Verify()) +} + func TestVerifyPrecompileUpgrades(t *testing.T) { admins := []common.Address{{1}} tests := []struct {