Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ var (
utils.MinerGasLimitFlag,
utils.MinerGasPriceFlag,
utils.MinerAlgoTypeFlag,
utils.MinerOnlyBlocksWithBundlesFlag,
utils.MinerEtherbaseFlag,
utils.MinerExtraDataFlag,
utils.MinerRecommitIntervalFlag,
Expand Down
8 changes: 8 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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)
}
Expand Down
27 changes: 14 additions & 13 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down