Skip to content

Commit

Permalink
feat: print out URLs of connected services
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Nov 8, 2023
1 parent d3f40d2 commit 80c6e78
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
5 changes: 4 additions & 1 deletion packages/beacon-node/src/eth1/provider/eth1Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export class Eth1Provider implements IEth1Provider {
this.logger = opts.logger;
this.deployBlock = opts.depositContractDeployBlock ?? 0;
this.depositContractAddress = toHexString(config.DEPOSIT_CONTRACT_ADDRESS);
this.rpc = new JsonRpcHttpClient(opts.providerUrls ?? DEFAULT_PROVIDER_URLS, {

const providerUrls = opts.providerUrls ?? DEFAULT_PROVIDER_URLS;
this.logger?.info("Eth1 provider", {urls: providerUrls.toString()});
this.rpc = new JsonRpcHttpClient(providerUrls, {
signal,
// Don't fallback with is truncated error. Throw early and let the retry on this class handle it
shouldNotFallback: isJsonRpcTruncatedError,
Expand Down
9 changes: 8 additions & 1 deletion packages/beacon-node/src/execution/builder/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
reconstructFullBlockOrContents,
} from "@lodestar/state-transition";
import {ChainForkConfig} from "@lodestar/config";
import {Logger} from "@lodestar/logger";
import {getClient, Api as BuilderApi} from "@lodestar/api/builder";
import {SLOTS_PER_EPOCH, ForkExecution} from "@lodestar/params";

Expand Down Expand Up @@ -41,9 +42,15 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {
faultInspectionWindow: number;
allowedFaults: number;

constructor(opts: ExecutionBuilderHttpOpts, config: ChainForkConfig, metrics: Metrics | null = null) {
constructor(
opts: ExecutionBuilderHttpOpts,
config: ChainForkConfig,
metrics: Metrics | null = null,
logger?: Logger
) {
const baseUrl = opts.urls[0];
if (!baseUrl) throw Error("No Url provided for executionBuilder");
logger?.info("External builder", {urls: opts.urls.toString()});
this.api = getClient(
{
baseUrl,
Expand Down
6 changes: 4 additions & 2 deletions packages/beacon-node/src/execution/builder/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {ChainForkConfig} from "@lodestar/config";
import {Logger} from "@lodestar/logger";
import {Metrics} from "../../metrics/metrics.js";
import {IExecutionBuilder} from "./interface.js";

Expand All @@ -12,11 +13,12 @@ export const defaultExecutionBuilderOpts: ExecutionBuilderOpts = defaultExecutio
export function initializeExecutionBuilder(
opts: ExecutionBuilderOpts,
config: ChainForkConfig,
metrics: Metrics | null = null
metrics: Metrics | null = null,
logger?: Logger
): IExecutionBuilder {
switch (opts.mode) {
case "http":
default:
return new ExecutionBuilderHttp(opts, config, metrics);
return new ExecutionBuilderHttp(opts, config, metrics, logger);
}
}
1 change: 1 addition & 0 deletions packages/beacon-node/src/execution/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function getExecutionEngineHttp(
opts: ExecutionEngineHttpOpts,
modules: ExecutionEngineModules
): IExecutionEngine {
modules.logger.info("Execution client", {urls: opts.urls.toString()});
const rpc = new JsonRpcHttpClient(opts.urls, {
...opts,
signal: modules.signal,
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/node/nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class BeaconNode {
logger: logger.child({module: LoggerModule.execution}),
}),
executionBuilder: opts.executionBuilder.enabled
? initializeExecutionBuilder(opts.executionBuilder, config, metrics)
? initializeExecutionBuilder(opts.executionBuilder, config, metrics, logger)
: undefined,
});

Expand Down
1 change: 1 addition & 0 deletions packages/validator/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export class Validator {
let api: Api;
if (typeof opts.api === "string" || Array.isArray(opts.api)) {
const urls = typeof opts.api === "string" ? [opts.api] : opts.api;
logger.info("Beacon node", {urls: urls.toString()});
// This new api instance can make do with default timeout as a faster timeout is
// not necessary since this instance won't be used for validator duties
api = getClient({urls, getAbortSignal: () => opts.abortController.signal}, {config, logger});
Expand Down

0 comments on commit 80c6e78

Please sign in to comment.