diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index db226c73d8..a9f19a3e70 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1646,6 +1646,43 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) { } } +func validateDeveloperGenesis(genesis *core.Genesis) error { + checkHFIsZero := func(forkName string, hfBlockNumber *big.Int) error { + if hfBlockNumber == nil { + return errors.New(fmt.Sprintf("%s: hard-fork not enabled", forkName)) + } else if hfBlockNumber.Cmp(big.NewInt(0)) != 0 { + return errors.New(fmt.Sprintf("%s: hard-fork not activated in block 0", forkName)) + } + return nil + } + + config := genesis.Config + if err := checkHFIsZero("Homestead", config.HomesteadBlock); err != nil { + return err + } else if config.DAOForkBlock != nil { + return errors.New("DAO hardfork cannot be enabled") + } else if err := checkHFIsZero("EIP150", config.EIP150Block); err != nil { + return err + } else if err := checkHFIsZero("EIP155", config.EIP155Block); err != nil { + return err + } else if err := checkHFIsZero("EIP158", config.EIP158Block); err != nil { + return err + } else if err := checkHFIsZero("Byzantium", config.ByzantiumBlock); err != nil { + return err + } else if err := checkHFIsZero("Constantinople", config.ConstantinopleBlock); err != nil { + return err + } else if err := checkHFIsZero("Istanbul", config.IstanbulBlock); err != nil { + return err + } else if err := checkHFIsZero("Berlin", config.BerlinBlock); err != nil { + return err + } else if err := checkHFIsZero("London", config.LondonBlock); err != nil { + return err + } else if config.TerminalTotalDifficultyPassed != true { + return errors.New("terminal total difficulty must be passed") + } + return nil +} + // SetEthConfig applies eth-related command line flags to the config. func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { // Avoid conflicting network flags @@ -1870,6 +1907,15 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { chaindb := tryMakeReadOnlyDatabase(ctx, stack) if rawdb.ReadCanonicalHash(chaindb, 0) != (common.Hash{}) { cfg.Genesis = nil // fallback to db content + + var genesis *core.Genesis + var err error + if genesis, err = core.ReadGenesis(chaindb); err != nil { + Fatalf("could not read genesis from database: %v", err) + } + if err = validateDeveloperGenesis(genesis); err != nil { + Fatalf("genesis configuration incompatible with development mode: %v", err) + } } chaindb.Close() } diff --git a/eth/catalyst/simulated_beacon.go b/eth/catalyst/simulated_beacon.go index a9a2bb4a9a..d8b8641e6a 100644 --- a/eth/catalyst/simulated_beacon.go +++ b/eth/catalyst/simulated_beacon.go @@ -82,10 +82,6 @@ type SimulatedBeacon struct { } func NewSimulatedBeacon(period uint64, eth *eth.Ethereum) (*SimulatedBeacon, error) { - chainConfig := eth.APIBackend.ChainConfig() - if !chainConfig.IsDevMode { - return nil, errors.New("incompatible pre-existing chain configuration") - } block := eth.BlockChain().CurrentBlock() current := engine.ForkchoiceStateV1{ HeadBlockHash: block.Hash(), diff --git a/params/config.go b/params/config.go index 88ff772a1d..517130f86a 100644 --- a/params/config.go +++ b/params/config.go @@ -180,7 +180,6 @@ var ( ShanghaiTime: newUint64(0), TerminalTotalDifficulty: big.NewInt(0), TerminalTotalDifficultyPassed: true, - IsDevMode: true, } // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced @@ -331,7 +330,6 @@ type ChainConfig struct { // Various consensus engines Ethash *EthashConfig `json:"ethash,omitempty"` Clique *CliqueConfig `json:"clique,omitempty"` - IsDevMode bool `json:"isDev,omitempty"` } // EthashConfig is the consensus engine configs for proof-of-work based sealing.