Skip to content

Commit

Permalink
[genesis] add Tsunami block height (#4180)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie authored Mar 13, 2024
1 parent 6eb9c5f commit 0ef24a2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
13 changes: 12 additions & 1 deletion blockchain/genesis/genesis.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 IoTeX Foundation
// Copyright (c) 2024 IoTeX Foundation
// This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
// or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
// This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
Expand Down Expand Up @@ -74,6 +74,7 @@ func defaultConfig() Genesis {
QuebecBlockHeight: 24838201,
RedseaBlockHeight: 26704441,
SumatraBlockHeight: 28516681,
TsunamiBlockHeight: 38516681,
ToBeEnabledBlockHeight: math.MaxUint64,
},
Account: Account{
Expand Down Expand Up @@ -249,6 +250,11 @@ type (
RedseaBlockHeight uint64 `yaml:"redseaHeight"`
// SumatraBlockHeight is the start height to enable Shanghai EVM
SumatraBlockHeight uint64 `yaml:"sumatraHeight"`
// TsunamiBlockHeight is the start height to
// 1. enable delegate endorsement
// 2. generate transaction log for Suicide() call in EVM
// 3. raise block gas limit to 50M
TsunamiBlockHeight uint64 `yaml:"tsunamiHeight"`
// 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 @@ -595,6 +601,11 @@ func (g *Blockchain) IsSumatra(height uint64) bool {
return g.isPost(g.SumatraBlockHeight, height)
}

// IsTsunami checks whether height is equal to or larger than tsunami height
func (g *Blockchain) IsTsunami(height uint64) bool {
return g.isPost(g.TsunamiBlockHeight, 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
5 changes: 4 additions & 1 deletion blockchain/genesis/heightupgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 IoTeX
// Copyright (c) 2024 IoTeX
// This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
// or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
// This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
Expand Down Expand Up @@ -61,6 +61,8 @@ func TestNewHeightChange(t *testing.T) {
require.True(cfg.IsRedsea(uint64(26704441)))
require.False(cfg.IsSumatra(uint64(28516680)))
require.True(cfg.IsSumatra(uint64(28516681)))
require.False(cfg.IsTsunami(uint64(38516680)))
require.True(cfg.IsTsunami(uint64(38516681)))

require.Equal(cfg.PacificBlockHeight, uint64(432001))
require.Equal(cfg.AleutianBlockHeight, uint64(864001))
Expand All @@ -84,4 +86,5 @@ func TestNewHeightChange(t *testing.T) {
require.Equal(cfg.QuebecBlockHeight, uint64(24838201))
require.Equal(cfg.RedseaBlockHeight, uint64(26704441))
require.Equal(cfg.SumatraBlockHeight, uint64(28516681))
require.Equal(cfg.TsunamiBlockHeight, uint64(38516681))
}
4 changes: 3 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 IoTeX Foundation
// Copyright (c) 2024 IoTeX Foundation
// This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
// or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
// This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
Expand Down Expand Up @@ -329,6 +329,8 @@ func ValidateForkHeights(cfg Config) error {
return errors.Wrap(ErrInvalidCfg, "Quebec is heigher than Redsea")
case hu.RedseaBlockHeight > hu.SumatraBlockHeight:
return errors.Wrap(ErrInvalidCfg, "Redsea is heigher than Sumatra")
case hu.SumatraBlockHeight > hu.TsunamiBlockHeight:
return errors.Wrap(ErrInvalidCfg, "Sumatra is heigher than Tsunami")
}
return nil
}
Expand Down
7 changes: 6 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023 IoTeX Foundation
// Copyright (c) 2024 IoTeX Foundation
// This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
// or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
// This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
Expand Down Expand Up @@ -377,6 +377,9 @@ func TestValidateForkHeights(t *testing.T) {
{
"Redsea", ErrInvalidCfg, "Redsea is heigher than Sumatra",
},
{
"Sumatra", ErrInvalidCfg, "Sumatra is heigher than Tsunami",
},
{
"", nil, "",
},
Expand Down Expand Up @@ -435,6 +438,8 @@ func newTestCfg(fork string) Config {
cfg.Genesis.QuebecBlockHeight = cfg.Genesis.RedseaBlockHeight + 1
case "Redsea":
cfg.Genesis.RedseaBlockHeight = cfg.Genesis.SumatraBlockHeight + 1
case "Sumatra":
cfg.Genesis.SumatraBlockHeight = cfg.Genesis.TsunamiBlockHeight + 1
}
return cfg
}
Expand Down

0 comments on commit 0ef24a2

Please sign in to comment.