Skip to content

Commit fa885d2

Browse files
committed
feature: introduce HertzBlock
1 parent 04fd806 commit fa885d2

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

eth/gasprice/gasprice_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func newTestBackend(t *testing.T, londonBlock *big.Int, pending bool) *testBacke
138138
config.GibbsBlock = nil
139139
config.LubanBlock = nil
140140
config.PlatoBlock = nil
141+
config.HertzBlock = nil
141142
engine := ethash.NewFaker()
142143
db := rawdb.NewMemoryDatabase()
143144
genesis, err := gspec.Commit(db)

eth/handler_eth_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func testForkIDSplit(t *testing.T, protocol uint) {
110110
MoranBlock: big.NewInt(5),
111111
LubanBlock: big.NewInt(6),
112112
PlatoBlock: big.NewInt(6),
113+
HertzBlock: big.NewInt(7),
113114
}
114115
dbNoFork = rawdb.NewMemoryDatabase()
115116
dbProFork = rawdb.NewMemoryDatabase()

params/config.go

+28-7
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,8 @@ var (
194194
// TODO Caution !!! it should be very careful !!!
195195
LubanBlock: nil,
196196
PlatoBlock: nil,
197-
198-
// TODO modify blockNumber to enable Berlin EIPs after the block.
199-
BerlinBlock: nil,
197+
// TODO modify blockNumber, this block should enable Berlin and London EIPs.
198+
HertzBlock: nil,
200199

201200
Parlia: &ParliaConfig{
202201
Period: 3,
@@ -229,6 +228,7 @@ var (
229228
// TODO Caution !!! it should be very careful !!!
230229
LubanBlock: big.NewInt(29295050),
231230
PlatoBlock: big.NewInt(29861024),
231+
HertzBlock: big.NewInt(0),
232232

233233
Parlia: &ParliaConfig{
234234
Period: 3,
@@ -260,6 +260,7 @@ var (
260260
// TODO
261261
LubanBlock: nil,
262262
PlatoBlock: nil,
263+
HertzBlock: nil,
263264

264265
Parlia: &ParliaConfig{
265266
Period: 3,
@@ -273,16 +274,16 @@ var (
273274
// This configuration is intentionally not using keyed fields to force anyone
274275
// adding flags to the config to also have to set these fields.
275276

276-
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil, nil}
277+
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil, nil}
277278

278279
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
279280
// and accepted by the Ethereum core developers into the Clique consensus.
280281
//
281282
// This configuration is intentionally not using keyed fields to force anyone
282283
// adding flags to the config to also have to set these fields.
283-
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil}
284+
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil}
284285

285-
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, big.NewInt(0), big.NewInt(0), new(EthashConfig), nil, nil}
286+
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, big.NewInt(0), big.NewInt(0), big.NewInt(0), new(EthashConfig), nil, nil}
286287
TestRules = TestChainConfig.Rules(new(big.Int), false)
287288
)
288289

@@ -381,6 +382,7 @@ type ChainConfig struct {
381382
PlanckBlock *big.Int `json:"planckBlock,omitempty" toml:",omitempty"` // planckBlock switch block (nil = no fork, 0 = already activated)
382383
LubanBlock *big.Int `json:"lubanBlock,omitempty" toml:",omitempty"` // lubanBlock switch block (nil = no fork, 0 = already activated)
383384
PlatoBlock *big.Int `json:"platoBlock,omitempty" toml:",omitempty"` // platoBlock switch block (nil = no fork, 0 = already activated)
385+
HertzBlock *big.Int `json:"hertzBlock,omitempty" toml:",omitempty"` // hertzBlock switch block (nil = no fork, 0 = already activated)
384386

385387
// Various consensus engines
386388
Ethash *EthashConfig `json:"ethash,omitempty" toml:",omitempty"`
@@ -432,7 +434,7 @@ func (c *ChainConfig) String() string {
432434
engine = "unknown"
433435
}
434436

435-
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Berlin: %v, YOLO v3: %v, CatalystBlock: %v, London: %v, ArrowGlacier: %v, MergeFork:%v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v,Luban: %v, Plato: %v, Engine: %v}",
437+
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Ramanujan: %v, Niels: %v, MirrorSync: %v, Bruno: %v, Berlin: %v, YOLO v3: %v, CatalystBlock: %v, London: %v, ArrowGlacier: %v, MergeFork:%v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v,Luban: %v, Plato: %v, Hertz: %v, Engine: %v}",
436438
c.ChainID,
437439
c.HomesteadBlock,
438440
c.DAOForkBlock,
@@ -462,6 +464,7 @@ func (c *ChainConfig) String() string {
462464
c.PlanckBlock,
463465
c.LubanBlock,
464466
c.PlatoBlock,
467+
c.HertzBlock,
465468
engine,
466469
)
467470
}
@@ -571,6 +574,16 @@ func (c *ChainConfig) IsOnPlato(num *big.Int) bool {
571574
return configNumEqual(c.PlatoBlock, num)
572575
}
573576

577+
// IsHertz returns whether num is either equal to the second fast finality fork block or greater.
578+
func (c *ChainConfig) IsHertz(num *big.Int) bool {
579+
return isForked(c.HertzBlock, num)
580+
}
581+
582+
// IsOnHertz returns whether num is equal to the second fast finality fork block.
583+
func (c *ChainConfig) IsOnHertz(num *big.Int) bool {
584+
return configNumEqual(c.HertzBlock, num)
585+
}
586+
574587
// IsMuirGlacier returns whether num is either equal to the Muir Glacier (EIP-2384) fork block or greater.
575588
func (c *ChainConfig) IsMuirGlacier(num *big.Int) bool {
576589
return isForked(c.MuirGlacierBlock, num)
@@ -590,6 +603,10 @@ func (c *ChainConfig) IsIstanbul(num *big.Int) bool {
590603

591604
// IsBerlin returns whether num is either equal to the Berlin fork block or greater.
592605
func (c *ChainConfig) IsBerlin(num *big.Int) bool {
606+
// Check if it is Hertz, which works on BSC
607+
if c.IsHertz(num) {
608+
return true
609+
}
593610
return isForked(c.BerlinBlock, num)
594611
}
595612

@@ -679,6 +696,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
679696
{name: "gibbsBlock", block: c.GibbsBlock},
680697
{name: "lubanBlock", block: c.LubanBlock},
681698
{name: "platoBlock", block: c.PlatoBlock},
699+
{name: "hertzBlock", block: c.HertzBlock},
682700
} {
683701
if lastFork.name != "" {
684702
// Next one must be higher number
@@ -784,6 +802,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
784802
if isForkIncompatible(c.PlatoBlock, newcfg.PlatoBlock, head) {
785803
return newCompatError("plato fork block", c.PlatoBlock, newcfg.PlatoBlock)
786804
}
805+
if isForkIncompatible(c.HertzBlock, newcfg.HertzBlock, head) {
806+
return newCompatError("hartz fork block", c.HertzBlock, newcfg.HertzBlock)
807+
}
787808
return nil
788809
}
789810

0 commit comments

Comments
 (0)