Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set default builderBoostFactor to 90 #6568

Merged
merged 10 commits into from
Apr 10, 2024
5 changes: 3 additions & 2 deletions docs/pages/validator-management/vc-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ With produceBlockV3 (enabled automatically after the Deneb hard fork), the `--bu

With Lodestar's `--builder.selection` validator options, you can select:

- `default`: Default setting for Lodestar set at `--builder.boostFactor=90`. This default setting will have a local block boost of ~10%. Using this option, you may customize your `--builder.boostFactor` to your preference. Examples of its usage are below.
- `default`: Default setting for Lodestar set at `--builder.boostFactor=90`. This default setting will have a local block boost of ~10%. Note that this value might change in the future depending on what we think is the most appropriate value to help increase censorship resistance.
- `maxprofit`: An alias of `--builder.boostFactor=100`, which will always choose the more profitable block. Using this option, you may customize your `--builder.boostFactor` to your preference. Examples of its usage are below.
- `executionalways`: An alias of `--builder.boostFactor=0`, which will select the local execution block, unless it fails to produce due to an error or a delay in the response from the execution client.
- `executiononly`: Beacon node will be requested to produce local execution block even if builder relays are configured. This option will always select the local execution block and will error if it couldn't produce one.
- `builderalways`: An alias of `--builder.boostFactor=18446744073709551615` (2\*\*64 - 1), which will select the builder block, unless the builder block fails to produce. The builder block may fail to produce if it's not available, not timely or there is an indication of censorship via `shouldOverrideBuilder` from the execution payload response.
Expand All @@ -102,7 +103,7 @@ Therefore, `--builder.boostFactor=80`.

Example 2: Setting a `--builder.boostFactor=0` will always prefer the local execution block, but will produce an available builder block if the local execution block fails.

Example 3: Setting a `--builder.boostFactor=100` will always select the most profitable block between the local execution engine and the builder block from the relay.
Example 3: Setting a `--builder.boostFactor=100` is the same as signaling `--builder.selection maxprofit` where the validator will always select the most profitable block between the local execution engine and the builder block from the relay.

### Submit a validator deposit

Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/beacon/routes/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ import {allForksBlockContentsResSerializer} from "../../utils/routes.js";
import {ExecutionOptimistic} from "./beacon/block.js";

export enum BuilderSelection {
Default = "default",
BuilderAlways = "builderalways",
ExecutionAlways = "executionalways",
Default = "default",
MaxProfit = "maxprofit",
/** Only activate builder flow for DVT block proposal protocols */
BuilderOnly = "builderonly",
/** Only builds execution block*/
Expand Down
8 changes: 4 additions & 4 deletions packages/api/test/unit/beacon/testData/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const testData: GenericServerTestCases<Api> = {
builderSelection: undefined,
strictFeeRecipientCheck: undefined,
blindedLocal: undefined,
builderBoostFactor: 90n,
builderBoostFactor: 100n,
},
] as unknown as GenericServerTestCases<Api>["produceBlock"]["args"],
res: {data: ssz.phase0.BeaconBlock.defaultValue()},
Expand All @@ -71,7 +71,7 @@ export const testData: GenericServerTestCases<Api> = {
builderSelection: undefined,
strictFeeRecipientCheck: undefined,
blindedLocal: undefined,
builderBoostFactor: 90n,
builderBoostFactor: 100n,
},
] as unknown as GenericServerTestCases<Api>["produceBlockV2"]["args"],
res: {
Expand All @@ -92,7 +92,7 @@ export const testData: GenericServerTestCases<Api> = {
builderSelection: undefined,
strictFeeRecipientCheck: undefined,
blindedLocal: undefined,
builderBoostFactor: 90n,
builderBoostFactor: 100n,
},
],
res: {
Expand All @@ -115,7 +115,7 @@ export const testData: GenericServerTestCases<Api> = {
builderSelection: undefined,
strictFeeRecipientCheck: undefined,
blindedLocal: undefined,
builderBoostFactor: 90n,
builderBoostFactor: 100n,
},
] as unknown as GenericServerTestCases<Api>["produceBlindedBlock"]["args"],
res: {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/test/unit/keymanager/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const pubkeyRand = "0x84105a985058fc8740a48bf1ede9d223ef09e8c6b1735ba0a55cf4a9ff
const ethaddressRand = "0xabcf8e0d4e9587369b2301d0790347320302cc09";
const graffitiRandUtf8 = "636861696e736166652f6c6f64657374";
const gasLimitRand = 30_000_000;
const builderBoostFactorRand = BigInt(90);
const builderBoostFactorRand = BigInt(100);

export const testData: GenericServerTestCases<Api> = {
listKeys: {
Expand Down
6 changes: 3 additions & 3 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,10 @@ export function getValidatorApi({

const fork = config.getForkName(slot);
// set some sensible opts
// builderSelection will be deprecated and will run in mode Default if builder is enabled
// builderSelection will be deprecated and will run in mode MaxProfit if builder is enabled
// and the actual selection will be determined using builderBoostFactor passed by the validator
builderSelection = builderSelection ?? routes.validator.BuilderSelection.Default;
builderBoostFactor = builderBoostFactor ?? BigInt(90);
builderSelection = builderSelection ?? routes.validator.BuilderSelection.MaxProfit;
builderBoostFactor = builderBoostFactor ?? BigInt(100);
Copy link
Member

@nflaig nflaig Apr 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the changes on the beacon node side as in case of Lodestar the boost factor is dictated by the validator client and setting a different default here is undocumented behavior we should avoid.

if (builderBoostFactor > MAX_BUILDER_BOOST_FACTOR) {
throw new ApiError(400, `Invalid builderBoostFactor=${builderBoostFactor} > MAX_BUILDER_BOOST_FACTOR`);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/beacon-node/src/api/impl/validator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ export function selectBlockProductionSource({
return ProducedBlockSource.engine;

case routes.validator.BuilderSelection.Default:
case routes.validator.BuilderSelection.MaxProfit:
return builderBoostFactor !== MAX_BUILDER_BOOST_FACTOR &&
(builderBoostFactor === BigInt(0) || engineBlockValue >= (builderBlockValue * builderBoostFactor) / BigInt(90))
(builderBoostFactor === BigInt(0) || engineBlockValue >= (builderBlockValue * builderBoostFactor) / BigInt(100))
? ProducedBlockSource.engine
: ProducedBlockSource.builder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ describe("api/validator - produceBlockV3", function () {
});

const testCases: [routes.validator.BuilderSelection, number | null, number | null, number, boolean, string][] = [
[routes.validator.BuilderSelection.Default, 1, 0, 0, false, "builder"],
[routes.validator.BuilderSelection.Default, 1, 2, 1, false, "engine"],
[routes.validator.BuilderSelection.Default, null, 0, 0, false, "engine"],
[routes.validator.BuilderSelection.Default, 0, null, 1, false, "builder"],
[routes.validator.BuilderSelection.Default, 0, null, 1, true, "builder"],
[routes.validator.BuilderSelection.Default, 1, 1, 1, true, "engine"],
[routes.validator.BuilderSelection.Default, 2, 1, 1, true, "engine"],
[routes.validator.BuilderSelection.MaxProfit, 1, 0, 0, false, "builder"],
[routes.validator.BuilderSelection.MaxProfit, 1, 2, 1, false, "engine"],
[routes.validator.BuilderSelection.MaxProfit, null, 0, 0, false, "engine"],
[routes.validator.BuilderSelection.MaxProfit, 0, null, 1, false, "builder"],
[routes.validator.BuilderSelection.MaxProfit, 0, null, 1, true, "builder"],
[routes.validator.BuilderSelection.MaxProfit, 1, 1, 1, true, "engine"],
[routes.validator.BuilderSelection.MaxProfit, 2, 1, 1, true, "engine"],

[routes.validator.BuilderSelection.BuilderAlways, 1, 2, 0, false, "builder"],
[routes.validator.BuilderSelection.BuilderAlways, 1, 0, 1, false, "builder"],
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cmds/validator/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,15 @@ export const validatorOptions: CliCommandOptions<IValidatorCliArgs> = {
"builder.selection": {
type: "string",
description:
"Builder block selection strategy `default`, `builderalways`, `builderonly`, `executionalways`, or `executiononly`",
"Builder block selection strategy `default`, `maxprofit`, `builderalways`, `builderonly`, `executionalways`, or `executiononly`",
defaultDescription: `${defaultOptions.builderSelection}`,
group: "builder",
},

"builder.boostFactor": {
type: "string",
description:
"Percentage multiplier the block producing beacon node must apply to boost (>100) or dampen (<100) builder block value for selection against execution block. The multiplier is ignored if `--builder.selection` is set to anything other than `default`",
"Percentage multiplier the block producing beacon node must apply to boost (>100) or dampen (<100) builder block value for selection against execution block. The multiplier is ignored if `--builder.selection` is set to anything other than `default` or `maxprofit`",
defaultDescription: `${defaultOptions.builderBoostFactor}`,
group: "builder",
},
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/util/proposerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export function parseBuilderSelection(builderSelection?: string): routes.validat
switch (builderSelection) {
case "default":
nflaig marked this conversation as resolved.
Show resolved Hide resolved
break;
case "maxprofit":
break;
case "builderalways":
break;
case "builderonly":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const testValue = {
feeRecipient: "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
builder: {
gasLimit: 35000000,
selection: routes.validator.BuilderSelection.Default,
selection: routes.validator.BuilderSelection.BuilderAlways,
boostFactor: BigInt(18446744073709551616),
},
},
Expand All @@ -37,7 +37,7 @@ const testValue = {
feeRecipient: "0xcccccccccccccccccccccccccccccccccccccccc",
builder: {
gasLimit: 30000000,
selection: routes.validator.BuilderSelection.BuilderAlways,
selection: routes.validator.BuilderSelection.Default,
boostFactor: BigInt(90),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ proposer_config:
fee_recipient: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
builder:
gas_limit: "35000000"
selection: "default"
boost_factor: "18446744073709551616"
selection: "maxprofit"
boost_factor: "50"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might encourage users to set it even lower :)

default_config:
graffiti: 'default graffiti'
strict_fee_recipient_check: "true"
fee_recipient: '0xcccccccccccccccccccccccccccccccccccccccc'
builder:
gas_limit: "30000000"
selection: "builderalways"
boost_factor: "90"
boost_factor: "18446744073709551616"
4 changes: 4 additions & 0 deletions packages/validator/src/services/validatorStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ export class ValidatorStore {
(this.validators.get(pubkeyHex)?.builder || {}).boostFactor ?? this.defaultProposerConfig.builder.boostFactor;
break;

case routes.validator.BuilderSelection.MaxProfit:
boostFactor = (this.validators.get(pubkeyHex)?.builder || {}).boostFactor ?? BigInt(100);
break;

case routes.validator.BuilderSelection.BuilderAlways:
case routes.validator.BuilderSelection.BuilderOnly:
boostFactor = MAX_BUILDER_BOOST_FACTOR;
Expand Down
Loading