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

fix: improve handling of non-integer builder boost factor values #6332

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/validator-management/vc-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ With Lodestar's `--builder.selection` validator options, you can select:

#### Calculating builder boost factor with examples

To calculate the builder boost factor setting, you need to know what percentage you will accept a builder block for against a local execution block using the following formula: `100*100/(100+percentage)`.
To calculate the builder boost factor setting, you need to know what percentage you will accept a builder block for against a local execution block using the following formula: `100*100/(100+percentage)`. The value passed to `--builder.boostFactor` must be a valid number without decimals.

Example 1: I will only accept a builder block with 25% more value than the local execution block.
```
Expand Down
16 changes: 13 additions & 3 deletions packages/cli/src/cmds/validator/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function getProposerConfigFromArgs(
selection: parseBuilderSelection(
args["builder.selection"] ?? (args["builder"] ? defaultOptions.builderAliasSelection : undefined)
),
boostFactor: args["builder.boostFactor"] !== undefined ? BigInt(args["builder.boostFactor"]) : undefined,
boostFactor: parseBuilderBoostFactor(args["builder.boostFactor"]),
},
};

Expand Down Expand Up @@ -266,7 +266,7 @@ function parseBuilderSelection(builderSelection?: string): routes.validator.Buil
case "executiononly":
break;
default:
throw Error("Invalid input for builder selection, check help.");
throw new YargsError("Invalid input for builder selection, check help");
}
}
return builderSelection as routes.validator.BuilderSelection;
Expand All @@ -280,9 +280,19 @@ function parseBroadcastValidation(broadcastValidation?: string): routes.beacon.B
case "consensus_and_equivocation":
break;
default:
throw Error("Invalid input for broadcastValidation, check help");
throw new YargsError("Invalid input for broadcastValidation, check help");
}
}

return broadcastValidation as routes.beacon.BroadcastValidation;
}

function parseBuilderBoostFactor(boostFactor?: string): bigint | undefined {
if (boostFactor === undefined) return;

if (!/^\d+$/.test(boostFactor)) {
throw new YargsError("Invalid input for builder boost factor, must be a valid number without decimals");
}

return BigInt(boostFactor);
}
2 changes: 1 addition & 1 deletion packages/cli/src/cmds/validator/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type IValidatorCliArgs = AccountValidatorArgs &

builder?: boolean;
"builder.selection"?: string;
"builder.boostFactor"?: bigint;
"builder.boostFactor"?: string;

useProduceBlockV3?: boolean;
broadcastValidation?: string;
Expand Down
Loading