@chainsafe/lodestar 1.51.0-dev.b3beff2246 → 1.51.0-dev.b74e8e576d

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.
Files changed (108) hide show
  1. package/.git-data.json +1 -1
  2. package/README.md +9 -7
  3. package/lib/cmds/beacon/handler.d.ts.map +1 -1
  4. package/lib/cmds/beacon/handler.js +26 -13
  5. package/lib/cmds/beacon/handler.js.map +1 -1
  6. package/lib/cmds/beacon/initBeaconState.d.ts.map +1 -1
  7. package/lib/cmds/beacon/initBeaconState.js +1 -1
  8. package/lib/cmds/beacon/initBeaconState.js.map +1 -1
  9. package/lib/cmds/beacon/pubkeysFile.d.ts +1 -1
  10. package/lib/cmds/beacon/pubkeysFile.d.ts.map +1 -1
  11. package/lib/cmds/builder/handler.d.ts.map +1 -1
  12. package/lib/cmds/builder/handler.js +52 -3
  13. package/lib/cmds/builder/handler.js.map +1 -1
  14. package/lib/cmds/builder/loadKeypair.d.ts.map +1 -1
  15. package/lib/cmds/builder/loadKeypair.js +1 -1
  16. package/lib/cmds/builder/loadKeypair.js.map +1 -1
  17. package/lib/cmds/builder/options.d.ts +13 -0
  18. package/lib/cmds/builder/options.d.ts.map +1 -1
  19. package/lib/cmds/builder/options.js +83 -1
  20. package/lib/cmds/builder/options.js.map +1 -1
  21. package/lib/cmds/dev/handler.js +6 -6
  22. package/lib/cmds/dev/handler.js.map +1 -1
  23. package/lib/cmds/dev/options.d.ts +4 -1
  24. package/lib/cmds/dev/options.d.ts.map +1 -1
  25. package/lib/cmds/dev/options.js +1 -3
  26. package/lib/cmds/dev/options.js.map +1 -1
  27. package/lib/cmds/validator/blsToExecutionChange.js +1 -1
  28. package/lib/cmds/validator/blsToExecutionChange.js.map +1 -1
  29. package/lib/cmds/validator/handler.d.ts.map +1 -1
  30. package/lib/cmds/validator/handler.js +12 -2
  31. package/lib/cmds/validator/handler.js.map +1 -1
  32. package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions.js +1 -1
  33. package/lib/cmds/validator/keymanager/decryptKeystoreDefinitions.js.map +1 -1
  34. package/lib/cmds/validator/keymanager/decryptKeystores/threadPool.d.ts +1 -1
  35. package/lib/cmds/validator/keymanager/decryptKeystores/threadPool.d.ts.map +1 -1
  36. package/lib/cmds/validator/keymanager/decryptKeystores/threadPool.js.map +1 -1
  37. package/lib/cmds/validator/keymanager/impl.d.ts.map +1 -1
  38. package/lib/cmds/validator/keymanager/impl.js +1 -1
  39. package/lib/cmds/validator/keymanager/impl.js.map +1 -1
  40. package/lib/cmds/validator/keymanager/keystoreCache.js +1 -1
  41. package/lib/cmds/validator/keymanager/keystoreCache.js.map +1 -1
  42. package/lib/cmds/validator/keymanager/persistedKeys.d.ts +1 -1
  43. package/lib/cmds/validator/keymanager/persistedKeys.d.ts.map +1 -1
  44. package/lib/cmds/validator/keymanager/persistedKeys.js +1 -1
  45. package/lib/cmds/validator/keymanager/persistedKeys.js.map +1 -1
  46. package/lib/cmds/validator/options.d.ts.map +1 -1
  47. package/lib/cmds/validator/options.js +3 -9
  48. package/lib/cmds/validator/options.js.map +1 -1
  49. package/lib/cmds/validator/signers/index.js +1 -1
  50. package/lib/cmds/validator/signers/index.js.map +1 -1
  51. package/lib/cmds/validator/slashingProtection/export.d.ts.map +1 -1
  52. package/lib/cmds/validator/slashingProtection/export.js +1 -3
  53. package/lib/cmds/validator/slashingProtection/export.js.map +1 -1
  54. package/lib/cmds/validator/slashingProtection/import.js +2 -2
  55. package/lib/cmds/validator/slashingProtection/import.js.map +1 -1
  56. package/lib/cmds/validator/voluntaryExit.d.ts.map +1 -1
  57. package/lib/cmds/validator/voluntaryExit.js +2 -4
  58. package/lib/cmds/validator/voluntaryExit.js.map +1 -1
  59. package/lib/options/beaconNodeOptions/api.d.ts +1 -0
  60. package/lib/options/beaconNodeOptions/api.d.ts.map +1 -1
  61. package/lib/options/beaconNodeOptions/api.js +8 -0
  62. package/lib/options/beaconNodeOptions/api.js.map +1 -1
  63. package/lib/options/beaconNodeOptions/builder.d.ts +1 -0
  64. package/lib/options/beaconNodeOptions/builder.d.ts.map +1 -1
  65. package/lib/options/beaconNodeOptions/builder.js +11 -0
  66. package/lib/options/beaconNodeOptions/builder.js.map +1 -1
  67. package/lib/options/beaconNodeOptions/chain.d.ts +1 -1
  68. package/lib/options/beaconNodeOptions/chain.d.ts.map +1 -1
  69. package/lib/options/beaconNodeOptions/chain.js +8 -8
  70. package/lib/options/beaconNodeOptions/chain.js.map +1 -1
  71. package/lib/options/beaconNodeOptions/index.d.ts +4 -1
  72. package/lib/options/beaconNodeOptions/index.d.ts.map +1 -1
  73. package/lib/options/beaconNodeOptions/network.d.ts +1 -0
  74. package/lib/options/beaconNodeOptions/network.d.ts.map +1 -1
  75. package/lib/options/beaconNodeOptions/network.js +16 -0
  76. package/lib/options/beaconNodeOptions/network.js.map +1 -1
  77. package/lib/util/file.d.ts.map +1 -1
  78. package/lib/util/file.js +3 -2
  79. package/lib/util/file.js.map +1 -1
  80. package/lib/util/format.js +1 -1
  81. package/lib/util/format.js.map +1 -1
  82. package/package.json +19 -17
  83. package/src/cmds/beacon/handler.ts +34 -13
  84. package/src/cmds/beacon/initBeaconState.ts +1 -1
  85. package/src/cmds/beacon/pubkeysFile.ts +1 -1
  86. package/src/cmds/builder/handler.ts +73 -3
  87. package/src/cmds/builder/loadKeypair.ts +1 -1
  88. package/src/cmds/builder/options.ts +118 -1
  89. package/src/cmds/dev/handler.ts +6 -6
  90. package/src/cmds/dev/options.ts +1 -3
  91. package/src/cmds/validator/blsToExecutionChange.ts +1 -1
  92. package/src/cmds/validator/handler.ts +10 -1
  93. package/src/cmds/validator/keymanager/decryptKeystoreDefinitions.ts +1 -1
  94. package/src/cmds/validator/keymanager/decryptKeystores/threadPool.ts +1 -1
  95. package/src/cmds/validator/keymanager/impl.ts +1 -1
  96. package/src/cmds/validator/keymanager/keystoreCache.ts +1 -1
  97. package/src/cmds/validator/keymanager/persistedKeys.ts +1 -1
  98. package/src/cmds/validator/options.ts +3 -9
  99. package/src/cmds/validator/signers/index.ts +1 -1
  100. package/src/cmds/validator/slashingProtection/export.ts +1 -3
  101. package/src/cmds/validator/slashingProtection/import.ts +2 -2
  102. package/src/cmds/validator/voluntaryExit.ts +2 -4
  103. package/src/options/beaconNodeOptions/api.ts +11 -0
  104. package/src/options/beaconNodeOptions/builder.ts +15 -0
  105. package/src/options/beaconNodeOptions/chain.ts +11 -11
  106. package/src/options/beaconNodeOptions/network.ts +25 -0
  107. package/src/util/file.ts +3 -2
  108. package/src/util/format.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainsafe/lodestar",
