Skip to content

Commit

Permalink
Changing "MaxProfit" to "Default"
Browse files Browse the repository at this point in the history
  • Loading branch information
fredriksvantes committed Mar 22, 2024
1 parent 7dbe996 commit b9c2d78
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions docs/pages/validator-management/vc-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ You may choose to use the `--strictFeeRecipientCheck` flag to enable a strict ch

If you are running a beacon node with connected builder relays, you may use these validator configurations to signal which block (builder vs. local execution) the beacon node should produce.

With produceBlockV3 (enabled automatically after the Deneb hard fork), the `--builder.boostFactor` is a 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 `maxprofit`. Even though this is set on the validator client, the calculation is requested and applied on the beacon node itself. For more information, see the [produceBlockV3 Beacon API](https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceBlockV3).
With produceBlockV3 (enabled automatically after the Deneb hard fork), the `--builder.boostFactor` is a 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`. Even though this is set on the validator client, the calculation is requested and applied on the beacon node itself. For more information, see the [produceBlockV3 Beacon API](https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/produceBlockV3).

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.
- `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.
- `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 @@ -100,7 +100,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` 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.
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.

### Submit a validator deposit

Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/beacon/routes/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {ExecutionOptimistic} from "./beacon/block.js";
export enum BuilderSelection {
BuilderAlways = "builderalways",
ExecutionAlways = "executionalways",
MaxProfit = "maxprofit",
Default = "default",
/** Only activate builder flow for DVT block proposal protocols */
BuilderOnly = "builderonly",
/** Only builds execution block*/
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(100);
const builderBoostFactorRand = BigInt(90);

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 @@ -488,10 +488,10 @@ export function getValidatorApi({

const fork = config.getForkName(slot);
// set some sensible opts
// builderSelection will be deprecated and will run in mode MaxProfit if builder is enabled
// builderSelection will be deprecated and will run in mode Default if builder is enabled
// and the actual selection will be determined using builderBoostFactor passed by the validator
builderSelection = builderSelection ?? routes.validator.BuilderSelection.MaxProfit;
builderBoostFactor = builderBoostFactor ?? BigInt(100);
builderSelection = builderSelection ?? routes.validator.BuilderSelection.Default;
builderBoostFactor = builderBoostFactor ?? BigInt(90);
if (builderBoostFactor > MAX_BUILDER_BOOST_FACTOR) {
throw new ApiError(400, `Invalid builderBoostFactor=${builderBoostFactor} > MAX_BUILDER_BOOST_FACTOR`);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/api/impl/validator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export function selectBlockProductionSource({
case routes.validator.BuilderSelection.ExecutionOnly:
return ProducedBlockSource.engine;

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

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

const testCases: [routes.validator.BuilderSelection, number | null, number | null, number, boolean, string][] = [
[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.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.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 @@ -244,15 +244,15 @@ export const validatorOptions: CliCommandOptions<IValidatorCliArgs> = {
"builder.selection": {
type: "string",
description:
"Builder block selection strategy `maxprofit`, `builderalways`, `builderonly`, `executionalways`, or `executiononly`",
"Builder block selection strategy `default`, `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 `maxprofit`",
"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`",
defaultDescription: `${defaultOptions.builderBoostFactor}`,
group: "builder",
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/proposerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function readProposerConfigDir(filepath: string, filename: string): Propo
export function parseBuilderSelection(builderSelection?: string): routes.validator.BuilderSelection | undefined {
if (builderSelection) {
switch (builderSelection) {
case "maxprofit":
case "default":
break;
case "builderalways":
break;
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/test/sim/multi_fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const env = await SimulationEnvironment.initWithDefaults(
// return with engine full block and publish via publishBlockV2
clientOptions: {
useProduceBlockV3: true,
"builder.selection": "maxprofit",
"builder.selection": "default",
},
},
},
Expand All @@ -71,7 +71,7 @@ const env = await SimulationEnvironment.initWithDefaults(
// builder is attached to beacon, and publish via publishBlindedBlockV2
clientOptions: {
useProduceBlockV3: true,
"builder.selection": "maxprofit",
"builder.selection": "default",
blindedLocal: true,
},
},
Expand Down Expand Up @@ -106,7 +106,7 @@ const env = await SimulationEnvironment.initWithDefaults(
// of local block and subsequent publishing via publishBlindedBlock
clientOptions: {
useProduceBlockV3: false,
"builder.selection": "maxprofit",
"builder.selection": "default",
},
},
},
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.MaxProfit,
selection: routes.validator.BuilderSelection.Default,
boostFactor: BigInt(18446744073709551616),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ proposer_config:
fee_recipient: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
builder:
gas_limit: "35000000"
selection: "maxprofit"
selection: "default"
boost_factor: "18446744073709551616"
default_config:
graffiti: 'default graffiti'
Expand All @@ -18,4 +18,4 @@ default_config:
builder:
gas_limit: "30000000"
selection: "builderalways"
boost_factor: "100"
boost_factor: "90"
4 changes: 2 additions & 2 deletions packages/validator/src/services/validatorStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const defaultOptions = {
suggestedFeeRecipient: "0x0000000000000000000000000000000000000000",
defaultGasLimit: 30_000_000,
builderSelection: routes.validator.BuilderSelection.ExecutionOnly,
builderAliasSelection: routes.validator.BuilderSelection.MaxProfit,
builderAliasSelection: routes.validator.BuilderSelection.Default,
builderBoostFactor: BigInt(90),
// spec asks for gossip validation by default
broadcastValidation: routes.beacon.BroadcastValidation.gossip,
Expand Down Expand Up @@ -267,7 +267,7 @@ export class ValidatorStore {

let boostFactor;
switch (selection) {
case routes.validator.BuilderSelection.MaxProfit:
case routes.validator.BuilderSelection.Default:
boostFactor =
(this.validators.get(pubkeyHex)?.builder || {}).boostFactor ?? this.defaultProposerConfig.builder.boostFactor;
break;
Expand Down
8 changes: 4 additions & 4 deletions packages/validator/test/unit/services/block.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe("BlockDutiesService", function () {
signature: signedBlock.signature,
}));
validatorStore.getBuilderSelectionParams.mockReturnValue({
selection: routes.validator.BuilderSelection.MaxProfit,
boostFactor: BigInt(100),
selection: routes.validator.BuilderSelection.Default,
boostFactor: BigInt(90),
});
validatorStore.getGraffiti.mockReturnValue("aaaa");
validatorStore.getFeeRecipient.mockReturnValue("0x00");
Expand Down Expand Up @@ -107,10 +107,10 @@ describe("BlockDutiesService", function () {
false,
{
feeRecipient: "0x00",
builderSelection: routes.validator.BuilderSelection.MaxProfit,
builderSelection: routes.validator.BuilderSelection.Default,
strictFeeRecipientCheck: false,
blindedLocal: false,
builderBoostFactor: BigInt(100),
builderBoostFactor: BigInt(90),
},
]);
});
Expand Down

0 comments on commit b9c2d78

Please sign in to comment.