Skip to content

Commit

Permalink
feat: add builder selection executionalways (#6370)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored Feb 1, 2024
1 parent 0db50b9 commit 00dfa63
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/pages/validator-management/vc-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_.
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/beacon/routes/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ export function getValidatorApi({
break;
}

case routes.validator.BuilderSelection.ExecutionAlways:
case routes.validator.BuilderSelection.ExecutionOnly: {
executionPayloadSource = ProducedBlockSource.engine;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cmds/validator/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ export const validatorOptions: CliCommandOptions<IValidatorCliArgs> = {

"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",
},
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/src/util/proposerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions packages/validator/src/services/validatorStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 00dfa63

Please sign in to comment.