diff options
author | Martin Holst Swende <martin@swende.se> | 2018-12-11 20:19:03 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-12-11 20:19:03 +0800 |
commit | 83a9a73b899e816a0d1493b7fb1e37abe4bc4566 (patch) | |
tree | a813e0e451a7a44ee12c91e40bcd76041f793895 | |
parent | 5584574217df29f5daf5db70b3d2536ec66a036c (diff) | |
download | dexon-83a9a73b899e816a0d1493b7fb1e37abe4bc4566.tar dexon-83a9a73b899e816a0d1493b7fb1e37abe4bc4566.tar.gz dexon-83a9a73b899e816a0d1493b7fb1e37abe4bc4566.tar.bz2 dexon-83a9a73b899e816a0d1493b7fb1e37abe4bc4566.tar.lz dexon-83a9a73b899e816a0d1493b7fb1e37abe4bc4566.tar.xz dexon-83a9a73b899e816a0d1493b7fb1e37abe4bc4566.tar.zst dexon-83a9a73b899e816a0d1493b7fb1e37abe4bc4566.zip |
cmd/geth, core, eth: implement Constantinople override flag (#18273)
* geth/core/eth: implement constantinople override flag
* les: implemnent constantinople override flag for les clients
* cmd/geth, eth, les: fix typo, move flag to experimentals
-rw-r--r-- | cmd/geth/config.go | 5 | ||||
-rw-r--r-- | cmd/geth/main.go | 1 | ||||
-rw-r--r-- | cmd/utils/flags.go | 6 | ||||
-rw-r--r-- | core/genesis.go | 6 | ||||
-rw-r--r-- | eth/backend.go | 2 | ||||
-rw-r--r-- | eth/config.go | 4 | ||||
-rw-r--r-- | les/backend.go | 2 |
7 files changed, 21 insertions, 5 deletions
diff --git a/cmd/geth/config.go b/cmd/geth/config.go index b0749d232..59f759f0e 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "io" + "math/big" "os" "reflect" "unicode" @@ -152,7 +153,9 @@ func enableWhisper(ctx *cli.Context) bool { func makeFullNode(ctx *cli.Context) *node.Node { stack, cfg := makeConfigNode(ctx) - + if ctx.GlobalIsSet(utils.ConstantinopleOverrideFlag.Name) { + cfg.Eth.ConstantinopleOverride = new(big.Int).SetUint64(ctx.GlobalUint64(utils.ConstantinopleOverrideFlag.Name)) + } utils.RegisterEthService(stack, &cfg.Eth) if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) { diff --git a/cmd/geth/main.go b/cmd/geth/main.go index fc1bf461f..ebaeba9f4 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -123,6 +123,7 @@ var ( utils.RinkebyFlag, utils.VMEnableDebugFlag, utils.NetworkIdFlag, + utils.ConstantinopleOverrideFlag, utils.RPCCORSDomainFlag, utils.RPCVirtualHostsFlag, utils.EthStatsURLFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c9115d7a3..60e45d095 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -140,6 +140,10 @@ var ( Name: "rinkeby", Usage: "Rinkeby network: pre-configured proof-of-authority test network", } + ConstantinopleOverrideFlag = cli.Uint64Flag{ + Name: "override.constantinople", + Usage: "Manually specify constantinople fork-block, overriding the bundled setting", + } DeveloperFlag = cli.BoolFlag{ Name: "dev", Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled", @@ -1178,7 +1182,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { if ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkId = ctx.GlobalUint64(NetworkIdFlag.Name) } - if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheDatabaseFlag.Name) { cfg.DatabaseCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheDatabaseFlag.Name) / 100 } @@ -1403,7 +1406,6 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database) { var err error chainDb = MakeChainDatabase(ctx, stack) - config, _, err := core.SetupGenesisBlock(chainDb, MakeGenesis(ctx)) if err != nil { Fatalf("%v", err) diff --git a/core/genesis.go b/core/genesis.go index 6e71afd61..c96cb17a3 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -151,6 +151,9 @@ func (e *GenesisMismatchError) Error() string { // // The returned chain configuration is never nil. func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig, common.Hash, error) { + return SetupGenesisBlockWithOverride(db, genesis, nil) +} +func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, constantinopleOverride *big.Int) (*params.ChainConfig, common.Hash, error) { if genesis != nil && genesis.Config == nil { return params.AllEthashProtocolChanges, common.Hash{}, errGenesisNoConfig } @@ -178,6 +181,9 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig // Get the existing chain configuration. newcfg := genesis.configOrDefault(stored) + if constantinopleOverride != nil { + newcfg.ConstantinopleBlock = constantinopleOverride + } storedcfg := rawdb.ReadChainConfig(db, stored) if storedcfg == nil { log.Warn("Found genesis block without chain config") diff --git a/eth/backend.go b/eth/backend.go index 3f538d5f5..354fc17d4 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -118,7 +118,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { if err != nil { return nil, err } - chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis) + chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.ConstantinopleOverride) if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok { return nil, genesisErr } diff --git a/eth/config.go b/eth/config.go index a5c209512..7c041d1af 100644 --- a/eth/config.go +++ b/eth/config.go @@ -129,8 +129,12 @@ type Config struct { // Type of the EWASM interpreter ("" for default) EWASMInterpreter string + // Type of the EVM interpreter ("" for default) EVMInterpreter string + + // Constantinople block override (TODO: remove after the fork) + ConstantinopleOverride *big.Int } type configMarshaling struct { diff --git a/les/backend.go b/les/backend.go index a3474a683..d0db71019 100644 --- a/les/backend.go +++ b/les/backend.go @@ -82,7 +82,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) { if err != nil { return nil, err } - chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis) + chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.ConstantinopleOverride) if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat { return nil, genesisErr } |