@chainsafe/lodestar 1.9.0-dev.812ac926d1 → 1.9.0-dev.82914a1443
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/beacon/handler.js +48 -11
- package/lib/cmds/beacon/handler.js.map +1 -1
- package/lib/cmds/beacon/options.d.ts +2 -0
- package/lib/cmds/beacon/options.js +9 -0
- package/lib/cmds/beacon/options.js.map +1 -1
- package/lib/cmds/dev/options.d.ts +3 -1
- package/lib/cmds/validator/handler.js +16 -20
- package/lib/cmds/validator/handler.js.map +1 -1
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions.d.ts +16 -0
- package/lib/cmds/validator/keymanager/{decryptKeystoreDefinitions/index.js → decryptKeystoreDefinitions.js} +42 -32
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions.js.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/index.d.ts +2 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/index.js +2 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/index.js.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/poolSize.d.ts +6 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/poolSize.js +19 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/poolSize.js.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/threadPool.d.ts +25 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/threadPool.js +53 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/threadPool.js.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/types.d.ts +11 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/types.js +4 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/types.js.map +1 -0
- package/lib/cmds/validator/keymanager/decryptKeystores/worker.d.ts +9 -0
- package/lib/cmds/validator/keymanager/{decryptKeystoreDefinitions → decryptKeystores}/worker.js +6 -5
- package/lib/cmds/validator/keymanager/decryptKeystores/worker.js.map +1 -0
- package/lib/cmds/validator/keymanager/impl.d.ts +2 -1
- package/lib/cmds/validator/keymanager/impl.js +23 -16
- package/lib/cmds/validator/keymanager/impl.js.map +1 -1
- package/lib/cmds/validator/keymanager/keystoreCache.js +2 -1
- package/lib/cmds/validator/keymanager/keystoreCache.js.map +1 -1
- package/lib/cmds/validator/options.d.ts +1 -0
- package/lib/cmds/validator/options.js +5 -0
- package/lib/cmds/validator/options.js.map +1 -1
- package/lib/cmds/validator/signers/importExternalKeystores.js +0 -2
- package/lib/cmds/validator/signers/importExternalKeystores.js.map +1 -1
- package/lib/cmds/validator/signers/index.js +3 -1
- package/lib/cmds/validator/signers/index.js.map +1 -1
- package/lib/cmds/validator/slashingProtection/export.js +1 -1
- package/lib/cmds/validator/slashingProtection/export.js.map +1 -1
- package/lib/cmds/validator/slashingProtection/import.js +1 -1
- package/lib/cmds/validator/slashingProtection/import.js.map +1 -1
- package/lib/cmds/validator/slashingProtection/utils.d.ts +2 -2
- package/lib/cmds/validator/slashingProtection/utils.js +4 -8
- package/lib/cmds/validator/slashingProtection/utils.js.map +1 -1
- package/lib/options/beaconNodeOptions/api.d.ts +1 -0
- package/lib/options/beaconNodeOptions/api.js +6 -0
- package/lib/options/beaconNodeOptions/api.js.map +1 -1
- package/lib/options/beaconNodeOptions/builder.d.ts +0 -1
- package/lib/options/beaconNodeOptions/builder.js +0 -9
- package/lib/options/beaconNodeOptions/builder.js.map +1 -1
- package/lib/options/beaconNodeOptions/index.d.ts +2 -1
- package/lib/options/beaconNodeOptions/network.d.ts +1 -0
- package/lib/options/beaconNodeOptions/network.js +6 -0
- package/lib/options/beaconNodeOptions/network.js.map +1 -1
- package/lib/options/logOptions.js +1 -1
- package/lib/options/logOptions.js.map +1 -1
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/pruneOldFilesInDir.d.ts +2 -0
- package/lib/util/pruneOldFilesInDir.js +17 -0
- package/lib/util/pruneOldFilesInDir.js.map +1 -0
- package/package.json +16 -16
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/index.d.ts +0 -8
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/index.js.map +0 -1
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/poolSize.d.ts +0 -6
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/poolSize.js +0 -19
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/poolSize.js.map +0 -1
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/types.d.ts +0 -12
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/types.js +0 -2
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/types.js.map +0 -1
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/worker.d.ts +0 -9
- package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions/worker.js.map +0 -1
package/.git-data.json
CHANGED
|
@@ -9,11 +9,13 @@ import { getNodeLogger } from "@lodestar/logger/node";
|
|
|
9
9
|
import { parseBeaconNodeArgs } from "../../options/index.js";
|
|
10
10
|
import { BeaconNodeOptions, getBeaconConfigFromArgs } from "../../config/index.js";
|
|
11
11
|
import { getNetworkBootnodes, getNetworkData, isKnownNetworkName, readBootnodes } from "../../networks/index.js";
|
|
12
|
-
import { onGracefulShutdown, mkdir, writeFile600Perm, cleanOldLogFiles, parseLoggerArgs } from "../../util/index.js";
|
|
12
|
+
import { onGracefulShutdown, mkdir, writeFile600Perm, cleanOldLogFiles, parseLoggerArgs, pruneOldFilesInDir, } from "../../util/index.js";
|
|
13
13
|
import { getVersionData } from "../../util/version.js";
|
|
14
14
|
import { getBeaconPaths } from "./paths.js";
|
|
15
15
|
import { initBeaconState } from "./initBeaconState.js";
|
|
16
16
|
import { initPeerIdAndEnr } from "./initPeerIdAndEnr.js";
|
|
17
|
+
const DEFAULT_RETENTION_SSZ_OBJECTS_HOURS = 15 * 24;
|
|
18
|
+
const HOURS_TO_MS = 3600 * 1000;
|
|
17
19
|
/**
|
|
18
20
|
* Runs a beacon node.
|
|
19
21
|
*/
|
|
@@ -40,11 +42,7 @@ export async function beaconHandler(args) {
|
|
|
40
42
|
networkRegistry = new Registry();
|
|
41
43
|
metricsRegistries.push(networkRegistry);
|
|
42
44
|
}
|
|
43
|
-
const db = new BeaconDb({
|
|
44
|
-
config,
|
|
45
|
-
controller: new LevelDbController(options.db, { metrics: null, logger }),
|
|
46
|
-
});
|
|
47
|
-
await db.start();
|
|
45
|
+
const db = new BeaconDb(config, await LevelDbController.create(options.db, { metrics: null, logger }));
|
|
48
46
|
logger.info("Connected to LevelDB database", { path: options.db.name });
|
|
49
47
|
// BeaconNode setup
|
|
50
48
|
try {
|
|
@@ -62,8 +60,25 @@ export async function beaconHandler(args) {
|
|
|
62
60
|
wsCheckpoint,
|
|
63
61
|
metricsRegistries,
|
|
64
62
|
});
|
|
65
|
-
|
|
63
|
+
// dev debug option to have access to the BN instance
|
|
64
|
+
if (args.attachToGlobalThis) {
|
|
66
65
|
globalThis.bn = node;
|
|
66
|
+
}
|
|
67
|
+
// Prune invalid SSZ objects every interval
|
|
68
|
+
const { persistInvalidSszObjectsDir } = args;
|
|
69
|
+
const pruneInvalidSSZObjectsInterval = persistInvalidSszObjectsDir
|
|
70
|
+
? setInterval(() => {
|
|
71
|
+
var _a;
|
|
72
|
+
try {
|
|
73
|
+
pruneOldFilesInDir(persistInvalidSszObjectsDir, ((_a = args.persistInvalidSszObjectsRetentionHours) !== null && _a !== void 0 ? _a : DEFAULT_RETENTION_SSZ_OBJECTS_HOURS) * HOURS_TO_MS);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
logger.warn("Error pruning invalid SSZ objects", { persistInvalidSszObjectsDir }, e);
|
|
77
|
+
}
|
|
78
|
+
// Run every ~1 hour
|
|
79
|
+
}, HOURS_TO_MS)
|
|
80
|
+
: null;
|
|
81
|
+
// Intercept SIGINT signal, to perform final ops before exiting
|
|
67
82
|
onGracefulShutdown(async () => {
|
|
68
83
|
if (args.persistNetworkIdentity) {
|
|
69
84
|
try {
|
|
@@ -76,11 +91,26 @@ export async function beaconHandler(args) {
|
|
|
76
91
|
}
|
|
77
92
|
}
|
|
78
93
|
abortController.abort();
|
|
94
|
+
if (pruneInvalidSSZObjectsInterval !== null) {
|
|
95
|
+
clearInterval(pruneInvalidSSZObjectsInterval);
|
|
96
|
+
}
|
|
79
97
|
}, logger.info.bind(logger));
|
|
80
|
-
abortController.signal.addEventListener("abort", () =>
|
|
98
|
+
abortController.signal.addEventListener("abort", async () => {
|
|
99
|
+
try {
|
|
100
|
+
await node.close();
|
|
101
|
+
logger.debug("Beacon node closed");
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
logger.error("Error closing beacon node", {}, e);
|
|
105
|
+
// Make sure db is always closed gracefully
|
|
106
|
+
await db.close();
|
|
107
|
+
// Must explicitly exit process due to potential active handles
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
}, { once: true });
|
|
81
111
|
}
|
|
82
112
|
catch (e) {
|
|
83
|
-
await db.
|
|
113
|
+
await db.close();
|
|
84
114
|
if (e instanceof ErrorAborted) {
|
|
85
115
|
logger.info(e.message); // Let the user know the abort was received but don't print as error
|
|
86
116
|
}
|
|
@@ -116,8 +146,15 @@ export async function beaconHandlerInit(args) {
|
|
|
116
146
|
const { peerId, enr } = await initPeerIdAndEnr(args, beaconPaths.beaconDir, logger);
|
|
117
147
|
// Inject ENR to beacon options
|
|
118
148
|
beaconNodeOptions.set({ network: { discv5: { enr: enr.encodeTxt(), config: { enrUpdate: !enr.ip && !enr.ip6 } } } });
|
|
119
|
-
|
|
120
|
-
|
|
149
|
+
if (args.private) {
|
|
150
|
+
beaconNodeOptions.set({ network: { private: true } });
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// Add simple version string for libp2p agent version
|
|
154
|
+
beaconNodeOptions.set({ network: { version: version.split("/")[0] } });
|
|
155
|
+
// Add User-Agent header to all builder requests
|
|
156
|
+
beaconNodeOptions.set({ executionBuilder: { userAgent: `Lodestar/${version}` } });
|
|
157
|
+
}
|
|
121
158
|
// Render final options
|
|
122
159
|
const options = beaconNodeOptions.getWithDefaults();
|
|
123
160
|
return { config, options, beaconPaths, network, version, commit, peerId, logger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/cmds/beacon/handler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAkB,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAa,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAa,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAC,iBAAiB,EAAE,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAC,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAC/G,OAAO,
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/cmds/beacon/handler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,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M,EAAE,MAAM,EAAE,MAAM,EAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,OAAe,EAAE,MAAuB;IACnF,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,aAAa,CAAC,eAAe,CAAC,IAAI,EAAE,EAAC,kBAAkB,EAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAClF,IAAI;QACF,gBAAgB,CAAC,IAAI,EAAE,EAAC,kBAAkB,EAAC,CAAC,CAAC;KAC9C;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,EAAE,EAAE,CAAU,CAAC,CAAC;KAC9D;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -14,8 +14,10 @@ type BeaconExtraArgs = {
|
|
|
14
14
|
beaconDir?: string;
|
|
15
15
|
dbDir?: string;
|
|
16
16
|
persistInvalidSszObjectsDir?: string;
|
|
17
|
+
persistInvalidSszObjectsRetentionHours?: number;
|
|
17
18
|
peerStoreDir?: string;
|
|
18
19
|
persistNetworkIdentity?: boolean;
|
|
20
|
+
private?: boolean;
|
|
19
21
|
};
|
|
20
22
|
export declare const beaconExtraOptions: CliCommandOptions<BeaconExtraArgs>;
|
|
21
23
|
type ENRArgs = {
|
|
@@ -55,6 +55,11 @@ export const beaconExtraOptions = {
|
|
|
55
55
|
hidden: true,
|
|
56
56
|
type: "string",
|
|
57
57
|
},
|
|
58
|
+
persistInvalidSszObjectsRetentionHours: {
|
|
59
|
+
description: "Number of hours to keep invalid SSZ objects on local disk",
|
|
60
|
+
hidden: true,
|
|
61
|
+
type: "number",
|
|
62
|
+
},
|
|
58
63
|
peerStoreDir: {
|
|
59
64
|
hidden: true,
|
|
60
65
|
description: "Peer store directory",
|
|
@@ -66,6 +71,10 @@ export const beaconExtraOptions = {
|
|
|
66
71
|
description: "Whether to reuse the same peer-id across restarts",
|
|
67
72
|
type: "boolean",
|
|
68
73
|
},
|
|
74
|
+
private: {
|
|
75
|
+
description: "Do not send implementation details over p2p identify protocol and in builder requests",
|
|
76
|
+
type: "boolean",
|
|
77
|
+
},
|
|
69
78
|
};
|
|
70
79
|
const enrOptions = {
|
|
71
80
|
"enr.ip": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/cmds/beacon/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAiB,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAU,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAC,kBAAkB,EAAc,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/cmds/beacon/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAE,aAAa,EAAiB,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAU,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAC,kBAAkB,EAAc,MAAM,YAAY,CAAC;AAmB3D,MAAM,CAAC,MAAM,kBAAkB,GAAuC;IACpE,YAAY,EAAE;QACZ,WAAW,EAAE,6CAA6C;QAC1D,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,IAAI;KACb;IAED,gBAAgB,EAAE;QAChB,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,oEAAoE;QACjF,IAAI,EAAE,QAAQ;KACf;IAED,UAAU,EAAE;QACV,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,kDAAkD;QAC/D,IAAI,EAAE,QAAQ;KACf;IAED,aAAa,EAAE;QACb,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,qBAAqB;QAClC,IAAI,EAAE,QAAQ;KACf;IAED,iBAAiB,EAAE;QACjB,WAAW,EACT,mIAAmI;QACrI,IAAI,EAAE,QA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EAAE,wBAAwB;QACrC,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,KAAK;KACb;IACD,SAAS,EAAE;QACT,WAAW,EAAE,wBAAwB;QACrC,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,KAAK;KACb;IACD,SAAS,EAAE;QACT,WAAW,EAAE,yBAAyB;QACtC,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,KAAK;KACb;IACD,UAAU,EAAE;QACV,WAAW,EAAE,wCAAwC;QACrD,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,KAAK;KACb;IACD,UAAU,EAAE;QACV,WAAW,EAAE,wCAAwC;QACrD,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,KAAK;KACb;IACD,GAAG,EAAE;QACH,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,4CAA4C;QACzD,KAAK,EAAE,KAAK;KACb;CACF,CAAC;AAGF,MAAM,CAAC,MAAM,YAAY,GAAiC;IACxD,kBAAkB,EAAE;QAClB,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,kFAAkF;QAC/F,IAAI,EAAE,SAAS;KAChB;CACF,CAAC;AAIF,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,GAAG,kBAAkB;IACrB,GAAG,UAAU;IACb,GAAG,iBAAiB;IACpB,GAAG,aAAa;IAChB,GAAG,UAAU;IACb,GAAG,YAAY;CAChB,CAAC"}
|
|
@@ -33,12 +33,12 @@ export declare const devOptions: {
|
|
|
33
33
|
"rest.cors"?: Options | undefined;
|
|
34
34
|
"rest.address"?: Options | undefined;
|
|
35
35
|
"rest.port"?: Options | undefined;
|
|
36
|
+
"rest.headerLimit"?: Options | undefined;
|
|
36
37
|
"rest.bodyLimit"?: Options | undefined;
|
|
37
38
|
"builder.urls"?: Options | undefined;
|
|
38
39
|
"builder.timeout"?: Options | undefined;
|
|
39
40
|
"builder.faultInspectionWindow"?: Options | undefined;
|
|
40
41
|
"builder.allowedFaults"?: Options | undefined;
|
|
41
|
-
"builder.userAgent"?: Options | undefined;
|
|
42
42
|
"chain.blsVerifyAllMultiThread"?: Options | undefined;
|
|
43
43
|
"chain.blsVerifyAllMainThread"?: Options | undefined;
|
|
44
44
|
"chain.disableBlsBatchVerify"?: Options | undefined;
|
|
@@ -83,6 +83,7 @@ export declare const devOptions: {
|
|
|
83
83
|
"network.gossipsubAwaitHandler"?: Options | undefined;
|
|
84
84
|
"network.rateLimitMultiplier"?: Options | undefined;
|
|
85
85
|
"network.maxGossipTopicConcurrency"?: Options | undefined;
|
|
86
|
+
"network.useWorker"?: Options | undefined;
|
|
86
87
|
listenAddress?: Options | undefined;
|
|
87
88
|
discoveryPort?: Options | undefined;
|
|
88
89
|
"network.requestCountPeerLimit"?: Options | undefined;
|
|
@@ -102,6 +103,7 @@ export declare const devOptions: {
|
|
|
102
103
|
"keymanager.port": Options;
|
|
103
104
|
"keymanager.address": Options;
|
|
104
105
|
"keymanager.cors": Options;
|
|
106
|
+
"keymanager.headerLimit": Options;
|
|
105
107
|
"keymanager.bodyLimit": Options;
|
|
106
108
|
logLevel: Options;
|
|
107
109
|
logFile: Options;
|
|
@@ -3,7 +3,7 @@ import { setMaxListeners } from "node:events";
|
|
|
3
3
|
import { LevelDbController } from "@lodestar/db";
|
|
4
4
|
import { SlashingProtection, Validator, } from "@lodestar/validator";
|
|
5
5
|
import { getMetrics } from "@lodestar/validator";
|
|
6
|
-
import { RegistryMetricCreator, collectNodeJSMetrics,
|
|
6
|
+
import { RegistryMetricCreator, collectNodeJSMetrics, getHttpMetricsServer, MonitoringService, } from "@lodestar/beacon-node";
|
|
7
7
|
import { getNodeLogger } from "@lodestar/logger/node";
|
|
8
8
|
import { getBeaconConfigFromArgs } from "../../config/index.js";
|
|
9
9
|
import { YargsError, cleanOldLogFiles, getDefaultGraffiti, mkdir, parseLoggerArgs } from "../../util/index.js";
|
|
@@ -54,6 +54,11 @@ export async function validatorHandler(args) {
|
|
|
54
54
|
};
|
|
55
55
|
// This AbortController interrupts various validators ops: genesis req, clients call, clock etc
|
|
56
56
|
const abortController = new AbortController();
|
|
57
|
+
// We set infinity for abort controller used for validator operations,
|
|
58
|
+
// to prevent MaxListenersExceededWarning which get logged when listeners > 10
|
|
59
|
+
// Since it is perfectly fine to have listeners > 10
|
|
60
|
+
setMaxListeners(Infinity, abortController.signal);
|
|
61
|
+
onGracefulShutdownCbs.push(async () => abortController.abort());
|
|
57
62
|
/**
|
|
58
63
|
* For rationale and documentation of how signers are loaded from args and disk,
|
|
59
64
|
* see {@link PersistedKeysBackend} and {@link getSignersFromArgs}
|
|
@@ -71,18 +76,9 @@ export async function validatorHandler(args) {
|
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
logSigners(logger, signers);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
setMaxListeners(Infinity, abortController.signal);
|
|
78
|
-
onGracefulShutdownCbs.push(async () => abortController.abort());
|
|
79
|
-
const dbOps = {
|
|
80
|
-
config,
|
|
81
|
-
controller: new LevelDbController({ name: dbPath }, { metrics: null, logger }),
|
|
82
|
-
};
|
|
83
|
-
onGracefulShutdownCbs.push(() => dbOps.controller.stop());
|
|
84
|
-
await dbOps.controller.start();
|
|
85
|
-
const slashingProtection = new SlashingProtection(dbOps);
|
|
79
|
+
const db = await LevelDbController.create({ name: dbPath }, { metrics: null, logger });
|
|
80
|
+
onGracefulShutdownCbs.push(() => db.close());
|
|
81
|
+
const slashingProtection = new SlashingProtection(db);
|
|
86
82
|
// Create metrics registry if metrics are enabled or monitoring endpoint is configured
|
|
87
83
|
// Send version and network data for static registries
|
|
88
84
|
const register = args["metrics"] || args["monitoring.endpoint"] ? new RegistryMetricCreator() : null;
|
|
@@ -95,9 +91,8 @@ export async function validatorHandler(args) {
|
|
|
95
91
|
if (args["metrics"]) {
|
|
96
92
|
const port = (_a = args["metrics.port"]) !== null && _a !== void 0 ? _a : validatorMetricsDefaultOptions.port;
|
|
97
93
|
const address = (_b = args["metrics.address"]) !== null && _b !== void 0 ? _b : validatorMetricsDefaultOptions.address;
|
|
98
|
-
const metricsServer =
|
|
99
|
-
onGracefulShutdownCbs.push(() => metricsServer.
|
|
100
|
-
await metricsServer.start();
|
|
94
|
+
const metricsServer = await getHttpMetricsServer({ port, address }, { register, logger });
|
|
95
|
+
onGracefulShutdownCbs.push(() => metricsServer.close());
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
98
|
if (args["monitoring.endpoint"]) {
|
|
@@ -109,13 +104,13 @@ export async function validatorHandler(args) {
|
|
|
109
104
|
requestTimeout: (_e = args["monitoring.requestTimeout"]) !== null && _e !== void 0 ? _e : requestTimeout,
|
|
110
105
|
collectSystemStats: (_f = args["monitoring.collectSystemStats"]) !== null && _f !== void 0 ? _f : collectSystemStats,
|
|
111
106
|
}, { register: register, logger });
|
|
112
|
-
onGracefulShutdownCbs.push(() => monitoring.
|
|
113
|
-
monitoring.start();
|
|
107
|
+
onGracefulShutdownCbs.push(() => monitoring.close());
|
|
114
108
|
}
|
|
115
109
|
// This promise resolves once genesis is available.
|
|
116
110
|
// It will wait for genesis, so this promise can be potentially very long
|
|
117
111
|
const validator = await Validator.initializeFromBeaconNode({
|
|
118
|
-
|
|
112
|
+
db,
|
|
113
|
+
config,
|
|
119
114
|
slashingProtection,
|
|
120
115
|
api: args.beaconNodes,
|
|
121
116
|
logger,
|
|
@@ -138,12 +133,13 @@ export async function validatorHandler(args) {
|
|
|
138
133
|
if (proposerConfigWriteDisabled) {
|
|
139
134
|
logger.warn("Proposer data updates (feeRecipient/gasLimit etc) will not be available via Keymanager API as proposerSettingsFile has been set");
|
|
140
135
|
}
|
|
141
|
-
const keymanagerApi = new KeymanagerApi(validator, persistedKeysBackend, proposerConfigWriteDisabled);
|
|
136
|
+
const keymanagerApi = new KeymanagerApi(validator, persistedKeysBackend, abortController.signal, proposerConfigWriteDisabled);
|
|
142
137
|
const keymanagerServer = new KeymanagerRestApiServer({
|
|
143
138
|
address: args["keymanager.address"],
|
|
144
139
|
port: args["keymanager.port"],
|
|
145
140
|
cors: args["keymanager.cors"],
|
|
146
141
|
isAuthEnabled: args["keymanager.authEnabled"],
|
|
142
|
+
headerLimit: args["keymanager.headerLimit"],
|
|
147
143
|
bodyLimit: args["keymanager.bodyLimit"],
|
|
148
144
|
tokenDir: dbPath,
|
|
149
145
|
}, { config, logger, api: keymanagerApi, metrics: metrics ? metrics.keymanagerApiRest : null });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/cmds/validator/handler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,EAEL,kBAAkB,EAClB,SAAS,GAGV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,UAAU,EAAkB,MAAM,qBAAqB,CAAC;AAChE,OAAO,
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/cmds/validator/handler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,EAEL,kBAAkB,EAClB,SAAS,GAGV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,UAAU,EAAkB,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,KAAK,EAAE,eAAe,E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;aAAM;YACL,iBAAiB,GAAG,EAAC,aAAa,EAA4B,CAAC;SAChE;KACF;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,qBAAqB,CAAC,gBAAyB;IACtD,IAAI,gBAAgB,EAAE;QACpB,QAAQ,gBAAgB,EAAE;YACxB,KAAK,WAAW;gBACd,MAAM;YACR,KAAK,eAAe;gBAClB,MAAM;YACR;gBACE,MAAM,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACnE;KACF;IACD,OAAO,gBAAoC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SignerLocal } from "@lodestar/validator";
|
|
2
|
+
import { LogLevel, Logger } from "@lodestar/utils";
|
|
3
|
+
import { LocalKeystoreDefinition } from "./interface.js";
|
|
4
|
+
type KeystoreDecryptOptions = {
|
|
5
|
+
ignoreLockFile?: boolean;
|
|
6
|
+
onDecrypt?: (index: number) => void;
|
|
7
|
+
cacheFilePath?: string;
|
|
8
|
+
logger: Pick<Logger, LogLevel.info | LogLevel.warn | LogLevel.debug>;
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Decrypt keystore definitions using a thread pool
|
|
13
|
+
*/
|
|
14
|
+
export declare function decryptKeystoreDefinitions(keystoreDefinitions: LocalKeystoreDefinition[], opts: KeystoreDecryptOptions): Promise<SignerLocal[]>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=decryptKeystoreDefinitions.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "node:path";
|
|
2
2
|
import { SignerType } from "@lodestar/validator";
|
|
3
3
|
import bls from "@chainsafe/bls";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { lockFilepath, unlockFilepath } from "../../../util/lockfile.js";
|
|
5
|
+
import { clearKeystoreCache, loadKeystoreCache, writeKeystoreCache } from "./keystoreCache.js";
|
|
6
|
+
import { DecryptKeystoresThreadPool } from "./decryptKeystores/index.js";
|
|
7
7
|
/**
|
|
8
|
-
* Decrypt keystore definitions using a
|
|
8
|
+
* Decrypt keystore definitions using a thread pool
|
|
9
9
|
*/
|
|
10
10
|
export async function decryptKeystoreDefinitions(keystoreDefinitions, opts) {
|
|
11
11
|
if (opts.cacheFilePath) {
|
|
@@ -25,20 +25,14 @@ export async function decryptKeystoreDefinitions(keystoreDefinitions, opts) {
|
|
|
25
25
|
await clearKeystoreCache(opts.cacheFilePath);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
28
|
+
const keystoreCount = keystoreDefinitions.length;
|
|
29
|
+
const signers = new Array(keystoreCount);
|
|
30
|
+
const passwords = new Array(keystoreCount);
|
|
31
31
|
const errors = [];
|
|
32
|
-
const
|
|
33
|
-
// The number below is big enough to almost disable the timeout which helps during tests run on unpredictablely slow hosts
|
|
34
|
-
timeout: 5 * 60 * 1000,
|
|
35
|
-
}), defaultPoolSize);
|
|
32
|
+
const decryptKeystores = new DecryptKeystoresThreadPool(keystoreCount, opts.signal);
|
|
36
33
|
for (const [index, definition] of keystoreDefinitions.entries()) {
|
|
37
34
|
lockKeystore(definition.keystorePath, opts);
|
|
38
|
-
|
|
39
|
-
tasks.push(task);
|
|
40
|
-
task
|
|
41
|
-
.then((secretKeyBytes) => {
|
|
35
|
+
decryptKeystores.queue(definition, (secretKeyBytes) => {
|
|
42
36
|
const signer = {
|
|
43
37
|
type: SignerType.Local,
|
|
44
38
|
secretKey: bls.SecretKey.fromBytes(secretKeyBytes),
|
|
@@ -48,31 +42,22 @@ export async function decryptKeystoreDefinitions(keystoreDefinitions, opts) {
|
|
|
48
42
|
if (opts === null || opts === void 0 ? void 0 : opts.onDecrypt) {
|
|
49
43
|
opts === null || opts === void 0 ? void 0 : opts.onDecrypt(index);
|
|
50
44
|
}
|
|
51
|
-
})
|
|
52
|
-
.catch((e) => {
|
|
45
|
+
}, (error) => {
|
|
53
46
|
// In-progress tasks can't be canceled, so there's a chance that multiple errors may be caught
|
|
54
47
|
// add to the list of errors
|
|
55
|
-
errors.push(
|
|
48
|
+
errors.push({ keystoreFile: path.basename(definition.keystorePath), error });
|
|
56
49
|
// cancel all pending tasks, no need to continue decrypting after we hit one error
|
|
57
|
-
|
|
58
|
-
task.cancel();
|
|
59
|
-
}
|
|
50
|
+
decryptKeystores.cancel();
|
|
60
51
|
});
|
|
61
52
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
await pool.completed(true);
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
53
|
+
await decryptKeystores.completed();
|
|
54
|
+
if (errors.length > 0) {
|
|
67
55
|
// If an error occurs, the program isn't going to be running,
|
|
68
56
|
// so we should unlock all lockfiles we created
|
|
69
57
|
for (const { keystorePath } of keystoreDefinitions) {
|
|
70
58
|
unlockFilepath(keystorePath);
|
|
71
59
|
}
|
|
72
|
-
throw
|
|
73
|
-
}
|
|
74
|
-
finally {
|
|
75
|
-
await pool.terminate();
|
|
60
|
+
throw formattedError(errors, signers, keystoreCount);
|
|
76
61
|
}
|
|
77
62
|
if (opts.cacheFilePath) {
|
|
78
63
|
await writeKeystoreCache(opts.cacheFilePath, signers, passwords);
|
|
@@ -95,4 +80,29 @@ function lockKeystore(keystorePath, opts) {
|
|
|
95
80
|
}
|
|
96
81
|
}
|
|
97
82
|
}
|
|
98
|
-
|
|
83
|
+
function formattedError(errors, signers, keystoreCount) {
|
|
84
|
+
// Filter out errors due to terminating the thread pool
|
|
85
|
+
// https://github.com/ChainSafe/threads.js/blob/df351552cb7d08b8465f5d1e7c543c952d74ac67/src/master/pool.ts#L244
|
|
86
|
+
const decryptErrors = errors.filter(({ error }) => !error.message.startsWith("Pool has been terminated"));
|
|
87
|
+
const errorCount = decryptErrors.length;
|
|
88
|
+
const decryptedCount = signers.filter(Boolean).length;
|
|
89
|
+
const abortedCount = keystoreCount - errorCount - decryptedCount;
|
|
90
|
+
let message = "Error importing keystores";
|
|
91
|
+
if (errorCount === 1) {
|
|
92
|
+
const { keystoreFile, error } = decryptErrors[0];
|
|
93
|
+
message = `Error importing keystore\n\n${keystoreFile}: ${error.message}`;
|
|
94
|
+
}
|
|
95
|
+
else if (errorCount > 1) {
|
|
96
|
+
message =
|
|
97
|
+
"Multiple errors importing keystores\n\n" +
|
|
98
|
+
decryptErrors.map(({ keystoreFile, error }) => `${keystoreFile}: ${error.message}`).join("\n");
|
|
99
|
+
}
|
|
100
|
+
if (abortedCount > 0) {
|
|
101
|
+
message += `\n\nAborted ${abortedCount} pending keystore import${abortedCount > 1 ? "s" : ""}`;
|
|
102
|
+
}
|
|
103
|
+
const error = new Error(message);
|
|
104
|
+
// Don't print out stack trace
|
|
105
|
+
error.stack = message;
|
|
106
|
+
return error;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=decryptKeystoreDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decryptKeystoreDefinitions.js","sourceRoot":"","sources":["../../../../src/cmds/validator/keymanager/decryptKeystoreDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAc,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAE5D,OAAO,GAAG,MAAM,gBAAgB,CAAC;AACjC,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAC,0BAA0B,EAAC,MAAM,6BAA6B,CAAC;AAgBvE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,mBAA8C,EAC9C,IAA4B;IAE5B,IAAI,IAAI,CAAC,aAAa,EAAE;QACtB,IAAI;YACF,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,I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GAAG,OAAO,CAAC;IAEtB,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/cmds/validator/keymanager/decryptKeystores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,0BAA0B,EAAC,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
let maxPoolSize;
|
|
3
|
+
try {
|
|
4
|
+
if (typeof navigator !== "undefined") {
|
|
5
|
+
maxPoolSize = (_a = navigator.hardwareConcurrency) !== null && _a !== void 0 ? _a : 4;
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
// TODO change this line to use os.availableParallelism() once we upgrade to node v20
|
|
9
|
+
maxPoolSize = (await import("node:os")).cpus().length;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
maxPoolSize = 8;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Cross-platform approx number of logical cores
|
|
17
|
+
*/
|
|
18
|
+
export { maxPoolSize };
|
|
19
|
+
//# sourceMappingURL=poolSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poolSize.js","sourceRoot":"","sources":["../../../../../src/cmds/validator/keymanager/decryptKeystores/poolSize.ts"],"names":[],"mappings":";AAAA,IAAI,WAAmB,CAAC;AAExB,IAAI;IACF,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE;QACpC,WAAW,GAAG,MAAA,SAAS,CAAC,mBAAmB,mCAAI,CAAC,CAAC;KAClD;SAAM;QACL,qFAAqF;QACrF,WAAW,GAAG,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;KACvD;CACF;AAAC,OAAO,CAAC,EAAE;IACV,WAAW,GAAG,CAAC,CAAC;CACjB;AAED;;GAEG;AACH,OAAO,EAAC,WAAW,EAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DecryptKeystoreArgs } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Thread pool to decrypt keystores
|
|
4
|
+
*/
|
|
5
|
+
export declare class DecryptKeystoresThreadPool {
|
|
6
|
+
private readonly signal;
|
|
7
|
+
private pool;
|
|
8
|
+
private tasks;
|
|
9
|
+
private terminatePoolHandler;
|
|
10
|
+
constructor(keystoreCount: number, signal: AbortSignal);
|
|
11
|
+
/**
|
|
12
|
+
* Add keystore to the task queue to be decrypted
|
|
13
|
+
*/
|
|
14
|
+
queue(args: DecryptKeystoreArgs, onDecrypted: (secretKeyBytes: Uint8Array) => void, onError: (e: Error) => void): void;
|
|
15
|
+
/**
|
|
16
|
+
* Resolves once all queued tasks are completed and terminates worker threads.
|
|
17
|
+
* Errors during executing can be captured in `onError` handler for each task.
|
|
18
|
+
*/
|
|
19
|
+
completed(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Cancel all pending tasks
|
|
22
|
+
*/
|
|
23
|
+
cancel(): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=threadPool.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { spawn, Pool, Worker } from "@chainsafe/threads";
|
|
2
|
+
import { maxPoolSize } from "./poolSize.js";
|
|
3
|
+
/**
|
|
4
|
+
* Thread pool to decrypt keystores
|
|
5
|
+
*/
|
|
6
|
+
export class DecryptKeystoresThreadPool {
|
|
7
|
+
constructor(keystoreCount, signal) {
|
|
8
|
+
this.signal = signal;
|
|
9
|
+
this.tasks = [];
|
|
10
|
+
this.pool = Pool(() => spawn(new Worker("./worker.js"), {
|
|
11
|
+
// The number below is big enough to almost disable the timeout
|
|
12
|
+
// which helps during tests run on unpredictably slow hosts
|
|
13
|
+
timeout: 5 * 60 * 1000,
|
|
14
|
+
}), {
|
|
15
|
+
// Adjust worker pool size based on keystore count
|
|
16
|
+
size: Math.min(keystoreCount, maxPoolSize),
|
|
17
|
+
// Decrypt keystores in sequence, increasing concurrency does not improve performance
|
|
18
|
+
concurrency: 1,
|
|
19
|
+
});
|
|
20
|
+
// Terminate worker threads when process receives exit signal
|
|
21
|
+
this.terminatePoolHandler = () => {
|
|
22
|
+
void this.pool.terminate(true);
|
|
23
|
+
};
|
|
24
|
+
signal.addEventListener("abort", this.terminatePoolHandler);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Add keystore to the task queue to be decrypted
|
|
28
|
+
*/
|
|
29
|
+
queue(args, onDecrypted, onError) {
|
|
30
|
+
const task = this.pool.queue((thread) => thread.decryptKeystore(args));
|
|
31
|
+
this.tasks.push(task);
|
|
32
|
+
task.then(onDecrypted).catch(onError);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolves once all queued tasks are completed and terminates worker threads.
|
|
36
|
+
* Errors during executing can be captured in `onError` handler for each task.
|
|
37
|
+
*/
|
|
38
|
+
async completed() {
|
|
39
|
+
await this.pool.settled(true);
|
|
40
|
+
await this.pool.terminate();
|
|
41
|
+
this.signal.removeEventListener("abort", this.terminatePoolHandler);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Cancel all pending tasks
|
|
45
|
+
*/
|
|
46
|
+
cancel() {
|
|
47
|
+
for (const task of this.tasks) {
|
|
48
|
+
task.cancel();
|
|
49
|
+
}
|
|
50
|
+
this.tasks = [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=threadPool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threadPool.js","sourceRoot":"","sources":["../../../../../src/cmds/validator/keymanager/decryptKeystores/threadPool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAA2B,MAAM,oBAAoB,CAAC;AAEjF,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C;;GAEG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AAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;SACf;QACD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { KeystoreStr } from "@lodestar/api/keymanager";
|
|
2
|
+
import { LocalKeystoreDefinition } from "../interface.js";
|
|
3
|
+
export type DecryptKeystoreWorkerAPI = {
|
|
4
|
+
decryptKeystore(args: DecryptKeystoreArgs): Promise<Uint8Array>;
|
|
5
|
+
};
|
|
6
|
+
export type DecryptKeystoreArgs = LocalKeystoreDefinition | {
|
|
7
|
+
keystoreStr: KeystoreStr;
|
|
8
|
+
password: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function isLocalKeystoreDefinition(args: DecryptKeystoreArgs): args is LocalKeystoreDefinition;
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|