Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nil timestamp in genesis should be upgradeable #461

Merged
merged 5 commits into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
aaronbuchwald marked this conversation as resolved.
Show resolved Hide resolved
if err := config.Verify(); err != nil {
return err
}
Expand Down
19 changes: 19 additions & 0 deletions params/precompile_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ 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),
}
darioush marked this conversation as resolved.
Show resolved Hide resolved
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