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

Commit e82869c

Browse files
committed
Merge remote-tracking branch 'origin/main' into bundle-tx-discard
2 parents 4ca2566 + 5c5ee0f commit e82869c

File tree

5 files changed

+102
-37
lines changed

5 files changed

+102
-37
lines changed

README.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,20 @@ $ geth --help
3838
--builder (default: false)
3939
Enable the builder
4040
41+
--builder.algotype value (default: "mev-geth")
42+
Block building algorithm to use [=mev-geth] (mev-geth, greedy, greedy-buckets)
43+
4144
--builder.beacon_endpoints value (default: "http://127.0.0.1:5052")
4245
Comma separated list of beacon endpoints to connect to for beacon chain data
4346
[$BUILDER_BEACON_ENDPOINTS]
4447
4548
--builder.bellatrix_fork_version value (default: "0x02000000")
4649
Bellatrix fork version. [$BUILDER_BELLATRIX_FORK_VERSION]
4750
51+
--builder.blacklist value
52+
Path to file containing blacklisted addresses, json-encoded list of strings.
53+
Builder will ignore transactions that touch mentioned addresses.
54+
4855
--builder.block_resubmit_interval value (default: "500ms")
4956
Determines the interval at which builder will resubmit block submissions
5057
[$FLASHBOTS_BUILDER_RATE_LIMIT_RESUBMIT_INTERVAL]
@@ -83,6 +90,15 @@ $ geth --help
8390
--builder.no_bundle_fetcher (default: false)
8491
Disable the bundle fetcher
8592
93+
--builder.price_cutoff_percent value (default: 50)
94+
flashbots - The minimum effective gas price threshold used for bucketing
95+
transactions by price. For example if the top transaction in a list has an
96+
effective gas price of 1000 wei and price_cutoff_percent is 10 (i.e. 10%), then
97+
the minimum effective gas price included in the same bucket as the top
98+
transaction is (1000 * 10%) = 100 wei.
99+
NOTE: This flag is only used when
100+
builder.algotype=greedy-buckets [$FLASHBOTS_BUILDER_PRICE_CUTOFF_PERCENT]
101+
86102
--builder.rate_limit_duration value (default: "500ms")
87103
Determines rate limit of events processed by builder. For example, a value of
88104
"500ms" denotes that the builder processes events every 500ms. A duration string
@@ -120,21 +136,19 @@ $ geth --help
120136
blocks. For example, if a slot is 12 seconds long, and the offset is 2 seconds,
121137
the builder will submit blocks at 10 seconds into the slot.
122138
[$FLASHBOTS_BUILDER_SUBMISSION_OFFSET]
123-
124-
--builder.validation_blacklist value
125-
Path to file containing blacklisted addresses, json-encoded list of strings
126-
139+
127140
--builder.validator_checks (default: false)
128141
Enable the validator checks
129142
130143
MINER
131144
132145
--miner.algotype value (default: "mev-geth")
133-
Block building algorithm to use [=mev-geth] (mev-geth, greedy)
146+
[NOTE: Deprecated, please use builder.algotype instead] Block building algorithm
147+
to use [=mev-geth] (mev-geth, greedy, greedy-buckets)
134148
135-
--miner.blocklist value
136-
flashbots - Path to JSON file with list of blocked addresses. Miner will ignore
137-
txs that touch mentioned addresses.
149+
--miner.blocklist value
150+
[NOTE: Deprecated, please use builder.blacklist] flashbots - Path to JSON file with
151+
list of blocked addresses. Miner will ignore txs that touch mentioned addresses.
138152
139153
--miner.extradata value
140154
Block extra data set by the miner (default = client version)
@@ -178,8 +192,7 @@ See the [metrics docs](https://geth.ethereum.org/docs/monitoring/metrics) for ge
178192

179193
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.
180194

181-
- for block building, use `--miner.blocklist`
182-
- for validation, use `--builder.validation_blacklist`
195+
- for block building and validation, use `--builder.blacklist`
183196

184197
--
185198

@@ -229,7 +242,7 @@ Miner is responsible for block creation. Request from the `builder` is routed to
229242
* `algo_greedy.go` implements logic of the block building. Bundles and transactions are sorted in the order of effective gas price then
230243
we try to insert everything into to block until gas limit is reached. Failing bundles are reverted during the insertion but txs are not.
231244
* Builder can filter transactions touching a particular set of addresses.
232-
If a bundle or transaction touches one of the addresses it is skipped. (see `--miner.blocklist` flag)
245+
If a bundle or transaction touches one of the addresses it is skipped. (see `--builder.blacklist` flag)
233246

234247
## Bundle Movement
235248

cmd/geth/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ var (
133133
utils.MinerMaxMergedBundlesFlag,
134134
utils.MinerBlocklistFileFlag,
135135
utils.MinerNewPayloadTimeout,
136-
utils.MinerPriceCutoffPercentFlag,
137136
utils.NATFlag,
138137
utils.NoDiscoverFlag,
139138
utils.DiscoveryV5Flag,
@@ -159,6 +158,8 @@ var (
159158

160159
builderApiFlags = []cli.Flag{
161160
utils.BuilderEnabled,
161+
utils.BuilderAlgoTypeFlag,
162+
utils.BuilderPriceCutoffPercentFlag,
162163
utils.BuilderEnableValidatorChecks,
163164
utils.BuilderBlockValidationBlacklistSourceFilePath,
164165
utils.BuilderEnableLocalRelay,

cmd/utils/flags.go

Lines changed: 70 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ var (
548548
}
549549
MinerAlgoTypeFlag = &cli.StringFlag{
550550
Name: "miner.algotype",
551-
Usage: "Block building algorithm to use [=mev-geth] (mev-geth, greedy, greedy-buckets)",
551+
Usage: "[NOTE: Deprecated, please use builder.algotype instead] Block building algorithm to use [=mev-geth] (mev-geth, greedy, greedy-buckets)",
552552
Value: "mev-geth",
553553
Category: flags.MinerCategory,
554554
}
@@ -581,8 +581,7 @@ var (
581581
}
582582
MinerBlocklistFileFlag = &cli.StringFlag{
583583
Name: "miner.blocklist",
584-
Usage: "flashbots - Path to JSON file with list of blocked addresses. Miner will ignore txs that touch mentioned addresses.",
585-
Value: "",
584+
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.",
586585
Category: flags.MinerCategory,
587586
}
588587
MinerNewPayloadTimeout = &cli.DurationFlag{
@@ -591,17 +590,6 @@ var (
591590
Value: ethconfig.Defaults.Miner.NewPayloadTimeout,
592591
Category: flags.MinerCategory,
593592
}
594-
MinerPriceCutoffPercentFlag = &cli.IntFlag{
595-
Name: "miner.price_cutoff_percent",
596-
Usage: "flashbots - The minimum effective gas price threshold used for bucketing transactions by price. " +
597-
"For example if the top transaction in a list has an effective gas price of 1000 wei and price_cutoff_percent " +
598-
"is 10 (i.e. 10%), then the minimum effective gas price included in the same bucket as the top transaction " +
599-
"is (1000 * 10%) = 100 wei.\n" +
600-
"NOTE: This flag is only used when miner.algotype=greedy-buckets",
601-
Value: ethconfig.Defaults.Miner.PriceCutoffPercent,
602-
Category: flags.MinerCategory,
603-
EnvVars: []string{"FLASHBOTS_MINER_PRICE_CUTOFF_PERCENT"},
604-
}
605593

606594
// Account settings
607595
UnlockedAccountFlag = &cli.StringFlag{
@@ -709,15 +697,42 @@ var (
709697
Usage: "Enable the builder",
710698
Category: flags.BuilderCategory,
711699
}
700+
701+
// BuilderAlgoTypeFlag replaces MinerAlgoTypeFlag to move away from deprecated miner package
702+
// Note: builder.algotype was previously miner.algotype - this flag is still propagated to the miner configuration,
703+
// see setMiner in cmd/utils/flags.go
704+
BuilderAlgoTypeFlag = &cli.StringFlag{
705+
Name: "builder.algotype",
706+
Usage: "Block building algorithm to use [=mev-geth] (mev-geth, greedy, greedy-buckets)",
707+
Category: flags.BuilderCategory,
708+
}
709+
710+
// BuilderPriceCutoffPercentFlag replaces MinerPriceCutoffPercentFlag to move away from deprecated miner package
711+
// Note: builder.price_cutoff_percent was previously miner.price_cutoff_percent -
712+
// this flag is still propagated to the miner configuration, see setMiner in cmd/utils/flags.go
713+
BuilderPriceCutoffPercentFlag = &cli.IntFlag{
714+
Name: "builder.price_cutoff_percent",
715+
Usage: "flashbots - The minimum effective gas price threshold used for bucketing transactions by price. " +
716+
"For example if the top transaction in a list has an effective gas price of 1000 wei and price_cutoff_percent " +
717+
"is 10 (i.e. 10%), then the minimum effective gas price included in the same bucket as the top transaction " +
718+
"is (1000 * 10%) = 100 wei.\n" +
719+
"NOTE: This flag is only used when builder.algotype=greedy-buckets",
720+
Value: ethconfig.Defaults.Miner.PriceCutoffPercent,
721+
Category: flags.BuilderCategory,
722+
EnvVars: []string{"FLASHBOTS_BUILDER_PRICE_CUTOFF_PERCENT"},
723+
}
724+
712725
BuilderEnableValidatorChecks = &cli.BoolFlag{
713726
Name: "builder.validator_checks",
714727
Usage: "Enable the validator checks",
715728
Category: flags.BuilderCategory,
716729
}
717730
BuilderBlockValidationBlacklistSourceFilePath = &cli.StringFlag{
718-
Name: "builder.validation_blacklist",
719-
Usage: "Path to file containing blacklisted addresses, json-encoded list of strings",
720-
Value: "",
731+
Name: "builder.blacklist",
732+
Usage: "Path to file containing blacklisted addresses, json-encoded list of strings. " +
733+
"Builder will ignore transactions that touch mentioned addresses. This flag is also used for block validation API.\n" +
734+
"NOTE: builder.validation_blacklist is deprecated and will be removed in the future in favor of builder.blacklist",
735+
Aliases: []string{"builder.validation_blacklist"},
721736
Category: flags.BuilderCategory,
722737
}
723738
BuilderEnableLocalRelay = &cli.BoolFlag{
@@ -1667,7 +1682,9 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
16671682

16681683
// SetBuilderConfig applies node-related command line flags to the builder config.
16691684
func SetBuilderConfig(ctx *cli.Context, cfg *builder.Config) {
1670-
cfg.Enabled = ctx.IsSet(BuilderEnabled.Name)
1685+
if ctx.IsSet(BuilderEnabled.Name) {
1686+
cfg.Enabled = ctx.Bool(BuilderEnabled.Name)
1687+
}
16711688
cfg.EnableValidatorChecks = ctx.IsSet(BuilderEnableValidatorChecks.Name)
16721689
cfg.EnableLocalRelay = ctx.IsSet(BuilderEnableLocalRelay.Name)
16731690
cfg.SlotsInEpoch = ctx.Uint64(BuilderSlotsInEpoch.Name)
@@ -1684,12 +1701,21 @@ func SetBuilderConfig(ctx *cli.Context, cfg *builder.Config) {
16841701
cfg.BeaconEndpoints = strings.Split(ctx.String(BuilderBeaconEndpoints.Name), ",")
16851702
cfg.RemoteRelayEndpoint = ctx.String(BuilderRemoteRelayEndpoint.Name)
16861703
cfg.SecondaryRemoteRelayEndpoints = strings.Split(ctx.String(BuilderSecondaryRemoteRelayEndpoints.Name), ",")
1687-
cfg.ValidationBlocklist = ctx.String(BuilderBlockValidationBlacklistSourceFilePath.Name)
1704+
// NOTE: This flag is deprecated and will be removed in the future in favor of BuilderBlockValidationBlacklistSourceFilePath
1705+
if ctx.IsSet(MinerBlocklistFileFlag.Name) {
1706+
cfg.ValidationBlocklist = ctx.String(MinerBlocklistFileFlag.Name)
1707+
}
1708+
1709+
// NOTE: This flag takes precedence and will overwrite value set by MinerBlocklistFileFlag
1710+
if ctx.IsSet(BuilderBlockValidationBlacklistSourceFilePath.Name) {
1711+
cfg.ValidationBlocklist = ctx.String(BuilderBlockValidationBlacklistSourceFilePath.Name)
1712+
}
16881713
cfg.BuilderRateLimitDuration = ctx.String(BuilderRateLimitDuration.Name)
16891714
cfg.BuilderRateLimitMaxBurst = ctx.Int(BuilderRateLimitMaxBurst.Name)
16901715
cfg.BuilderSubmissionOffset = ctx.Duration(BuilderSubmissionOffset.Name)
16911716
cfg.DiscardRevertibleTxOnErr = ctx.Bool(BuilderDiscardRevertibleTxOnErr.Name)
16921717
cfg.EnableCancellations = ctx.IsSet(BuilderEnableCancellations.Name)
1718+
cfg.BuilderRateLimitResubmitInterval = ctx.String(BuilderBlockResubmitInterval.Name)
16931719
}
16941720

16951721
// SetNodeConfig applies node-related command line flags to the config.
@@ -1885,10 +1911,19 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
18851911
if ctx.IsSet(MinerGasPriceFlag.Name) {
18861912
cfg.GasPrice = flags.GlobalBig(ctx, MinerGasPriceFlag.Name)
18871913
}
1914+
// NOTE: This flag is deprecated and will be removed in the future.
18881915
if ctx.IsSet(MinerAlgoTypeFlag.Name) {
1889-
algoType, err := miner.AlgoTypeFlagToEnum(ctx.String(MinerAlgoTypeFlag.Name))
1916+
algoType, err := miner.AlgoTypeFlagToEnum(ctx.String(BuilderAlgoTypeFlag.Name))
1917+
if err != nil {
1918+
Fatalf("Invalid algo in --miner.algotype: %s", ctx.String(BuilderAlgoTypeFlag.Name))
1919+
}
1920+
cfg.AlgoType = algoType
1921+
}
1922+
// NOTE: BuilderAlgoTypeFlag takes precedence and will overwrite value set by MinerAlgoTypeFlag.
1923+
if ctx.IsSet(BuilderAlgoTypeFlag.Name) {
1924+
algoType, err := miner.AlgoTypeFlagToEnum(ctx.String(BuilderAlgoTypeFlag.Name))
18901925
if err != nil {
1891-
Fatalf("Invalid algo in --miner.algotype: %s", ctx.String(MinerAlgoTypeFlag.Name))
1926+
Fatalf("Invalid algo in --builder.algotype: %s", ctx.String(BuilderAlgoTypeFlag.Name))
18921927
}
18931928
cfg.AlgoType = algoType
18941929
}
@@ -1904,6 +1939,7 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
19041939

19051940
cfg.MaxMergedBundles = ctx.Int(MinerMaxMergedBundlesFlag.Name)
19061941

1942+
// NOTE: This flag is deprecated and will be removed in the future in favor of BuilderBlockValidationBlacklistSourceFilePath
19071943
if ctx.IsSet(MinerBlocklistFileFlag.Name) {
19081944
bytes, err := os.ReadFile(ctx.String(MinerBlocklistFileFlag.Name))
19091945
if err != nil {
@@ -1915,7 +1951,19 @@ func setMiner(ctx *cli.Context, cfg *miner.Config) {
19151951
}
19161952
}
19171953

1918-
cfg.PriceCutoffPercent = ctx.Int(MinerPriceCutoffPercentFlag.Name)
1954+
// NOTE: This flag takes precedence and will overwrite value set by MinerBlocklistFileFlag
1955+
if ctx.IsSet(BuilderBlockValidationBlacklistSourceFilePath.Name) {
1956+
bytes, err := os.ReadFile(ctx.String(BuilderBlockValidationBlacklistSourceFilePath.Name))
1957+
if err != nil {
1958+
Fatalf("Failed to read blocklist file: %s", err)
1959+
}
1960+
1961+
if err := json.Unmarshal(bytes, &cfg.Blocklist); err != nil {
1962+
Fatalf("Failed to parse blocklist: %s", err)
1963+
}
1964+
}
1965+
1966+
cfg.PriceCutoffPercent = ctx.Int(BuilderPriceCutoffPercentFlag.Name)
19191967
}
19201968

19211969
func setRequiredBlocks(ctx *cli.Context, cfg *ethconfig.Config) {

eth/backend.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
231231
}
232232

233233
eth.miner = miner.New(eth, &config.Miner, eth.blockchain.Config(), eth.EventMux(), eth.engine, eth.isLocalBlock)
234-
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
234+
err = eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
235+
if err != nil {
236+
return nil, err
237+
}
235238

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

miner/algo_greedy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ func TestBuildBlockGasLimit(t *testing.T) {
3030
var result *environment
3131
switch algo {
3232
case ALGO_GREEDY_BUCKETS:
33-
builder := newGreedyBuilder(chData.chain, chData.chainConfig, nil, nil, env, nil, nil)
33+
builder := newGreedyBucketsBuilder(chData.chain, chData.chainConfig, nil, nil, env, nil, nil)
3434
result, _, _ = builder.buildBlock([]types.SimulatedBundle{}, nil, txs)
3535
case ALGO_GREEDY:
36-
builder := newGreedyBucketsBuilder(chData.chain, chData.chainConfig, nil, nil, env, nil, nil)
36+
builder := newGreedyBuilder(chData.chain, chData.chainConfig, nil, nil, env, nil, nil)
3737
result, _, _ = builder.buildBlock([]types.SimulatedBundle{}, nil, txs)
3838
}
3939

0 commit comments

Comments
 (0)