diff --git a/README.md b/README.md index 392dcc5b93..a1fb29cccc 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,9 @@ $ geth --help --miner.algotype value (default: "mev-geth") Block building algorithm to use [=mev-geth] (mev-geth, greedy) + + --miner.only_bundle_blocks (default: false) + Build only blocks with bundles --miner.blocklist value flashbots - Path to JSON file with list of blocked addresses. Miner will ignore diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 2c517fd4b9..2dcba5f2ab 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -131,6 +131,7 @@ var ( utils.MinerGasLimitFlag, utils.MinerGasPriceFlag, utils.MinerAlgoTypeFlag, + utils.MinerOnlyBlocksWithBundlesFlag, utils.MinerEtherbaseFlag, utils.MinerExtraDataFlag, utils.MinerRecommitIntervalFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 423a9ac1c6..13e1afdd7f 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -553,6 +553,11 @@ var ( Value: "mev-geth", Category: flags.MinerCategory, } + MinerOnlyBlocksWithBundlesFlag = &cli.BoolFlag{ + Name: "miner.only_bundle_blocks", + Usage: "Build only blocks with bundles", + Category: flags.MinerCategory, + } MinerEtherbaseFlag = &cli.StringFlag{ Name: "miner.etherbase", Usage: "Public address for block mining rewards (default = first account)", @@ -1813,6 +1818,9 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) { } cfg.AlgoType = algoType } + if ctx.IsSet(MinerOnlyBlocksWithBundlesFlag.Name) { + cfg.OnlyBlocksWithBundles = ctx.Bool(MinerOnlyBlocksWithBundlesFlag.Name) + } if ctx.IsSet(MinerRecommitIntervalFlag.Name) { cfg.Recommit = ctx.Duration(MinerRecommitIntervalFlag.Name) } diff --git a/miner/miner.go b/miner/miner.go index 4eb06a213d..2ac80703fe 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -67,19 +67,20 @@ func AlgoTypeFlagToEnum(algoString string) (AlgoType, error) { // Config is the configuration parameters of mining. type Config struct { - Etherbase common.Address `toml:",omitempty"` // Public address for block mining rewards (default = first account) - Notify []string `toml:",omitempty"` // HTTP URL list to be notified of new work packages (only useful in ethash). - NotifyFull bool `toml:",omitempty"` // Notify with pending block headers instead of work packages - ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner - GasFloor uint64 // Target gas floor for mined blocks. - GasCeil uint64 // Target gas ceiling for mined blocks. - GasPrice *big.Int // Minimum gas price for mining a transaction - AlgoType AlgoType // Algorithm to use for block building - Recommit time.Duration // The time interval for miner to re-create mining work. - Noverify bool // Disable remote mining solution verification(only useful in ethash). - BuilderTxSigningKey *ecdsa.PrivateKey // Signing key of builder coinbase to make transaction to validator - MaxMergedBundles int - Blocklist []common.Address `toml:",omitempty"` + Etherbase common.Address `toml:",omitempty"` // Public address for block mining rewards (default = first account) + Notify []string `toml:",omitempty"` // HTTP URL list to be notified of new work packages (only useful in ethash). + NotifyFull bool `toml:",omitempty"` // Notify with pending block headers instead of work packages + ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner + GasFloor uint64 // Target gas floor for mined blocks. + GasCeil uint64 // Target gas ceiling for mined blocks. + GasPrice *big.Int // Minimum gas price for mining a transaction + AlgoType AlgoType // Algorithm to use for block building + OnlyBlocksWithBundles bool // Build only blocks with bundles + Recommit time.Duration // The time interval for miner to re-create mining work. + Noverify bool // Disable remote mining solution verification(only useful in ethash). + BuilderTxSigningKey *ecdsa.PrivateKey // Signing key of builder coinbase to make transaction to validator + MaxMergedBundles int + Blocklist []common.Address `toml:",omitempty"` } // Miner creates blocks and searches for proof-of-work values. diff --git a/miner/worker.go b/miner/worker.go index fd22e5fc1c..c3c489cef0 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1338,6 +1338,9 @@ func (w *worker) fillTransactions(interrupt *int32, env *environment) (error, [] var allBundles []types.SimulatedBundle if w.flashbots.isFlashbots { bundles := w.eth.TxPool().MevBundles(env.header.Number, env.header.Time) + if w.config.OnlyBlocksWithBundles && len(bundles) == 0 { + return errors.New("no bundles included, skipping block building"), nil, nil + } var bundleTxs types.Transactions var resultingBundle simulatedBundle @@ -1405,6 +1408,9 @@ func (w *worker) getSimulatedBundles(env *environment) ([]types.SimulatedBundle, } bundles := w.eth.TxPool().MevBundles(env.header.Number, env.header.Time) + if w.config.OnlyBlocksWithBundles && len(bundles) == 0 { + return nil, errors.New("no bundles included, skipping block building") + } // TODO: consider interrupt simBundles, err := w.simulateBundles(env, bundles, nil) /* do not consider gas impact of mempool txs as bundles are treated as transactions wrt ordering */