Skip to content

Commit

Permalink
Fix CLI issues (ethereum#92)
Browse files Browse the repository at this point in the history
* When miner.blocklist was not specified, it still tried to load empty file with the CLI flag, because Value was set to ""
* When builder.algotype was not specified, it still tried to load default value of mev-geth, overriding miner.algotype if specified
* SetBuilderConfig had a bug - cfg.Enabled was being set to whether or not BuilderEnabled was set. This was leading to incorrect behavior when --builder=false was set
* Fix BuilderBlockValidationBlacklistSourceFilePath referencing wrong flag for file load
* Add fixes for above issues
  • Loading branch information
Wazzymandias authored Aug 1, 2023
1 parent 893d4c8 commit 5c5ee0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 4 additions & 5 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,6 @@ var (
MinerBlocklistFileFlag = &cli.StringFlag{
Name: "miner.blocklist",
Usage: "[NOTE: Deprecated, please use builder.blacklist] flashbots - Path to JSON file with list of blocked addresses. Miner will ignore txs that touch mentioned addresses.",
Value: "",
Category: flags.MinerCategory,
}
MinerNewPayloadTimeout = &cli.DurationFlag{
Expand Down Expand Up @@ -705,7 +704,6 @@ var (
BuilderAlgoTypeFlag = &cli.StringFlag{
Name: "builder.algotype",
Usage: "Block building algorithm to use [=mev-geth] (mev-geth, greedy, greedy-buckets)",
Value: "mev-geth",
Category: flags.BuilderCategory,
}

Expand Down Expand Up @@ -734,7 +732,6 @@ var (
Usage: "Path to file containing blacklisted addresses, json-encoded list of strings. " +
"Builder will ignore transactions that touch mentioned addresses. This flag is also used for block validation API.\n" +
"NOTE: builder.validation_blacklist is deprecated and will be removed in the future in favor of builder.blacklist",
Value: "",
Aliases: []string{"builder.validation_blacklist"},
Category: flags.BuilderCategory,
}
Expand Down Expand Up @@ -1676,7 +1673,9 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {

// SetBuilderConfig applies node-related command line flags to the builder config.
func SetBuilderConfig(ctx *cli.Context, cfg *builder.Config) {
cfg.Enabled = ctx.IsSet(BuilderEnabled.Name)
if ctx.IsSet(BuilderEnabled.Name) {
cfg.Enabled = ctx.Bool(BuilderEnabled.Name)
}
cfg.EnableValidatorChecks = ctx.IsSet(BuilderEnableValidatorChecks.Name)
cfg.EnableLocalRelay = ctx.IsSet(BuilderEnableLocalRelay.Name)
cfg.SlotsInEpoch = ctx.Uint64(BuilderSlotsInEpoch.Name)
Expand Down Expand Up @@ -1944,7 +1943,7 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {

// NOTE: This flag takes precedence and will overwrite value set by MinerBlocklistFileFlag
if ctx.IsSet(BuilderBlockValidationBlacklistSourceFilePath.Name) {
bytes, err := os.ReadFile(ctx.String(MinerBlocklistFileFlag.Name))
bytes, err := os.ReadFile(ctx.String(BuilderBlockValidationBlacklistSourceFilePath.Name))
if err != nil {
Fatalf("Failed to read blocklist file: %s", err)
}
Expand Down
5 changes: 4 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
}

eth.miner = miner.New(eth, &config.Miner, eth.blockchain.Config(), eth.EventMux(), eth.engine, eth.isLocalBlock)
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
err = eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
if err != nil {
return nil, err
}

eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
if eth.APIBackend.allowUnprotectedTxs {
Expand Down

0 comments on commit 5c5ee0f

Please sign in to comment.