From c3a5054c273687c8818ddbe94be44f076a6ae7f1 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Wed, 27 Apr 2022 11:45:14 +0200 Subject: [PATCH] cmd/utils: utilize beacon wrapper in makechain (#24620) * cmd/utils: utilize beacon wrapper in makechain * cmd/utils: fix fake-pow to also be wrapped in beacon * consensus/misc: correct error message --- cmd/utils/flags.go | 22 +++++----------------- consensus/misc/eip1559.go | 2 +- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 1fb48973244b..3652b3e35ab3 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -38,7 +38,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/fdlimit" "github.com/ethereum/go-ethereum/consensus" - "github.com/ethereum/go-ethereum/consensus/clique" "github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" @@ -1968,24 +1967,13 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai if err != nil { Fatalf("%v", err) } + var engine consensus.Engine - if config.Clique != nil { - engine = clique.New(config.Clique, chainDb) - } else { - engine = ethash.NewFaker() - if !ctx.GlobalBool(FakePoWFlag.Name) { - engine = ethash.New(ethash.Config{ - CacheDir: stack.ResolvePath(ethconfig.Defaults.Ethash.CacheDir), - CachesInMem: ethconfig.Defaults.Ethash.CachesInMem, - CachesOnDisk: ethconfig.Defaults.Ethash.CachesOnDisk, - CachesLockMmap: ethconfig.Defaults.Ethash.CachesLockMmap, - DatasetDir: stack.ResolvePath(ethconfig.Defaults.Ethash.DatasetDir), - DatasetsInMem: ethconfig.Defaults.Ethash.DatasetsInMem, - DatasetsOnDisk: ethconfig.Defaults.Ethash.DatasetsOnDisk, - DatasetsLockMmap: ethconfig.Defaults.Ethash.DatasetsLockMmap, - }, nil, false) - } + ethashConf := ethconfig.Defaults.Ethash + if ctx.GlobalBool(FakePoWFlag.Name) { + ethashConf.PowMode = ethash.ModeFake } + engine = ethconfig.CreateConsensusEngine(stack, config, ðashConf, nil, false, chainDb) if gcmode := ctx.GlobalString(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" { Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name) } diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index 8fca0fdc7092..e18340b0f33e 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -46,7 +46,7 @@ func VerifyEip1559Header(config *params.ChainConfig, parent, header *types.Heade expectedBaseFee := CalcBaseFee(config, parent) if header.BaseFee.Cmp(expectedBaseFee) != 0 { return fmt.Errorf("invalid baseFee: have %s, want %s, parentBaseFee %s, parentGasUsed %d", - expectedBaseFee, header.BaseFee, parent.BaseFee, parent.GasUsed) + header.BaseFee, expectedBaseFee, parent.BaseFee, parent.GasUsed) } return nil }