params: core: enable shanghai based on timestamps
This commit is contained in:
+15
-13
@@ -281,7 +281,7 @@ var (
|
||||
|
||||
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), nil, nil, nil, nil, false, new(EthashConfig), nil}
|
||||
NonActivatedConfig = &ChainConfig{big.NewInt(1), nil, nil, false, nil, common.Hash{}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, false, new(EthashConfig), nil}
|
||||
TestRules = TestChainConfig.Rules(new(big.Int), false)
|
||||
TestRules = TestChainConfig.Rules(new(big.Int), false, new(big.Int))
|
||||
)
|
||||
|
||||
// NetworkNames are user friendly names to use in the chain spec banner.
|
||||
@@ -371,7 +371,7 @@ type ChainConfig struct {
|
||||
ArrowGlacierBlock *big.Int `json:"arrowGlacierBlock,omitempty"` // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
|
||||
GrayGlacierBlock *big.Int `json:"grayGlacierBlock,omitempty"` // Eip-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
|
||||
MergeNetsplitBlock *big.Int `json:"mergeNetsplitBlock,omitempty"` // Virtual fork after The Merge to use as a network splitter
|
||||
ShanghaiBlock *big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch block (nil = no fork, 0 = already on shanghai)
|
||||
ShanghaiTime *big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
|
||||
CancunBlock *big.Int `json:"cancunBlock,omitempty"` // Cancun switch block (nil = no fork, 0 = already on cancun)
|
||||
|
||||
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
||||
@@ -465,8 +465,8 @@ func (c *ChainConfig) Description() string {
|
||||
if c.GrayGlacierBlock != nil {
|
||||
banner += fmt.Sprintf(" - Gray Glacier: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/gray-glacier.md)\n", c.GrayGlacierBlock)
|
||||
}
|
||||
if c.ShanghaiBlock != nil {
|
||||
banner += fmt.Sprintf(" - Shanghai: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md)\n", c.ShanghaiBlock)
|
||||
if c.ShanghaiTime != nil {
|
||||
banner += fmt.Sprintf(" - Shanghai: %-8v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md)\n", c.ShanghaiTime)
|
||||
}
|
||||
if c.CancunBlock != nil {
|
||||
banner += fmt.Sprintf(" - Cancun: %-8v\n", c.CancunBlock)
|
||||
@@ -567,9 +567,9 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi
|
||||
return parentTotalDiff.Cmp(c.TerminalTotalDifficulty) < 0 && totalDiff.Cmp(c.TerminalTotalDifficulty) >= 0
|
||||
}
|
||||
|
||||
// IsShanghai returns whether num is either equal to the Shanghai fork block or greater.
|
||||
func (c *ChainConfig) IsShanghai(num *big.Int) bool {
|
||||
return isForked(c.ShanghaiBlock, num)
|
||||
// IsShanghai returns whether time is either equal to the Shanghai fork time or greater.
|
||||
func (c *ChainConfig) IsShanghai(time *big.Int) bool {
|
||||
return isForked(c.ShanghaiTime, time)
|
||||
}
|
||||
|
||||
// IsCancun returns whether num is either equal to the Cancun fork block or greater.
|
||||
@@ -620,7 +620,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
|
||||
{name: "arrowGlacierBlock", block: c.ArrowGlacierBlock, optional: true},
|
||||
{name: "grayGlacierBlock", block: c.GrayGlacierBlock, optional: true},
|
||||
{name: "mergeNetsplitBlock", block: c.MergeNetsplitBlock, optional: true},
|
||||
{name: "shanghaiBlock", block: c.ShanghaiBlock, optional: true},
|
||||
//{name: "shanghaiBlock", block: c.ShanghaiBlock, optional: true},
|
||||
{name: "cancunBlock", block: c.CancunBlock, optional: true},
|
||||
} {
|
||||
if lastFork.name != "" {
|
||||
@@ -700,9 +700,11 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
|
||||
if isForkIncompatible(c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock, head) {
|
||||
return newCompatError("Merge netsplit fork block", c.MergeNetsplitBlock, newcfg.MergeNetsplitBlock)
|
||||
}
|
||||
if isForkIncompatible(c.ShanghaiBlock, newcfg.ShanghaiBlock, head) {
|
||||
return newCompatError("Shanghai fork block", c.ShanghaiBlock, newcfg.ShanghaiBlock)
|
||||
}
|
||||
/*
|
||||
if isForkIncompatible(c.ShanghaiBlock, newcfg.ShanghaiBlock, head) {
|
||||
return newCompatError("Shanghai fork block", c.ShanghaiBlock, newcfg.ShanghaiBlock)
|
||||
}
|
||||
*/
|
||||
if isForkIncompatible(c.CancunBlock, newcfg.CancunBlock, head) {
|
||||
return newCompatError("Cancun fork block", c.CancunBlock, newcfg.CancunBlock)
|
||||
}
|
||||
@@ -788,7 +790,7 @@ type Rules struct {
|
||||
}
|
||||
|
||||
// Rules ensures c's ChainID is not nil.
|
||||
func (c *ChainConfig) Rules(num *big.Int, isMerge bool) Rules {
|
||||
func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp *big.Int) Rules {
|
||||
chainID := c.ChainID
|
||||
if chainID == nil {
|
||||
chainID = new(big.Int)
|
||||
@@ -806,7 +808,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool) Rules {
|
||||
IsBerlin: c.IsBerlin(num),
|
||||
IsLondon: c.IsLondon(num),
|
||||
IsMerge: isMerge,
|
||||
IsShanghai: c.IsShanghai(num),
|
||||
IsShanghai: c.IsShanghai(timestamp),
|
||||
isCancun: c.IsCancun(num),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user