From 0ef24a2c7bac12e0e91cb5647f4646408fdf4b1c Mon Sep 17 00:00:00 2001 From: dustinxie Date: Tue, 12 Mar 2024 21:58:08 -0700 Subject: [PATCH] [genesis] add Tsunami block height (#4180) --- blockchain/genesis/genesis.go | 13 ++++++++++++- blockchain/genesis/heightupgrade_test.go | 5 ++++- config/config.go | 4 +++- config/config_test.go | 7 ++++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/blockchain/genesis/genesis.go b/blockchain/genesis/genesis.go index 0a9c35fde0..d4abb55547 100644 --- a/blockchain/genesis/genesis.go +++ b/blockchain/genesis/genesis.go @@ -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. @@ -74,6 +74,7 @@ func defaultConfig() Genesis { QuebecBlockHeight: 24838201, RedseaBlockHeight: 26704441, SumatraBlockHeight: 28516681, + TsunamiBlockHeight: 38516681, ToBeEnabledBlockHeight: math.MaxUint64, }, Account: Account{ @@ -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"` @@ -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) diff --git a/blockchain/genesis/heightupgrade_test.go b/blockchain/genesis/heightupgrade_test.go index a2674509a0..acac164bad 100644 --- a/blockchain/genesis/heightupgrade_test.go +++ b/blockchain/genesis/heightupgrade_test.go @@ -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. @@ -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)) @@ -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)) } diff --git a/config/config.go b/config/config.go index 1bdc738c4d..1def5da96b 100644 --- a/config/config.go +++ b/config/config.go @@ -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. @@ -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 } diff --git a/config/config_test.go b/config/config_test.go index c8d8f3c7a7..243bc5961e 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -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. @@ -377,6 +377,9 @@ func TestValidateForkHeights(t *testing.T) { { "Redsea", ErrInvalidCfg, "Redsea is heigher than Sumatra", }, + { + "Sumatra", ErrInvalidCfg, "Sumatra is heigher than Tsunami", + }, { "", nil, "", }, @@ -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 }