Skip to content

Commit

Permalink
[genesis] add Upernavik block height (#4206)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie committed Mar 29, 2024
1 parent 85559fb commit dadc907
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#Specific owners
/consensus/ @CoderZhi @dustinxie @Liuhaai @envestcc
/ioctl/ @CoderZhi @dustinxie @Liuhaai
/api/ @CoderZhi @dustinxie @Liuhaai @millken
/config/ @CoderZhi @dustinxie @Liuhaai @envestcc
/ioctl/ @CoderZhi @dustinxie @Liuhaai @envestcc @millken
/api/ @CoderZhi @dustinxie @Liuhaai @millken @envestcc
/config/ @CoderZhi @dustinxie @Liuhaai @envestcc @millken
/p2p/ @CoderZhi @dustinxie @Liuhaai @envestcc
/action/ @CoderZhi @dustinxie @Liuhaai @envestcc
/blockchain/ @CoderZhi @dustinxie @Liuhaai
Expand Down
9 changes: 9 additions & 0 deletions blockchain/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func defaultConfig() Genesis {
RedseaBlockHeight: 26704441,
SumatraBlockHeight: 28516681,
TsunamiBlockHeight: 29275561,
UpernavikBlockHeight: 39275561,
ToBeEnabledBlockHeight: math.MaxUint64,
},
Account: Account{
Expand Down Expand Up @@ -258,6 +259,9 @@ type (
// 2. generate transaction log for Suicide() call in EVM
// 3. raise block gas limit to 50M
TsunamiBlockHeight uint64 `yaml:"tsunamiHeight"`
// UpernavikBlockHeight is the start height to
// 1. enable Cancun EVM
UpernavikBlockHeight uint64 `yaml:"upernavikHeight"`
// 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 @@ -609,6 +613,11 @@ func (g *Blockchain) IsTsunami(height uint64) bool {
return g.isPost(g.TsunamiBlockHeight, height)
}

// IsUpernavik checks whether height is equal to or larger than upernavik height
func (g *Blockchain) IsUpernavik(height uint64) bool {
return g.isPost(g.UpernavikBlockHeight, 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 @@ -63,6 +63,8 @@ func TestNewHeightChange(t *testing.T) {
require.True(cfg.IsSumatra(uint64(28516681)))
require.False(cfg.IsTsunami(uint64(29275560)))
require.True(cfg.IsTsunami(uint64(29275561)))
require.False(cfg.IsUpernavik(uint64(39275560)))
require.True(cfg.IsUpernavik(uint64(39275561)))

require.Equal(cfg.PacificBlockHeight, uint64(432001))
require.Equal(cfg.AleutianBlockHeight, uint64(864001))
Expand All @@ -87,4 +89,5 @@ func TestNewHeightChange(t *testing.T) {
require.Equal(cfg.RedseaBlockHeight, uint64(26704441))
require.Equal(cfg.SumatraBlockHeight, uint64(28516681))
require.Equal(cfg.TsunamiBlockHeight, uint64(29275561))
require.Equal(cfg.UpernavikBlockHeight, uint64(39275561))
}
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ func ValidateForkHeights(cfg Config) error {
return errors.Wrap(ErrInvalidCfg, "Redsea is heigher than Sumatra")
case hu.SumatraBlockHeight > hu.TsunamiBlockHeight:
return errors.Wrap(ErrInvalidCfg, "Sumatra is heigher than Tsunami")
case hu.TsunamiBlockHeight > hu.UpernavikBlockHeight:
return errors.Wrap(ErrInvalidCfg, "Tsunami is heigher than Upernavik")
}
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 @@ -380,6 +380,9 @@ func TestValidateForkHeights(t *testing.T) {
{
"Sumatra", ErrInvalidCfg, "Sumatra is heigher than Tsunami",
},
{
"Tsunami", ErrInvalidCfg, "Tsunami is heigher than Upernavik",
},
{
"", nil, "",
},
Expand Down Expand Up @@ -440,6 +443,8 @@ func newTestCfg(fork string) Config {
cfg.Genesis.RedseaBlockHeight = cfg.Genesis.SumatraBlockHeight + 1
case "Sumatra":
cfg.Genesis.SumatraBlockHeight = cfg.Genesis.TsunamiBlockHeight + 1
case "Tsunami":
cfg.Genesis.TsunamiBlockHeight = cfg.Genesis.UpernavikBlockHeight + 1
}
return cfg
}
Expand Down

0 comments on commit dadc907

Please sign in to comment.