From aa2f2b742a2e49665d423cdd1c1b3cc7ad8358f5 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Mon, 20 Apr 2020 11:46:38 +0200 Subject: [PATCH] cmd, core: remove override muir glacier and override istanbul (#20942) # Conflicts: # core/genesis.go # eth/backend.go # les/client.go --- cmd/geth/config.go | 7 ------- cmd/geth/main.go | 2 -- cmd/utils/flags.go | 8 -------- core/genesis.go | 35 +++++++++++++++++++---------------- eth/backend.go | 5 +++-- eth/config.go | 6 ------ eth/gen_config.go | 8 -------- 7 files changed, 22 insertions(+), 49 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 48c41477f6..dc7a209850 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -20,7 +20,6 @@ import ( "bufio" "errors" "fmt" - "math/big" "os" "reflect" "unicode" @@ -134,12 +133,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { func makeFullNode(ctx *cli.Context) *node.Node { stack, cfg := makeConfigNode(ctx) - if ctx.GlobalIsSet(utils.OverrideIstanbulFlag.Name) { - cfg.Eth.OverrideIstanbul = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideIstanbulFlag.Name)) - } - if ctx.GlobalIsSet(utils.OverrideMuirGlacierFlag.Name) { - cfg.Eth.OverrideMuirGlacier = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideMuirGlacierFlag.Name)) - } utils.RegisterEthService(stack, &cfg.Eth) // Configure GraphQL if required diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 3f298ee645..55b326d681 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -69,8 +69,6 @@ var ( utils.ExternalSignerFlag, utils.NoUSBFlag, utils.SmartCardDaemonPathFlag, - utils.OverrideIstanbulFlag, - utils.OverrideMuirGlacierFlag, utils.EthashCacheDirFlag, utils.EthashCachesInMemoryFlag, utils.EthashCachesOnDiskFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index cded7ea667..dfde2fce07 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -265,14 +265,6 @@ var ( Name: "whitelist", Usage: "Comma separated block number-to-hash mappings to enforce (<number>=<hash>)", } - OverrideIstanbulFlag = cli.Uint64Flag{ - Name: "override.istanbul", - Usage: "Manually specify Istanbul fork-block, overriding the bundled setting", - } - OverrideMuirGlacierFlag = cli.Uint64Flag{ - Name: "override.muirglacier", - Usage: "Manually specify Muir Glacier fork-block, overriding the bundled setting", - } // Light server and client settings LightLegacyServFlag = cli.IntFlag{ // Deprecated in favor of light.serve, remove in 2021 Name: "lightserv", diff --git a/core/genesis.go b/core/genesis.go index 749e09d4c2..ffb2d0ecaf 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -153,16 +153,6 @@ func (e *GenesisMismatchError) Error() string { // // The returned chain configuration is never nil. func SetupGenesisBlock(db ethdb.Database, genesis *Genesis, history bool) (*params.ChainConfig, common.Hash, *state.IntraBlockState, error) { - return SetupGenesisBlockWithOverride(db, genesis, nil, nil, history) -} -func SetupGenesisBlockWithOverride(db ethdb.Database, - genesis *Genesis, - overrideIstanbul *big.Int, - overrideMuirGlacier *big.Int, - history bool, -) (*params.ChainConfig, common.Hash, *state.IntraBlockState, error) { - var stateDB *state.IntraBlockState - if genesis != nil && genesis.Config == nil { return params.AllEthashProtocolChanges, common.Hash{}, stateDB, errGenesisNoConfig } @@ -176,6 +166,25 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, log.Info("Writing custom genesis block") } block, stateDB1, err := genesis.Commit(db, history) + if err != nil { + return genesis.Config, common.Hash{}, err + } + return genesis.Config, block.Hash(), nil + } + + // We have the genesis block in database(perhaps in ancient database) + // but the corresponding state is missing. + header := rawdb.ReadHeader(db, stored, 0) + if _, err := state.New(header.Root, state.NewDatabaseWithCache(db, 0), nil); err != nil { + if genesis == nil { + genesis = DefaultGenesisBlock() + } + // Ensure the stored genesis matches with the given one. + hash := genesis.ToBlock(nil).Hash() + if hash != stored { + return genesis.Config, hash, &GenesisMismatchError{stored, hash} + } + block, err := genesis.Commit(db) if err != nil { return nil, common.Hash{}, nil, err } @@ -196,12 +205,6 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, // Get the existing chain configuration. newcfg := genesis.configOrDefault(stored) - if overrideIstanbul != nil { - newcfg.IstanbulBlock = overrideIstanbul - } - if overrideMuirGlacier != nil { - newcfg.MuirGlacierBlock = overrideMuirGlacier - } if err := newcfg.CheckConfigForkOrder(); err != nil { return newcfg, common.Hash{}, nil, err } diff --git a/eth/backend.go b/eth/backend.go index 2239d0f337..e29c30d7bb 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -146,7 +146,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { } } - chainConfig, genesisHash, _, genesisErr := core.SetupGenesisBlockWithOverride( + chainConfig, genesisHash, _, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis) chainDb, config.Genesis, config.OverrideIstanbul, @@ -226,8 +226,9 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { BlocksToPrune: config.BlocksToPrune, PruneTimeout: config.PruningTimeout, TrieCleanLimit: config.TrieCleanCache, - TrieDirtyLimit: config.TrieDirtyCache, TrieCleanNoPrefetch: config.NoPrefetch, + TrieDirtyLimit: config.TrieDirtyCache, + TrieDirtyDisabled: config.NoPruning, TrieTimeLimit: config.TrieTimeout, DownloadOnly: config.DownloadOnly, NoHistory: !config.StorageMode.History, diff --git a/eth/config.go b/eth/config.go index 1396579054..595a374415 100644 --- a/eth/config.go +++ b/eth/config.go @@ -219,10 +219,4 @@ type Config struct { // CheckpointOracle is the configuration for checkpoint oracle. CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"` - - // Istanbul block override (TODO: remove after the fork) - OverrideIstanbul *big.Int `toml:",omitempty"` - - // MuirGlacier block override (TODO: remove after the fork) - OverrideMuirGlacier *big.Int `toml:",omitempty"` } diff --git a/eth/gen_config.go b/eth/gen_config.go index 3b1c615c87..c771dda15e 100644 --- a/eth/gen_config.go +++ b/eth/gen_config.go @@ -85,8 +85,6 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.RPCGasCap = c.RPCGasCap enc.Checkpoint = c.Checkpoint enc.CheckpointOracle = c.CheckpointOracle - enc.OverrideIstanbul = c.OverrideIstanbul - enc.OverrideMuirGlacier = c.OverrideMuirGlacier return &enc, nil } @@ -229,11 +227,5 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.CheckpointOracle != nil { c.CheckpointOracle = dec.CheckpointOracle } - if dec.OverrideIstanbul != nil { - c.OverrideIstanbul = dec.OverrideIstanbul - } - if dec.OverrideMuirGlacier != nil { - c.OverrideMuirGlacier = dec.OverrideMuirGlacier - } return nil } -- GitLab