3
- "version": "1.51.0-dev.b3beff2246",
3
+ "version": "1.51.0-dev.b74e8e576d",
4
4
  "description": "Command line interface for lodestar",
5
5
  "author": "ChainSafe Systems",
6
6
  "license": "Apache-2.0",
@@ -9,6 +9,9 @@
9
9
  },
10
10
  "homepage": "https://github.com/ChainSafe/lodestar#readme",
11
11
  "type": "module",
12
+ "engines": {
13
+ "node": "^24.22.1"
14
+ },
12
15
  "exports": {
13
16
  ".": {
14
17
  "typescript": "./src/index.ts",
@@ -61,24 +64,24 @@
61
64
  "@chainsafe/bls-keystore": "^3.1.0",
62
65
  "@chainsafe/discv5": "^12.0.2",
63
66
  "@chainsafe/enr": "^6.0.2",
64
- "@chainsafe/lodestar-z": "catalog:",
65
67
  "@chainsafe/persistent-merkle-tree": "^1.3.1",
66
- "@chainsafe/ssz": "^1.8.1",
68
+ "@chainsafe/ssz": "^1.9.0",
67
69
  "@chainsafe/threads": "^1.11.3",
68
70
  "@libp2p/crypto": "^5.1.25",
69
71
  "@libp2p/interface": "^3.4.0",
70
72
  "@libp2p/peer-id": "^6.0.17",
71
- "@lodestar/api": "^1.51.0-dev.b3beff2246",
72
- "@lodestar/beacon-node": "^1.51.0-dev.b3beff2246",
73
- "@lodestar/builder": "^1.51.0-dev.b3beff2246",
74
- "@lodestar/config": "^1.51.0-dev.b3beff2246",
75
- "@lodestar/db": "^1.51.0-dev.b3beff2246",
76
- "@lodestar/logger": "^1.51.0-dev.b3beff2246",
77
- "@lodestar/params": "^1.51.0-dev.b3beff2246",
78
- "@lodestar/state-transition": "^1.51.0-dev.b3beff2246",
79
- "@lodestar/types": "^1.51.0-dev.b3beff2246",
80
- "@lodestar/utils": "^1.51.0-dev.b3beff2246",
81
- "@lodestar/validator": "^1.51.0-dev.b3beff2246",
73
+ "@lodestar/api": "^1.51.0-dev.b74e8e576d",
74
+ "@lodestar/beacon-node": "^1.51.0-dev.b74e8e576d",
75
+ "@lodestar/builder": "^1.51.0-dev.b74e8e576d",
76
+ "@lodestar/config": "^1.51.0-dev.b74e8e576d",
77
+ "@lodestar/db": "^1.51.0-dev.b74e8e576d",
78
+ "@lodestar/logger": "^1.51.0-dev.b74e8e576d",
79
+ "@lodestar/native": "^1.51.0-dev.b74e8e576d",
80
+ "@lodestar/params": "^1.51.0-dev.b74e8e576d",
81
+ "@lodestar/state-transition": "^1.51.0-dev.b74e8e576d",
82
+ "@lodestar/types": "^1.51.0-dev.b74e8e576d",
83
+ "@lodestar/utils": "^1.51.0-dev.b74e8e576d",
84
+ "@lodestar/validator": "^1.51.0-dev.b74e8e576d",
82
85
  "@multiformats/multiaddr": "^13.0.1",
83
86
  "deepmerge": "^4.3.1",
84
87
  "ethers": "^6.7.0",
@@ -86,7 +89,6 @@
86
89
  "inquirer": "^9.1.5",
87
90
  "js-yaml": "^4.1.0",
88
91
  "proper-lockfile": "^4.1.2",
89
- "rimraf": "^4.4.1",
90
92
  "source-map-support": "^0.5.21",
91
93
  "uint8arrays": "^5.0.1",
92
94
  "yargs": "^17.7.1"
@@ -94,7 +96,7 @@
94
96
  "devDependencies": {
95
97
  "@chainsafe/as-sha256": "^1.2.5",
96
98
  "@ethereumjs/rlp": "^4.0.1",
97
- "@lodestar/test-utils": "^1.51.0-dev.b3beff2246",
99
+ "@lodestar/test-utils": "^1.51.0-dev.b74e8e576d",
98
100
  "@types/debug": "^4.1.7",
99
101
  "@types/inquirer": "^9.0.3",
100
102
  "@types/js-yaml": "^4.0.5",
@@ -108,5 +110,5 @@
108
110
  "web3": "^4.0.3",
109
111
  "web3-eth-accounts": "^4.0.3"
110
112
  },
111
- "gitHead": "7b70bcaf48e0f212ad066039e2e4674f9643e284"
113
+ "gitHead": "3a9aa6c8044a527ff9bf39eb3a5fc584743be6c4"
112
114
  }
@@ -1,13 +1,18 @@
1
1
  import path from "node:path";
2
2
  import {getHeapStatistics} from "node:v8";
3
3
  import {SignableENR} from "@chainsafe/enr";
4
- import {pubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
5
4
  import {hasher} from "@chainsafe/persistent-merkle-tree";
6
- import {BeaconDb, BeaconNode} from "@lodestar/beacon-node";
5
+ import {
6
+ BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS,
7
+ BUILDER_BID_LAG_BUFFER_MS,
8
+ BeaconDb,
9
+ BeaconNode,
10
+ } from "@lodestar/beacon-node";
7
11
  import {ChainForkConfig} from "@lodestar/config";
8
12
  import {LevelDbController} from "@lodestar/db/controller/level";
9
13
  import {LoggerNode, getNodeLogger} from "@lodestar/logger/node";
10
- import {ACTIVE_PRESET, PresetName} from "@lodestar/params";
14
+ import {pubkeyCache} from "@lodestar/native/pubkeys";
15
+ import {ACTIVE_PRESET, PresetName, isForkPostGloas} from "@lodestar/params";
11
16
  import {ErrorAborted, bytesToInt, formatBytes} from "@lodestar/utils";
12
17
  import {ProcessShutdownCallback} from "@lodestar/validator";
13
18
  import {BeaconNodeOptions, getBeaconConfigFromArgs} from "../../config/index.js";
@@ -61,6 +66,7 @@ export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise<void
61
66
  // Callback for beacon to request forced exit, for e.g. in case of irrecoverable
62
67
  // forkchoice errors
63
68
  const processShutdownCallback: ProcessShutdownCallback = (err) => {
69
+ process.exitCode = 1;
64
70
  logger.error("Process shutdown requested", {}, err);
65
71
  process.kill(process.pid, "SIGINT");
66
72
  };
@@ -142,21 +148,21 @@ export async function beaconHandler(args: BeaconArgs & GlobalArgs): Promise<void
142
148
  abortController.signal.addEventListener(
143
149
  "abort",
144
150
  async () => {
145
- let exitCode = 0;
146
151
  try {
147
152
  await node.close();
148
153
  logger.debug("Beacon node closed");
149
154
  } catch (e) {
150
155
  // If we start from unfinalized state, we don't have checkpoint state so there is this error
151
156
  // "No state in cache for finalized checkpoint state epoch"
152
- logger.warn("Error closing beacon node", {}, e as Error);
153
- // Make sure db is always closed gracefully
154
- await db.close();
155
- exitCode = 1;
157
+ // The logger prints only the message and stack of an AggregateError, not its causes
158
+ for (const error of e instanceof AggregateError ? e.errors : [e]) {
159
+ logger.warn("Error closing beacon node", {}, error as Error);
160
+ }
161
+ process.exitCode = 1;
156
162
  }
157
163
  savePubkeysFile(pubkeyCache, beaconPaths.pubkeysFile, logger);
158
164
  // Explicitly exit process due to potential active handles
159
- process.exit(exitCode);
165
+ process.exit(process.exitCode ?? 0);
160
166
  },
161
167
  {once: true}
162
168
  );
@@ -219,8 +225,8 @@ export async function beaconHandlerInit(args: BeaconArgs & GlobalArgs) {
219
225
  beaconNodeOptions.set({network: {private: true}, api: {private: true}});
220
226
  } else {
221
227
  const versionStr = `Lodestar/${version}`;
222
- // Add version string for libp2p agent version
223
- beaconNodeOptions.set({network: {version}});
228
+ const advertiseVersion = network !== "mainnet";
229
+ beaconNodeOptions.set({network: {version, advertiseVersion}});
224
230
  // Add User-Agent header to all builder requests
225
231
  beaconNodeOptions.set({executionBuilder: {userAgent: versionStr}});
226
232
  // Set jwt version with version string
@@ -232,12 +238,27 @@ export async function beaconHandlerInit(args: BeaconArgs & GlobalArgs) {
232
238
  // Render final options
233
239
  const options = beaconNodeOptions.getWithDefaults();
234
240
 
235
- if (options.chain.nativeStateTransition && config.GLOAS_FORK_EPOCH !== Infinity) {
241
+ if (options.chain.nativeStateTransition && config.HEZE_FORK_EPOCH !== Infinity) {
236
242
  throw Error(
237
- `--chain.nativeStateTransition does not support Gloas, which is scheduled at epoch ${config.GLOAS_FORK_EPOCH}`
243
+ `--chain.nativeStateTransition does not support Heze, which is scheduled at epoch ${config.HEZE_FORK_EPOCH}`
238
244
  );
239
245
  }
240
246
 
247
+ // Bids received up to the deadline plus the lag buffer must still have a chance to win the block
248
+ // production race, otherwise the local block is selected at the race cutoff before any bid.
249
+ // Only enforced on an explicitly configured deadline, the default is used as is on short slots
250
+ const bidDeadline = args["builder.bidDeadline"];
251
+ if (bidDeadline !== undefined) {
252
+ for (const {name: fork, epoch} of config.forksAscendingEpochOrder) {
253
+ const raceCutoffMs = config.getSlotComponentDurationMs(fork, BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS);
254
+ if (isForkPostGloas(fork) && epoch !== Infinity && bidDeadline + BUILDER_BID_LAG_BUFFER_MS >= raceCutoffMs) {
255
+ throw Error(
256
+ `--builder.bidDeadline of ${bidDeadline}ms must be below ${raceCutoffMs - BUILDER_BID_LAG_BUFFER_MS}ms for fork ${fork}`
257
+ );
258
+ }
259
+ }
260
+ }
261
+
241
262
  return {config, options, beaconPaths, network, version, commit, privateKey, logger};
242
263
  }
243
264
 
@@ -1,6 +1,6 @@
1
- import {pubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
2
1
  import {IBeaconDb} from "@lodestar/beacon-node";
3
2
  import {BeaconConfig, ChainForkConfig} from "@lodestar/config";
3
+ import {pubkeyCache} from "@lodestar/native/pubkeys";
4
4
  import {MAX_PENDING_DEPOSITS_PER_EPOCH, SLOTS_PER_EPOCH} from "@lodestar/params";
5
5
  import {
6
6
  IBeaconStateView,
@@ -1,5 +1,5 @@
1
- import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
2
1
  import {ChainForkConfig} from "@lodestar/config";
2
+ import {type PubkeyCache} from "@lodestar/native/pubkeys";
3
3
  import {getValidatorPubkeyFromStateBytes} from "@lodestar/state-transition";
4
4
  import {Logger, byteArrayEquals} from "@lodestar/utils";
5
5
 
@@ -1,13 +1,27 @@
1
+ import fs from "node:fs";
1
2
  import path from "node:path";
2
3
  import {getClient} from "@lodestar/api";
3
- import {RegistryMetricCreator, collectNodeJSMetrics, getHttpMetricsServer} from "@lodestar/beacon-node";
4
- import {Builder, getMetrics} from "@lodestar/builder";
4
+ import {
5
+ ExecutionPayloadStatus,
6
+ RegistryMetricCreator,
7
+ collectNodeJSMetrics,
8
+ defaultExecutionEngineHttpOpts,
9
+ getHttpMetricsServer,
10
+ initializeExecutionEngine,
11
+ } from "@lodestar/beacon-node";
12
+ import {Builder, EnginePayloadResult, EnginePayloadSource, getMetrics} from "@lodestar/builder";
5
13
  import {getNodeLogger} from "@lodestar/logger/node";
6
14
  import {fromHex, toPrintableUrl} from "@lodestar/utils";
7
15
  import {getBeaconConfigFromArgs} from "../../config/beaconParams.js";
8
16
  import {GlobalArgs} from "../../options/index.js";
9
17
  import {getGlobalPaths} from "../../paths/global.js";
10
- import {cleanOldLogFiles, onGracefulShutdown, parseFeeRecipient, parseLoggerArgs} from "../../util/index.js";
18
+ import {
19
+ cleanOldLogFiles,
20
+ extractJwtHexSecret,
21
+ onGracefulShutdown,
22
+ parseFeeRecipient,
23
+ parseLoggerArgs,
24
+ } from "../../util/index.js";
11
25
  import {getVersionData} from "../../util/version.js";
12
26
  import {loadBuilderKeypair} from "./loadKeypair.js";
13
27
  import {IBuilderCliArgs, builderMetricsDefaultOptions} from "./options.js";
@@ -71,6 +85,51 @@ export async function builderHandler(args: IBuilderCliArgs & GlobalArgs): Promis
71
85
 
72
86
  logger.info("Beacon node", {beaconNode: toPrintableUrl(args.beaconNodeUrl), timeoutMs: args.requestTimeout});
73
87
 
88
+ // Payload ids are local to the execution client that issued them, fallback urls can't be used
89
+ if (args["execution.urls"].length !== 1) {
90
+ throw Error("Exactly one execution client url is required");
91
+ }
92
+ const executionUrl = args["execution.urls"][0];
93
+ const engine = initializeExecutionEngine(
94
+ {
95
+ mode: "http",
96
+ urls: [executionUrl],
97
+ timeout: args["execution.timeout"] ?? defaultExecutionEngineHttpOpts.timeout,
98
+ retries: args["execution.retries"],
99
+ retryDelay: args["execution.retryDelay"],
100
+ jwtSecretHex: args["execution.jwtSecret"]
101
+ ? extractJwtHexSecret(fs.readFileSync(args["execution.jwtSecret"], "utf-8").trim())
102
+ : undefined,
103
+ version,
104
+ commit,
105
+ },
106
+ {signal: abortController.signal, logger}
107
+ );
108
+ const payloadSource = new EnginePayloadSource(toPrintableUrl(executionUrl), {
109
+ notifyForkchoiceUpdate: async (fork, headBlockHash, safeBlockHash, finalizedBlockHash, payloadAttributes) => {
110
+ try {
111
+ const {payloadStatus, payloadId} = await engine.notifyForkchoiceUpdate(
112
+ fork,
113
+ headBlockHash,
114
+ safeBlockHash,
115
+ finalizedBlockHash,
116
+ payloadAttributes
117
+ );
118
+ if (payloadStatus.status === ExecutionPayloadStatus.INVALID) {
119
+ throw Error(`Invalid prepare payload, validationError=${payloadStatus.validationError ?? ""}`);
120
+ }
121
+ return payloadId;
122
+ } catch (e) {
123
+ // Only retry while the execution client is syncing, it has not imported the parent payload yet.
124
+ // The engine interface does not expose the fcU status, this matches the error thrown for the SYNCING status
125
+ // in ExecutionEngineHttp.notifyForkchoiceUpdate until a typed error is added to the beacon node
126
+ if (e instanceof Error && e.message === "Execution Layer Syncing") return null;
127
+ throw e;
128
+ }
129
+ },
130
+ getPayload: async (fork, payloadId) => (await engine.getPayload(fork, payloadId)) as EnginePayloadResult,
131
+ });
132
+
74
133
  const builder = await Builder.init({
75
134
  keypair,
76
135
  logger,
@@ -79,6 +138,17 @@ export async function builderHandler(args: IBuilderCliArgs & GlobalArgs): Promis
79
138
  api,
80
139
  executionFeeRecipient: fromHex(executionFeeRecipient),
81
140
  metrics,
141
+ payloadSource,
142
+ bidding: {
143
+ shareBps: args["bidding.shareBps"],
144
+ fixedCostGwei: args["bidding.fixedCostGwei"],
145
+ minValueGwei: args["bidding.minValueGwei"],
146
+ maxValueGwei: args["bidding.maxValueGwei"],
147
+ deadlineBps: args["bidding.deadlineBps"],
148
+ getPayloadTimeout: args["bidding.getPayloadTimeout"],
149
+ minOperatingBalanceGwei: args["bidding.minOperatingBalanceGwei"],
150
+ },
151
+ reveal: {cutoffBps: args["reveal.cutoffBps"]},
82
152
  });
83
153
 
84
154
  onGracefulShutdownCbs.push(() => builder.close());
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import {Keystore} from "@chainsafe/bls-keystore";
3
- import {SecretKey} from "@chainsafe/lodestar-z/blst";
4
3
  import {Keypair} from "@lodestar/builder";
4
+ import {SecretKey} from "@lodestar/native/blst";
5
5
  import {Logger} from "@lodestar/utils";
6
6
  import {ensure0xPrefix} from "../../util/format.js";
7
7
  import {readPassphraseFile} from "../../util/passphrase.js";
@@ -1,3 +1,4 @@
1
+ import {defaultExecutionEngineHttpOpts} from "@lodestar/beacon-node";
1
2
  import {defaultOptions} from "@lodestar/builder";
2
3
  import {CliCommandOptions} from "@lodestar/utils";
3
4
  import {LogArgs, logOptions} from "../../options/logOptions.js";
@@ -16,6 +17,21 @@ export type IBuilderCliArgs = LogArgs & {
16
17
  executionFeeRecipient: string;
17
18
  requestTimeout: number;
18
19
 
20
+ "execution.urls": string[];
21
+ "execution.timeout"?: number;
22
+ "execution.retries": number;
23
+ "execution.retryDelay": number;
24
+ "execution.jwtSecret"?: string;
25
+
26
+ "bidding.shareBps": number;
27
+ "bidding.fixedCostGwei": number;
28
+ "bidding.minValueGwei": number;
29
+ "bidding.maxValueGwei"?: number;
30
+ "bidding.deadlineBps": number;
31
+ "bidding.getPayloadTimeout": number;
32
+ "bidding.minOperatingBalanceGwei": number;
33
+ "reveal.cutoffBps"?: number;
34
+
19
35
  metrics?: boolean;
20
36
  "metrics.port"?: number;
21
37
  "metrics.address"?: string;
@@ -25,7 +41,8 @@ export const builderOptions: CliCommandOptions<IBuilderCliArgs> = {
25
41
  ...logOptions,
26
42
 
27
43
  beaconNodeUrl: {
28
- description: "Url to a trusted beacon node",
44
+ description:
45
+ "URL of the beacon node. It must run with `--emitPayloadAttributes` to emit payload attributes for every slot",
29
46
  type: "string",
30
47
  default: defaultOptions.beaconNodeUrl,
31
48
  },
@@ -59,6 +76,106 @@ export const builderOptions: CliCommandOptions<IBuilderCliArgs> = {
59
76
  default: defaultOptions.requestTimeout,
60
77
  },
61
78
 
79
+ // Execution
80
+
81
+ "execution.urls": {
82
+ description:
83
+ "Url to the execution client engine API that builds the payloads. The execution client must be kept in sync by a beacon node",
84
+ default: defaultExecutionEngineHttpOpts.urls.join(","),
85
+ type: "array",
86
+ string: true,
87
+ coerce: (urls: string[]): string[] =>
88
+ // Parse ["url1,url2"] to ["url1", "url2"]
89
+ urls.flatMap((item) => item.split(",")),
90
+ group: "execution",
91
+ },
92
+
93
+ "execution.timeout": {
94
+ description: "Timeout in milliseconds for execution engine API HTTP client",
95
+ type: "number",
96
+ defaultDescription: String(defaultExecutionEngineHttpOpts.timeout),
97
+ group: "execution",
98
+ },
99
+
100
+ "execution.retries": {
101
+ description: "Number of retries when calling execution engine API",
102
+ type: "number",
103
+ default: defaultExecutionEngineHttpOpts.retries,
104
+ group: "execution",
105
+ },
106
+
107
+ "execution.retryDelay": {
108
+ description: "Delay time in milliseconds between retries when retrying calls to the execution engine API",
109
+ type: "number",
110
+ default: defaultExecutionEngineHttpOpts.retryDelay,
111
+ group: "execution",
112
+ },
113
+
114
+ "execution.jwtSecret": {
115
+ description:
116
+ "File path to a shared hex-encoded jwt secret which will be used to generate and bundle HS256 encoded jwt tokens for authentication with the EL client's rpc server hosting engine apis. Secret to be exactly same as the one used by the corresponding EL client.",
117
+ type: "string",
118
+ group: "execution",
119
+ },
120
+
121
+ // Bidding
122
+
123
+ "bidding.shareBps": {
124
+ description: "Share of the payload value offered to the proposer, in basis points",
125
+ type: "number",
126
+ default: defaultOptions.bidding.shareBps,
127
+ group: "bidding",
128
+ },
129
+
130
+ "bidding.fixedCostGwei": {
131
+ description: "Fixed amount in gwei deducted from the proposer share of every bid",
132
+ type: "number",
133
+ default: defaultOptions.bidding.fixedCostGwei,
134
+ group: "bidding",
135
+ },
136
+
137
+ "bidding.minValueGwei": {
138
+ description: "Never bid below this value in gwei",
139
+ type: "number",
140
+ default: defaultOptions.bidding.minValueGwei,
141
+ group: "bidding",
142
+ },
143
+
144
+ "bidding.maxValueGwei": {
145
+ description: "Never bid above this value in gwei",
146
+ type: "number",
147
+ group: "bidding",
148
+ },
149
+
150
+ "bidding.deadlineBps": {
151
+ description:
152
+ "Point within the slot before the proposal slot at which the payload is retrieved and the bid is published, in basis points",
153
+ type: "number",
154
+ default: defaultOptions.bidding.deadlineBps,
155
+ group: "bidding",
156
+ },
157
+
158
+ "bidding.getPayloadTimeout": {
159
+ description: "Timeout in milliseconds for retrieving the payload from the execution client at the bid deadline",
160
+ type: "number",
161
+ default: defaultOptions.bidding.getPayloadTimeout,
162
+ group: "bidding",
163
+ },
164
+
165
+ "bidding.minOperatingBalanceGwei": {
166
+ description: "Do not bid while the builder balance is below this value in gwei",
167
+ type: "number",
168
+ default: defaultOptions.bidding.minOperatingBalanceGwei,
169
+ group: "bidding",
170
+ },
171
+
172
+ "reveal.cutoffBps": {
173
+ description:
174
+ "Do not reveal the payload if the block committing to our bid arrives after this point within its slot, in basis points. Defaults to PAYLOAD_ATTESTATION_DUE_BPS of the network",
175
+ type: "number",
176
+ group: "reveal",
177
+ },
178
+
62
179
  // Metrics
63
180
 
64
181
  metrics: {
@@ -1,5 +1,5 @@
1
1
  import fs from "node:fs";
2
- import {rimraf} from "rimraf";
2
+ import {rm} from "node:fs/promises";
3
3
  import {nodeUtils} from "@lodestar/beacon-node";
4
4
  import {fromHex, toHex} from "@lodestar/utils";
5
5
  import {getBeaconConfigFromArgs} from "../../config/beaconParams.js";
@@ -37,10 +37,10 @@ export async function devHandler(args: IDevArgs & GlobalArgs): Promise<void> {
37
37
  // Remove slashing protection db. Otherwise the validators won't be able to propose nor attest
38
38
  // until the clock reach a higher slot than the previous run of the dev command
39
39
  if (args.genesisTime === undefined) {
40
- await rimraf(beaconDbDir);
41
- await rimraf(validatorsDbDir);
40
+ await rm(beaconDbDir, {recursive: true, force: true});
41
+ await rm(validatorsDbDir, {recursive: true, force: true});
42
42
  // Validators deposited in the previous run do not exist on the new chain
43
- await rimraf(pubkeysFile);
43
+ await rm(pubkeysFile, {recursive: true, force: true});
44
44
  }
45
45
 
46
46
  mkdir(beaconDbDir);
@@ -48,8 +48,8 @@ export async function devHandler(args: IDevArgs & GlobalArgs): Promise<void> {
48
48
 
49
49
  if (args.reset) {
50
50
  onGracefulShutdown(async () => {
51
- await rimraf(beaconDbDir);
52
- await rimraf(validatorsDbDir);
51
+ await rm(beaconDbDir, {recursive: true, force: true});
52
+ await rm(validatorsDbDir, {recursive: true, force: true});
53
53
  });
54
54
  }
55
55
 
@@ -34,9 +34,7 @@ const devOwnOptions: CliCommandOptions<IDevOwnArgs> = {
34
34
  type: "array",
35
35
  coerce: (indexes: string[]): number[] =>
36
36
  // Parse ["11..13,15..17"] to ["11..13", "15..17"]
37
- indexes
38
- .flatMap((item) => item.split(","))
39
- .flatMap(parseRange),
37
+ indexes.flatMap((item) => item.split(",")).flatMap(parseRange),
40
38
  group: "dev",
41
39
  },
42
40
 
@@ -1,6 +1,6 @@
1
- import {SecretKey} from "@chainsafe/lodestar-z/blst";
2
1
  import {getClient} from "@lodestar/api";
3
2
  import {createBeaconConfig} from "@lodestar/config";
3
+ import {SecretKey} from "@lodestar/native/blst";
4
4
  import {DOMAIN_BLS_TO_EXECUTION_CHANGE, ForkName} from "@lodestar/params";
5
5
  import {computeSigningRoot} from "@lodestar/state-transition";
6
6
  import {capella, ssz} from "@lodestar/types";
@@ -77,7 +77,16 @@ export async function validatorHandler(args: IValidatorCliArgs & GlobalArgs): Pr
77
77
 
78
78
  const onGracefulShutdownCbs: (() => Promise<void> | void)[] = [];
79
79
  onGracefulShutdown(async () => {
80
- for (const cb of onGracefulShutdownCbs) await cb();
80
+ let exitCode = 0;
81
+ try {
82
+ for (const cb of onGracefulShutdownCbs) await cb();
83
+ logger.debug("Validator client closed");
84
+ } catch (e) {
85
+ logger.warn("Error closing validator client", {}, e as Error);
86
+ exitCode = 1;
87
+ }
88
+ // Explicitly exit process due to potential active handles (e.g. EventSource / in-flight HTTP via DVT middleware)
89
+ process.exit(exitCode);
81
90
  }, logger.info.bind(logger));
82
91
 
83
92
  // Callback for validator to request forced exit, in case of doppelganger detection
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import {Keystore} from "@chainsafe/bls-keystore";
4
- import {SecretKey} from "@chainsafe/lodestar-z/blst";
4
+ import {SecretKey} from "@lodestar/native/blst";
5
5
  import {LogLevel, Logger} from "@lodestar/utils";
6
6
  import {SignerLocal, SignerType} from "@lodestar/validator";
7
7
  import {lockFilepath, unlockFilepath} from "../../../util/lockfile.js";
@@ -45,7 +45,7 @@ export class DecryptKeystoresThreadPool {
45
45
  */
46
46
  queue(
47
47
  args: DecryptKeystoreArgs,
48
- onDecrypted: (secretKeyBytes: Uint8Array) => void,
48
+ onDecrypted: (secretKeyBytes: Uint8Array) => void | Promise<void>,
49
49
  onError: (e: Error) => void
50
50
  ): void {
51
51
  const task = this.pool.queue((thread) => thread.decryptKeystore(args));
@@ -1,5 +1,4 @@
1
1
  import {Keystore} from "@chainsafe/bls-keystore";
2
- import {SecretKey} from "@chainsafe/lodestar-z/blst";
3
2
  import {
4
3
  BuilderBoostFactorData,
5
4
  BuilderConfigData,
@@ -20,6 +19,7 @@ import {
20
19
  } from "@lodestar/api/keymanager";
21
20
  import {KeymanagerApiMethods as Api} from "@lodestar/api/keymanager/server";
22
21
  import {ApiError} from "@lodestar/api/server";
22
+ import {SecretKey} from "@lodestar/native/blst";
23
23
  import {Epoch} from "@lodestar/types";
24
24
  import {fromHex, isValidHttpUrl} from "@lodestar/utils";
25
25
  import {Interchange, SignerType, Validator} from "@lodestar/validator";
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import {Keystore} from "@chainsafe/bls-keystore";
4
- import {SecretKey} from "@chainsafe/lodestar-z/blst";
4
+ import {SecretKey} from "@lodestar/native/blst";
5
5
  import {fromHex, toHex, toPubkeyHex} from "@lodestar/utils";
6
6
  import {SignerLocal, SignerType} from "@lodestar/validator";
7
7
  import {writeFile600Perm} from "../../../util/file.js";
@@ -14,7 +14,7 @@ import {
14
14
  import {lockFilepath} from "../../../util/lockfile.js";
15
15
  import {IPersistedKeysBackend, LocalKeystoreDefinition} from "./interface.js";
16
16
 
17
- export {ImportStatus, DeletionStatus};
17
+ export {DeletionStatus, ImportStatus};
18
18
 
19
19
  type PathArgs = {
20
20
  keystoresDir: string;
@@ -416,9 +416,7 @@ export const validatorOptions: CliCommandOptions<IValidatorCliArgs> = {
416
416
  string: true, // Ensures the pubkey string is not automatically converted to numbers
417
417
  coerce: (pubkeys: string[]): string[] =>
418
418
  // Parse ["0x11,0x22"] to ["0x11", "0x22"]
419
- pubkeys
420
- .flatMap((item) => item.split(","))
421
- .map(ensure0xPrefix),
419
+ pubkeys.flatMap((item) => item.split(",")).map(ensure0xPrefix),
422
420
  group: "externalSigner",
423
421
  },
424
422
 
@@ -518,9 +516,7 @@ export const validatorOptions: CliCommandOptions<IValidatorCliArgs> = {
518
516
  type: "array",
519
517
  coerce: (indexes: string[]): number[] =>
520
518
  // Parse ["11..13,15..17"] to ["11..13", "15..17"]
521
- indexes
522
- .flatMap((item) => item.split(","))
523
- .flatMap(parseRange),
519
+ indexes.flatMap((item) => item.split(",")).flatMap(parseRange),
524
520
  },
525
521
 
526
522
  fromMnemonic: {
@@ -535,8 +531,6 @@ export const validatorOptions: CliCommandOptions<IValidatorCliArgs> = {
535
531
  type: "array",
536
532
  coerce: (indexes: string[]): number[] =>
537
533
  // Parse ["11..13,15..17"] to ["11..13", "15..17"]
538
- indexes
539
- .flatMap((item) => item.split(","))
540
- .flatMap(parseRange),
534
+ indexes.flatMap((item) => item.split(",")).flatMap(parseRange),
541
535
  },
542
536
  };
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import {deriveEth2ValidatorKeys, deriveKeyFromMnemonic} from "@chainsafe/bls-keygen";
3
- import {SecretKey} from "@chainsafe/lodestar-z/blst";
3
+ import {SecretKey} from "@lodestar/native/blst";
4
4
  import {interopSecretKey} from "@lodestar/state-transition";
5
5
  import {LogLevel, Logger, isValidHttpUrl} from "@lodestar/utils";
6
6
  import {Signer, SignerType, externalSignerGetKeys} from "@lodestar/validator";
@@ -42,9 +42,7 @@ export const exportCmd: CliCommand<ExportArgs, ISlashingProtectionArgs & Account
42
42
  string: true, // Ensures the pubkey string is not automatically converted to numbers
43
43
  coerce: (pubkeys: string[]): string[] =>
44
44
  // Parse ["0x11,0x22"] to ["0x11", "0x22"]
45
- pubkeys
46
- .flatMap((item) => item.split(","))
47
- .map(ensure0xPrefix),
45
+ pubkeys.flatMap((item) => item.split(",")).map(ensure0xPrefix),
48
46
  },
49
47
  },
50
48
 
@@ -1,4 +1,4 @@
1
- import fs from "node:fs";
1
+ import {readFile} from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import {getNodeLogger} from "@lodestar/logger/node";
4
4
  import {CliCommand} from "@lodestar/utils";
@@ -61,7 +61,7 @@ export const importCmd: CliCommand<ImportArgs, ISlashingProtectionArgs & Account
61
61
  (await metadata.getGenesisValidatorsRoot()) ?? (await getGenesisValidatorsRoot(args));
62
62
 
63
63
  logger.verbose("Reading slashing protection data", {file});
64
- const interchangeStr = await fs.promises.readFile(file, "utf8");
64
+ const interchangeStr = await readFile(file, "utf8");
65
65
  const interchangeJson = JSON.parse(interchangeStr) as Interchange;
66
66
 
67
67
  await slashingProtection.importInterchange(interchangeJson, genesisValidatorsRoot, logger);