@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.
- package/README.md +6 -4
- package/dist/browser/src/index.js +374 -170
- package/dist/browser/src/index.js.map +1 -1
- package/dist/cjs/src/blsUtils.js +19 -2
- package/dist/cjs/src/blsUtils.js.map +1 -1
- package/dist/cjs/src/index.js +382 -170
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/verification/clusterLockValidationWorker.js +14694 -0
- package/dist/cjs/src/verification/clusterLockValidationWorker.js.map +1 -0
- package/dist/cjs/src/verification/lockWorker.js +13 -1
- package/dist/cjs/src/verification/lockWorker.js.map +1 -1
- package/dist/cjs/src/verification/parallelPool.js +227 -35
- package/dist/cjs/src/verification/parallelPool.js.map +1 -1
- package/dist/esm/src/blsUtils.js +7 -3
- package/dist/esm/src/{chunk-267HIPEB.js → chunk-LOSYOJC3.js} +16 -1
- package/dist/esm/src/{chunk-267HIPEB.js.map → chunk-LOSYOJC3.js.map} +1 -1
- package/dist/esm/src/chunk-T74RX3N2.js +10240 -0
- package/dist/esm/src/chunk-T74RX3N2.js.map +1 -0
- package/dist/esm/src/chunk-YSXFCSVK.js +389 -0
- package/dist/esm/src/chunk-YSXFCSVK.js.map +1 -0
- package/dist/esm/src/index.js +234 -10339
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/verification/clusterLockValidationWorker.js +18 -0
- package/dist/esm/src/verification/clusterLockValidationWorker.js.map +1 -0
- package/dist/esm/src/verification/lockWorker.js +7 -2
- package/dist/esm/src/verification/lockWorker.js.map +1 -1
- package/dist/esm/src/verification/parallelPool.js +8 -2
- package/dist/types/src/base.d.ts +5 -3
- package/dist/types/src/blsUtils.d.ts +3 -0
- package/dist/types/src/errors.d.ts +21 -0
- package/dist/types/src/index.d.ts +5 -6
- package/dist/types/src/services.d.ts +4 -1
- package/dist/types/src/types.d.ts +6 -0
- package/dist/types/src/verification/clusterLockValidationWorker.d.ts +1 -0
- package/dist/types/src/verification/common.d.ts +17 -7
- package/dist/types/src/verification/lockWorker.d.ts +7 -2
- package/dist/types/src/verification/parallelPool.d.ts +9 -0
- package/dist/types/test/client/baseUrl.spec.d.ts +1 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/esm/src/chunk-OYZHSNKR.js +0 -186
- package/dist/esm/src/chunk-OYZHSNKR.js.map +0 -1
|
@@ -98,7 +98,7 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
98
98
|
// package.json
|
|
99
99
|
var package_default = {
|
|
100
100
|
name: "@obolnetwork/obol-sdk",
|
|
101
|
-
version: "2.12.
|
|
101
|
+
version: "2.12.2",
|
|
102
102
|
description: "A package for creating Distributed Validators using the Obol API.",
|
|
103
103
|
bugs: {
|
|
104
104
|
url: "https://github.com/obolnetwork/obol-sdk/issues"
|
|
@@ -176,7 +176,6 @@ var package_default = {
|
|
|
176
176
|
"ajv-formats": "3.0.1",
|
|
177
177
|
"ajv-keywords": "5.1.0",
|
|
178
178
|
"cross-fetch": "4.1.0",
|
|
179
|
-
dotenv: "17.4.2",
|
|
180
179
|
elliptic: "6.6.1",
|
|
181
180
|
ethers: "6.16.0",
|
|
182
181
|
semver: "7.7.4",
|
|
@@ -189,6 +188,7 @@ var package_default = {
|
|
|
189
188
|
"@types/node": "24.12.2",
|
|
190
189
|
"@types/semver": "7.7.1",
|
|
191
190
|
"@types/uuid": "9.0.8",
|
|
191
|
+
dotenv: "17.4.2",
|
|
192
192
|
"@typescript-eslint/eslint-plugin": "6.21.0",
|
|
193
193
|
"@typescript-eslint/parser": "6.21.0",
|
|
194
194
|
eslint: "8.57.1",
|
|
@@ -316,8 +316,6 @@ var MAINNET_SPLIT_V2_FACTORY_BYTECODE = "0x6080604090808252600480361015610015575
|
|
|
316
316
|
var HOODI_SPLIT_V2_FACTORY_BYTECODE = "0x6080604090808252600480361015610015575f80fd5b5f3560e01c9182632556fa391461043c5750816380ebf0ab146102be5781639e317f121461027a578163cd6bc1211461023f578163e9889edd1461016d578163f79918b0146100de575063fc6119b11461006d575f80fd5b346100da575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100da576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000f9c25250523df26343222fc46de932355b850c97168152f35b5f80fd5b82346100da577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc916080833601126100da5780359267ffffffffffffffff84116100da5760809084360301126100da5761016573ffffffffffffffffffffffffffffffffffffffff916020946101526105e7565b61015a61060a565b91606435930161090f565b915191168152f35b82346100da5760209073ffffffffffffffffffffffffffffffffffffffff6101656101a061019a3661062d565b91610b37565b309061023a7f000000000000000000000000f9c25250523df26343222fc46de932355b850c9790604051916c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f20916040525f606052565b610b7a565b82346100da576102546101a061019a3661062d565b803b151573ffffffffffffffffffffffffffffffffffffffff8351921682526020820152f35b82346100da5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100da57602091355f525f8252805f20549051908152f35b82346100da577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc9181833601126100da5780359267ffffffffffffffff84116100da5760809084360301126100da5761016561039c73ffffffffffffffffffffffffffffffffffffffff9261034a6103766103376105e7565b875192839160209a8b84019601866107c7565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282610858565b519020805f525f8652845f205490855191878301528682526103978261083c565b6108c2565b848151910120309061023a7f000000000000000000000000f9c25250523df26343222fc46de932355b850c9790604051916c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f20916040525f606052565b9083346100da577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc6060813601126100da5782359067ffffffffffffffff82116100da5760809082850192360301126100da576104976105e7565b6105286104a261060a565b6104e4602097888101906104bb8161034a888a866107c7565b519020805f525f8952865f20908154916001830190558751918a8301528982526103978261083c565b73ffffffffffffffffffffffffffffffffffffffff9281898593519101207f000000000000000000000000f9c25250523df26343222fc46de932355b850c97610aae565b1695863b156100da575f858592610569895194859384937fbaa7fda400000000000000000000000000000000000000000000000000000000855284016107c7565b0381838b5af180156105dd57928795927fb3ec24e9259e438f9917b49f27c0dd89a11b7626cb63e6fc977863c0b26a681b95926105ba956105ce575b508188519586956060875260608701906106f5565b93168a85015216868301520390a251908152f35b6105d7906107fb565b8a6105a5565b86513d5f823e3d90fd5b6024359073ffffffffffffffffffffffffffffffffffffffff821682036100da57565b6044359073ffffffffffffffffffffffffffffffffffffffff821682036100da57565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc906060828201126100da576004359167ffffffffffffffff83116100da57826080920301126100da576004019060243573ffffffffffffffffffffffffffffffffffffffff811681036100da579060443590565b90357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1823603018112156100da57016020813591019167ffffffffffffffff82116100da578160051b360383136100da57565b6080820161070382806106a2565b608085529182905260a08401915f905b80821061078f5750505061072a60208301836106a2565b909284830360208601528183527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82116100da5760609160051b8094602085013760408101356040860152013561ffff81168091036100da5760606020940152010190565b90919283359073ffffffffffffffffffffffffffffffffffffffff82168092036100da57600191815260208091019401920190610713565b9073ffffffffffffffffffffffffffffffffffffffff6107f46020929594956040855260408501906106f5565b9416910152565b67ffffffffffffffff811161080f57604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040810190811067ffffffffffffffff82111761080f57604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761080f57604052565b908151915f5b8381106108af575050015f815290565b806020809284010151818501520161089f565b61090d909291926108e160405194859260208401526040830190610899565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283610858565b565b93929161091d838387610b37565b7f000000000000000000000000f9c25250523df26343222fc46de932355b850c976109bb308361023a8490604051916c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f20916040525f606052565b803b610aa55750906109cc91610aae565b9473ffffffffffffffffffffffffffffffffffffffff9283871694853b156100da57604051947fbaa7fda40000000000000000000000000000000000000000000000000000000086525f8680610a268688600484016107c7565b0381838b5af1948515610a9a577fc4cec5a1846f5c98dc275670618bfecffec4da2e7cba63760ef46f38c75d236e96610a7496610a8b575b50816040519687966080885260808801906106f5565b9416602086015216604084015260608301520390a2565b610a94906107fb565b5f610a5e565b6040513d5f823e3d90fd5b96505050505050565b9190604051926c5af43d3d93803e605757fd5bf36051526044526f593da1005b3d3d3d3d363d3d37363d736030527f9e4ac34f21c619cefc926c8bd93b54bf5a39c7ab2127a895af1cc0691d7e3dff6020527060593d8160093d39f336602c57343d527f5f526071600f5ff5916040525f6060528115610b2a57565b63301164255f526004601cfd5b6040519291610b4f9184916108e191602084016107c7565b610b7460206040518093610b668383018097610899565b908152038084520182610858565b51902090565b91909160ff5f5360355260601b60015260155260555f20905f60355256fea2646970667358221220edd55753c55f257991df670fc562cdf54adb62d710125933fc4a0a7afddbc02564736f6c63430008170033";
|
|
317
317
|
|
|
318
318
|
// src/constants.ts
|
|
319
|
-
import * as dotenv from "dotenv";
|
|
320
|
-
dotenv.config();
|
|
321
319
|
var CONFLICT_ERROR_MSG = "Conflict";
|
|
322
320
|
var EIP712_DOMAIN_NAME = "Obol";
|
|
323
321
|
var EIP712_DOMAIN_VERSION = "1";
|
|
@@ -526,27 +524,88 @@ var CAPELLA_FORK_MAPPING = {
|
|
|
526
524
|
// Hoodi
|
|
527
525
|
};
|
|
528
526
|
|
|
527
|
+
// src/errors.ts
|
|
528
|
+
var ConflictError = class _ConflictError extends Error {
|
|
529
|
+
constructor() {
|
|
530
|
+
super("This Cluster has been already posted.");
|
|
531
|
+
this.name = "ConflictError";
|
|
532
|
+
Object.setPrototypeOf(this, _ConflictError.prototype);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
var SignerRequiredError = class _SignerRequiredError extends Error {
|
|
536
|
+
constructor(method) {
|
|
537
|
+
super(`Signer is required in ${method}`);
|
|
538
|
+
this.name = "SignerRequiredError";
|
|
539
|
+
Object.setPrototypeOf(this, _SignerRequiredError.prototype);
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
var UnsupportedChainError = class _UnsupportedChainError extends Error {
|
|
543
|
+
constructor(chainId, operation) {
|
|
544
|
+
super(`${operation} is not supported on chain ${chainId}`);
|
|
545
|
+
this.name = "UnsupportedChainError";
|
|
546
|
+
Object.setPrototypeOf(this, _UnsupportedChainError.prototype);
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
var InvalidBaseUrlError = class _InvalidBaseUrlError extends Error {
|
|
550
|
+
constructor(message2) {
|
|
551
|
+
super(message2);
|
|
552
|
+
this.name = "InvalidBaseUrlError";
|
|
553
|
+
Object.setPrototypeOf(this, _InvalidBaseUrlError.prototype);
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
var ClusterLockValidationTimeoutError = class _ClusterLockValidationTimeoutError extends Error {
|
|
557
|
+
/**
|
|
558
|
+
* @param timeoutMs - Same value as SDK whole-lock validation worker timeout.
|
|
559
|
+
*/
|
|
560
|
+
constructor(timeoutMs) {
|
|
561
|
+
super(
|
|
562
|
+
`Cluster lock validation exceeded worker time limit (${timeoutMs} ms). Retry later; this does not imply invalid lock data.`
|
|
563
|
+
);
|
|
564
|
+
this.timeoutMs = timeoutMs;
|
|
565
|
+
this.name = "ClusterLockValidationTimeoutError";
|
|
566
|
+
Object.setPrototypeOf(this, _ClusterLockValidationTimeoutError.prototype);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
|
|
529
570
|
// src/base.ts
|
|
571
|
+
var ALLOWED_OBOL_API_BASE_URLS = [
|
|
572
|
+
DEFAULT_BASE_URL,
|
|
573
|
+
"https://obol-api-nonprod-dev.dev.obol.tech",
|
|
574
|
+
"https://obol-api-nonprod-qa.dev.obol.tech"
|
|
575
|
+
];
|
|
576
|
+
var ALLOWED_BASE_URLS = new Set(ALLOWED_OBOL_API_BASE_URLS);
|
|
577
|
+
function assertAllowedBaseUrl(baseUrl) {
|
|
578
|
+
let candidate = baseUrl.trim();
|
|
579
|
+
while (candidate.endsWith("/")) {
|
|
580
|
+
candidate = candidate.slice(0, -1);
|
|
581
|
+
}
|
|
582
|
+
if (!ALLOWED_BASE_URLS.has(candidate)) {
|
|
583
|
+
throw new InvalidBaseUrlError(
|
|
584
|
+
`baseUrl must be one of: ${ALLOWED_OBOL_API_BASE_URLS.join(", ")}`
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
return candidate;
|
|
588
|
+
}
|
|
530
589
|
var Base = class {
|
|
531
590
|
constructor({
|
|
532
591
|
baseUrl = DEFAULT_BASE_URL,
|
|
533
592
|
chainId = DEFAULT_CHAIN_ID
|
|
534
593
|
}) {
|
|
535
|
-
this.baseUrl = baseUrl;
|
|
594
|
+
this.baseUrl = assertAllowedBaseUrl(baseUrl);
|
|
536
595
|
this.chainId = chainId;
|
|
537
596
|
this.fork_version = FORK_MAPPING[this.chainId];
|
|
538
597
|
}
|
|
539
598
|
request(endpoint, options) {
|
|
540
599
|
return __async(this, null, function* () {
|
|
541
600
|
const url = `${this.baseUrl}${endpoint}`;
|
|
542
|
-
const
|
|
601
|
+
const config = __spreadProps(__spreadValues({}, options), {
|
|
543
602
|
headers: __spreadValues({
|
|
544
603
|
"Content-Type": "application/json",
|
|
545
604
|
"User-Agent": `Obol-SDK/${SDK_VERSION}`
|
|
546
605
|
}, options == null ? void 0 : options.headers)
|
|
547
606
|
});
|
|
548
607
|
try {
|
|
549
|
-
const response = yield fetch(url,
|
|
608
|
+
const response = yield fetch(url, config);
|
|
550
609
|
if (response.ok) {
|
|
551
610
|
return yield response.json();
|
|
552
611
|
} else {
|
|
@@ -560,29 +619,6 @@ var Base = class {
|
|
|
560
619
|
}
|
|
561
620
|
};
|
|
562
621
|
|
|
563
|
-
// src/errors.ts
|
|
564
|
-
var ConflictError = class _ConflictError extends Error {
|
|
565
|
-
constructor() {
|
|
566
|
-
super("This Cluster has been already posted.");
|
|
567
|
-
this.name = "ConflictError";
|
|
568
|
-
Object.setPrototypeOf(this, _ConflictError.prototype);
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
var SignerRequiredError = class _SignerRequiredError extends Error {
|
|
572
|
-
constructor(method) {
|
|
573
|
-
super(`Signer is required in ${method}`);
|
|
574
|
-
this.name = "SignerRequiredError";
|
|
575
|
-
Object.setPrototypeOf(this, _SignerRequiredError.prototype);
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
var UnsupportedChainError = class _UnsupportedChainError extends Error {
|
|
579
|
-
constructor(chainId, operation) {
|
|
580
|
-
super(`${operation} is not supported on chain ${chainId}`);
|
|
581
|
-
this.name = "UnsupportedChainError";
|
|
582
|
-
Object.setPrototypeOf(this, _UnsupportedChainError.prototype);
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
|
|
586
622
|
// src/verification/common.ts
|
|
587
623
|
import { fromHexString as fromHexString6 } from "@chainsafe/ssz";
|
|
588
624
|
import elliptic from "elliptic";
|
|
@@ -714,6 +750,9 @@ import {
|
|
|
714
750
|
fromHexString as fromHexString2
|
|
715
751
|
} from "@chainsafe/ssz";
|
|
716
752
|
|
|
753
|
+
// src/verification/parallelPool.ts
|
|
754
|
+
import { fromHexString } from "@chainsafe/ssz";
|
|
755
|
+
|
|
717
756
|
// node_modules/@noble/curves/node_modules/@noble/hashes/utils.js
|
|
718
757
|
function isBytes(a) {
|
|
719
758
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
@@ -5139,6 +5178,12 @@ function blsVerify(pubkey, message2, signature) {
|
|
|
5139
5178
|
return false;
|
|
5140
5179
|
}
|
|
5141
5180
|
}
|
|
5181
|
+
function blsAggregatePublicKeys(pubkeys) {
|
|
5182
|
+
if (pubkeys.length === 0) {
|
|
5183
|
+
throw new Error("cannot aggregate empty pubkey set");
|
|
5184
|
+
}
|
|
5185
|
+
return ls.aggregatePublicKeys(pubkeys).toBytes();
|
|
5186
|
+
}
|
|
5142
5187
|
function blsVerifyAggregate(pubkeys, message2, signature) {
|
|
5143
5188
|
try {
|
|
5144
5189
|
return ls.verify(
|
|
@@ -5150,6 +5195,13 @@ function blsVerifyAggregate(pubkeys, message2, signature) {
|
|
|
5150
5195
|
return false;
|
|
5151
5196
|
}
|
|
5152
5197
|
}
|
|
5198
|
+
function blsVerifyWithAggregatedPubkey(aggregatedPubkey, message2, signature) {
|
|
5199
|
+
try {
|
|
5200
|
+
return ls.verify(signature, ls.hash(message2, ETH2_DST), aggregatedPubkey);
|
|
5201
|
+
} catch (e) {
|
|
5202
|
+
return false;
|
|
5203
|
+
}
|
|
5204
|
+
}
|
|
5153
5205
|
function blsVerifyMultiple(pubkeys, messages, signature) {
|
|
5154
5206
|
try {
|
|
5155
5207
|
if (pubkeys.length !== messages.length) return false;
|
|
@@ -5215,16 +5267,23 @@ function blsVerifyExtraShares(pubshares, threshold, distributedPubkey) {
|
|
|
5215
5267
|
}
|
|
5216
5268
|
|
|
5217
5269
|
// src/verification/parallelPool.ts
|
|
5218
|
-
import { fromHexString } from "@chainsafe/ssz";
|
|
5219
5270
|
var MIN_PARALLEL_VALIDATORS = 50;
|
|
5220
5271
|
var MIN_PARALLEL_BATCH_PAIRS = 100;
|
|
5221
5272
|
var MAX_WORKERS = 8;
|
|
5222
5273
|
var MIN_VALIDATORS_PER_WORKER = 25;
|
|
5223
5274
|
var MIN_PAIRS_PER_WORKER = 50;
|
|
5275
|
+
var MIN_PARALLEL_AGGREGATE_KEYS = 400;
|
|
5276
|
+
var MIN_KEYS_PER_WORKER_AGG = 100;
|
|
5277
|
+
var MIN_VALIDATORS_FOR_VALIDATION_WORKER = 50;
|
|
5278
|
+
var VALIDATION_WORKER_TIMEOUT_MS = 12e4;
|
|
5224
5279
|
var WORKER_TIMEOUT_MS = 6e4;
|
|
5280
|
+
var MAX_CONCURRENT_WORKERS_CAP = 8;
|
|
5281
|
+
function maxConcurrentWorkers(numWorkers) {
|
|
5282
|
+
return Math.min(numWorkers, MAX_CONCURRENT_WORKERS_CAP);
|
|
5283
|
+
}
|
|
5225
5284
|
var workerThreadsCache;
|
|
5226
5285
|
var osCache;
|
|
5227
|
-
var
|
|
5286
|
+
var workerPathByFile = /* @__PURE__ */ new Map();
|
|
5228
5287
|
function loadWorkerThreads() {
|
|
5229
5288
|
if (workerThreadsCache !== void 0) return workerThreadsCache;
|
|
5230
5289
|
try {
|
|
@@ -5243,18 +5302,47 @@ function loadOs() {
|
|
|
5243
5302
|
}
|
|
5244
5303
|
return osCache;
|
|
5245
5304
|
}
|
|
5246
|
-
function getWorkerPath() {
|
|
5247
|
-
|
|
5248
|
-
if (
|
|
5305
|
+
function getWorkerPath(filename) {
|
|
5306
|
+
const cached = workerPathByFile.get(filename);
|
|
5307
|
+
if (cached !== void 0) return cached;
|
|
5308
|
+
if (typeof __dirname === "undefined") {
|
|
5309
|
+
workerPathByFile.set(filename, null);
|
|
5310
|
+
return null;
|
|
5311
|
+
}
|
|
5249
5312
|
const path = __require("path");
|
|
5250
|
-
const
|
|
5313
|
+
const fs = __require("fs");
|
|
5314
|
+
const candidates = [
|
|
5315
|
+
path.join(__dirname, filename),
|
|
5316
|
+
path.join(__dirname, "verification", filename)
|
|
5317
|
+
];
|
|
5251
5318
|
try {
|
|
5252
|
-
const
|
|
5253
|
-
|
|
5319
|
+
for (const candidate of candidates) {
|
|
5320
|
+
if (fs.existsSync(candidate)) {
|
|
5321
|
+
workerPathByFile.set(filename, candidate);
|
|
5322
|
+
return candidate;
|
|
5323
|
+
}
|
|
5324
|
+
}
|
|
5254
5325
|
} catch (e) {
|
|
5255
|
-
return workerPathCache = null;
|
|
5256
5326
|
}
|
|
5257
|
-
|
|
5327
|
+
workerPathByFile.set(filename, null);
|
|
5328
|
+
return null;
|
|
5329
|
+
}
|
|
5330
|
+
function mapWithConcurrency(items, concurrency, fn) {
|
|
5331
|
+
return __async(this, null, function* () {
|
|
5332
|
+
const results = new Array(items.length);
|
|
5333
|
+
let next = 0;
|
|
5334
|
+
const runners = Array.from(
|
|
5335
|
+
{ length: Math.min(concurrency, items.length) },
|
|
5336
|
+
() => __async(null, null, function* () {
|
|
5337
|
+
while (next < items.length) {
|
|
5338
|
+
const i = next++;
|
|
5339
|
+
results[i] = yield fn(items[i], i);
|
|
5340
|
+
}
|
|
5341
|
+
})
|
|
5342
|
+
);
|
|
5343
|
+
yield Promise.all(runners);
|
|
5344
|
+
return results;
|
|
5345
|
+
});
|
|
5258
5346
|
}
|
|
5259
5347
|
function chunkArrays(arr, n) {
|
|
5260
5348
|
const size = Math.ceil(arr.length / n);
|
|
@@ -5283,6 +5371,33 @@ function verifySharesSync(shares, distributedKeys, threshold) {
|
|
|
5283
5371
|
}
|
|
5284
5372
|
return true;
|
|
5285
5373
|
}
|
|
5374
|
+
function runWorkerAggregatePubkeys(wt, workerFile, data) {
|
|
5375
|
+
return __async(this, null, function* () {
|
|
5376
|
+
return yield new Promise((resolve) => {
|
|
5377
|
+
let settled = false;
|
|
5378
|
+
const worker = new wt.Worker(workerFile, { workerData: data });
|
|
5379
|
+
const finish = (result) => {
|
|
5380
|
+
if (settled) return;
|
|
5381
|
+
settled = true;
|
|
5382
|
+
clearTimeout(timer);
|
|
5383
|
+
worker.terminate();
|
|
5384
|
+
resolve(result);
|
|
5385
|
+
};
|
|
5386
|
+
const timer = setTimeout(() => {
|
|
5387
|
+
finish(null);
|
|
5388
|
+
}, WORKER_TIMEOUT_MS);
|
|
5389
|
+
worker.once("message", (msg) => {
|
|
5390
|
+
finish(msg instanceof Uint8Array ? msg : null);
|
|
5391
|
+
});
|
|
5392
|
+
worker.once("error", () => {
|
|
5393
|
+
finish(null);
|
|
5394
|
+
});
|
|
5395
|
+
worker.once("exit", (code2) => {
|
|
5396
|
+
if (code2 !== 0) finish(null);
|
|
5397
|
+
});
|
|
5398
|
+
});
|
|
5399
|
+
});
|
|
5400
|
+
}
|
|
5286
5401
|
function runWorker(wt, workerFile, data) {
|
|
5287
5402
|
return __async(this, null, function* () {
|
|
5288
5403
|
return yield new Promise((resolve) => {
|
|
@@ -5313,8 +5428,8 @@ function runWorker(wt, workerFile, data) {
|
|
|
5313
5428
|
function poolSize(itemCount, minPerWorker) {
|
|
5314
5429
|
const wt = loadWorkerThreads();
|
|
5315
5430
|
const os = loadOs();
|
|
5316
|
-
const workerFile = getWorkerPath();
|
|
5317
|
-
const numCpus = os ? os.cpus().length : 1;
|
|
5431
|
+
const workerFile = getWorkerPath("lockWorker.js");
|
|
5432
|
+
const numCpus = os ? Math.max(1, os.cpus().length) : 1;
|
|
5318
5433
|
const numWorkers = Math.min(
|
|
5319
5434
|
MAX_WORKERS,
|
|
5320
5435
|
Math.max(1, Math.floor(itemCount / minPerWorker)),
|
|
@@ -5322,6 +5437,18 @@ function poolSize(itemCount, minPerWorker) {
|
|
|
5322
5437
|
);
|
|
5323
5438
|
return { numWorkers, wt, workerFile };
|
|
5324
5439
|
}
|
|
5440
|
+
function runWorkerChunks(wt, workerFile, chunks) {
|
|
5441
|
+
return __async(this, null, function* () {
|
|
5442
|
+
const results = yield mapWithConcurrency(
|
|
5443
|
+
chunks,
|
|
5444
|
+
maxConcurrentWorkers(chunks.length),
|
|
5445
|
+
(data) => __async(null, null, function* () {
|
|
5446
|
+
return yield runWorker(wt, workerFile, data);
|
|
5447
|
+
})
|
|
5448
|
+
);
|
|
5449
|
+
return results.every(Boolean);
|
|
5450
|
+
});
|
|
5451
|
+
}
|
|
5325
5452
|
function verifySharesBinding(shares, distributedKeys, threshold) {
|
|
5326
5453
|
return __async(this, null, function* () {
|
|
5327
5454
|
if (shares.length !== distributedKeys.length) return false;
|
|
@@ -5335,19 +5462,26 @@ function verifySharesBinding(shares, distributedKeys, threshold) {
|
|
|
5335
5462
|
}
|
|
5336
5463
|
const shareChunks = chunkArrays(shares, numWorkers);
|
|
5337
5464
|
const keyChunks = chunkArrays(distributedKeys, numWorkers);
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5465
|
+
return yield runWorkerChunks(
|
|
5466
|
+
wt,
|
|
5467
|
+
workerFile,
|
|
5468
|
+
shareChunks.map((chunk, i) => ({
|
|
5469
|
+
mode: "shareBinding",
|
|
5470
|
+
shares: chunk,
|
|
5471
|
+
distributedKeys: keyChunks[i],
|
|
5472
|
+
threshold
|
|
5473
|
+
}))
|
|
5474
|
+
);
|
|
5475
|
+
});
|
|
5476
|
+
}
|
|
5477
|
+
function verifyBlsChecksParallel(checks) {
|
|
5478
|
+
return __async(this, null, function* () {
|
|
5479
|
+
if (checks.length === 0) return true;
|
|
5480
|
+
return yield verifyBatchParallel(
|
|
5481
|
+
checks.map((c) => c.pubkey),
|
|
5482
|
+
checks.map((c) => c.message),
|
|
5483
|
+
checks.map((c) => c.signature)
|
|
5349
5484
|
);
|
|
5350
|
-
return results.every(Boolean);
|
|
5351
5485
|
});
|
|
5352
5486
|
}
|
|
5353
5487
|
function verifyBatchParallel(pubkeys, messages, signatures) {
|
|
@@ -5370,19 +5504,83 @@ function verifyBatchParallel(pubkeys, messages, signatures) {
|
|
|
5370
5504
|
const pkChunks = chunkArrays(pubkeys, numWorkers);
|
|
5371
5505
|
const msgChunks = chunkArrays(messages, numWorkers);
|
|
5372
5506
|
const sigChunks = chunkArrays(signatures, numWorkers);
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
})
|
|
5383
|
-
)
|
|
5507
|
+
return yield runWorkerChunks(
|
|
5508
|
+
wt,
|
|
5509
|
+
workerFile,
|
|
5510
|
+
pkChunks.map((pks, i) => ({
|
|
5511
|
+
mode: "verifyBatch",
|
|
5512
|
+
pubkeys: pks,
|
|
5513
|
+
messages: msgChunks[i],
|
|
5514
|
+
signatures: sigChunks[i]
|
|
5515
|
+
}))
|
|
5384
5516
|
);
|
|
5385
|
-
|
|
5517
|
+
});
|
|
5518
|
+
}
|
|
5519
|
+
function verifyAggregateParallel(pubkeys, message2, signature) {
|
|
5520
|
+
return __async(this, null, function* () {
|
|
5521
|
+
if (pubkeys.length === 0) return false;
|
|
5522
|
+
const { numWorkers, wt, workerFile } = poolSize(
|
|
5523
|
+
pubkeys.length,
|
|
5524
|
+
MIN_KEYS_PER_WORKER_AGG
|
|
5525
|
+
);
|
|
5526
|
+
if (wt === null || workerFile === null || pubkeys.length < MIN_PARALLEL_AGGREGATE_KEYS || numWorkers < 2) {
|
|
5527
|
+
return blsVerifyAggregate(pubkeys, message2, signature);
|
|
5528
|
+
}
|
|
5529
|
+
const pkChunks = chunkArrays(pubkeys, numWorkers);
|
|
5530
|
+
const partials = yield mapWithConcurrency(
|
|
5531
|
+
pkChunks,
|
|
5532
|
+
maxConcurrentWorkers(pkChunks.length),
|
|
5533
|
+
(chunk) => __async(null, null, function* () {
|
|
5534
|
+
return yield runWorkerAggregatePubkeys(wt, workerFile, {
|
|
5535
|
+
mode: "aggregatePubkeys",
|
|
5536
|
+
pubkeys: chunk
|
|
5537
|
+
});
|
|
5538
|
+
})
|
|
5539
|
+
);
|
|
5540
|
+
if (partials.some((p) => p === null)) return false;
|
|
5541
|
+
const aggregated = blsAggregatePublicKeys(partials);
|
|
5542
|
+
return blsVerifyWithAggregatedPubkey(aggregated, message2, signature);
|
|
5543
|
+
});
|
|
5544
|
+
}
|
|
5545
|
+
function validateClusterLockInWorker(lock, safeRpcUrl) {
|
|
5546
|
+
return __async(this, null, function* () {
|
|
5547
|
+
var _a6, _b2;
|
|
5548
|
+
const n = (_b2 = (_a6 = lock.distributed_validators) == null ? void 0 : _a6.length) != null ? _b2 : 0;
|
|
5549
|
+
if (n < MIN_VALIDATORS_FOR_VALIDATION_WORKER) return null;
|
|
5550
|
+
const wt = loadWorkerThreads();
|
|
5551
|
+
const workerFile = getWorkerPath("clusterLockValidationWorker.js");
|
|
5552
|
+
if (wt === null || workerFile === null) return null;
|
|
5553
|
+
return yield new Promise((resolve, reject) => {
|
|
5554
|
+
let settled = false;
|
|
5555
|
+
const worker = new wt.Worker(workerFile, {
|
|
5556
|
+
workerData: { lock, safeRpcUrl }
|
|
5557
|
+
});
|
|
5558
|
+
const timer = setTimeout(() => {
|
|
5559
|
+
if (settled) return;
|
|
5560
|
+
settled = true;
|
|
5561
|
+
clearTimeout(timer);
|
|
5562
|
+
void worker.terminate();
|
|
5563
|
+
reject(
|
|
5564
|
+
new ClusterLockValidationTimeoutError(VALIDATION_WORKER_TIMEOUT_MS)
|
|
5565
|
+
);
|
|
5566
|
+
}, VALIDATION_WORKER_TIMEOUT_MS);
|
|
5567
|
+
const finish = (result) => {
|
|
5568
|
+
if (settled) return;
|
|
5569
|
+
settled = true;
|
|
5570
|
+
clearTimeout(timer);
|
|
5571
|
+
worker.terminate();
|
|
5572
|
+
resolve(result);
|
|
5573
|
+
};
|
|
5574
|
+
worker.once("message", (msg) => {
|
|
5575
|
+
finish(msg === true);
|
|
5576
|
+
});
|
|
5577
|
+
worker.once("error", () => {
|
|
5578
|
+
finish(null);
|
|
5579
|
+
});
|
|
5580
|
+
worker.once("exit", (code2) => {
|
|
5581
|
+
if (code2 !== 0) finish(null);
|
|
5582
|
+
});
|
|
5583
|
+
});
|
|
5386
5584
|
});
|
|
5387
5585
|
}
|
|
5388
5586
|
|
|
@@ -5487,7 +5685,6 @@ var hashClusterLockV1X6 = (cluster) => {
|
|
|
5487
5685
|
return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
|
|
5488
5686
|
};
|
|
5489
5687
|
var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
5490
|
-
var _a6;
|
|
5491
5688
|
const validators = clusterLock.distributed_validators;
|
|
5492
5689
|
const operatorCount = clusterLock.cluster_definition.operators.length;
|
|
5493
5690
|
const threshold = clusterLock.cluster_definition.threshold;
|
|
@@ -5506,9 +5703,7 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
|
5506
5703
|
return false;
|
|
5507
5704
|
}
|
|
5508
5705
|
const pubShares = [];
|
|
5509
|
-
const
|
|
5510
|
-
const builderRegistrationAndDepositDataMessages = [];
|
|
5511
|
-
const blsSignatures = [];
|
|
5706
|
+
const blsChecks = [];
|
|
5512
5707
|
for (let i = 0; i < validators.length; i++) {
|
|
5513
5708
|
const validator = validators[i];
|
|
5514
5709
|
const validatorPublicShares = validator.public_shares;
|
|
@@ -5526,33 +5721,23 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
|
5526
5721
|
for (const share of validatorPublicSharesBytes) {
|
|
5527
5722
|
pubShares.push(share);
|
|
5528
5723
|
}
|
|
5529
|
-
const
|
|
5724
|
+
const depositCheck = depositBlsCheck(
|
|
5530
5725
|
distributedPublicKey,
|
|
5531
5726
|
validator.deposit_data,
|
|
5532
5727
|
clusterLock.cluster_definition.validators[i].withdrawal_address,
|
|
5533
5728
|
clusterLock.cluster_definition.fork_version
|
|
5534
5729
|
);
|
|
5535
|
-
if (!
|
|
5536
|
-
|
|
5537
|
-
}
|
|
5538
|
-
pubKeys.push(fromHexString2(validator.distributed_public_key));
|
|
5539
|
-
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
5540
|
-
blsSignatures.push(
|
|
5541
|
-
fromHexString2((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
|
|
5542
|
-
);
|
|
5730
|
+
if (!depositCheck) return false;
|
|
5731
|
+
blsChecks.push(depositCheck);
|
|
5543
5732
|
}
|
|
5544
|
-
if (!(yield
|
|
5545
|
-
pubKeys,
|
|
5546
|
-
builderRegistrationAndDepositDataMessages,
|
|
5547
|
-
blsSignatures
|
|
5548
|
-
))) {
|
|
5733
|
+
if (!(yield verifyBlsChecksParallel(blsChecks))) {
|
|
5549
5734
|
return false;
|
|
5550
5735
|
}
|
|
5551
|
-
if (!
|
|
5736
|
+
if (!(yield verifyAggregateParallel(
|
|
5552
5737
|
pubShares,
|
|
5553
5738
|
fromHexString2(clusterLock.lock_hash),
|
|
5554
5739
|
fromHexString2(clusterLock.signature_aggregate)
|
|
5555
|
-
)) {
|
|
5740
|
+
))) {
|
|
5556
5741
|
return false;
|
|
5557
5742
|
}
|
|
5558
5743
|
return true;
|
|
@@ -5686,7 +5871,6 @@ var hashClusterLockV1X7 = (cluster) => {
|
|
|
5686
5871
|
return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
|
|
5687
5872
|
};
|
|
5688
5873
|
var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
5689
|
-
var _a6, _b2;
|
|
5690
5874
|
const validators = clusterLock.distributed_validators;
|
|
5691
5875
|
const operatorCount = clusterLock.cluster_definition.operators.length;
|
|
5692
5876
|
const threshold = clusterLock.cluster_definition.threshold;
|
|
@@ -5705,9 +5889,7 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5705
5889
|
return false;
|
|
5706
5890
|
}
|
|
5707
5891
|
const pubShares = [];
|
|
5708
|
-
const
|
|
5709
|
-
const builderRegistrationAndDepositDataMessages = [];
|
|
5710
|
-
const blsSignatures = [];
|
|
5892
|
+
const blsChecks = [];
|
|
5711
5893
|
for (let i = 0; i < validators.length; i++) {
|
|
5712
5894
|
const validator = validators[i];
|
|
5713
5895
|
const validatorPublicShares = validator.public_shares;
|
|
@@ -5725,49 +5907,33 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5725
5907
|
for (const share of validatorPublicSharesBytes) {
|
|
5726
5908
|
pubShares.push(share);
|
|
5727
5909
|
}
|
|
5728
|
-
const
|
|
5910
|
+
const depositCheck = depositBlsCheck(
|
|
5729
5911
|
distributedPublicKey,
|
|
5730
5912
|
validator.deposit_data,
|
|
5731
5913
|
clusterLock.cluster_definition.validators[i].withdrawal_address,
|
|
5732
5914
|
clusterLock.cluster_definition.fork_version
|
|
5733
5915
|
);
|
|
5734
|
-
if (!
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
pubKeys.push(fromHexString3(distributedPublicKey));
|
|
5738
|
-
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
5739
|
-
blsSignatures.push(
|
|
5740
|
-
fromHexString3((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
|
|
5741
|
-
);
|
|
5742
|
-
const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
|
|
5916
|
+
if (!depositCheck) return false;
|
|
5917
|
+
blsChecks.push(depositCheck);
|
|
5918
|
+
const builderCheck = builderBlsCheck(
|
|
5743
5919
|
validator,
|
|
5744
5920
|
clusterLock.cluster_definition.validators[i].fee_recipient_address,
|
|
5745
5921
|
clusterLock.cluster_definition.fork_version
|
|
5746
5922
|
);
|
|
5747
|
-
if (!
|
|
5748
|
-
|
|
5749
|
-
}
|
|
5750
|
-
pubKeys.push(fromHexString3(distributedPublicKey));
|
|
5751
|
-
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
5752
|
-
blsSignatures.push(
|
|
5753
|
-
fromHexString3((_b2 = validator.builder_registration) == null ? void 0 : _b2.signature)
|
|
5754
|
-
);
|
|
5923
|
+
if (!builderCheck) return false;
|
|
5924
|
+
blsChecks.push(builderCheck);
|
|
5755
5925
|
}
|
|
5756
|
-
if (!(yield
|
|
5757
|
-
pubKeys,
|
|
5758
|
-
builderRegistrationAndDepositDataMessages,
|
|
5759
|
-
blsSignatures
|
|
5760
|
-
))) {
|
|
5926
|
+
if (!(yield verifyBlsChecksParallel(blsChecks))) {
|
|
5761
5927
|
return false;
|
|
5762
5928
|
}
|
|
5763
5929
|
if (!verifyNodeSignatures(clusterLock)) {
|
|
5764
5930
|
return false;
|
|
5765
5931
|
}
|
|
5766
|
-
if (!
|
|
5932
|
+
if (!(yield verifyAggregateParallel(
|
|
5767
5933
|
pubShares,
|
|
5768
5934
|
fromHexString3(clusterLock.lock_hash),
|
|
5769
5935
|
fromHexString3(clusterLock.signature_aggregate)
|
|
5770
|
-
)) {
|
|
5936
|
+
))) {
|
|
5771
5937
|
return false;
|
|
5772
5938
|
}
|
|
5773
5939
|
return true;
|
|
@@ -15364,7 +15530,6 @@ var hashClusterLockV1X8 = (cluster) => {
|
|
|
15364
15530
|
return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
|
|
15365
15531
|
};
|
|
15366
15532
|
var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
15367
|
-
var _a6;
|
|
15368
15533
|
const validators = clusterLock.distributed_validators;
|
|
15369
15534
|
const operatorCount = clusterLock.cluster_definition.operators.length;
|
|
15370
15535
|
const threshold = clusterLock.cluster_definition.threshold;
|
|
@@ -15383,9 +15548,10 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
15383
15548
|
return false;
|
|
15384
15549
|
}
|
|
15385
15550
|
const pubShares = [];
|
|
15386
|
-
const
|
|
15387
|
-
const
|
|
15388
|
-
const
|
|
15551
|
+
const blsChecks = [];
|
|
15552
|
+
const forkVersion = clusterLock.cluster_definition.fork_version;
|
|
15553
|
+
const depositDomain = depositDomainForFork(forkVersion);
|
|
15554
|
+
const builderDomain = builderDomainForFork(forkVersion);
|
|
15389
15555
|
for (let i = 0; i < validators.length; i++) {
|
|
15390
15556
|
const validator = validators[i];
|
|
15391
15557
|
const validatorPublicShares = validator.public_shares;
|
|
@@ -15412,51 +15578,38 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
15412
15578
|
return false;
|
|
15413
15579
|
}
|
|
15414
15580
|
}
|
|
15415
|
-
for (const
|
|
15416
|
-
const
|
|
15417
|
-
const { isValidDepositData, depositDataMsg } = verifyDepositData(
|
|
15581
|
+
for (const depositData of validator.partial_deposit_data) {
|
|
15582
|
+
const check = depositBlsCheck(
|
|
15418
15583
|
distributedPublicKey,
|
|
15419
15584
|
depositData,
|
|
15420
15585
|
clusterLock.cluster_definition.validators[i].withdrawal_address,
|
|
15421
|
-
|
|
15422
|
-
clusterLock.cluster_definition.compounding
|
|
15586
|
+
forkVersion,
|
|
15587
|
+
clusterLock.cluster_definition.compounding,
|
|
15588
|
+
depositDomain
|
|
15423
15589
|
);
|
|
15424
|
-
if (!
|
|
15425
|
-
|
|
15426
|
-
}
|
|
15427
|
-
pubKeys.push(fromHexString4(distributedPublicKey));
|
|
15428
|
-
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
15429
|
-
blsSignatures.push(fromHexString4(depositData == null ? void 0 : depositData.signature));
|
|
15590
|
+
if (!check) return false;
|
|
15591
|
+
blsChecks.push(check);
|
|
15430
15592
|
}
|
|
15431
|
-
const
|
|
15593
|
+
const builderCheck = builderBlsCheck(
|
|
15432
15594
|
validator,
|
|
15433
15595
|
clusterLock.cluster_definition.validators[i].fee_recipient_address,
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
if (!isValidBuilderRegistration) {
|
|
15437
|
-
return false;
|
|
15438
|
-
}
|
|
15439
|
-
pubKeys.push(fromHexString4(distributedPublicKey));
|
|
15440
|
-
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
15441
|
-
blsSignatures.push(
|
|
15442
|
-
fromHexString4((_a6 = validator.builder_registration) == null ? void 0 : _a6.signature)
|
|
15596
|
+
forkVersion,
|
|
15597
|
+
builderDomain
|
|
15443
15598
|
);
|
|
15599
|
+
if (!builderCheck) return false;
|
|
15600
|
+
blsChecks.push(builderCheck);
|
|
15444
15601
|
}
|
|
15445
|
-
if (!(yield
|
|
15446
|
-
pubKeys,
|
|
15447
|
-
builderRegistrationAndDepositDataMessages,
|
|
15448
|
-
blsSignatures
|
|
15449
|
-
))) {
|
|
15602
|
+
if (!(yield verifyBlsChecksParallel(blsChecks))) {
|
|
15450
15603
|
return false;
|
|
15451
15604
|
}
|
|
15452
15605
|
if (!verifyNodeSignatures(clusterLock)) {
|
|
15453
15606
|
return false;
|
|
15454
15607
|
}
|
|
15455
|
-
if (!
|
|
15608
|
+
if (!(yield verifyAggregateParallel(
|
|
15456
15609
|
pubShares,
|
|
15457
15610
|
fromHexString4(clusterLock.lock_hash),
|
|
15458
15611
|
fromHexString4(clusterLock.signature_aggregate)
|
|
15459
|
-
)) {
|
|
15612
|
+
))) {
|
|
15460
15613
|
return false;
|
|
15461
15614
|
}
|
|
15462
15615
|
return true;
|
|
@@ -15871,37 +16024,62 @@ var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = fromHe
|
|
|
15871
16024
|
domain.set(forkDataRoot.subarray(0, 28), 4);
|
|
15872
16025
|
return domain;
|
|
15873
16026
|
};
|
|
15874
|
-
var
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
);
|
|
16027
|
+
var depositDomainForFork = (forkVersion) => computeDomain(fromHexString6(DOMAIN_DEPOSIT), forkVersion);
|
|
16028
|
+
var builderDomainForFork = (forkVersion) => computeDomain(fromHexString6(DOMAIN_APPLICATION_BUILDER), forkVersion);
|
|
16029
|
+
var validateDepositDataStructure = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding, precomputedDepositDomain) => {
|
|
16030
|
+
const depositDomain = precomputedDepositDomain != null ? precomputedDepositDomain : computeDomain(fromHexString6(DOMAIN_DEPOSIT), forkVersion);
|
|
15879
16031
|
const withdrawalPrefix = compounding ? "0x02" : "0x01";
|
|
15880
16032
|
const expectedWithdrawalCredentials = withdrawalPrefix + "0".repeat(22) + withdrawalAddress.toLowerCase().slice(2);
|
|
15881
16033
|
if (expectedWithdrawalCredentials !== depositData.withdrawal_credentials) {
|
|
15882
|
-
return {
|
|
16034
|
+
return { valid: false, message: new Uint8Array(0) };
|
|
15883
16035
|
}
|
|
15884
16036
|
if (distributedPublicKey !== depositData.pubkey) {
|
|
15885
|
-
return {
|
|
16037
|
+
return { valid: false, message: new Uint8Array(0) };
|
|
15886
16038
|
}
|
|
15887
16039
|
const depositMessageBuffer = computeDepositMsgRoot(depositData);
|
|
15888
|
-
const
|
|
16040
|
+
const message2 = signingRoot(depositDomain, depositMessageBuffer);
|
|
15889
16041
|
if (!depositData.signature) {
|
|
15890
|
-
return {
|
|
16042
|
+
return { valid: false, message: message2 };
|
|
16043
|
+
}
|
|
16044
|
+
return { valid: true, message: message2 };
|
|
16045
|
+
};
|
|
16046
|
+
var depositBlsCheck = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding, precomputedDepositDomain) => {
|
|
16047
|
+
const { valid, message: message2 } = validateDepositDataStructure(
|
|
16048
|
+
distributedPublicKey,
|
|
16049
|
+
depositData,
|
|
16050
|
+
withdrawalAddress,
|
|
16051
|
+
forkVersion,
|
|
16052
|
+
compounding,
|
|
16053
|
+
precomputedDepositDomain
|
|
16054
|
+
);
|
|
16055
|
+
if (!valid || !depositData.signature || !depositData.pubkey) return null;
|
|
16056
|
+
return {
|
|
16057
|
+
pubkey: fromHexString6(depositData.pubkey),
|
|
16058
|
+
message: message2,
|
|
16059
|
+
signature: fromHexString6(depositData.signature)
|
|
16060
|
+
};
|
|
16061
|
+
};
|
|
16062
|
+
var verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding) => {
|
|
16063
|
+
const { valid, message: message2 } = validateDepositDataStructure(
|
|
16064
|
+
distributedPublicKey,
|
|
16065
|
+
depositData,
|
|
16066
|
+
withdrawalAddress,
|
|
16067
|
+
forkVersion,
|
|
16068
|
+
compounding
|
|
16069
|
+
);
|
|
16070
|
+
if (!valid || !depositData.signature || !depositData.pubkey) {
|
|
16071
|
+
return { isValidDepositData: false, depositDataMsg: message2 };
|
|
15891
16072
|
}
|
|
15892
16073
|
const isValidDepositData = blsVerify(
|
|
15893
16074
|
fromHexString6(depositData.pubkey),
|
|
15894
|
-
|
|
16075
|
+
message2,
|
|
15895
16076
|
fromHexString6(depositData.signature)
|
|
15896
16077
|
);
|
|
15897
|
-
return { isValidDepositData, depositDataMsg:
|
|
16078
|
+
return { isValidDepositData, depositDataMsg: message2 };
|
|
15898
16079
|
};
|
|
15899
|
-
var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion) => {
|
|
16080
|
+
var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion, precomputedBuilderDomain) => {
|
|
15900
16081
|
var _a6;
|
|
15901
|
-
const builderDomain = computeDomain(
|
|
15902
|
-
fromHexString6(DOMAIN_APPLICATION_BUILDER),
|
|
15903
|
-
forkVersion
|
|
15904
|
-
);
|
|
16082
|
+
const builderDomain = precomputedBuilderDomain != null ? precomputedBuilderDomain : computeDomain(fromHexString6(DOMAIN_APPLICATION_BUILDER), forkVersion);
|
|
15905
16083
|
if (validator.distributed_public_key !== ((_a6 = validator.builder_registration) == null ? void 0 : _a6.message.pubkey)) {
|
|
15906
16084
|
return {
|
|
15907
16085
|
isValidBuilderRegistration: false,
|
|
@@ -15926,6 +16104,22 @@ var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion) =>
|
|
|
15926
16104
|
builderRegistrationMsg: builderRegistrationMessage
|
|
15927
16105
|
};
|
|
15928
16106
|
};
|
|
16107
|
+
var builderBlsCheck = (validator, feeRecipientAddress, forkVersion, precomputedBuilderDomain) => {
|
|
16108
|
+
var _a6;
|
|
16109
|
+
const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
|
|
16110
|
+
validator,
|
|
16111
|
+
feeRecipientAddress,
|
|
16112
|
+
forkVersion,
|
|
16113
|
+
precomputedBuilderDomain
|
|
16114
|
+
);
|
|
16115
|
+
const sig = (_a6 = validator.builder_registration) == null ? void 0 : _a6.signature;
|
|
16116
|
+
if (!isValidBuilderRegistration || !sig) return null;
|
|
16117
|
+
return {
|
|
16118
|
+
pubkey: fromHexString6(validator.distributed_public_key),
|
|
16119
|
+
message: builderRegistrationMsg,
|
|
16120
|
+
signature: fromHexString6(sig)
|
|
16121
|
+
};
|
|
16122
|
+
};
|
|
15929
16123
|
var verifyNodeSignatures = (clusterLock) => {
|
|
15930
16124
|
const ec2 = new elliptic.ec("secp256k1");
|
|
15931
16125
|
const nodeSignatures = clusterLock.node_signatures;
|
|
@@ -19360,11 +19554,11 @@ var encodeCreateSplitV2DeterministicTxData = (splitParams, splitOwnerAddress, sa
|
|
|
19360
19554
|
);
|
|
19361
19555
|
};
|
|
19362
19556
|
var getChainConfig = (chainId) => {
|
|
19363
|
-
const
|
|
19364
|
-
if (!
|
|
19557
|
+
const config = CHAIN_CONFIGURATION[chainId];
|
|
19558
|
+
if (!config) {
|
|
19365
19559
|
throw new Error(`Chain configuration not found for chain ID ${chainId}`);
|
|
19366
19560
|
}
|
|
19367
|
-
return
|
|
19561
|
+
return config;
|
|
19368
19562
|
};
|
|
19369
19563
|
var requestWithdrawalFromOVM = (_0) => __async(null, [_0], function* ({
|
|
19370
19564
|
ovmAddress,
|
|
@@ -20945,8 +21139,9 @@ var EOA = class {
|
|
|
20945
21139
|
// src/services.ts
|
|
20946
21140
|
var validateClusterLock = (lock, safeRpcUrl) => __async(null, null, function* () {
|
|
20947
21141
|
try {
|
|
20948
|
-
const
|
|
20949
|
-
return
|
|
21142
|
+
const inWorker = yield validateClusterLockInWorker(lock, safeRpcUrl);
|
|
21143
|
+
if (inWorker !== null) return inWorker;
|
|
21144
|
+
return yield isValidClusterLock(lock, safeRpcUrl);
|
|
20950
21145
|
} catch (err) {
|
|
20951
21146
|
throw err;
|
|
20952
21147
|
}
|
|
@@ -20959,6 +21154,7 @@ var Client = class extends Base {
|
|
|
20959
21154
|
*
|
|
20960
21155
|
* @param config - Client configuration object.
|
|
20961
21156
|
* @param config.baseUrl - Obol API base URL. Defaults to `https://api.obol.tech`.
|
|
21157
|
+
* Must match one of {@link ALLOWED_OBOL_API_BASE_URLS} (API paths use `/v1/...` separately).
|
|
20962
21158
|
* @param config.chainId - Target chain ID. Defaults to `560048` (Hoodi).
|
|
20963
21159
|
* Supported: 1 (Mainnet), 560048 (Hoodi), 100 (Gnosis), 11155111 (Sepolia).
|
|
20964
21160
|
* @param signer - An ethers `Wallet` or `JsonRpcSigner`. Required for any
|
|
@@ -20976,8 +21172,8 @@ var Client = class extends Base {
|
|
|
20976
21172
|
* const client = new Client({ chainId: 560048 }, signer);
|
|
20977
21173
|
* ```
|
|
20978
21174
|
*/
|
|
20979
|
-
constructor(
|
|
20980
|
-
super(
|
|
21175
|
+
constructor(config, signer, provider) {
|
|
21176
|
+
super(config);
|
|
20981
21177
|
this.signer = signer;
|
|
20982
21178
|
this.provider = provider != null ? provider : signer && "provider" in signer ? signer.provider : void 0;
|
|
20983
21179
|
this.incentives = new Incentives(
|
|
@@ -21539,12 +21735,14 @@ var Client = class extends Base {
|
|
|
21539
21735
|
}
|
|
21540
21736
|
};
|
|
21541
21737
|
export {
|
|
21738
|
+
ALLOWED_OBOL_API_BASE_URLS,
|
|
21542
21739
|
AVAILABLE_SPLITTER_CHAINS,
|
|
21543
21740
|
CAPELLA_FORK_MAPPING,
|
|
21544
21741
|
CHAIN_CONFIGURATION,
|
|
21545
21742
|
CONFIG_VERSION,
|
|
21546
21743
|
CONFLICT_ERROR_MSG,
|
|
21547
21744
|
Client,
|
|
21745
|
+
ClusterLockValidationTimeoutError,
|
|
21548
21746
|
ConflictError,
|
|
21549
21747
|
CreatorConfigHashSigningTypes,
|
|
21550
21748
|
CreatorTypedMessage,
|
|
@@ -21570,6 +21768,7 @@ export {
|
|
|
21570
21768
|
FORK_NAMES,
|
|
21571
21769
|
GENESIS_VALIDATOR_ROOT,
|
|
21572
21770
|
Incentives,
|
|
21771
|
+
InvalidBaseUrlError,
|
|
21573
21772
|
OBOL_SDK_EMAIL,
|
|
21574
21773
|
ObolSplits,
|
|
21575
21774
|
OperatorConfigHashSigningTypes,
|
|
@@ -21585,8 +21784,12 @@ export {
|
|
|
21585
21784
|
TermsAndConditionsSigningTypes,
|
|
21586
21785
|
UnsupportedChainError,
|
|
21587
21786
|
blsVerify,
|
|
21787
|
+
builderBlsCheck,
|
|
21788
|
+
builderDomainForFork,
|
|
21588
21789
|
clusterConfigOrDefinitionHash,
|
|
21589
21790
|
clusterLockHash,
|
|
21791
|
+
depositBlsCheck,
|
|
21792
|
+
depositDomainForFork,
|
|
21590
21793
|
hasUniqueDistributedKeys,
|
|
21591
21794
|
isChainSupportedForSplitters,
|
|
21592
21795
|
isValidClusterLock,
|
|
@@ -21596,6 +21799,7 @@ export {
|
|
|
21596
21799
|
signingRoot,
|
|
21597
21800
|
validateAddressSignature,
|
|
21598
21801
|
validateClusterLock,
|
|
21802
|
+
validateDepositDataStructure,
|
|
21599
21803
|
validateEOASignature,
|
|
21600
21804
|
validateSmartContractSignature,
|
|
21601
21805
|
verifyBuilderRegistration,
|