Skip to content

Commit

Permalink
feat(cli): add URLS for connected services
Browse files Browse the repository at this point in the history
  • Loading branch information
harshal619 committed Nov 7, 2023
1 parent bf5d92b commit 4504a4a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/cli/src/cmds/beacon/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {BeaconArgs} from "./options.js";
import {getBeaconPaths} from "./paths.js";
import {initBeaconState} from "./initBeaconState.js";
import {initPeerIdAndEnr} from "./initPeerIdAndEnr.js";
import {logArguments} from "./logArguments.js";

const DEFAULT_RETENTION_SSZ_OBJECTS_HOURS = 15 * 24;
const HOURS_TO_MS = 3600 * 1000;
Expand Down Expand Up @@ -208,6 +209,8 @@ export async function beaconHandlerInit(args: BeaconArgs & GlobalArgs) {
// Render final options
const options = beaconNodeOptions.getWithDefaults();

logArguments(logger, args);

return {config, options, beaconPaths, network, version, commit, peerId, logger};
}

Expand Down
35 changes: 35 additions & 0 deletions packages/cli/src/cmds/beacon/logArguments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {LogLevel, Logger} from "@lodestar/utils";
import {GlobalArgs} from "../../options/index.js";
import {BeaconArgs} from "./options.js";

/**
* Log urls from CLI arguments for execution.urls, eth1.providerUrls and builder.urls
*/
export function logArguments(logger: Pick<Logger, LogLevel.info>, args: BeaconArgs & GlobalArgs): void {
const executionUrls = args["execution.urls"];

if (executionUrls?.length > 0) {
logger.info(`Total execution urls: ${executionUrls.length}`);
executionUrls.forEach((url, index) => {
logger.info(`Execution url (${index + 1}): ${url}`);
});
}

const eth1ProviderUrls = args["eth1.providerUrls"];

if (eth1ProviderUrls && eth1ProviderUrls?.length > 0) {
logger.info(`Total eth1 provider urls: ${eth1ProviderUrls.length}`);
eth1ProviderUrls.forEach((url, index) => {
logger.info(`Eth1 provider url (${index + 1}): ${url}`);
});
}

const builderUrls = args["builder.urls"];

if (builderUrls && builderUrls?.length > 0) {
logger.info(`Total builder url(s): ${builderUrls.length}`);
builderUrls.forEach((url, index) => {
logger.info(`Builder url (${index + 1}): ${url}`);
});
}
}
2 changes: 2 additions & 0 deletions packages/cli/src/cmds/validator/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {KeymanagerApi} from "./keymanager/impl.js";
import {PersistedKeysBackend} from "./keymanager/persistedKeys.js";
import {IPersistedKeysBackend} from "./keymanager/interface.js";
import {KeymanagerRestApiServer} from "./keymanager/server.js";
import {logArguments} from "./logArguments.js";

/**
* Runs a validator client.
Expand Down Expand Up @@ -102,6 +103,7 @@ export async function validatorHandler(args: IValidatorCliArgs & GlobalArgs): Pr
}

logSigners(logger, signers);
logArguments(logger, args);

const db = await LevelDbController.create({name: dbPath}, {metrics: null, logger});
onGracefulShutdownCbs.push(() => db.close());
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/src/cmds/validator/logArguments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {LogLevel, Logger} from "@lodestar/utils";
import {GlobalArgs} from "../../options/index.js";
import {IValidatorCliArgs} from "./options.js";

/**
* Log beacon node urls
*/
export function logArguments(logger: Pick<Logger, LogLevel.info>, args: IValidatorCliArgs & GlobalArgs): void {
const beaconNodes = args["beaconNodes"];

if (beaconNodes?.length > 0) {
logger.info(`${beaconNodes.length} beacon nodes`);
beaconNodes.forEach((url, index) => {
logger.info(`Beacon node url ${index + 1}: ${url}`);
});
}
}

0 comments on commit 4504a4a

Please sign in to comment.