diff --git a/cmd/geth/config.go b/cmd/geth/config.go index fc1c5f78a5..36d9b068fa 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -255,6 +255,16 @@ func makeFullNode(ctx *cli.Context) *node.Node { } } + cfg.Eth.BlockingPrefetch = ctx.Bool(utils.BlockingPrefetchFlag.Name) + if ctx.IsSet(utils.PrefetchWorkersFlag.Name) { + prefetchWorkers := ctx.Uint(utils.PrefetchWorkersFlag.Name) + if prefetchWorkers == 0 { + prefetchWorkers = uint(runtime.NumCPU()) + log.Warn(fmt.Sprintf("invalid value for --bal.prefetchworkers. got 0. sanitizing to %d", prefetchWorkers)) + } + cfg.Eth.PrefetchWorkers = prefetchWorkers + } + // Start metrics export if enabled utils.SetupMetrics(&cfg.Metrics) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 56ec5b1541..9b865e584a 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -160,7 +160,7 @@ var ( utils.BeaconCheckpointFileFlag, utils.LogSlowBlockFlag, utils.PrefetchWorkersFlag, - utils.BlockingPrefetch, + utils.BlockingPrefetchFlag, }, utils.NetworkFlags, utils.DatabaseFlags) rpcFlags = []cli.Flag{ diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a1f15d52db..c5cbc39d56 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -721,7 +721,7 @@ var ( Category: flags.MiscCategory, } - BlockingPrefetch = &cli.BoolFlag{ + BlockingPrefetchFlag = &cli.BoolFlag{ Name: "bal.blockingprefetch", Usage: "only relevant when executing in parallel with a BAL: if true, the prefetcher will block tx/state-root calculation until all scheduled fetching tasks have completed.", Category: flags.MiscCategory, @@ -2474,7 +2474,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh NodeFullValueCheckpoint: uint32(ctx.Uint(TrienodeHistoryFullValueCheckpointFlag.Name)), PrefetchWorkers: int(ctx.Uint(PrefetchWorkersFlag.Name)), - BlockingPrefetch: ctx.Bool(BlockingPrefetch.Name), + BlockingPrefetch: ctx.Bool(BlockingPrefetchFlag.Name), // Disable transaction indexing/unindexing. TxLookupLimit: -1, diff --git a/eth/backend.go b/eth/backend.go index 51dc7ef2e0..c9993566be 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -282,6 +282,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { } options.Overrides = &overrides options.BALExecutionMode = config.BALExecutionMode + options.BlockingPrefetch = config.BlockingPrefetch + options.PrefetchWorkers = int(config.PrefetchWorkers) eth.blockchain, err = core.NewBlockChain(chainDb, config.Genesis, eth.engine, options) if err != nil { diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index e0b6c978e9..6fc951f95b 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -213,6 +213,8 @@ type Config struct { RangeLimit uint64 `toml:",omitempty"` BALExecutionMode bal.BALExecutionMode + PrefetchWorkers uint + BlockingPrefetch bool } // CreateConsensusEngine creates a consensus engine for the given chain config.