@chainsafe/lodestar 1.47.0-dev.ec596194e2 → 1.47.0-dev.ee197a8d7f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.git-data.json +1 -1
- package/lib/cmds/builder/handler.d.ts.map +1 -1
- package/lib/cmds/builder/handler.js +19 -3
- package/lib/cmds/builder/handler.js.map +1 -1
- package/lib/cmds/builder/loadKeypair.d.ts +2 -1
- package/lib/cmds/builder/loadKeypair.d.ts.map +1 -1
- package/lib/cmds/builder/loadKeypair.js +2 -1
- package/lib/cmds/builder/loadKeypair.js.map +1 -1
- package/lib/cmds/builder/options.d.ts +8 -0
- package/lib/cmds/builder/options.d.ts.map +1 -1
- package/lib/cmds/builder/options.js +24 -0
- package/lib/cmds/builder/options.js.map +1 -1
- package/package.json +14 -14
- package/src/cmds/builder/handler.ts +24 -4
- package/src/cmds/builder/loadKeypair.ts +4 -0
- package/src/cmds/builder/options.ts +33 -0
package/.git-data.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAKlD,OAAO,EAAC,eAAe,EAA+B,MAAM,cAAc,CAAC;AAI3E,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAoEtF"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { getClient } from "@lodestar/api";
|
|
3
|
-
import {
|
|
3
|
+
import { RegistryMetricCreator, collectNodeJSMetrics, getHttpMetricsServer } from "@lodestar/beacon-node";
|
|
4
|
+
import { Builder, getMetrics } from "@lodestar/builder";
|
|
4
5
|
import { getNodeLogger } from "@lodestar/logger/node";
|
|
5
6
|
import { fromHex, toPrintableUrl } from "@lodestar/utils";
|
|
6
7
|
import { getBeaconConfigFromArgs } from "../../config/beaconParams.js";
|
|
7
8
|
import { getGlobalPaths } from "../../paths/global.js";
|
|
8
9
|
import { cleanOldLogFiles, onGracefulShutdown, parseFeeRecipient, parseLoggerArgs } from "../../util/index.js";
|
|
10
|
+
import { getVersionData } from "../../util/version.js";
|
|
9
11
|
import { loadBuilderKeypair } from "./loadKeypair.js";
|
|
12
|
+
import { builderMetricsDefaultOptions } from "./options.js";
|
|
10
13
|
const ZERO_ADDRESS = "0x" + "0".repeat(40);
|
|
11
14
|
export async function builderHandler(args) {
|
|
12
15
|
const { config, network } = getBeaconConfigFromArgs(args);
|
|
@@ -22,11 +25,13 @@ export async function builderHandler(args) {
|
|
|
22
25
|
catch (e) {
|
|
23
26
|
logger.debug("Not able to delete log files", {}, e);
|
|
24
27
|
}
|
|
28
|
+
const { version, commit } = getVersionData();
|
|
29
|
+
logger.info("Lodestar", { network, version, commit });
|
|
25
30
|
const executionFeeRecipient = parseFeeRecipient(args.executionFeeRecipient);
|
|
26
31
|
if (executionFeeRecipient === ZERO_ADDRESS) {
|
|
27
32
|
throw Error("Cannot put zero address as an executionFeeRecipient");
|
|
28
33
|
}
|
|
29
|
-
const keypair = await loadBuilderKeypair(args.keystore, args.keystorePassword, args.builderPubkey);
|
|
34
|
+
const keypair = await loadBuilderKeypair(logger, args.keystore, args.keystorePassword, args.builderPubkey);
|
|
30
35
|
const onGracefulShutdownCbs = [];
|
|
31
36
|
onGracefulShutdown(async () => {
|
|
32
37
|
for (const cb of onGracefulShutdownCbs)
|
|
@@ -34,7 +39,17 @@ export async function builderHandler(args) {
|
|
|
34
39
|
}, logger.info.bind(logger));
|
|
35
40
|
const abortController = new AbortController();
|
|
36
41
|
onGracefulShutdownCbs.push(async () => abortController.abort());
|
|
37
|
-
const
|
|
42
|
+
const register = args.metrics ? new RegistryMetricCreator() : null;
|
|
43
|
+
const metrics = register && getMetrics(register, { version, commit, network });
|
|
44
|
+
if (metrics) {
|
|
45
|
+
const closeMetrics = collectNodeJSMetrics(register);
|
|
46
|
+
onGracefulShutdownCbs.push(() => closeMetrics());
|
|
47
|
+
const port = args["metrics.port"] ?? builderMetricsDefaultOptions.port;
|
|
48
|
+
const address = args["metrics.address"] ?? builderMetricsDefaultOptions.address;
|
|
49
|
+
const metricsServer = await getHttpMetricsServer({ port, address }, { register, logger });
|
|
50
|
+
onGracefulShutdownCbs.push(() => metricsServer.close());
|
|
51
|
+
}
|
|
52
|
+
const api = getClient({ urls: [args.beaconNodeUrl], globalInit: { signal: abortController.signal, timeoutMs: args.requestTimeout } }, { config, logger, metrics: metrics?.restApiClient });
|
|
38
53
|
logger.info("Beacon node", { beaconNode: toPrintableUrl(args.beaconNodeUrl), timeoutMs: args.requestTimeout });
|
|
39
54
|
const builder = await Builder.init({
|
|
40
55
|
keypair,
|
|
@@ -43,6 +58,7 @@ export async function builderHandler(args) {
|
|
|
43
58
|
abortController,
|
|
44
59
|
api,
|
|
45
60
|
executionFeeRecipient: fromHex(executionFeeRecipient),
|
|
61
|
+
metrics,
|
|
46
62
|
});
|
|
47
63
|
onGracefulShutdownCbs.push(() => builder.close());
|
|
48
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/cmds/builder/handler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/cmds/builder/handler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,EAAC,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C,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Keypair } from "@lodestar/builder";
|
|
2
|
-
|
|
2
|
+
import { Logger } from "@lodestar/utils";
|
|
3
|
+
export declare function loadBuilderKeypair(logger: Logger, keystorePath: string, passwordPath: string, expectedPubkey?: string): Promise<Keypair>;
|
|
3
4
|
//# sourceMappingURL=loadKeypair.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadKeypair.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/loadKeypair.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"loadKeypair.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/loadKeypair.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAIvC,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,OAAO,CAAC,CAsBlB"}
|
|
@@ -3,7 +3,7 @@ import { Keystore } from "@chainsafe/bls-keystore";
|
|
|
3
3
|
import { SecretKey } from "@chainsafe/blst";
|
|
4
4
|
import { ensure0xPrefix } from "../../util/format.js";
|
|
5
5
|
import { readPassphraseFile } from "../../util/passphrase.js";
|
|
6
|
-
export async function loadBuilderKeypair(keystorePath, passwordPath, expectedPubkey) {
|
|
6
|
+
export async function loadBuilderKeypair(logger, keystorePath, passwordPath, expectedPubkey) {
|
|
7
7
|
const password = readPassphraseFile(passwordPath);
|
|
8
8
|
const keystoreStr = fs.readFileSync(keystorePath, "utf8");
|
|
9
9
|
const keystore = Keystore.parse(keystoreStr);
|
|
@@ -17,6 +17,7 @@ export async function loadBuilderKeypair(keystorePath, passwordPath, expectedPub
|
|
|
17
17
|
if (expectedPubkey && publicKeyHex !== ensure0xPrefix(expectedPubkey.toLowerCase())) {
|
|
18
18
|
throw Error(`Pubkey mismatch: keystore ${publicKeyHex}, expected ${expectedPubkey}`);
|
|
19
19
|
}
|
|
20
|
+
logger.info("Loaded builder keystore", { pubkey: publicKeyHex });
|
|
20
21
|
return { secretKey, publicKey };
|
|
21
22
|
}
|
|
22
23
|
//# sourceMappingURL=loadKeypair.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadKeypair.js","sourceRoot":"","sources":["../../../src/cmds/builder/loadKeypair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"loadKeypair.js","sourceRoot":"","sources":["../../../src/cmds/builder/loadKeypair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,YAAoB,EACpB,YAAoB,EACpB,cAAuB;IAEvB,MAAM,QAAQ,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAClD,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAE7C,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QAC/C,MAAM,KAAK,CAAC,iCAAiC,YAAY,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAEtD,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;IAC1C,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC;IAEvC,IAAI,cAAc,IAAI,YAAY,KAAK,cAAc,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QACpF,MAAM,KAAK,CAAC,6BAA6B,YAAY,cAAc,cAAc,EAAE,CAAC,CAAC;IACvF,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAC,MAAM,EAAE,YAAY,EAAC,CAAC,CAAC;IAE/D,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,CAAC;AAChC,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { CliCommandOptions } from "@lodestar/utils";
|
|
2
2
|
import { LogArgs } from "../../options/logOptions.js";
|
|
3
|
+
export declare const builderMetricsDefaultOptions: {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
port: number;
|
|
6
|
+
address: string;
|
|
7
|
+
};
|
|
3
8
|
export type IBuilderCliArgs = LogArgs & {
|
|
4
9
|
beaconNodeUrl: string;
|
|
5
10
|
keystore: string;
|
|
@@ -7,6 +12,9 @@ export type IBuilderCliArgs = LogArgs & {
|
|
|
7
12
|
builderPubkey?: string;
|
|
8
13
|
executionFeeRecipient: string;
|
|
9
14
|
requestTimeout: number;
|
|
15
|
+
metrics?: boolean;
|
|
16
|
+
"metrics.port"?: number;
|
|
17
|
+
"metrics.address"?: string;
|
|
10
18
|
};
|
|
11
19
|
export declare const builderOptions: CliCommandOptions<IBuilderCliArgs>;
|
|
12
20
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,OAAO,EAAa,MAAM,6BAA6B,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,OAAO,EAAa,MAAM,6BAA6B,CAAC;AAEhE,eAAO,MAAM,4BAA4B;IACvC,OAAO;IACP,IAAI;IACJ,OAAO;CACR,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;IAEvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,eAAe,CA4D7D,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { defaultOptions } from "@lodestar/builder";
|
|
2
2
|
import { logOptions } from "../../options/logOptions.js";
|
|
3
|
+
export const builderMetricsDefaultOptions = {
|
|
4
|
+
enabled: false,
|
|
5
|
+
port: 5065,
|
|
6
|
+
address: "127.0.0.1",
|
|
7
|
+
};
|
|
3
8
|
export const builderOptions = {
|
|
4
9
|
...logOptions,
|
|
5
10
|
beaconNodeUrl: {
|
|
@@ -31,5 +36,24 @@ export const builderOptions = {
|
|
|
31
36
|
type: "number",
|
|
32
37
|
default: defaultOptions.requestTimeout,
|
|
33
38
|
},
|
|
39
|
+
// Metrics
|
|
40
|
+
metrics: {
|
|
41
|
+
description: "Enable the Prometheus metrics HTTP server",
|
|
42
|
+
type: "boolean",
|
|
43
|
+
defaultDescription: String(builderMetricsDefaultOptions.enabled),
|
|
44
|
+
group: "metrics",
|
|
45
|
+
},
|
|
46
|
+
"metrics.port": {
|
|
47
|
+
description: "Listen TCP port for the Prometheus metrics HTTP server",
|
|
48
|
+
type: "number",
|
|
49
|
+
defaultDescription: String(builderMetricsDefaultOptions.port),
|
|
50
|
+
group: "metrics",
|
|
51
|
+
},
|
|
52
|
+
"metrics.address": {
|
|
53
|
+
description: "Listen address for the Prometheus metrics HTTP server",
|
|
54
|
+
type: "string",
|
|
55
|
+
defaultDescription: String(builderMetricsDefaultOptions.address),
|
|
56
|
+
group: "metrics",
|
|
57
|
+
},
|
|
34
58
|
};
|
|
35
59
|
//# sourceMappingURL=options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/cmds/builder/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAU,UAAU,EAAC,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/cmds/builder/options.ts"],"names":[],"mappings":"AAAA,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;QACpE,IAAI,EAAE,QAAQ;QACd,kBAAkB,EAAE,MAAM,CAAC,4BAA4B,CAAC,OAAO,CAAC;QAChE,KAAK,EAAE,SAAS;KACjB;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainsafe/lodestar",
|
|
3
|
-
"version": "1.47.0-dev.
|
|
3
|
+
"version": "1.47.0-dev.ee197a8d7f",
|
|
4
4
|
"description": "Command line interface for lodestar",
|
|
5
5
|
"author": "ChainSafe Systems",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -68,17 +68,17 @@
|
|
|
68
68
|
"@libp2p/crypto": "^5.1.13",
|
|
69
69
|
"@libp2p/interface": "^3.1.0",
|
|
70
70
|
"@libp2p/peer-id": "^6.0.4",
|
|
71
|
-
"@lodestar/api": "^1.47.0-dev.
|
|
72
|
-
"@lodestar/beacon-node": "^1.47.0-dev.
|
|
73
|
-
"@lodestar/builder": "^1.47.0-dev.
|
|
74
|
-
"@lodestar/config": "^1.47.0-dev.
|
|
75
|
-
"@lodestar/db": "^1.47.0-dev.
|
|
76
|
-
"@lodestar/logger": "^1.47.0-dev.
|
|
77
|
-
"@lodestar/params": "^1.47.0-dev.
|
|
78
|
-
"@lodestar/state-transition": "^1.47.0-dev.
|
|
79
|
-
"@lodestar/types": "^1.47.0-dev.
|
|
80
|
-
"@lodestar/utils": "^1.47.0-dev.
|
|
81
|
-
"@lodestar/validator": "^1.47.0-dev.
|
|
71
|
+
"@lodestar/api": "^1.47.0-dev.ee197a8d7f",
|
|
72
|
+
"@lodestar/beacon-node": "^1.47.0-dev.ee197a8d7f",
|
|
73
|
+
"@lodestar/builder": "^1.47.0-dev.ee197a8d7f",
|
|
74
|
+
"@lodestar/config": "^1.47.0-dev.ee197a8d7f",
|
|
75
|
+
"@lodestar/db": "^1.47.0-dev.ee197a8d7f",
|
|
76
|
+
"@lodestar/logger": "^1.47.0-dev.ee197a8d7f",
|
|
77
|
+
"@lodestar/params": "^1.47.0-dev.ee197a8d7f",
|
|
78
|
+
"@lodestar/state-transition": "^1.47.0-dev.ee197a8d7f",
|
|
79
|
+
"@lodestar/types": "^1.47.0-dev.ee197a8d7f",
|
|
80
|
+
"@lodestar/utils": "^1.47.0-dev.ee197a8d7f",
|
|
81
|
+
"@lodestar/validator": "^1.47.0-dev.ee197a8d7f",
|
|
82
82
|
"@multiformats/multiaddr": "^13.0.1",
|
|
83
83
|
"deepmerge": "^4.3.1",
|
|
84
84
|
"ethers": "^6.7.0",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@chainsafe/as-sha256": "^1.2.4",
|
|
96
96
|
"@ethereumjs/rlp": "^4.0.1",
|
|
97
|
-
"@lodestar/test-utils": "^1.47.0-dev.
|
|
97
|
+
"@lodestar/test-utils": "^1.47.0-dev.ee197a8d7f",
|
|
98
98
|
"@types/debug": "^4.1.7",
|
|
99
99
|
"@types/inquirer": "^9.0.3",
|
|
100
100
|
"@types/js-yaml": "^4.0.5",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"web3": "^4.0.3",
|
|
109
109
|
"web3-eth-accounts": "^4.0.3"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "2e730bed9c064ffd8cfd4d1ff9f4a916fe82dfea"
|
|
112
112
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import {getClient} from "@lodestar/api";
|
|
3
|
-
import {
|
|
3
|
+
import {RegistryMetricCreator, collectNodeJSMetrics, getHttpMetricsServer} from "@lodestar/beacon-node";
|
|
4
|
+
import {Builder, getMetrics} from "@lodestar/builder";
|
|
4
5
|
import {getNodeLogger} from "@lodestar/logger/node";
|
|
5
6
|
import {fromHex, toPrintableUrl} from "@lodestar/utils";
|
|
6
7
|
import {getBeaconConfigFromArgs} from "../../config/beaconParams.js";
|
|
7
8
|
import {GlobalArgs} from "../../options/index.js";
|
|
8
9
|
import {getGlobalPaths} from "../../paths/global.js";
|
|
9
10
|
import {cleanOldLogFiles, onGracefulShutdown, parseFeeRecipient, parseLoggerArgs} from "../../util/index.js";
|
|
11
|
+
import {getVersionData} from "../../util/version.js";
|
|
10
12
|
import {loadBuilderKeypair} from "./loadKeypair.js";
|
|
11
|
-
import {IBuilderCliArgs} from "./options.js";
|
|
13
|
+
import {IBuilderCliArgs, builderMetricsDefaultOptions} from "./options.js";
|
|
12
14
|
|
|
13
15
|
const ZERO_ADDRESS = "0x" + "0".repeat(40);
|
|
14
16
|
|
|
@@ -29,13 +31,16 @@ export async function builderHandler(args: IBuilderCliArgs & GlobalArgs): Promis
|
|
|
29
31
|
logger.debug("Not able to delete log files", {}, e as Error);
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
const {version, commit} = getVersionData();
|
|
35
|
+
logger.info("Lodestar", {network, version, commit});
|
|
36
|
+
|
|
32
37
|
const executionFeeRecipient = parseFeeRecipient(args.executionFeeRecipient);
|
|
33
38
|
|
|
34
39
|
if (executionFeeRecipient === ZERO_ADDRESS) {
|
|
35
40
|
throw Error("Cannot put zero address as an executionFeeRecipient");
|
|
36
41
|
}
|
|
37
42
|
|
|
38
|
-
const keypair = await loadBuilderKeypair(args.keystore, args.keystorePassword, args.builderPubkey);
|
|
43
|
+
const keypair = await loadBuilderKeypair(logger, args.keystore, args.keystorePassword, args.builderPubkey);
|
|
39
44
|
|
|
40
45
|
const onGracefulShutdownCbs: (() => Promise<void> | void)[] = [];
|
|
41
46
|
onGracefulShutdown(async () => {
|
|
@@ -45,9 +50,23 @@ export async function builderHandler(args: IBuilderCliArgs & GlobalArgs): Promis
|
|
|
45
50
|
const abortController = new AbortController();
|
|
46
51
|
onGracefulShutdownCbs.push(async () => abortController.abort());
|
|
47
52
|
|
|
53
|
+
const register = args.metrics ? new RegistryMetricCreator() : null;
|
|
54
|
+
const metrics = register && getMetrics(register, {version, commit, network});
|
|
55
|
+
|
|
56
|
+
if (metrics) {
|
|
57
|
+
const closeMetrics = collectNodeJSMetrics(register);
|
|
58
|
+
onGracefulShutdownCbs.push(() => closeMetrics());
|
|
59
|
+
|
|
60
|
+
const port = args["metrics.port"] ?? builderMetricsDefaultOptions.port;
|
|
61
|
+
const address = args["metrics.address"] ?? builderMetricsDefaultOptions.address;
|
|
62
|
+
const metricsServer = await getHttpMetricsServer({port, address}, {register, logger});
|
|
63
|
+
|
|
64
|
+
onGracefulShutdownCbs.push(() => metricsServer.close());
|
|
65
|
+
}
|
|
66
|
+
|
|
48
67
|
const api = getClient(
|
|
49
68
|
{urls: [args.beaconNodeUrl], globalInit: {signal: abortController.signal, timeoutMs: args.requestTimeout}},
|
|
50
|
-
{config, logger}
|
|
69
|
+
{config, logger, metrics: metrics?.restApiClient}
|
|
51
70
|
);
|
|
52
71
|
|
|
53
72
|
logger.info("Beacon node", {beaconNode: toPrintableUrl(args.beaconNodeUrl), timeoutMs: args.requestTimeout});
|
|
@@ -59,6 +78,7 @@ export async function builderHandler(args: IBuilderCliArgs & GlobalArgs): Promis
|
|
|
59
78
|
abortController,
|
|
60
79
|
api,
|
|
61
80
|
executionFeeRecipient: fromHex(executionFeeRecipient),
|
|
81
|
+
metrics,
|
|
62
82
|
});
|
|
63
83
|
|
|
64
84
|
onGracefulShutdownCbs.push(() => builder.close());
|
|
@@ -2,10 +2,12 @@ import fs from "node:fs";
|
|
|
2
2
|
import {Keystore} from "@chainsafe/bls-keystore";
|
|
3
3
|
import {SecretKey} from "@chainsafe/blst";
|
|
4
4
|
import {Keypair} from "@lodestar/builder";
|
|
5
|
+
import {Logger} from "@lodestar/utils";
|
|
5
6
|
import {ensure0xPrefix} from "../../util/format.js";
|
|
6
7
|
import {readPassphraseFile} from "../../util/passphrase.js";
|
|
7
8
|
|
|
8
9
|
export async function loadBuilderKeypair(
|
|
10
|
+
logger: Logger,
|
|
9
11
|
keystorePath: string,
|
|
10
12
|
passwordPath: string,
|
|
11
13
|
expectedPubkey?: string
|
|
@@ -28,5 +30,7 @@ export async function loadBuilderKeypair(
|
|
|
28
30
|
throw Error(`Pubkey mismatch: keystore ${publicKeyHex}, expected ${expectedPubkey}`);
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
logger.info("Loaded builder keystore", {pubkey: publicKeyHex});
|
|
34
|
+
|
|
31
35
|
return {secretKey, publicKey};
|
|
32
36
|
}
|
|
@@ -2,6 +2,12 @@ import {defaultOptions} from "@lodestar/builder";
|
|
|
2
2
|
import {CliCommandOptions} from "@lodestar/utils";
|
|
3
3
|
import {LogArgs, logOptions} from "../../options/logOptions.js";
|
|
4
4
|
|
|
5
|
+
export const builderMetricsDefaultOptions = {
|
|
6
|
+
enabled: false,
|
|
7
|
+
port: 5065,
|
|
8
|
+
address: "127.0.0.1",
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
export type IBuilderCliArgs = LogArgs & {
|
|
6
12
|
beaconNodeUrl: string;
|
|
7
13
|
keystore: string;
|
|
@@ -9,6 +15,10 @@ export type IBuilderCliArgs = LogArgs & {
|
|
|
9
15
|
builderPubkey?: string;
|
|
10
16
|
executionFeeRecipient: string;
|
|
11
17
|
requestTimeout: number;
|
|
18
|
+
|
|
19
|
+
metrics?: boolean;
|
|
20
|
+
"metrics.port"?: number;
|
|
21
|
+
"metrics.address"?: string;
|
|
12
22
|
};
|
|
13
23
|
|
|
14
24
|
export const builderOptions: CliCommandOptions<IBuilderCliArgs> = {
|
|
@@ -48,4 +58,27 @@ export const builderOptions: CliCommandOptions<IBuilderCliArgs> = {
|
|
|
48
58
|
type: "number",
|
|
49
59
|
default: defaultOptions.requestTimeout,
|
|
50
60
|
},
|
|
61
|
+
|
|
62
|
+
// Metrics
|
|
63
|
+
|
|
64
|
+
metrics: {
|
|
65
|
+
description: "Enable the Prometheus metrics HTTP server",
|
|
66
|
+
type: "boolean",
|
|
67
|
+
defaultDescription: String(builderMetricsDefaultOptions.enabled),
|
|
68
|
+
group: "metrics",
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
"metrics.port": {
|
|
72
|
+
description: "Listen TCP port for the Prometheus metrics HTTP server",
|
|
73
|
+
type: "number",
|
|
74
|
+
defaultDescription: String(builderMetricsDefaultOptions.port),
|
|
75
|
+
group: "metrics",
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
"metrics.address": {
|
|
79
|
+
description: "Listen address for the Prometheus metrics HTTP server",
|
|
80
|
+
type: "string",
|
|
81
|
+
defaultDescription: String(builderMetricsDefaultOptions.address),
|
|
82
|
+
group: "metrics",
|
|
83
|
+
},
|
|
51
84
|
};
|