@obolnetwork/obol-sdk 2.12.0 → 2.12.2

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 (42) hide show
  1. package/README.md +6 -4
  2. package/dist/browser/src/index.js +374 -170
  3. package/dist/browser/src/index.js.map +1 -1
  4. package/dist/cjs/src/blsUtils.js +19 -2
  5. package/dist/cjs/src/blsUtils.js.map +1 -1
  6. package/dist/cjs/src/index.js +382 -170
  7. package/dist/cjs/src/index.js.map +1 -1
  8. package/dist/cjs/src/verification/clusterLockValidationWorker.js +14694 -0
  9. package/dist/cjs/src/verification/clusterLockValidationWorker.js.map +1 -0
  10. package/dist/cjs/src/verification/lockWorker.js +13 -1
  11. package/dist/cjs/src/verification/lockWorker.js.map +1 -1
  12. package/dist/cjs/src/verification/parallelPool.js +227 -35
  13. package/dist/cjs/src/verification/parallelPool.js.map +1 -1
  14. package/dist/esm/src/blsUtils.js +7 -3
  15. package/dist/esm/src/{chunk-267HIPEB.js → chunk-LOSYOJC3.js} +16 -1
  16. package/dist/esm/src/{chunk-267HIPEB.js.map → chunk-LOSYOJC3.js.map} +1 -1
  17. package/dist/esm/src/chunk-T74RX3N2.js +10240 -0
  18. package/dist/esm/src/chunk-T74RX3N2.js.map +1 -0
  19. package/dist/esm/src/chunk-YSXFCSVK.js +389 -0
  20. package/dist/esm/src/chunk-YSXFCSVK.js.map +1 -0
  21. package/dist/esm/src/index.js +234 -10339
  22. package/dist/esm/src/index.js.map +1 -1
  23. package/dist/esm/src/verification/clusterLockValidationWorker.js +18 -0
  24. package/dist/esm/src/verification/clusterLockValidationWorker.js.map +1 -0
  25. package/dist/esm/src/verification/lockWorker.js +7 -2
  26. package/dist/esm/src/verification/lockWorker.js.map +1 -1
  27. package/dist/esm/src/verification/parallelPool.js +8 -2
  28. package/dist/types/src/base.d.ts +5 -3
  29. package/dist/types/src/blsUtils.d.ts +3 -0
  30. package/dist/types/src/errors.d.ts +21 -0
  31. package/dist/types/src/index.d.ts +5 -6
  32. package/dist/types/src/services.d.ts +4 -1
  33. package/dist/types/src/types.d.ts +6 -0
  34. package/dist/types/src/verification/clusterLockValidationWorker.d.ts +1 -0
  35. package/dist/types/src/verification/common.d.ts +17 -7
  36. package/dist/types/src/verification/lockWorker.d.ts +7 -2
  37. package/dist/types/src/verification/parallelPool.d.ts +9 -0
  38. package/dist/types/test/client/baseUrl.spec.d.ts +1 -0
  39. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  40. package/package.json +2 -2
  41. package/dist/esm/src/chunk-OYZHSNKR.js +0 -186
  42. package/dist/esm/src/chunk-OYZHSNKR.js.map +0 -1
