From 093a287e3289b9bfcfda5dabe03e677135745faa Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Mon, 29 Jan 2024 12:03:30 +0100 Subject: [PATCH] feat: add builder selection executionalways --- docs/pages/validator-management/vc-configuration.md | 1 + packages/api/src/beacon/routes/validator.ts | 1 + packages/beacon-node/src/api/impl/validator/index.ts | 1 + .../test/unit/api/impl/validator/produceBlockV3.test.ts | 6 ++++++ packages/cli/src/cmds/validator/options.ts | 3 ++- packages/cli/src/util/proposerConfig.ts | 7 ++++--- packages/validator/src/services/validatorStore.ts | 1 + 7 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/pages/validator-management/vc-configuration.md b/docs/pages/validator-management/vc-configuration.md index a1077997cd77..f1fa720c7ee1 100644 --- a/docs/pages/validator-management/vc-configuration.md +++ b/docs/pages/validator-management/vc-configuration.md @@ -97,6 +97,7 @@ With produceBlockV3 (enabled automatically after the Deneb hard fork), the `--bu With Lodestar's `--builder.selection` validator options, you can select: - `maxprofit`: Default setting for Lodestar set at `--builder.boostFactor=100`. This default setting 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. - `builderonly`: Generally used for distributed validators (DVs). No execution block production will be triggered. Therefore, if a builder block is not produced, the API will fail and _no block will be produced_. diff --git a/packages/api/src/beacon/routes/validator.ts b/packages/api/src/beacon/routes/validator.ts index 09fbd9de3162..5b6fa7797d88 100644 --- a/packages/api/src/beacon/routes/validator.ts +++ b/packages/api/src/beacon/routes/validator.ts @@ -43,6 +43,7 @@ import {ExecutionOptimistic} from "./beacon/block.js"; export enum BuilderSelection { BuilderAlways = "builderalways", + ExecutionAlways = "executionalways", MaxProfit = "maxprofit", /** Only activate builder flow for DVT block proposal protocols */ BuilderOnly = "builderonly", diff --git a/packages/beacon-node/src/api/impl/validator/index.ts b/packages/beacon-node/src/api/impl/validator/index.ts index e795d1c5afad..e6dac77b3a7c 100644 --- a/packages/beacon-node/src/api/impl/validator/index.ts +++ b/packages/beacon-node/src/api/impl/validator/index.ts @@ -612,6 +612,7 @@ export function getValidatorApi({ break; } + case routes.validator.BuilderSelection.ExecutionAlways: case routes.validator.BuilderSelection.ExecutionOnly: { executionPayloadSource = ProducedBlockSource.engine; break; diff --git a/packages/beacon-node/test/unit/api/impl/validator/produceBlockV3.test.ts b/packages/beacon-node/test/unit/api/impl/validator/produceBlockV3.test.ts index 4484bcf03563..ba0267fc5810 100644 --- a/packages/beacon-node/test/unit/api/impl/validator/produceBlockV3.test.ts +++ b/packages/beacon-node/test/unit/api/impl/validator/produceBlockV3.test.ts @@ -49,6 +49,12 @@ describe("api/validator - produceBlockV3", function () { [routes.validator.BuilderSelection.BuilderAlways, 1, 1, 1, true, "engine"], [routes.validator.BuilderSelection.BuilderAlways, 1, null, 1, true, "builder"], + [routes.validator.BuilderSelection.ExecutionAlways, 2, 1, 0, false, "engine"], + [routes.validator.BuilderSelection.ExecutionAlways, 0, 1, 1, false, "engine"], + [routes.validator.BuilderSelection.ExecutionAlways, 0, null, 0, false, "builder"], + [routes.validator.BuilderSelection.ExecutionAlways, null, 0, 1, false, "engine"], + [routes.validator.BuilderSelection.ExecutionAlways, 1, 1, 1, true, "engine"], + [routes.validator.BuilderSelection.BuilderOnly, 0, 2, 0, false, "builder"], [routes.validator.BuilderSelection.ExecutionOnly, 2, 0, 1, false, "engine"], [routes.validator.BuilderSelection.BuilderOnly, 1, 1, 0, true, "builder"], diff --git a/packages/cli/src/cmds/validator/options.ts b/packages/cli/src/cmds/validator/options.ts index ecc8ad32ca87..20bfc106d258 100644 --- a/packages/cli/src/cmds/validator/options.ts +++ b/packages/cli/src/cmds/validator/options.ts @@ -242,7 +242,8 @@ export const validatorOptions: CliCommandOptions = { "builder.selection": { type: "string", - description: "Builder block selection strategy `maxprofit`, `builderalways`, `builderonly` or `executiononly`", + description: + "Builder block selection strategy `maxprofit`, `builderalways`, `builderonly`, `executionalways`, or `executiononly`", defaultDescription: `${defaultOptions.builderSelection}`, group: "builder", }, diff --git a/packages/cli/src/util/proposerConfig.ts b/packages/cli/src/util/proposerConfig.ts index 661c81ee63af..ae56cc45513a 100644 --- a/packages/cli/src/util/proposerConfig.ts +++ b/packages/cli/src/util/proposerConfig.ts @@ -8,7 +8,6 @@ import {routes} from "@lodestar/api"; import {parseFeeRecipient} from "./feeRecipient.js"; import {readFile} from "./file.js"; -import {YargsError} from "./index.js"; type ProposerConfig = ValidatorProposerConfig["defaultConfig"]; @@ -114,10 +113,12 @@ export function parseBuilderSelection(builderSelection?: string): routes.validat break; case "builderonly": break; + case "executionalways": + break; case "executiononly": break; default: - throw new YargsError("Invalid input for builder selection, check help"); + throw Error("Invalid input for builder selection, check help"); } } return builderSelection as routes.validator.BuilderSelection; @@ -127,7 +128,7 @@ export function parseBuilderBoostFactor(boostFactor?: string): bigint | undefine if (boostFactor === undefined) return; if (!/^\d+$/.test(boostFactor)) { - throw new YargsError("Invalid input for builder boost factor, must be a valid number without decimals"); + throw Error("Invalid input for builder boost factor, must be a valid number without decimals"); } return BigInt(boostFactor); diff --git a/packages/validator/src/services/validatorStore.ts b/packages/validator/src/services/validatorStore.ts index 03811062c2ad..d1474e7fdd28 100644 --- a/packages/validator/src/services/validatorStore.ts +++ b/packages/validator/src/services/validatorStore.ts @@ -277,6 +277,7 @@ export class ValidatorStore { boostFactor = MAX_BUILDER_BOOST_FACTOR; break; + case routes.validator.BuilderSelection.ExecutionAlways: case routes.validator.BuilderSelection.ExecutionOnly: boostFactor = BigInt(0); }