prevent users from misconfiguring their nodes so that fork ordering is not preserved.
This commit is contained in:
committed by
GitHub
parent
028af3457d
commit
c476460cb2
@ -415,6 +415,42 @@ func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *Confi
|
||||
return lasterr
|
||||
}
|
||||
|
||||
// CheckConfigForkOrder checks that we don't "skip" any forks, geth isn't pluggable enough
|
||||
// to guarantee that forks
|
||||
func (c *ChainConfig) CheckConfigForkOrder() error {
|
||||
type fork struct {
|
||||
name string
|
||||
block *big.Int
|
||||
}
|
||||
var lastFork fork
|
||||
for _, cur := range []fork{
|
||||
{"homesteadBlock", c.HomesteadBlock},
|
||||
{"eip150Block", c.EIP150Block},
|
||||
{"eip155Block", c.EIP155Block},
|
||||
{"eip158Block", c.EIP158Block},
|
||||
{"byzantiumBlock", c.ByzantiumBlock},
|
||||
{"constantinopleBlock", c.ConstantinopleBlock},
|
||||
{"petersburgBlock", c.PetersburgBlock},
|
||||
{"istanbulBlock", c.IstanbulBlock},
|
||||
} {
|
||||
if lastFork.name != "" {
|
||||
// Next one must be higher number
|
||||
if lastFork.block == nil && cur.block != nil {
|
||||
return fmt.Errorf("unsupported fork ordering: %v not enabled, but %v enabled at %v",
|
||||
lastFork.name, cur.name, cur.block)
|
||||
}
|
||||
if lastFork.block != nil && cur.block != nil {
|
||||
if lastFork.block.Cmp(cur.block) > 0 {
|
||||
return fmt.Errorf("unsupported fork ordering: %v enabled at %v, but %v enabled at %v",
|
||||
lastFork.name, lastFork.block, cur.name, cur.block)
|
||||
}
|
||||
}
|
||||
}
|
||||
lastFork = cur
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *ConfigCompatError {
|
||||
if isForkIncompatible(c.HomesteadBlock, newcfg.HomesteadBlock, head) {
|
||||
return newCompatError("Homestead fork block", c.HomesteadBlock, newcfg.HomesteadBlock)
|
||||
|
Reference in New Issue
Block a user