@@ -108,12 +108,14 @@ var __yieldStar = (value) => {
108
108
  // src/index.ts
109
109
  var index_exports = {};
110
110
  __export(index_exports, {
111
+ ALLOWED_OBOL_API_BASE_URLS: () => ALLOWED_OBOL_API_BASE_URLS,
111
112
  AVAILABLE_SPLITTER_CHAINS: () => AVAILABLE_SPLITTER_CHAINS,
112
113
  CAPELLA_FORK_MAPPING: () => CAPELLA_FORK_MAPPING,
113
114
  CHAIN_CONFIGURATION: () => CHAIN_CONFIGURATION,
114
115
  CONFIG_VERSION: () => CONFIG_VERSION,
115
116
  CONFLICT_ERROR_MSG: () => CONFLICT_ERROR_MSG,
116
117
  Client: () => Client,
118
+ ClusterLockValidationTimeoutError: () => ClusterLockValidationTimeoutError,
117
119
  ConflictError: () => ConflictError,
118
120
  CreatorConfigHashSigningTypes: () => CreatorConfigHashSigningTypes,
119
121
  CreatorTypedMessage: () => CreatorTypedMessage,
@@ -139,6 +141,7 @@ __export(index_exports, {
139
141
  FORK_NAMES: () => FORK_NAMES,
140
142
  GENESIS_VALIDATOR_ROOT: () => GENESIS_VALIDATOR_ROOT,
141
143
  Incentives: () => Incentives,
144
+ InvalidBaseUrlError: () => InvalidBaseUrlError,
142
145
  OBOL_SDK_EMAIL: () => OBOL_SDK_EMAIL,
143
146
  ObolSplits: () => ObolSplits,
144
147
  OperatorConfigHashSigningTypes: () => OperatorConfigHashSigningTypes,
@@ -154,8 +157,12 @@ __export(index_exports, {
154
157
  TermsAndConditionsSigningTypes: () => TermsAndConditionsSigningTypes,
155
158
  UnsupportedChainError: () => UnsupportedChainError,
156
159
  blsVerify: () => blsVerify,
160
+ builderBlsCheck: () => builderBlsCheck,
161
+ builderDomainForFork: () => builderDomainForFork,
157
162
  clusterConfigOrDefinitionHash: () => clusterConfigOrDefinitionHash,
158
163
  clusterLockHash: () => clusterLockHash,
164
+ depositBlsCheck: () => depositBlsCheck,
165
+ depositDomainForFork: () => depositDomainForFork,
159
166
  hasUniqueDistributedKeys: () => hasUniqueDistributedKeys,
160
167
  isChainSupportedForSplitters: () => isChainSupportedForSplitters,
161
168
  isValidClusterLock: () => isValidClusterLock,
@@ -165,6 +172,7 @@ __export(index_exports, {
165
172
  signingRoot: () => signingRoot,
166
173
  validateAddressSignature: () => validateAddressSignature,
167
174
  validateClusterLock: () => validateClusterLock,
175
+ validateDepositDataStructure: () => validateDepositDataStructure,
168
176
  validateEOASignature: () => validateEOASignature,
169
177
  validateSmartContractSignature: () => validateSmartContractSignature,
170
178
  verifyBuilderRegistration: () => verifyBuilderRegistration,
@@ -177,7 +185,7 @@ var import_uuid = require("uuid");
177
185
  // package.json
178
186
  var package_default = {
179
187
  name: "@obolnetwork/obol-sdk",
180
- version: "2.12.0",
188
+ version: "2.12.2",
181
189
  description: "A package for creating Distributed Validators using the Obol API.",
182
190
  bugs: {
183
191
  url: "https://github.com/obolnetwork/obol-sdk/issues"
@@ -255,7 +263,6 @@ var package_default = {
255
263
  "ajv-formats": "3.0.1",
256
264
  "ajv-keywords": "5.1.0",
257
265
  "cross-fetch": "4.1.0",
258
- dotenv: "17.4.2",
259
266
  elliptic: "6.6.1",
260
267
  ethers: "6.16.0",
261
268
  semver: "7.7.4",
@@ -268,6 +275,7 @@ var package_default = {
268
275
  "@types/node": "24.12.2",
269
276
  "@types/semver": "7.7.1",
270
277
  "@types/uuid": "9.0.8",
278
+ dotenv: "17.4.2",
271
279
  "@typescript-eslint/eslint-plugin": "6.21.0",
272
280
  "@typescript-eslint/parser": "6.21.0",
273
281
  eslint: "8.57.1",
@@ -395,8 +403,6 @@ var MAINNET_SPLIT_V2_FACTORY_BYTECODE = "0x6080604090808252600480361015610015575
395
403
  var HOODI_SPLIT_V2_FACTORY_BYTECODE = "0x6080604090808252600480361015610015575f80fd5b5f3560e01c9182632556fa391461043c5750816380ebf0ab146102be5781639e317f121461027a578163cd6bc1211461023f578163e9889edd1461016d578163f79918b0146100de575063fc6119b11461006d575f80fd5b346100da575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100da576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000f9c25250523df26343222fc46de932355b850c97168152f35b5f80fd5b82346100da577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc916080833601126100da5780359267ffffffffffffffff84116100da5760809084360301126100da5761016573ffffffffffffffffffffffffffffffffffffffff916020946101526105e7565b61015a61060a565b91606435930161090f565b915191168152f35b82346100da5760209073ffffffffffffffffffffffffffffffffffffffff6101656101a061019a3661062d565b91610b37565b309061023a7f000000000000000000000000f9c25250523df26343222fc46de932355b850c9790604051916c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f20916040525f606052565b610b7a565b82346100da576102546101a061019a3661062d565b803b151573ffffffffffffffffffffffffffffffffffffffff8351921682526020820152f35b82346100da5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100da57602091355f525f8252805f20549051908152f35b82346100da577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc9181833601126100da5780359267ffffffffffffffff84116100da5760809084360301126100da5761016561039c73ffffffffffffffffffffffffffffffffffffffff9261034a6103766103376105e7565b875192839160209a8b84019601866107c7565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282610858565b519020805f525f8652845f205490855191878301528682526103978261083c565b6108c2565b848151910120309061023a7f000000000000000000000000f9c25250523df26343222fc46de932355b850c9790604051916c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f20916040525f606052565b9083346100da577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc6060813601126100da5782359067ffffffffffffffff82116100da5760809082850192360301126100da576104976105e7565b6105286104a261060a565b6104e4602097888101906104bb8161034a888a866107c7565b519020805f525f8952865f20908154916001830190558751918a8301528982526103978261083c565b73ffffffffffffffffffffffffffffffffffffffff9281898593519101207f000000000000000000000000f9c25250523df26343222fc46de932355b850c97610aae565b1695863b156100da575f858592610569895194859384937fbaa7fda400000000000000000000000000000000000000000000000000000000855284016107c7565b0381838b5af180156105dd57928795927fb3ec24e9259e438f9917b49f27c0dd89a11b7626cb63e6fc977863c0b26a681b95926105ba956105ce575b508188519586956060875260608701906106f5565b93168a85015216868301520390a251908152f35b6105d7906107fb565b8a6105a5565b86513d5f823e3d90fd5b6024359073ffffffffffffffffffffffffffffffffffffffff821682036100da57565b6044359073ffffffffffffffffffffffffffffffffffffffff821682036100da57565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc906060828201126100da576004359167ffffffffffffffff83116100da57826080920301126100da576004019060243573ffffffffffffffffffffffffffffffffffffffff811681036100da579060443590565b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156100da57016020813591019167ffffffffffffffff82116100da578160051b360383136100da57565b6080820161070382806106a2565b608085529182905260a08401915f905b80821061078f5750505061072a60208301836106a2565b909284830360208601528183527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116100da5760609160051b8094602085013760408101356040860152013561ffff81168091036100da5760606020940152010190565b90919283359073ffffffffffffffffffffffffffffffffffffffff82168092036100da57600191815260208091019401920190610713565b9073ffffffffffffffffffffffffffffffffffffffff6107f46020929594956040855260408501906106f5565b9416910152565b67ffffffffffffffff811161080f57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040810190811067ffffffffffffffff82111761080f57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761080f57604052565b908151915f5b8381106108af575050015f815290565b806020809284010151818501520161089f565b61090d909291926108e160405194859260208401526040830190610899565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283610858565b565b93929161091d838387610b37565b7f000000000000000000000000f9c25250523df26343222fc46de932355b850c976109bb308361023a8490604051916c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f20916040525f606052565b803b610aa55750906109cc91610aae565b9473ffffffffffffffffffffffffffffffffffffffff9283871694853b156100da57604051947fbaa7fda40000000000000000000000000000000000000000000000000000000086525f8680610a268688600484016107c7565b0381838b5af1948515610a9a577fc4cec5a1846f5c98dc275670618bfecffec4da2e7cba63760ef46f38c75d236e96610a7496610a8b575b50816040519687966080885260808801906106f5565b9416602086015216604084015260608301520390a2565b610a94906107fb565b5f610a5e565b6040513d5f823e3d90fd5b96505050505050565b9190604051926c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f5ff5916040525f6060528115610b2a57565b63301164255f526004601cfd5b6040519291610b4f9184916108e191602084016107c7565b610b7460206040518093610b668383018097610899565b908152038084520182610858565b51902090565b91909160ff5f5360355260601b60015260155260555f20905f60355256fea2646970667358221220edd55753c55f257991df670fc562cdf54adb62d710125933fc4a0a7afddbc02564736f6c63430008170033";
396
404
 
397
405
  // src/constants.ts
398
- var dotenv = __toESM(require("dotenv"));
399
- dotenv.config();
400
406
  var CONFLICT_ERROR_MSG = "Conflict";
401
407
  var EIP712_DOMAIN_NAME = "Obol";
402
408
  var EIP712_DOMAIN_VERSION = "1";
@@ -605,27 +611,88 @@ var CAPELLA_FORK_MAPPING = {
605
611
  // Hoodi
606
612
  };
607
613
 
614
+ // src/errors.ts
615
+ var ConflictError = class _ConflictError extends Error {
616
+ constructor() {
617
+ super("This Cluster has been already posted.");
618
+ this.name = "ConflictError";
619
+ Object.setPrototypeOf(this, _ConflictError.prototype);
620
+ }
621
+ };
622
+ var SignerRequiredError = class _SignerRequiredError extends Error {
623
+ constructor(method) {
624
+ super(`Signer is required in ${method}`);
625
+ this.name = "SignerRequiredError";
626
+ Object.setPrototypeOf(this, _SignerRequiredError.prototype);
627
+ }
628
+ };
629
+ var UnsupportedChainError = class _UnsupportedChainError extends Error {
630
+ constructor(chainId, operation) {
631
+ super(`${operation} is not supported on chain ${chainId}`);
632
+ this.name = "UnsupportedChainError";
633
+ Object.setPrototypeOf(this, _UnsupportedChainError.prototype);
634
+ }
635
+ };
636
+ var InvalidBaseUrlError = class _InvalidBaseUrlError extends Error {
637
+ constructor(message2) {
638
+ super(message2);
639
+ this.name = "InvalidBaseUrlError";
640
+ Object.setPrototypeOf(this, _InvalidBaseUrlError.prototype);
641
+ }
642
+ };
643
+ var ClusterLockValidationTimeoutError = class _ClusterLockValidationTimeoutError extends Error {
644
+ /**
645
+ * @param timeoutMs - Same value as SDK whole-lock validation worker timeout.
646
+ */
647
+ constructor(timeoutMs) {
648
+ super(
649
+ `Cluster lock validation exceeded worker time limit (${timeoutMs} ms). Retry later; this does not imply invalid lock data.`
650
+ );
651
+ this.timeoutMs = timeoutMs;
652
+ this.name = "ClusterLockValidationTimeoutError";
653
+ Object.setPrototypeOf(this, _ClusterLockValidationTimeoutError.prototype);
654
+ }
655
+ };
656
+
608
657
  // src/base.ts
658
+ var ALLOWED_OBOL_API_BASE_URLS = [
659
+ DEFAULT_BASE_URL,
660
+ "https://obol-api-nonprod-dev.dev.obol.tech",
661
+ "https://obol-api-nonprod-qa.dev.obol.tech"
662
+ ];
663
+ var ALLOWED_BASE_URLS = new Set(ALLOWED_OBOL_API_BASE_URLS);
664
+ function assertAllowedBaseUrl(baseUrl) {
665
+ let candidate = baseUrl.trim();
666
+ while (candidate.endsWith("/")) {
667
+ candidate = candidate.slice(0, -1);
668
+ }
669
+ if (!ALLOWED_BASE_URLS.has(candidate)) {
670
+ throw new InvalidBaseUrlError(
671
+ `baseUrl must be one of: ${ALLOWED_OBOL_API_BASE_URLS.join(", ")}`
672
+ );
673
+ }
674
+ return candidate;
675
+ }
609
676
  var Base = class {
610
677
  constructor({
611
678
  baseUrl = DEFAULT_BASE_URL,
612
679
  chainId = DEFAULT_CHAIN_ID
613
680
  }) {
614
- this.baseUrl = baseUrl;
681
+ this.baseUrl = assertAllowedBaseUrl(baseUrl);
615
682
  this.chainId = chainId;
616
683
  this.fork_version = FORK_MAPPING[this.chainId];
617
684
  }
618
685
  request(endpoint, options) {
619
686
  return __async(this, null, function* () {
620
687
  const url = `${this.baseUrl}${endpoint}`;
621
- const config2 = __spreadProps(__spreadValues({}, options), {
688
+ const config = __spreadProps(__spreadValues({}, options), {
622
689
  headers: __spreadValues({
623
690
  "Content-Type": "application/json",
624
691
  "User-Agent": `Obol-SDK/${SDK_VERSION}`
625
692
  }, options == null ? void 0 : options.headers)
626
693
  });
627
694
  try {
628
- const response = yield fetch(url, config2);
695
+ const response = yield fetch(url, config);
629
696
  if (response.ok) {
630
697
  return yield response.json();
631
698
  } else {
@@ -639,29 +706,6 @@ var Base = class {
639
706
  }
640
707
  };
641
708
 
642
- // src/errors.ts
643
- var ConflictError = class _ConflictError extends Error {
644
- constructor() {
645
- super("This Cluster has been already posted.");
646
- this.name = "ConflictError";
647
- Object.setPrototypeOf(this, _ConflictError.prototype);
648
- }
649
- };
650
- var SignerRequiredError = class _SignerRequiredError extends Error {
651
- constructor(method) {
652
- super(`Signer is required in ${method}`);
653
- this.name = "SignerRequiredError";
654
- Object.setPrototypeOf(this, _SignerRequiredError.prototype);
655
- }
656
- };
657
- var UnsupportedChainError = class _UnsupportedChainError extends Error {
658
- constructor(chainId, operation) {
659
- super(`${operation} is not supported on chain ${chainId}`);
660
- this.name = "UnsupportedChainError";
661
- Object.setPrototypeOf(this, _UnsupportedChainError.prototype);
662
- }
663
- };
664
-
665
709
  // src/verification/common.ts
666
710
  var import_ssz7 = require("@chainsafe/ssz");
667
711
  var import_elliptic = __toESM(require("elliptic"));
@@ -780,6 +824,9 @@ var signingRootType = new import_ssz.ContainerType({
780
824
  // src/verification/v1.6.0.ts
781
825
  var import_ssz3 = require("@chainsafe/ssz");
782
826
 
827
+ // src/verification/parallelPool.ts
828
+ var import_ssz2 = require("@chainsafe/ssz");
829
+
783
830
  // node_modules/@noble/curves/node_modules/@noble/hashes/utils.js
784
831
  function isBytes(a) {
785
832
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
@@ -4934,6 +4981,12 @@ function blsVerify(pubkey, message2, signature) {
4934
4981
  return false;
4935
4982
  }
4936
4983
  }
4984
+ function blsAggregatePublicKeys(pubkeys) {
4985
+ if (pubkeys.length === 0) {
4986
+ throw new Error("cannot aggregate empty pubkey set");
4987
+ }
4988
+ return ls.aggregatePublicKeys(pubkeys).toBytes();
4989
+ }
4937
4990
  function blsVerifyAggregate(pubkeys, message2, signature) {
4938
4991
  try {
4939
4992
  return ls.verify(
@@ -4945,6 +4998,13 @@ function blsVerifyAggregate(pubkeys, message2, signature) {
4945
4998
  return false;
4946
4999
  }
4947
5000
  }
5001
+ function blsVerifyWithAggregatedPubkey(aggregatedPubkey, message2, signature) {
5002
+ try {
5003
+ return ls.verify(signature, ls.hash(message2, ETH2_DST), aggregatedPubkey);
5004
+ } catch (e) {
5005
+ return false;
5006
+ }
5007
+ }
4948
5008
  function blsVerifyMultiple(pubkeys, messages, signature) {
4949
5009
  try {
4950
5010
  if (pubkeys.length !== messages.length) return false;
@@ -5010,16 +5070,23 @@ function blsVerifyExtraShares(pubshares, threshold, distributedPubkey) {
5010
5070
  }
5011
5071
 
5012
5072
  // src/verification/parallelPool.ts
5013
- var import_ssz2 = require("@chainsafe/ssz");
5014
5073
  var MIN_PARALLEL_VALIDATORS = 50;
5015
5074
  var MIN_PARALLEL_BATCH_PAIRS = 100;
5016
5075
  var MAX_WORKERS = 8;
5017
5076
  var MIN_VALIDATORS_PER_WORKER = 25;
5018
5077
  var MIN_PAIRS_PER_WORKER = 50;
5078
+ var MIN_PARALLEL_AGGREGATE_KEYS = 400;
5079
+ var MIN_KEYS_PER_WORKER_AGG = 100;
5080
+ var MIN_VALIDATORS_FOR_VALIDATION_WORKER = 50;
5081
+ var VALIDATION_WORKER_TIMEOUT_MS = 12e4;
5019
5082
  var WORKER_TIMEOUT_MS = 6e4;
5083
+ var MAX_CONCURRENT_WORKERS_CAP = 8;
5084
+ function maxConcurrentWorkers(numWorkers) {
5085
+ return Math.min(numWorkers, MAX_CONCURRENT_WORKERS_CAP);
5086
+ }
5020
5087
  var workerThreadsCache;
5021
5088
  var osCache;
5022
- var workerPathCache;
5089
+ var workerPathByFile = /* @__PURE__ */ new Map();
5023
5090
  function loadWorkerThreads() {
5024
5091
  if (workerThreadsCache !== void 0) return workerThreadsCache;
5025
5092
  try {
@@ -5038,18 +5105,47 @@ function loadOs() {
5038
5105
  }
5039
5106
  return osCache;
5040
5107
  }
5041
- function getWorkerPath() {
5042
- if (workerPathCache !== void 0) return workerPathCache;
5043
- if (typeof __dirname === "undefined") return workerPathCache = null;
5108
+ function getWorkerPath(filename) {
5109
+ const cached = workerPathByFile.get(filename);
5110
+ if (cached !== void 0) return cached;
5111
+ if (typeof __dirname === "undefined") {
5112
+ workerPathByFile.set(filename, null);
5113
+ return null;
5114
+ }
5044
5115
  const path = require("path");
5045
- const candidate = path.join(__dirname, "lockWorker.js");
5116
+ const fs = require("fs");
5117
+ const candidates = [
5118
+ path.join(__dirname, filename),
5119
+ path.join(__dirname, "verification", filename)
5120
+ ];
5046
5121
  try {
5047
- const fs = require("fs");
5048
- if (!fs.existsSync(candidate)) return workerPathCache = null;
5122
+ for (const candidate of candidates) {
5123
+ if (fs.existsSync(candidate)) {
5124
+ workerPathByFile.set(filename, candidate);
5125
+ return candidate;
5126
+ }
5127
+ }
5049
5128
  } catch (e) {
5050
- return workerPathCache = null;
5051
5129
  }
5052
- return workerPathCache = candidate;
5130
+ workerPathByFile.set(filename, null);
5131
+ return null;
5132
+ }
5133
+ function mapWithConcurrency(items, concurrency, fn) {
5134
+ return __async(this, null, function* () {
5135
+ const results = new Array(items.length);
5136
+ let next = 0;
5137
+ const runners = Array.from(
5138
+ { length: Math.min(concurrency, items.length) },
5139
+ () => __async(null, null, function* () {
5140
+ while (next < items.length) {
5141
+ const i = next++;
5142
+ results[i] = yield fn(items[i], i);
5143
+ }
5144
+ })
5145
+ );
5146
+ yield Promise.all(runners);
5147
+ return results;
5148
+ });
5053
5149
  }
5054
5150
  function chunkArrays(arr, n) {
5055
5151
  const size = Math.ceil(arr.length / n);
@@ -5078,6 +5174,33 @@ function verifySharesSync(shares, distributedKeys, threshold) {
5078
5174
  }
5079
5175
  return true;
5080
5176
  }
5177
+ function runWorkerAggregatePubkeys(wt, workerFile, data) {
5178
+ return __async(this, null, function* () {
5179
+ return yield new Promise((resolve) => {
5180
+ let settled = false;
5181
+ const worker = new wt.Worker(workerFile, { workerData: data });
5182
+ const finish = (result) => {
5183
+ if (settled) return;
5184
+ settled = true;
5185
+ clearTimeout(timer);
5186
+ worker.terminate();
5187
+ resolve(result);
5188
+ };
5189
+ const timer = setTimeout(() => {
5190
+ finish(null);
5191
+ }, WORKER_TIMEOUT_MS);
5192
+ worker.once("message", (msg) => {
5193
+ finish(msg instanceof Uint8Array ? msg : null);
5194
+ });
5195
+ worker.once("error", () => {
5196
+ finish(null);
5197
+ });
5198
+ worker.once("exit", (code2) => {
5199
+ if (code2 !== 0) finish(null);
5200
+ });
5201
+ });
5202
+ });
5203
+ }
5081
5204
  function runWorker(wt, workerFile, data) {
5082
5205
  return __async(this, null, function* () {
5083
5206
  return yield new Promise((resolve) => {
@@ -5108,8 +5231,8 @@ function runWorker(wt, workerFile, data) {
5108
5231
  function poolSize(itemCount, minPerWorker) {
5109
5232
  const wt = loadWorkerThreads();
5110
5233
  const os = loadOs();
5111
- const workerFile = getWorkerPath();
5112
- const numCpus = os ? os.cpus().length : 1;
5234
+ const workerFile = getWorkerPath("lockWorker.js");
5235
+ const numCpus = os ? Math.max(1, os.cpus().length) : 1;
5113
5236
  const numWorkers = Math.min(
5114
5237
  MAX_WORKERS,
5115
5238
  Math.max(1, Math.floor(itemCount / minPerWorker)),
@@ -5117,6 +5240,18 @@ function poolSize(itemCount, minPerWorker) {
5117
5240
  );
5118
5241
  return { numWorkers, wt, workerFile };
5119
5242
  }
5243
+ function runWorkerChunks(wt, workerFile, chunks) {
5244
+ return __async(this, null, function* () {
5245
+ const results = yield mapWithConcurrency(
5246
+ chunks,
5247
+ maxConcurrentWorkers(chunks.length),
5248
+ (data) => __async(null, null, function* () {
5249
+ return yield runWorker(wt, workerFile, data);
5250
+ })
5251
+ );
5252
+ return results.every(Boolean);
5253
+ });
5254
+ }
5120
5255
  function verifySharesBinding(shares, distributedKeys, threshold) {
5121
5256
  return __async(this, null, function* () {
5122
5257
  if (shares.length !== distributedKeys.length) return false;
@@ -5130,19 +5265,26 @@ function verifySharesBinding(shares, distributedKeys, threshold) {
5130
5265
  }
5131
5266
  const shareChunks = chunkArrays(shares, numWorkers);
5132
5267
  const keyChunks = chunkArrays(distributedKeys, numWorkers);
5133
- const results = yield Promise.all(
5134
- shareChunks.map(
5135
- (chunk, i) => __async(null, null, function* () {
5136
- return yield runWorker(wt, workerFile, {
5137
- mode: "shareBinding",
5138
- shares: chunk,
5139
- distributedKeys: keyChunks[i],
5140
- threshold
5141
- });
5142
- })
5143
- )
5268
+ return yield runWorkerChunks(
5269
+ wt,
5270
+ workerFile,
5271
+ shareChunks.map((chunk, i) => ({
5272
+ mode: "shareBinding",
5273
+ shares: chunk,
5274
+ distributedKeys: keyChunks[i],
5275
+ threshold
5276
+ }))
5277
+ );
5278
+ });
5279
+ }
5280
+ function verifyBlsChecksParallel(checks) {
5281
+ return __async(this, null, function* () {
5282
+ if (checks.length === 0) return true;
5283
+ return yield verifyBatchParallel(
5284
+ checks.map((c) => c.pubkey),
5285
+ checks.map((c) => c.message),
5286
+ checks.map((c) => c.signature)
5144
5287
  );
5145
- return results.every(Boolean);
5146
5288
  });
5147
5289
  }
5148
5290
  function verifyBatchParallel(pubkeys, messages, signatures) {
@@ -5165,19 +5307,83 @@ function verifyBatchParallel(pubkeys, messages, signatures) {
5165
5307
  const pkChunks = chunkArrays(pubkeys, numWorkers);
5166
5308
  const msgChunks = chunkArrays(messages, numWorkers);
5167
5309
  const sigChunks = chunkArrays(signatures, numWorkers);
5168
- const results = yield Promise.all(
5169
- pkChunks.map(
5170
- (pks, i) => __async(null, null, function* () {
5171
- return yield runWorker(wt, workerFile, {
5172
- mode: "verifyBatch",
5173
- pubkeys: pks,
5174
- messages: msgChunks[i],
5175
- aggregateSignature: blsAggregateSignatures(sigChunks[i])
5176
- });
5177
- })
5178
- )
5310
+ return yield runWorkerChunks(
5311
+ wt,
5312
+ workerFile,
5313
+ pkChunks.map((pks, i) => ({
5314
+ mode: "verifyBatch",
5315
+ pubkeys: pks,
5316
+ messages: msgChunks[i],
5317
+ signatures: sigChunks[i]
5318
+ }))
5179
5319
  );
5180
- return results.every(Boolean);
5320
+ });
5321
+ }
5322
+ function verifyAggregateParallel(pubkeys, message2, signature) {
5323
+ return __async(this, null, function* () {
5324
+ if (pubkeys.length === 0) return false;
5325
+ const { numWorkers, wt, workerFile } = poolSize(
5326
+ pubkeys.length,
5327
+ MIN_KEYS_PER_WORKER_AGG
5328
+ );
5329
+ if (wt === null || workerFile === null || pubkeys.length < MIN_PARALLEL_AGGREGATE_KEYS || numWorkers < 2) {
5330
+ return blsVerifyAggregate(pubkeys, message2, signature);
5331
+ }
5332
+ const pkChunks = chunkArrays(pubkeys, numWorkers);
5333
+ const partials = yield mapWithConcurrency(
5334
+ pkChunks,
5335
+ maxConcurrentWorkers(pkChunks.length),
5336
+ (chunk) => __async(null, null, function* () {
5337
+ return yield runWorkerAggregatePubkeys(wt, workerFile, {
5338
+ mode: "aggregatePubkeys",
5339
+ pubkeys: chunk
5340
+ });
5341
+ })
5342
+ );
5343
+ if (partials.some((p) => p === null)) return false;
5344
+ const aggregated = blsAggregatePublicKeys(partials);
5345
+ return blsVerifyWithAggregatedPubkey(aggregated, message2, signature);
5346
+ });
5347
+ }
5348
+ function validateClusterLockInWorker(lock, safeRpcUrl) {
5349
+ return __async(this, null, function* () {
5350
+ var _a6, _b2;
5351
+ const n = (_b2 = (_a6 = lock.distributed_validators) == null ? void 0 : _a6.length) != null ? _b2 : 0;
5352
+ if (n < MIN_VALIDATORS_FOR_VALIDATION_WORKER) return null;
5353
+ const wt = loadWorkerThreads();
5354
+ const workerFile = getWorkerPath("clusterLockValidationWorker.js");
5355
+ if (wt === null || workerFile === null) return null;
5356
+ return yield new Promise((resolve, reject) => {
5357
+ let settled = false;
5358
+ const worker = new wt.Worker(workerFile, {
5359
+ workerData: { lock, safeRpcUrl }
5360
+ });
5361
+ const timer = setTimeout(() => {
5362
+ if (settled) return;
5363
+ settled = true;
5364
+ clearTimeout(timer);
5365
+ void worker.terminate();
5366
+ reject(
5367
+ new ClusterLockValidationTimeoutError(VALIDATION_WORKER_TIMEOUT_MS)
5368
+ );
5369
+ }, VALIDATION_WORKER_TIMEOUT_MS);
5370
+ const finish = (result) => {
5371
+ if (settled) return;
5372
+ settled = true;
5373
+ clearTimeout(timer);
5374
+ worker.terminate();
5375
+ resolve(result);
5376
+ };
5377
+ worker.once("message", (msg) => {
5378
+ finish(msg === true);
5379
+ });
5380
+ worker.once("error", () => {
5381
+ finish(null);
5382
+ });
5383
+ worker.once("exit", (code2) => {
5384
+ if (code2 !== 0) finish(null);
5385
+ });
5386
+ });
5181
5387
  });
5182
5388
  }
5183
5389
 
@@ -5282,7 +5488,6 @@ var hashClusterLockV1X6 = (cluster) => {
5282
5488
  return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
5283
5489
  };
5284
5490
  var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
5285
- var _a6;
5286
5491
  const validators = clusterLock.distributed_validators;
5287
5492
  const operatorCount = clusterLock.cluster_definition.operators.length;
5288
5493
  const threshold = clusterLock.cluster_definition.threshold;
@@ -5301,9 +5506,7 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
5301
5506
  return false;
5302
5507
  }
5303
5508
  const pubShares = [];
5304
- const pubKeys = [];
5305
- const builderRegistrationAndDepositDataMessages = [];
5306
- const blsSignatures = [];
5509
+ const blsChecks = [];
5307
5510
  for (let i = 0; i < validators.length; i++) {
5308
5511
  const validator = validators[i];
5309
5512
  const validatorPublicShares = validator.public_shares;
@@ -5321,33 +5524,23 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
5321
5524
  for (const share of validatorPublicSharesBytes) {
5322
5525
  pubShares.push(share);
5323
5526
  }
5324
- const { isValidDepositData, depositDataMsg } = verifyDepositData(
5527
+ const depositCheck = depositBlsCheck(
5325
5528
  distributedPublicKey,
5326
5529
  validator.deposit_data,
5327
5530
  clusterLock.cluster_definition.validators[i].withdrawal_address,
5328
5531
  clusterLock.cluster_definition.fork_version
5329
5532
  );
5330
- if (!isValidDepositData) {
5331
- return false;
5332
- }
5333
- pubKeys.push((0, import_ssz3.fromHexString)(validator.distributed_public_key));
5334
- builderRegistrationAndDepositDataMessages.push(depositDataMsg);
5335
- blsSignatures.push(
5336
- (0, import_ssz3.fromHexString)((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
5337
- );
5533
+ if (!depositCheck) return false;
5534
+ blsChecks.push(depositCheck);
5338
5535
  }
5339
- if (!(yield verifyBatchParallel(
5340
- pubKeys,
5341
- builderRegistrationAndDepositDataMessages,
5342
- blsSignatures
5343
- ))) {
5536
+ if (!(yield verifyBlsChecksParallel(blsChecks))) {
5344
5537
  return false;
5345
5538
  }
5346
- if (!blsVerifyAggregate(
5539
+ if (!(yield verifyAggregateParallel(
5347
5540
  pubShares,
5348
5541
  (0, import_ssz3.fromHexString)(clusterLock.lock_hash),
5349
5542
  (0, import_ssz3.fromHexString)(clusterLock.signature_aggregate)
5350
- )) {
5543
+ ))) {
5351
5544
  return false;
5352
5545
  }
5353
5546
  return true;
@@ -5473,7 +5666,6 @@ var hashClusterLockV1X7 = (cluster) => {
5473
5666
  return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
5474
5667
  };
5475
5668
  var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
5476
- var _a6, _b2;
5477
5669
  const validators = clusterLock.distributed_validators;
5478
5670
  const operatorCount = clusterLock.cluster_definition.operators.length;
5479
5671
  const threshold = clusterLock.cluster_definition.threshold;
@@ -5492,9 +5684,7 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
5492
5684
  return false;
5493
5685
  }
5494
5686
  const pubShares = [];
5495
- const pubKeys = [];
5496
- const builderRegistrationAndDepositDataMessages = [];
5497
- const blsSignatures = [];
5687
+ const blsChecks = [];
5498
5688
  for (let i = 0; i < validators.length; i++) {
5499
5689
  const validator = validators[i];
5500
5690
  const validatorPublicShares = validator.public_shares;
@@ -5512,49 +5702,33 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
5512
5702
  for (const share of validatorPublicSharesBytes) {
5513
5703
  pubShares.push(share);
5514
5704
  }
5515
- const { isValidDepositData, depositDataMsg } = verifyDepositData(
5705
+ const depositCheck = depositBlsCheck(
5516
5706
  distributedPublicKey,
5517
5707
  validator.deposit_data,
5518
5708
  clusterLock.cluster_definition.validators[i].withdrawal_address,
5519
5709
  clusterLock.cluster_definition.fork_version
5520
5710
  );
5521
- if (!isValidDepositData) {
5522
- return false;
5523
- }
5524
- pubKeys.push((0, import_ssz4.fromHexString)(distributedPublicKey));
5525
- builderRegistrationAndDepositDataMessages.push(depositDataMsg);
5526
- blsSignatures.push(
5527
- (0, import_ssz4.fromHexString)((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
5528
- );
5529
- const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
5711
+ if (!depositCheck) return false;
5712
+ blsChecks.push(depositCheck);
5713
+ const builderCheck = builderBlsCheck(
5530
5714
  validator,
5531
5715
  clusterLock.cluster_definition.validators[i].fee_recipient_address,
5532
5716
  clusterLock.cluster_definition.fork_version
5533
5717
  );
5534
- if (!isValidBuilderRegistration) {
5535
- return false;
5536
- }
5537
- pubKeys.push((0, import_ssz4.fromHexString)(distributedPublicKey));
5538
- builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
5539
- blsSignatures.push(
5540
- (0, import_ssz4.fromHexString)((_b2 = validator.builder_registration) == null ? void 0 : _b2.signature)
5541
- );
5718
+ if (!builderCheck) return false;
5719
+ blsChecks.push(builderCheck);
5542
5720
  }
5543
- if (!(yield verifyBatchParallel(
5544
- pubKeys,
5545
- builderRegistrationAndDepositDataMessages,
5546
- blsSignatures
5547
- ))) {
5721
+ if (!(yield verifyBlsChecksParallel(blsChecks))) {
5548
5722
  return false;
5549
5723
  }
5550
5724
  if (!verifyNodeSignatures(clusterLock)) {
5551
5725
  return false;
5552
5726
  }
5553
- if (!blsVerifyAggregate(
5727
+ if (!(yield verifyAggregateParallel(
5554
5728
  pubShares,
5555
5729
  (0, import_ssz4.fromHexString)(clusterLock.lock_hash),
5556
5730
  (0, import_ssz4.fromHexString)(clusterLock.signature_aggregate)
5557
- )) {
5731
+ ))) {
5558
5732
  return false;
5559
5733
  }
5560
5734
  return true;
@@ -14107,7 +14281,6 @@ var hashClusterLockV1X8 = (cluster) => {
14107
14281
  return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
14108
14282
  };
14109
14283
  var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
14110
- var _a6;
14111
14284
  const validators = clusterLock.distributed_validators;
14112
14285
  const operatorCount = clusterLock.cluster_definition.operators.length;
14113
14286
  const threshold = clusterLock.cluster_definition.threshold;
@@ -14126,9 +14299,10 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
14126
14299
  return false;
14127
14300
  }
14128
14301
  const pubShares = [];
14129
- const pubKeys = [];
14130
- const builderRegistrationAndDepositDataMessages = [];
14131
- const blsSignatures = [];
14302
+ const blsChecks = [];
14303
+ const forkVersion = clusterLock.cluster_definition.fork_version;
14304
+ const depositDomain = depositDomainForFork(forkVersion);
14305
+ const builderDomain = builderDomainForFork(forkVersion);
14132
14306
  for (let i = 0; i < validators.length; i++) {
14133
14307
  const validator = validators[i];
14134
14308
  const validatorPublicShares = validator.public_shares;
@@ -14155,51 +14329,38 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
14155
14329
  return false;
14156
14330
  }
14157
14331
  }
14158
- for (const element of validator.partial_deposit_data) {
14159
- const depositData = element;
14160
- const { isValidDepositData, depositDataMsg } = verifyDepositData(
14332
+ for (const depositData of validator.partial_deposit_data) {
14333
+ const check = depositBlsCheck(
14161
14334
  distributedPublicKey,
14162
14335
  depositData,
14163
14336
  clusterLock.cluster_definition.validators[i].withdrawal_address,
14164
- clusterLock.cluster_definition.fork_version,
14165
- clusterLock.cluster_definition.compounding
14337
+ forkVersion,
14338
+ clusterLock.cluster_definition.compounding,
14339
+ depositDomain
14166
14340
  );
14167
- if (!isValidDepositData) {
14168
- return false;
14169
- }
14170
- pubKeys.push((0, import_ssz5.fromHexString)(distributedPublicKey));
14171
- builderRegistrationAndDepositDataMessages.push(depositDataMsg);
14172
- blsSignatures.push((0, import_ssz5.fromHexString)(depositData == null ? void 0 : depositData.signature));
14341
+ if (!check) return false;
14342
+ blsChecks.push(check);
14173
14343
  }
14174
- const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
14344
+ const builderCheck = builderBlsCheck(
14175
14345
  validator,
14176
14346
  clusterLock.cluster_definition.validators[i].fee_recipient_address,
14177
- clusterLock.cluster_definition.fork_version
14178
- );
14179
- if (!isValidBuilderRegistration) {
14180
- return false;
14181
- }
14182
- pubKeys.push((0, import_ssz5.fromHexString)(distributedPublicKey));
14183
- builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
14184
- blsSignatures.push(
14185
- (0, import_ssz5.fromHexString)((_a6 = validator.builder_registration) == null ? void 0 : _a6.signature)
14347
+ forkVersion,
14348
+ builderDomain
14186
14349
  );
14350
+ if (!builderCheck) return false;
14351
+ blsChecks.push(builderCheck);
14187
14352
  }
14188
- if (!(yield verifyBatchParallel(
14189
- pubKeys,
14190
- builderRegistrationAndDepositDataMessages,
14191
- blsSignatures
14192
- ))) {
14353
+ if (!(yield verifyBlsChecksParallel(blsChecks))) {
14193
14354
  return false;
14194
14355
  }
14195
14356
  if (!verifyNodeSignatures(clusterLock)) {
14196
14357
  return false;
14197
14358
  }
14198
- if (!blsVerifyAggregate(
14359
+ if (!(yield verifyAggregateParallel(
14199
14360
  pubShares,
14200
14361
  (0, import_ssz5.fromHexString)(clusterLock.lock_hash),
14201
14362
  (0, import_ssz5.fromHexString)(clusterLock.signature_aggregate)
14202
- )) {
14363
+ ))) {
14203
14364
  return false;
14204
14365
  }
14205
14366
  return true;
@@ -14601,37 +14762,62 @@ var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, im
14601
14762
  domain.set(forkDataRoot.subarray(0, 28), 4);
14602
14763
  return domain;
14603
14764
  };
14604
- var verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding) => {
14605
- const depositDomain = computeDomain(
14606
- (0, import_ssz7.fromHexString)(DOMAIN_DEPOSIT),
14607
- forkVersion
14608
- );
14765
+ var depositDomainForFork = (forkVersion) => computeDomain((0, import_ssz7.fromHexString)(DOMAIN_DEPOSIT), forkVersion);
14766
+ var builderDomainForFork = (forkVersion) => computeDomain((0, import_ssz7.fromHexString)(DOMAIN_APPLICATION_BUILDER), forkVersion);
14767
+ var validateDepositDataStructure = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding, precomputedDepositDomain) => {
14768
+ const depositDomain = precomputedDepositDomain != null ? precomputedDepositDomain : computeDomain((0, import_ssz7.fromHexString)(DOMAIN_DEPOSIT), forkVersion);
14609
14769
  const withdrawalPrefix = compounding ? "0x02" : "0x01";
14610
14770
  const expectedWithdrawalCredentials = withdrawalPrefix + "0".repeat(22) + withdrawalAddress.toLowerCase().slice(2);
14611
14771
  if (expectedWithdrawalCredentials !== depositData.withdrawal_credentials) {
14612
- return { isValidDepositData: false, depositDataMsg: new Uint8Array(0) };
14772
+ return { valid: false, message: new Uint8Array(0) };
14613
14773
  }
14614
14774
  if (distributedPublicKey !== depositData.pubkey) {
14615
- return { isValidDepositData: false, depositDataMsg: new Uint8Array(0) };
14775
+ return { valid: false, message: new Uint8Array(0) };
14616
14776
  }
14617
14777
  const depositMessageBuffer = computeDepositMsgRoot(depositData);
14618
- const depositDataRoot = signingRoot(depositDomain, depositMessageBuffer);
14778
+ const message2 = signingRoot(depositDomain, depositMessageBuffer);
14619
14779
  if (!depositData.signature) {
14620
- return { isValidDepositData: false, depositDataMsg: depositDataRoot };
14780
+ return { valid: false, message: message2 };
14781
+ }
14782
+ return { valid: true, message: message2 };
14783
+ };
14784
+ var depositBlsCheck = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding, precomputedDepositDomain) => {
14785
+ const { valid, message: message2 } = validateDepositDataStructure(
14786
+ distributedPublicKey,
14787
+ depositData,
14788
+ withdrawalAddress,
14789
+ forkVersion,
14790
+ compounding,
14791
+ precomputedDepositDomain
14792
+ );
14793
+ if (!valid || !depositData.signature || !depositData.pubkey) return null;
14794
+ return {
14795
+ pubkey: (0, import_ssz7.fromHexString)(depositData.pubkey),
14796
+ message: message2,
14797
+ signature: (0, import_ssz7.fromHexString)(depositData.signature)
14798
+ };
14799
+ };
14800
+ var verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding) => {
14801
+ const { valid, message: message2 } = validateDepositDataStructure(
14802
+ distributedPublicKey,
14803
+ depositData,
14804
+ withdrawalAddress,
14805
+ forkVersion,
14806
+ compounding
14807
+ );
14808
+ if (!valid || !depositData.signature || !depositData.pubkey) {
14809
+ return { isValidDepositData: false, depositDataMsg: message2 };
14621
14810
  }
14622
14811
  const isValidDepositData = blsVerify(
14623
14812
  (0, import_ssz7.fromHexString)(depositData.pubkey),
14624
- depositDataRoot,
14813
+ message2,
14625
14814
  (0, import_ssz7.fromHexString)(depositData.signature)
14626
14815
  );
14627
- return { isValidDepositData, depositDataMsg: depositDataRoot };
14816
+ return { isValidDepositData, depositDataMsg: message2 };
14628
14817
  };
14629
- var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion) => {
14818
+ var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion, precomputedBuilderDomain) => {
14630
14819
  var _a6;
14631
- const builderDomain = computeDomain(
14632
- (0, import_ssz7.fromHexString)(DOMAIN_APPLICATION_BUILDER),
14633
- forkVersion
14634
- );
14820
+ const builderDomain = precomputedBuilderDomain != null ? precomputedBuilderDomain : computeDomain((0, import_ssz7.fromHexString)(DOMAIN_APPLICATION_BUILDER), forkVersion);
14635
14821
  if (validator.distributed_public_key !== ((_a6 = validator.builder_registration) == null ? void 0 : _a6.message.pubkey)) {
14636
14822
  return {
14637
14823
  isValidBuilderRegistration: false,
@@ -14656,6 +14842,22 @@ var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion) =>
14656
14842
  builderRegistrationMsg: builderRegistrationMessage
14657
14843
  };
14658
14844
  };
14845
+ var builderBlsCheck = (validator, feeRecipientAddress, forkVersion, precomputedBuilderDomain) => {
14846
+ var _a6;
14847
+ const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
14848
+ validator,
14849
+ feeRecipientAddress,
14850
+ forkVersion,
14851
+ precomputedBuilderDomain
14852
+ );
14853
+ const sig = (_a6 = validator.builder_registration) == null ? void 0 : _a6.signature;
14854
+ if (!isValidBuilderRegistration || !sig) return null;
14855
+ return {
14856
+ pubkey: (0, import_ssz7.fromHexString)(validator.distributed_public_key),
14857
+ message: builderRegistrationMsg,
14858
+ signature: (0, import_ssz7.fromHexString)(sig)
14859
+ };
14860
+ };
14659
14861
  var verifyNodeSignatures = (clusterLock) => {
14660
14862
  const ec2 = new import_elliptic.default.ec("secp256k1");
14661
14863
  const nodeSignatures = clusterLock.node_signatures;
@@ -18084,11 +18286,11 @@ var encodeCreateSplitV2DeterministicTxData = (splitParams, splitOwnerAddress, sa
18084
18286
  );
18085
18287
  };
18086
18288
  var getChainConfig = (chainId) => {
18087
- const config2 = CHAIN_CONFIGURATION[chainId];
18088
- if (!config2) {
18289
+ const config = CHAIN_CONFIGURATION[chainId];
18290
+ if (!config) {
18089
18291
  throw new Error(`Chain configuration not found for chain ID ${chainId}`);
18090
18292
  }
18091
- return config2;
18293
+ return config;
18092
18294
  };
18093
18295
  var requestWithdrawalFromOVM = (_0) => __async(null, [_0], function* ({
18094
18296
  ovmAddress,
@@ -19663,8 +19865,9 @@ var EOA = class {
19663
19865
  // src/services.ts
19664
19866
  var validateClusterLock = (lock, safeRpcUrl) => __async(null, null, function* () {
19665
19867
  try {
19666
- const isLockValid = yield isValidClusterLock(lock, safeRpcUrl);
19667
- return isLockValid;
19868
+ const inWorker = yield validateClusterLockInWorker(lock, safeRpcUrl);
19869
+ if (inWorker !== null) return inWorker;
19870
+ return yield isValidClusterLock(lock, safeRpcUrl);
19668
19871
  } catch (err) {
19669
19872
  throw err;
19670
19873
  }
@@ -19677,6 +19880,7 @@ var Client = class extends Base {
19677
19880
  *
19678
19881
  * @param config - Client configuration object.
19679
19882
  * @param config.baseUrl - Obol API base URL. Defaults to `https://api.obol.tech`.
19883
+ * Must match one of {@link ALLOWED_OBOL_API_BASE_URLS} (API paths use `/v1/...` separately).
19680
19884
  * @param config.chainId - Target chain ID. Defaults to `560048` (Hoodi).
19681
19885
  * Supported: 1 (Mainnet), 560048 (Hoodi), 100 (Gnosis), 11155111 (Sepolia).
19682
19886
  * @param signer - An ethers `Wallet` or `JsonRpcSigner`. Required for any
@@ -19694,8 +19898,8 @@ var Client = class extends Base {
19694
19898
  * const client = new Client({ chainId: 560048 }, signer);
19695
19899
  * ```
19696
19900
  */
19697
- constructor(config2, signer, provider) {
19698
- super(config2);
19901
+ constructor(config, signer, provider) {
19902
+ super(config);
19699
19903
  this.signer = signer;
19700
19904
  this.provider = provider != null ? provider : signer && "provider" in signer ? signer.provider : void 0;
19701
19905
  this.incentives = new Incentives(
@@ -20258,12 +20462,14 @@ var Client = class extends Base {
20258
20462
  };
20259
20463
  // Annotate the CommonJS export names for ESM import in node:
20260
20464
  0 && (module.exports = {
20465
+ ALLOWED_OBOL_API_BASE_URLS,
20261
20466
  AVAILABLE_SPLITTER_CHAINS,
20262
20467
  CAPELLA_FORK_MAPPING,
20263
20468
  CHAIN_CONFIGURATION,
20264
20469
  CONFIG_VERSION,
20265
20470
  CONFLICT_ERROR_MSG,
20266
20471
  Client,
20472
+ ClusterLockValidationTimeoutError,
20267
20473
  ConflictError,
20268
20474
  CreatorConfigHashSigningTypes,
20269
20475
  CreatorTypedMessage,
@@ -20289,6 +20495,7 @@ var Client = class extends Base {
20289
20495
  FORK_NAMES,
20290
20496
  GENESIS_VALIDATOR_ROOT,
20291
20497
  Incentives,
20498
+ InvalidBaseUrlError,
20292
20499
  OBOL_SDK_EMAIL,
20293
20500
  ObolSplits,
20294
20501
  OperatorConfigHashSigningTypes,
@@ -20304,8 +20511,12 @@ var Client = class extends Base {
20304
20511
  TermsAndConditionsSigningTypes,
20305
20512
  UnsupportedChainError,
20306
20513
  blsVerify,
20514
+ builderBlsCheck,
20515
+ builderDomainForFork,
20307
20516
  clusterConfigOrDefinitionHash,
20308
20517
  clusterLockHash,
20518
+ depositBlsCheck,
20519
+ depositDomainForFork,
20309
20520
  hasUniqueDistributedKeys,
20310
20521
  isChainSupportedForSplitters,
20311
20522
  isValidClusterLock,
@@ -20315,6 +20526,7 @@ var Client = class extends Base {
20315
20526
  signingRoot,
20316
20527
  validateAddressSignature,
20317
20528
  validateClusterLock,
20529
+ validateDepositDataStructure,
20318
20530
  validateEOASignature,
20319
20531
  validateSmartContractSignature,
20320
20532
  verifyBuilderRegistration,