From ba743778ef6c36394e97fc2930b9b19323a4db7e Mon Sep 17 00:00:00 2001 From: Wasif Iqbal Date: Mon, 24 Jul 2023 17:57:24 -0500 Subject: [PATCH 1/6] Migrate miner.algotype and miner.price_cutoff_percent to builder.algotype and builder.price_cutoff_percent --- README.md | 12 +++++++++++ cmd/geth/main.go | 4 ++-- cmd/utils/flags.go | 51 +++++++++++++++++++++++++++------------------- 3 files changed, 44 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index c7d67376d3..f5b2908d4a 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,9 @@ $ geth --help --builder (default: false) Enable the builder + --builder.algotype value (default: "mev-geth") + Block building algorithm to use [=mev-geth] (mev-geth, greedy, greedy-buckets) + --builder.beacon_endpoints value (default: "http://127.0.0.1:5052") Comma separated list of beacon endpoints to connect to for beacon chain data [$BUILDER_BEACON_ENDPOINTS] @@ -74,6 +77,15 @@ $ geth --help --builder.no_bundle_fetcher (default: false) Disable the bundle fetcher + --builder.price_cutoff_percent value (default: 50) + flashbots - The minimum effective gas price threshold used for bucketing + transactions by price. For example if the top transaction in a list has an + effective gas price of 1000 wei and price_cutoff_percent is 10 (i.e. 10%), then + the minimum effective gas price included in the same bucket as the top + transaction is (1000 * 10%) = 100 wei. + NOTE: This flag is only used when + miner.algotype=greedy-buckets [$FLASHBOTS_BUILDER_PRICE_CUTOFF_PERCENT] + --builder.rate_limit_duration value (default: "500ms") Determines rate limit of events processed by builder. For example, a value of "500ms" denotes that the builder processes events every 500ms. A duration string diff --git a/cmd/geth/main.go b/cmd/geth/main.go index cd4a004680..c6e9b1e888 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -125,7 +125,6 @@ var ( utils.MinerNotifyFlag, utils.MinerGasLimitFlag, utils.MinerGasPriceFlag, - utils.MinerAlgoTypeFlag, utils.MinerEtherbaseFlag, utils.MinerExtraDataFlag, utils.MinerRecommitIntervalFlag, @@ -133,7 +132,6 @@ var ( utils.MinerMaxMergedBundlesFlag, utils.MinerBlocklistFileFlag, utils.MinerNewPayloadTimeout, - utils.MinerPriceCutoffPercentFlag, utils.NATFlag, utils.NoDiscoverFlag, utils.DiscoveryV5Flag, @@ -159,6 +157,8 @@ var ( builderApiFlags = []cli.Flag{ utils.BuilderEnabled, + utils.BuilderAlgoTypeFlag, + utils.BuilderPriceCutoffPercentFlag, utils.BuilderEnableValidatorChecks, utils.BuilderBlockValidationBlacklistSourceFilePath, utils.BuilderEnableLocalRelay, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 248c20ff61..28a8c2fe36 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -546,12 +546,6 @@ var ( Value: ethconfig.Defaults.Miner.GasPrice, Category: flags.MinerCategory, } - MinerAlgoTypeFlag = &cli.StringFlag{ - Name: "miner.algotype", - Usage: "Block building algorithm to use [=mev-geth] (mev-geth, greedy, greedy-buckets)", - Value: "mev-geth", - Category: flags.MinerCategory, - } MinerEtherbaseFlag = &cli.StringFlag{ Name: "miner.etherbase", Usage: "0x prefixed public address for block mining rewards", @@ -591,17 +585,6 @@ var ( Value: ethconfig.Defaults.Miner.NewPayloadTimeout, Category: flags.MinerCategory, } - MinerPriceCutoffPercentFlag = &cli.IntFlag{ - Name: "miner.price_cutoff_percent", - Usage: "flashbots - The minimum effective gas price threshold used for bucketing transactions by price. " + - "For example if the top transaction in a list has an effective gas price of 1000 wei and price_cutoff_percent " + - "is 10 (i.e. 10%), then the minimum effective gas price included in the same bucket as the top transaction " + - "is (1000 * 10%) = 100 wei.\n" + - "NOTE: This flag is only used when miner.algotype=greedy-buckets", - Value: ethconfig.Defaults.Miner.PriceCutoffPercent, - Category: flags.MinerCategory, - EnvVars: []string{"FLASHBOTS_MINER_PRICE_CUTOFF_PERCENT"}, - } // Account settings UnlockedAccountFlag = &cli.StringFlag{ @@ -709,6 +692,32 @@ var ( Usage: "Enable the builder", Category: flags.BuilderCategory, } + + // BuilderAlgoTypeFlag replaces MinerAlgoTypeFlag to move away from deprecated miner package + // Note: builder.algotype was previously miner.algotype - this flag is still propagated to the miner configuration, + // see setMiner in cmd/utils/flags.go + 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, + } + + // BuilderPriceCutoffPercentFlag replaces MinerPriceCutoffPercentFlag to move away from deprecated miner package + // Note: builder.price_cutoff_percent was previously miner.price_cutoff_percent - + // this flag is still propagated to the miner configuration, see setMiner in cmd/utils/flags.go + BuilderPriceCutoffPercentFlag = &cli.IntFlag{ + Name: "builder.price_cutoff_percent", + Usage: "flashbots - The minimum effective gas price threshold used for bucketing transactions by price. " + + "For example if the top transaction in a list has an effective gas price of 1000 wei and price_cutoff_percent " + + "is 10 (i.e. 10%), then the minimum effective gas price included in the same bucket as the top transaction " + + "is (1000 * 10%) = 100 wei.\n" + + "NOTE: This flag is only used when miner.algotype=greedy-buckets", + Value: ethconfig.Defaults.Miner.PriceCutoffPercent, + Category: flags.BuilderCategory, + EnvVars: []string{"FLASHBOTS_BUILDER_PRICE_CUTOFF_PERCENT"}, + } + BuilderEnableValidatorChecks = &cli.BoolFlag{ Name: "builder.validator_checks", Usage: "Enable the validator checks", @@ -1876,10 +1885,10 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) { if ctx.IsSet(MinerGasPriceFlag.Name) { cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name) } - if ctx.IsSet(MinerAlgoTypeFlag.Name) { - algoType, err := miner.AlgoTypeFlagToEnum(ctx.String(MinerAlgoTypeFlag.Name)) + if ctx.IsSet(BuilderAlgoTypeFlag.Name) { + algoType, err := miner.AlgoTypeFlagToEnum(ctx.String(BuilderAlgoTypeFlag.Name)) if err != nil { - Fatalf("Invalid algo in --miner.algotype: %s", ctx.String(MinerAlgoTypeFlag.Name)) + Fatalf("Invalid algo in --builder.algotype: %s", ctx.String(BuilderAlgoTypeFlag.Name)) } cfg.AlgoType = algoType } @@ -1906,7 +1915,7 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) { } } - cfg.PriceCutoffPercent = ctx.Int(MinerPriceCutoffPercentFlag.Name) + cfg.PriceCutoffPercent = ctx.Int(BuilderPriceCutoffPercentFlag.Name) } func setRequiredBlocks(ctx *cli.Context, cfg *ethconfig.Config) { From b877c1cc3fcabd95ea861048a8c54b448e098dd1 Mon Sep 17 00:00:00 2001 From: Wasif Iqbal Date: Mon, 24 Jul 2023 22:15:48 -0500 Subject: [PATCH 2/6] Update README.md Co-authored-by: shana --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f5b2908d4a..39ecd97c79 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ $ geth --help the minimum effective gas price included in the same bucket as the top transaction is (1000 * 10%) = 100 wei. NOTE: This flag is only used when - miner.algotype=greedy-buckets [$FLASHBOTS_BUILDER_PRICE_CUTOFF_PERCENT] + builder.algotype=greedy-buckets [$FLASHBOTS_BUILDER_PRICE_CUTOFF_PERCENT] --builder.rate_limit_duration value (default: "500ms") Determines rate limit of events processed by builder. For example, a value of From 9eb4c61b059624342b46ec6fff9a8dd5db653ab4 Mon Sep 17 00:00:00 2001 From: Wasif Iqbal Date: Mon, 24 Jul 2023 22:15:55 -0500 Subject: [PATCH 3/6] Update cmd/utils/flags.go Co-authored-by: shana --- cmd/utils/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 28a8c2fe36..2cde755fe3 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -712,7 +712,7 @@ var ( "For example if the top transaction in a list has an effective gas price of 1000 wei and price_cutoff_percent " + "is 10 (i.e. 10%), then the minimum effective gas price included in the same bucket as the top transaction " + "is (1000 * 10%) = 100 wei.\n" + - "NOTE: This flag is only used when miner.algotype=greedy-buckets", + "NOTE: This flag is only used when builder.algotype=greedy-buckets", Value: ethconfig.Defaults.Miner.PriceCutoffPercent, Category: flags.BuilderCategory, EnvVars: []string{"FLASHBOTS_BUILDER_PRICE_CUTOFF_PERCENT"}, From c862c2913d066011cdda789bf267a32f70fa5e29 Mon Sep 17 00:00:00 2001 From: Wasif Iqbal Date: Thu, 27 Jul 2023 18:44:28 -0500 Subject: [PATCH 4/6] Add back original flags with deprecation notice for backwards compatibility, rename builder.validation_blacklist to builder.blacklist --- README.md | 18 ++++++++++-------- cmd/geth/main.go | 1 + cmd/utils/flags.go | 45 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 39ecd97c79..553ef59ccd 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,10 @@ $ geth --help --builder.bellatrix_fork_version value (default: "0x02000000") Bellatrix fork version. [$BUILDER_BELLATRIX_FORK_VERSION] + --builder.blacklist value + Path to file containing blacklisted addresses, json-encoded list of strings. + Builder will ignore transactions that touch mentioned addresses. + --builder.block_resubmit_interval value (default: "500ms") Determines the interval at which builder will resubmit block submissions [$FLASHBOTS_BUILDER_RATE_LIMIT_RESUBMIT_INTERVAL] @@ -123,21 +127,19 @@ $ geth --help blocks. For example, if a slot is 12 seconds long, and the offset is 2 seconds, the builder will submit blocks at 10 seconds into the slot. [$FLASHBOTS_BUILDER_SUBMISSION_OFFSET] - - --builder.validation_blacklist value - Path to file containing blacklisted addresses, json-encoded list of strings - + --builder.validator_checks (default: false) Enable the validator checks MINER --miner.algotype value (default: "mev-geth") - Block building algorithm to use [=mev-geth] (mev-geth, greedy, greedy-buckets) + [NOTE: Deprecated, please use builder.algotype instead] Block building algorithm + to use [=mev-geth] (mev-geth, greedy, greedy-buckets) - --miner.blocklist value - flashbots - Path to JSON file with list of blocked addresses. Miner will ignore - txs that touch mentioned addresses. + --miner.blocklist value + [NOTE: Deprecated, please use builder.blacklist] flashbots - Path to JSON file with + list of blocked addresses. Miner will ignore txs that touch mentioned addresses. --miner.extradata value Block extra data set by the miner (default = client version) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index c6e9b1e888..927aaf0436 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -125,6 +125,7 @@ var ( utils.MinerNotifyFlag, utils.MinerGasLimitFlag, utils.MinerGasPriceFlag, + utils.MinerAlgoTypeFlag, utils.MinerEtherbaseFlag, utils.MinerExtraDataFlag, utils.MinerRecommitIntervalFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2cde755fe3..79bf678731 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -546,6 +546,12 @@ var ( Value: ethconfig.Defaults.Miner.GasPrice, Category: flags.MinerCategory, } + MinerAlgoTypeFlag = &cli.StringFlag{ + Name: "miner.algotype", + Usage: "[NOTE: Deprecated, please use builder.algotype instead] Block building algorithm to use [=mev-geth] (mev-geth, greedy, greedy-buckets)", + Value: "mev-geth", + Category: flags.MinerCategory, + } MinerEtherbaseFlag = &cli.StringFlag{ Name: "miner.etherbase", Usage: "0x prefixed public address for block mining rewards", @@ -575,7 +581,7 @@ var ( } MinerBlocklistFileFlag = &cli.StringFlag{ Name: "miner.blocklist", - Usage: "flashbots - Path to JSON file with list of blocked addresses. Miner will ignore txs that touch mentioned addresses.", + 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, } @@ -724,8 +730,9 @@ var ( Category: flags.BuilderCategory, } BuilderBlockValidationBlacklistSourceFilePath = &cli.StringFlag{ - Name: "builder.validation_blacklist", - Usage: "Path to file containing blacklisted addresses, json-encoded list of strings", + Name: "builder.blacklist", + Usage: "Path to file containing blacklisted addresses, json-encoded list of strings. " + + "Builder will ignore transactions that touch mentioned addresses.", Value: "", Category: flags.BuilderCategory, } @@ -1684,7 +1691,15 @@ func SetBuilderConfig(ctx *cli.Context, cfg *builder.Config) { cfg.BeaconEndpoints = strings.Split(ctx.String(BuilderBeaconEndpoints.Name), ",") cfg.RemoteRelayEndpoint = ctx.String(BuilderRemoteRelayEndpoint.Name) cfg.SecondaryRemoteRelayEndpoints = strings.Split(ctx.String(BuilderSecondaryRemoteRelayEndpoints.Name), ",") - cfg.ValidationBlocklist = ctx.String(BuilderBlockValidationBlacklistSourceFilePath.Name) + // NOTE: This flag is deprecated and will be removed in the future in favor of BuilderBlockValidationBlacklistSourceFilePath + if ctx.IsSet(MinerBlocklistFileFlag.Name) { + cfg.ValidationBlocklist = ctx.String(MinerBlocklistFileFlag.Name) + } + + // NOTE: This flag takes precedence and will overwrite value set by MinerBlocklistFileFlag + if ctx.IsSet(BuilderBlockValidationBlacklistSourceFilePath.Name) { + cfg.ValidationBlocklist = ctx.String(BuilderBlockValidationBlacklistSourceFilePath.Name) + } cfg.BuilderRateLimitDuration = ctx.String(BuilderRateLimitDuration.Name) cfg.BuilderRateLimitMaxBurst = ctx.Int(BuilderRateLimitMaxBurst.Name) cfg.BuilderSubmissionOffset = ctx.Duration(BuilderSubmissionOffset.Name) @@ -1885,6 +1900,15 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) { if ctx.IsSet(MinerGasPriceFlag.Name) { cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name) } + // NOTE: This flag is deprecated and will be removed in the future. + if ctx.IsSet(MinerAlgoTypeFlag.Name) { + algoType, err := miner.AlgoTypeFlagToEnum(ctx.String(BuilderAlgoTypeFlag.Name)) + if err != nil { + Fatalf("Invalid algo in --builder.algotype: %s", ctx.String(BuilderAlgoTypeFlag.Name)) + } + cfg.AlgoType = algoType + } + // NOTE: BuilderAlgoTypeFlag takes precedence and will overwrite value set by MinerAlgoTypeFlag. if ctx.IsSet(BuilderAlgoTypeFlag.Name) { algoType, err := miner.AlgoTypeFlagToEnum(ctx.String(BuilderAlgoTypeFlag.Name)) if err != nil { @@ -1904,6 +1928,7 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) { cfg.MaxMergedBundles = ctx.Int(MinerMaxMergedBundlesFlag.Name) + // NOTE: This flag is deprecated and will be removed in the future in favor of BuilderBlockValidationBlacklistSourceFilePath if ctx.IsSet(MinerBlocklistFileFlag.Name) { bytes, err := os.ReadFile(ctx.String(MinerBlocklistFileFlag.Name)) if err != nil { @@ -1915,6 +1940,18 @@ 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)) + if err != nil { + Fatalf("Failed to read blocklist file: %s", err) + } + + if err := json.Unmarshal(bytes, &cfg.Blocklist); err != nil { + Fatalf("Failed to parse blocklist: %s", err) + } + } + cfg.PriceCutoffPercent = ctx.Int(BuilderPriceCutoffPercentFlag.Name) } From dda1465465e8707e26673864f8fd9402c14e606f Mon Sep 17 00:00:00 2001 From: Wasif Iqbal Date: Thu, 27 Jul 2023 18:52:01 -0500 Subject: [PATCH 5/6] Update error message --- cmd/utils/flags.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 79bf678731..51b1465774 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1904,7 +1904,7 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) { if ctx.IsSet(MinerAlgoTypeFlag.Name) { algoType, err := miner.AlgoTypeFlagToEnum(ctx.String(BuilderAlgoTypeFlag.Name)) if err != nil { - Fatalf("Invalid algo in --builder.algotype: %s", ctx.String(BuilderAlgoTypeFlag.Name)) + Fatalf("Invalid algo in --miner.algotype: %s", ctx.String(BuilderAlgoTypeFlag.Name)) } cfg.AlgoType = algoType } From 564dfbbf628c5adba59db61974fa65ab4745ff7c Mon Sep 17 00:00:00 2001 From: Wasif Iqbal Date: Fri, 28 Jul 2023 15:13:10 -0500 Subject: [PATCH 6/6] Add back flag for backwards compatibility, update README --- README.md | 5 ++--- cmd/utils/flags.go | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 553ef59ccd..399798f425 100644 --- a/README.md +++ b/README.md @@ -183,8 +183,7 @@ See the [metrics docs](https://geth.ethereum.org/docs/monitoring/metrics) for ge If you want to reject transactions interacting with certain addresses, save the addresses in json file with an array of strings. Deciding whether to use such a list, as well as maintaining it, is your own responsibility. -- for block building, use `--miner.blocklist` -- for validation, use `--builder.validation_blacklist` +- for block building and validation, use `--builder.blacklist` -- @@ -234,7 +233,7 @@ Miner is responsible for block creation. Request from the `builder` is routed to * `algo_greedy.go` implements logic of the block building. Bundles and transactions are sorted in the order of effective gas price then we try to insert everything into to block until gas limit is reached. Failing bundles are reverted during the insertion but txs are not. * Builder can filter transactions touching a particular set of addresses. - If a bundle or transaction touches one of the addresses it is skipped. (see `--miner.blocklist` flag) + If a bundle or transaction touches one of the addresses it is skipped. (see `--builder.blacklist` flag) ## Bundle Movement diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 51b1465774..9e1bd014eb 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -732,8 +732,10 @@ var ( BuilderBlockValidationBlacklistSourceFilePath = &cli.StringFlag{ Name: "builder.blacklist", Usage: "Path to file containing blacklisted addresses, json-encoded list of strings. " + - "Builder will ignore transactions that touch mentioned addresses.", + "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, } BuilderEnableLocalRelay = &cli.BoolFlag{