Skip to content

Commit

Permalink
chore: update flag to pass builder url (#6190)
Browse files Browse the repository at this point in the history
* Update flag to pass builder url

* Throw error if multiple builder urls are set
  • Loading branch information
nflaig committed Dec 18, 2023
1 parent e09702d commit 54e8c45
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ All you have to do is:

1. Provide lodestar beacon node with a Builder endpoint (which corresponds to the network you are running) via these additional flags:
```shell
--builder --builder.urls <builder/relay/boost url>
--builder --builder.url <builder/relay/boost url>
```
2. Run lodestar validator client with these additional flags
```shell
Expand Down
6 changes: 3 additions & 3 deletions packages/beacon-node/src/execution/builder/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {IExecutionBuilder} from "./interface.js";

export type ExecutionBuilderHttpOpts = {
enabled: boolean;
urls: string[];
url: string;
timeout?: number;
faultInspectionWindow?: number;
allowedFaults?: number;
Expand All @@ -29,7 +29,7 @@ export type ExecutionBuilderHttpOpts = {

export const defaultExecutionBuilderHttpOpts: ExecutionBuilderHttpOpts = {
enabled: false,
urls: ["http://localhost:8661"],
url: "http://localhost:8661",
timeout: 12000,
};

Expand All @@ -48,7 +48,7 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {
metrics: Metrics | null = null,
logger?: Logger
) {
const baseUrl = opts.urls[0];
const baseUrl = opts.url;
if (!baseUrl) throw Error("No Url provided for executionBuilder");
this.api = getClient(
{
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/test/sim/mergemock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe("executionEngine / ExecutionEngineHttp", function () {
eth1: {enabled: false, providerUrls: [engineRpcUrl], jwtSecretHex},
executionEngine: {urls: [engineRpcUrl], jwtSecretHex},
executionBuilder: {
urls: [ethRpcUrl],
url: ethRpcUrl,
enabled: true,
issueLocalFcUWithFeeRecipient: feeRecipientMevBoost,
allowedFaults: 16,
Expand Down
25 changes: 14 additions & 11 deletions packages/cli/src/options/beaconNodeOptions/builder.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import {defaultExecutionBuilderHttpOpts, IBeaconNodeOptions} from "@lodestar/beacon-node";
import {CliCommandOptions} from "../../util/index.js";
import {CliCommandOptions, YargsError} from "../../util/index.js";

export type ExecutionBuilderArgs = {
builder: boolean;
"builder.urls"?: string[];
"builder.url"?: string;
"builder.timeout"?: number;
"builder.faultInspectionWindow"?: number;
"builder.allowedFaults"?: number;
};

export function parseArgs(args: ExecutionBuilderArgs): IBeaconNodeOptions["executionBuilder"] {
if (Array.isArray(args["builder.url"]) || args["builder.url"]?.includes(",http")) {
throw new YargsError(
"Lodestar only supports a single builder URL. External tooling like mev-boost can be used to connect to multiple builder/relays"
);
}

return {
enabled: args["builder"],
urls: args["builder.urls"] ?? defaultExecutionBuilderHttpOpts.urls,
url: args["builder.url"] ?? defaultExecutionBuilderHttpOpts.url,
timeout: args["builder.timeout"],
faultInspectionWindow: args["builder.faultInspectionWindow"],
allowedFaults: args["builder.allowedFaults"],
Expand All @@ -27,14 +33,11 @@ export const options: CliCommandOptions<ExecutionBuilderArgs> = {
group: "builder",
},

"builder.urls": {
description: "Urls hosting the builder API",
defaultDescription: defaultExecutionBuilderHttpOpts.urls.join(","),
type: "array",
string: true,
coerce: (urls: string[]): string[] =>
// Parse ["url1,url2"] to ["url1", "url2"]
urls.map((item) => item.split(",")).flat(1),
"builder.url": {
alias: ["builder.urls"],
description: "Url hosting the builder API",
defaultDescription: defaultExecutionBuilderHttpOpts.url,
type: "string",
group: "builder",
},

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/test/unit/options/beaconNodeOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("options / beaconNodeOptions", () => {
"execution.retryAttempts": 1,

builder: false,
"builder.urls": ["http://localhost:8661"],
"builder.url": "http://localhost:8661",
"builder.timeout": 12000,
"builder.faultInspectionWindow": 32,
"builder.allowedFaults": 16,
Expand Down Expand Up @@ -157,7 +157,7 @@ describe("options / beaconNodeOptions", () => {
},
executionBuilder: {
enabled: false,
urls: ["http://localhost:8661"],
url: "http://localhost:8661",
timeout: 12000,
faultInspectionWindow: 32,
allowedFaults: 16,
Expand Down

0 comments on commit 54e8c45

Please sign in to comment.