Skip to content

Commit

Permalink
add SumatraHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc committed Nov 7, 2023
1 parent 7815705 commit 85701ac
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions blockchain/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func defaultConfig() Genesis {
PalauBlockHeight: 22991401,
QuebecBlockHeight: 24838201,
RedseaBlockHeight: 26704441,
SumatraBlockHeight: 36704441,
ToBeEnabledBlockHeight: math.MaxUint64,
},
Account: Account{
Expand Down Expand Up @@ -243,6 +244,8 @@ type (
// 1. upgrade go-ethereum to Bellatrix release
// 2. correct weighted votes for contract staking bucket
RedseaBlockHeight uint64 `yaml:"redseaHeight"`
// SumatraBlockHeight is the start height to enable Shanghai EVM
SumatraBlockHeight uint64 `yaml:"sumatraHeight"`
// ToBeEnabledBlockHeight is a fake height that acts as a gating factor for WIP features
// upon next release, change IsToBeEnabled() to IsNextHeight() for features to be released
ToBeEnabledBlockHeight uint64 `yaml:"toBeEnabledHeight"`
Expand Down Expand Up @@ -581,6 +584,11 @@ func (g *Blockchain) IsRedsea(height uint64) bool {
return g.isPost(g.RedseaBlockHeight, height)
}

// IsSumatra checks whether height is equal to or larger than sumatra height
func (g *Blockchain) IsSumatra(height uint64) bool {
return g.isPost(g.SumatraBlockHeight, height)
}

// IsToBeEnabled checks whether height is equal to or larger than toBeEnabled height
func (g *Blockchain) IsToBeEnabled(height uint64) bool {
return g.isPost(g.ToBeEnabledBlockHeight, height)
Expand Down
3 changes: 3 additions & 0 deletions blockchain/genesis/heightupgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func TestNewHeightChange(t *testing.T) {
require.True(cfg.IsQuebec(uint64(24838201)))
require.False(cfg.IsRedsea(uint64(26704440)))
require.True(cfg.IsRedsea(uint64(26704441)))
require.False(cfg.IsSumatra(uint64(36704440)))
require.True(cfg.IsSumatra(uint64(36704441)))

require.Equal(cfg.PacificBlockHeight, uint64(432001))
require.Equal(cfg.AleutianBlockHeight, uint64(864001))
Expand All @@ -81,4 +83,5 @@ func TestNewHeightChange(t *testing.T) {
require.Equal(cfg.PalauBlockHeight, uint64(22991401))
require.Equal(cfg.QuebecBlockHeight, uint64(24838201))
require.Equal(cfg.RedseaBlockHeight, uint64(26704441))
require.Equal(cfg.SumatraBlockHeight, uint64(36704441))
}
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ func ValidateForkHeights(cfg Config) error {
return errors.Wrap(ErrInvalidCfg, "Palau is heigher than Quebec")
case hu.QuebecBlockHeight > hu.RedseaBlockHeight:
return errors.Wrap(ErrInvalidCfg, "Quebec is heigher than Redsea")
case hu.RedseaBlockHeight > hu.SumatraBlockHeight:
return errors.Wrap(ErrInvalidCfg, "Redsea is heigher than Sumatra")
}
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ func TestValidateForkHeights(t *testing.T) {
{
"Quebec", ErrInvalidCfg, "Quebec is heigher than Redsea",
},
{
"Redsea", ErrInvalidCfg, "Redsea is heigher than Sumatra",
},
{
"", nil, "",
},
Expand Down Expand Up @@ -430,6 +433,8 @@ func newTestCfg(fork string) Config {
cfg.Genesis.PalauBlockHeight = cfg.Genesis.QuebecBlockHeight + 1
case "Quebec":
cfg.Genesis.QuebecBlockHeight = cfg.Genesis.RedseaBlockHeight + 1
case "Redsea":
cfg.Genesis.RedseaBlockHeight = cfg.Genesis.SumatraBlockHeight + 1
}
return cfg
}
Expand Down

0 comments on commit 85701ac

Please sign in to comment.