Skip to content

Commit d79cc74

Browse files
authored
add new englishHeight for slashing (iotexproject#1811)
1 parent 2787fb7 commit d79cc74

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

blockchain/genesis/genesis.go

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func defaultConfig() Genesis {
5353
BeringBlockHeight: 1512001,
5454
CookBlockHeight: 1641601,
5555
DardanellesBlockHeight: 1816201,
56+
EnglishBlockHeight: 3000001,
5657
},
5758
Account: Account{
5859
InitBalanceMap: make(map[string]string),
@@ -132,6 +133,8 @@ type (
132133
CookBlockHeight uint64 `yaml:"cookHeight"`
133134
// DardanellesBlockHeight is the start height of 5s block internal
134135
DardanellesBlockHeight uint64 `yaml:"dardanellesHeight"`
136+
// EnglishBlockHeight is the start height of kick-out for slashing
137+
EnglishBlockHeight uint64 `yaml:englishHeight`
135138
}
136139
// Account contains the configs for account protocol
137140
Account struct {

config/heightupgrade.go

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const (
1919
Bering
2020
Cook
2121
Dardanelles
22+
English
2223
)
2324

2425
type (
@@ -32,6 +33,7 @@ type (
3233
beringHeight uint64
3334
cookHeight uint64
3435
dardanellesHeight uint64
36+
englishHeight uint64
3537
}
3638
)
3739

@@ -43,6 +45,7 @@ func NewHeightUpgrade(cfg *genesis.Genesis) HeightUpgrade {
4345
cfg.BeringBlockHeight,
4446
cfg.CookBlockHeight,
4547
cfg.DardanellesBlockHeight,
48+
cfg.EnglishBlockHeight,
4649
}
4750
}
4851

@@ -60,6 +63,8 @@ func (hu *HeightUpgrade) IsPost(name HeightName, height uint64) bool {
6063
h = hu.cookHeight
6164
case Dardanelles:
6265
h = hu.dardanellesHeight
66+
case English:
67+
h = hu.englishHeight
6368
default:
6469
log.Panic("invalid height name!")
6570
}
@@ -85,3 +90,6 @@ func (hu *HeightUpgrade) CookBlockHeight() uint64 { return hu.cookHeight }
8590

8691
// DardanellesBlockHeight returns the dardanelles height
8792
func (hu *HeightUpgrade) DardanellesBlockHeight() uint64 { return hu.dardanellesHeight }
93+
94+
// EnglishBlockHeight returns the english height
95+
func (hu *HeightUpgrade) EnglishBlockHeight() uint64 { return hu.englishHeight }

config/heightupgrade_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func TestNewHeightChange(t *testing.T) {
2020
require.Equal(2, Bering)
2121
require.Equal(3, Cook)
2222
require.Equal(4, Dardanelles)
23+
require.Equal(5, English)
2324

2425
cfg := Default
2526
cfg.Genesis.PacificBlockHeight = uint64(432001)
@@ -35,6 +36,8 @@ func TestNewHeightChange(t *testing.T) {
3536
require.True(hu.IsPost(Cook, uint64(1641601)))
3637
require.True(hu.IsPre(Dardanelles, uint64(1816200)))
3738
require.True(hu.IsPost(Dardanelles, uint64(1816201)))
39+
require.True(hu.IsPre(English, uint64(3000000)))
40+
require.True(hu.IsPost(English, uint64(3000001)))
3841
require.Panics(func() {
3942
hu.IsPost(-1, 0)
4043
})
@@ -44,5 +47,6 @@ func TestNewHeightChange(t *testing.T) {
4447
require.Equal(hu.BeringBlockHeight(), uint64(1512001))
4548
require.Equal(hu.CookBlockHeight(), uint64(1641601))
4649
require.Equal(hu.DardanellesBlockHeight(), uint64(1816201))
50+
require.Equal(hu.EnglishBlockHeight(), uint64(3000001))
4751

4852
}

0 commit comments

Comments
 (0)