Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Pass discard flag to miner from builder, revertible transaction gas used #95

Merged
merged 1 commit into from
Aug 9, 2023
Merged
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
1 change: 1 addition & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,7 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
}
}

cfg.DiscardRevertibleTxOnErr = ctx.Bool(BuilderDiscardRevertibleTxOnErr.Name)
cfg.PriceCutoffPercent = ctx.Int(BuilderPriceCutoffPercentFlag.Name)
}

Expand Down
8 changes: 7 additions & 1 deletion miner/algo_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,13 @@ func (envDiff *environmentDiff) commitBundle(bundle *types.SimulatedBundle, chDa
bundleProfit := coinbaseBalanceDelta

gasUsedBigInt := new(big.Int).SetUint64(gasUsed)
bundleActualEffGP := bundleProfit.Div(bundleProfit, gasUsedBigInt)

var bundleActualEffGP *big.Int
if gasUsed == 0 {
bundleActualEffGP = big.NewInt(0)
} else {
bundleActualEffGP = bundleProfit.Div(bundleProfit, gasUsedBigInt)
}
bundleSimEffGP := new(big.Int).Set(bundle.MevGasPrice)

// allow >-1% divergence
Expand Down
31 changes: 16 additions & 15 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,22 @@ 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 `toml:",omitempty"` // Signing key of builder coinbase to make transaction to validator
MaxMergedBundles int
Blocklist []common.Address `toml:",omitempty"`
NewPayloadTimeout time.Duration // The maximum time allowance for creating a new payload
PriceCutoffPercent int // Effective gas price cutoff % used for bucketing transactions by price (only useful in greedy-buckets AlgoType)
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 `toml:",omitempty"` // Signing key of builder coinbase to make transaction to validator
MaxMergedBundles int
Blocklist []common.Address `toml:",omitempty"`
NewPayloadTimeout time.Duration // The maximum time allowance for creating a new payload
DiscardRevertibleTxOnErr bool // Whether to discard revertible transactions on error
PriceCutoffPercent int // Effective gas price cutoff % used for bucketing transactions by price (only useful in greedy-buckets AlgoType)
}

// DefaultConfig contains default settings for miner.
Expand Down
11 changes: 5 additions & 6 deletions miner/multi_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,9 @@ func newMultiWorkerMevGeth(config *Config, chainConfig *params.ChainConfig, engi
}

type flashbotsData struct {
isFlashbots bool
queue chan *task
maxMergedBundles int
algoType AlgoType
bundleCache *BundleCache
discardRevertedHashes bool
isFlashbots bool
queue chan *task
maxMergedBundles int
algoType AlgoType
bundleCache *BundleCache
}
4 changes: 2 additions & 2 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ func (w *worker) fillTransactionsAlgoWorker(interrupt *int32, env *environment)
}

algoConf := &algorithmConfig{
DropRevertibleTxOnErr: w.flashbots.discardRevertedHashes,
DropRevertibleTxOnErr: w.config.DiscardRevertibleTxOnErr,
EnforceProfit: true,
ProfitThresholdPercent: defaultProfitThresholdPercent,
PriceCutoffPercent: priceCutoffPercent,
Expand All @@ -1426,7 +1426,7 @@ func (w *worker) fillTransactionsAlgoWorker(interrupt *int32, env *environment)
// For default greedy builder, set algorithm configuration to default values,
// except DropRevertibleTxOnErr which is passed in from worker config
algoConf := &algorithmConfig{
DropRevertibleTxOnErr: w.flashbots.discardRevertedHashes,
DropRevertibleTxOnErr: w.config.DiscardRevertibleTxOnErr,
EnforceProfit: defaultAlgorithmConfig.EnforceProfit,
ProfitThresholdPercent: defaultAlgorithmConfig.ProfitThresholdPercent,
}
Expand Down
Loading