@@ -415,6 +415,42 @@ func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *Confi
415415 return lasterr
416416}
417417
418+ // CheckConfigForkOrder checks that we don't "skip" any forks, geth isn't pluggable enough
419+ // to guarantee that forks
420+ func (c * ChainConfig ) CheckConfigForkOrder () error {
421+ type fork struct {
422+ name string
423+ block * big.Int
424+ }
425+ var lastFork fork
426+ for _ , cur := range []fork {
427+ {"homesteadBlock" , c .HomesteadBlock },
428+ {"eip150Block" , c .EIP150Block },
429+ {"eip155Block" , c .EIP155Block },
430+ {"eip158Block" , c .EIP158Block },
431+ {"byzantiumBlock" , c .ByzantiumBlock },
432+ {"constantinopleBlock" , c .ConstantinopleBlock },
433+ {"petersburgBlock" , c .PetersburgBlock },
434+ {"istanbulBlock" , c .IstanbulBlock },
435+ } {
436+ if lastFork .name != "" {
437+ // Next one must be higher number
438+ if lastFork .block == nil && cur .block != nil {
439+ return fmt .Errorf ("unsupported fork ordering: %v not enabled, but %v enabled at %v" ,
440+ lastFork .name , cur .name , cur .block )
441+ }
442+ if lastFork .block != nil && cur .block != nil {
443+ if lastFork .block .Cmp (cur .block ) > 0 {
444+ return fmt .Errorf ("unsupported fork ordering: %v enabled at %v, but %v enabled at %v" ,
445+ lastFork .name , lastFork .block , cur .name , cur .block )
446+ }
447+ }
448+ }
449+ lastFork = cur
450+ }
451+ return nil
452+ }
453+
418454func (c * ChainConfig ) checkCompatible (newcfg * ChainConfig , head * big.Int ) * ConfigCompatError {
419455 if isForkIncompatible (c .HomesteadBlock , newcfg .HomesteadBlock , head ) {
420456 return newCompatError ("Homestead fork block" , c .HomesteadBlock , newcfg .HomesteadBlock )
0 commit comments