Skip to content

Commit

Permalink
nil timestamp in genesis should be upgradeable (#461)
Browse files Browse the repository at this point in the history
* nil timestamp in genesis should be upgradeable

* add assert
  • Loading branch information
darioush authored Jan 28, 2023
1 parent 13d49a7 commit d1cbe9d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion params/precompile_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 20 additions & 0 deletions params/precompile_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d1cbe9d

Please sign in to comment.