Skip to content

Commit

Permalink
config: add hera hard fork
Browse files Browse the repository at this point in the history
  • Loading branch information
zfliex924 authored and charles2023wood committed Jan 22, 2024
1 parent 5a0d6b3 commit 59f05db
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ var (
MuirGlacierBlock: big.NewInt(0),
HashPowerBlock: big.NewInt(0),
ZeusBlock: big.NewInt(8_020_000),
HeraBlock: nil,
Satoshi: &SatoshiConfig{
Period: 3,
Epoch: 200,
Expand All @@ -277,6 +278,7 @@ var (
MuirGlacierBlock: big.NewInt(0),
HashPowerBlock: big.NewInt(4_545_256),
ZeusBlock: big.NewInt(12_666_000),
HeraBlock: nil,
Satoshi: &SatoshiConfig{
Period: 3,
Epoch: 200,
Expand Down Expand Up @@ -307,16 +309,16 @@ var (
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.

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, nil, nil, new(EthashConfig), nil, nil}
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, nil, nil, nil, new(EthashConfig), nil, nil}

// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Clique consensus.
//
// This configuration is intentionally not using keyed fields to force anyone
// adding flags to the config to also have to set these fields.
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, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil}
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, nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil}

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, nil, nil, new(EthashConfig), nil, nil}
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, nil, nil, nil, new(EthashConfig), nil, nil}
TestRules = TestChainConfig.Rules(new(big.Int), false)
)

Expand Down Expand Up @@ -406,6 +408,7 @@ type ChainConfig struct {

HashPowerBlock *big.Int `json:"hashPowerBlock,omitempty"`
ZeusBlock *big.Int `json:"zeusBlock,omitempty"`
HeraBlock *big.Int `json:"heraBlock,omitempty"`

// Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty" toml:",omitempty"`
Expand Down Expand Up @@ -457,7 +460,7 @@ func (c *ChainConfig) String() string {
default:
engine = "unknown"
}
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, Berlin: %v, YOLO v3: %v, London: %v, HashPower: %v, Zeus: %v, Engine: %v}",
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, Berlin: %v, YOLO v3: %v, London: %v, HashPower: %v, Zeus: %v, Hera: %v, Engine: %v}",
c.ChainID,
c.HomesteadBlock,
c.DAOForkBlock,
Expand All @@ -475,6 +478,7 @@ func (c *ChainConfig) String() string {
c.LondonBlock,
c.HashPowerBlock,
c.ZeusBlock,
c.HeraBlock,
engine,
)
}
Expand Down Expand Up @@ -570,6 +574,14 @@ func (c *ChainConfig) IsOnZeus(num *big.Int) bool {
return configNumEqual(c.ZeusBlock, num)
}

func (c *ChainConfig) IsHera(num *big.Int) bool {
return isForked(c.HeraBlock, num)
}

func (c *ChainConfig) IsOnHera(num *big.Int) bool {
return configNumEqual(c.HeraBlock, num)
}

// CheckCompatible checks whether scheduled fork transitions have been imported
// with a mismatching chain configuration.
func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *ConfigCompatError {
Expand Down Expand Up @@ -683,6 +695,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
if isForkIncompatible(c.ZeusBlock, newcfg.ZeusBlock, head) {
return newCompatError("zeus fork block", c.ZeusBlock, newcfg.ZeusBlock)
}
if isForkIncompatible(c.HeraBlock, newcfg.HeraBlock, head) {
return newCompatError("hera fork block", c.HeraBlock, newcfg.HeraBlock)
}
return nil
}

Expand Down

0 comments on commit 59f05db

Please sign in to comment.