@obolnetwork/obol-sdk 2.12.2 → 2.12.5
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/dist/browser/src/index.js +72 -13
- package/dist/browser/src/index.js.map +1 -1
- package/dist/cjs/src/index.js +73 -13
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/verification/clusterLockValidationWorker.js +39 -8
- package/dist/cjs/src/verification/clusterLockValidationWorker.js.map +1 -1
- package/dist/cjs/src/verification/parallelPool.js +27 -7
- package/dist/cjs/src/verification/parallelPool.js.map +1 -1
- package/dist/esm/src/{chunk-YSXFCSVK.js → chunk-BJWBUH75.js} +39 -8
- package/dist/esm/src/chunk-BJWBUH75.js.map +1 -0
- package/dist/esm/src/{chunk-T74RX3N2.js → chunk-L2GZF5CQ.js} +8 -4
- package/dist/esm/src/chunk-L2GZF5CQ.js.map +1 -0
- package/dist/esm/src/index.js +33 -6
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/verification/clusterLockValidationWorker.js +9 -3
- package/dist/esm/src/verification/clusterLockValidationWorker.js.map +1 -1
- package/dist/esm/src/verification/parallelPool.js +1 -1
- package/dist/types/src/errors.d.ts +17 -7
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/services.d.ts +6 -3
- package/dist/types/src/verification/parallelPool.d.ts +4 -0
- package/dist/types/src/verification/validationConcurrency.d.ts +11 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/esm/src/chunk-T74RX3N2.js.map +0 -1
- package/dist/esm/src/chunk-YSXFCSVK.js.map +0 -1
- package/dist/types/test/client/ajv.spec.d.ts +0 -1
- package/dist/types/test/client/baseUrl.spec.d.ts +0 -1
- package/dist/types/test/client/methods.spec.d.ts +0 -18
- package/dist/types/test/eoa/eoa.spec.d.ts +0 -1
- package/dist/types/test/exit/ethUtils.spec.d.ts +0 -1
- package/dist/types/test/exit/exit.spec.d.ts +0 -1
- package/dist/types/test/exit/verificationHelpers.spec.d.ts +0 -1
- package/dist/types/test/fixtures.d.ts +0 -359
- package/dist/types/test/incentives/incentives.spec.d.ts +0 -1
- package/dist/types/test/splits/splits.spec.d.ts +0 -1
- package/dist/types/test/verification/parallelPool.spec.d.ts +0 -1
package/dist/cjs/src/index.js
CHANGED
|
@@ -115,6 +115,7 @@ __export(index_exports, {
|
|
|
115
115
|
CONFIG_VERSION: () => CONFIG_VERSION,
|
|
116
116
|
CONFLICT_ERROR_MSG: () => CONFLICT_ERROR_MSG,
|
|
117
117
|
Client: () => Client,
|
|
118
|
+
ClusterLockValidationBusyError: () => ClusterLockValidationBusyError,
|
|
118
119
|
ClusterLockValidationTimeoutError: () => ClusterLockValidationTimeoutError,
|
|
119
120
|
ConflictError: () => ConflictError,
|
|
120
121
|
CreatorConfigHashSigningTypes: () => CreatorConfigHashSigningTypes,
|
|
@@ -185,7 +186,7 @@ var import_uuid = require("uuid");
|
|
|
185
186
|
// package.json
|
|
186
187
|
var package_default = {
|
|
187
188
|
name: "@obolnetwork/obol-sdk",
|
|
188
|
-
version: "2.12.
|
|
189
|
+
version: "2.12.5",
|
|
189
190
|
description: "A package for creating Distributed Validators using the Obol API.",
|
|
190
191
|
bugs: {
|
|
191
192
|
url: "https://github.com/obolnetwork/obol-sdk/issues"
|
|
@@ -200,7 +201,7 @@ var package_default = {
|
|
|
200
201
|
"build:clean": "rm -rf ./dist",
|
|
201
202
|
build: "npm-run-all build:clean build:tsup",
|
|
202
203
|
"build:tsup": "tsup && tsc -b ./tsconfig.types.json",
|
|
203
|
-
test: "NODE_OPTIONS=--experimental-vm-modules jest test/**/**.spec.ts --testPathIgnorePatterns=test/sdk-package/",
|
|
204
|
+
test: "NODE_OPTIONS=--experimental-vm-modules OBOL_SDK_MAX_CONCURRENT_LOCK_VALIDATIONS=0 jest test/**/**.spec.ts --testPathIgnorePatterns=test/sdk-package/",
|
|
204
205
|
"generate-typedoc": "typedoc",
|
|
205
206
|
"npm:publish": "npm publish --tag latest",
|
|
206
207
|
"npm:publish:next": "npm publish --tag next",
|
|
@@ -642,7 +643,8 @@ var InvalidBaseUrlError = class _InvalidBaseUrlError extends Error {
|
|
|
642
643
|
};
|
|
643
644
|
var ClusterLockValidationTimeoutError = class _ClusterLockValidationTimeoutError extends Error {
|
|
644
645
|
/**
|
|
645
|
-
* @param timeoutMs -
|
|
646
|
+
* @param timeoutMs - Worker deadline that was exceeded (`VALIDATION_WORKER_TIMEOUT_MS`
|
|
647
|
+
* for the whole-lock worker, `WORKER_TIMEOUT_MS` for per-chunk BLS workers).
|
|
646
648
|
*/
|
|
647
649
|
constructor(timeoutMs) {
|
|
648
650
|
super(
|
|
@@ -653,6 +655,16 @@ var ClusterLockValidationTimeoutError = class _ClusterLockValidationTimeoutError
|
|
|
653
655
|
Object.setPrototypeOf(this, _ClusterLockValidationTimeoutError.prototype);
|
|
654
656
|
}
|
|
655
657
|
};
|
|
658
|
+
var ClusterLockValidationBusyError = class _ClusterLockValidationBusyError extends Error {
|
|
659
|
+
constructor(maxConcurrent) {
|
|
660
|
+
super(
|
|
661
|
+
`Too many cluster lock validations in progress (limit: ${maxConcurrent}). Retry later.`
|
|
662
|
+
);
|
|
663
|
+
this.maxConcurrent = maxConcurrent;
|
|
664
|
+
this.name = "ClusterLockValidationBusyError";
|
|
665
|
+
Object.setPrototypeOf(this, _ClusterLockValidationBusyError.prototype);
|
|
666
|
+
}
|
|
667
|
+
};
|
|
656
668
|
|
|
657
669
|
// src/base.ts
|
|
658
670
|
var ALLOWED_OBOL_API_BASE_URLS = [
|
|
@@ -5078,8 +5090,11 @@ var MIN_PAIRS_PER_WORKER = 50;
|
|
|
5078
5090
|
var MIN_PARALLEL_AGGREGATE_KEYS = 400;
|
|
5079
5091
|
var MIN_KEYS_PER_WORKER_AGG = 100;
|
|
5080
5092
|
var MIN_VALIDATORS_FOR_VALIDATION_WORKER = 50;
|
|
5081
|
-
var VALIDATION_WORKER_TIMEOUT_MS =
|
|
5082
|
-
var WORKER_TIMEOUT_MS =
|
|
5093
|
+
var VALIDATION_WORKER_TIMEOUT_MS = 3e5;
|
|
5094
|
+
var WORKER_TIMEOUT_MS = 18e4;
|
|
5095
|
+
function isValidationTimeoutReply(msg) {
|
|
5096
|
+
return typeof msg === "object" && msg !== null && "validationTimeoutMs" in msg && typeof msg.validationTimeoutMs === "number";
|
|
5097
|
+
}
|
|
5083
5098
|
var MAX_CONCURRENT_WORKERS_CAP = 8;
|
|
5084
5099
|
function maxConcurrentWorkers(numWorkers) {
|
|
5085
5100
|
return Math.min(numWorkers, MAX_CONCURRENT_WORKERS_CAP);
|
|
@@ -5176,7 +5191,7 @@ function verifySharesSync(shares, distributedKeys, threshold) {
|
|
|
5176
5191
|
}
|
|
5177
5192
|
function runWorkerAggregatePubkeys(wt, workerFile, data) {
|
|
5178
5193
|
return __async(this, null, function* () {
|
|
5179
|
-
return yield new Promise((resolve) => {
|
|
5194
|
+
return yield new Promise((resolve, reject) => {
|
|
5180
5195
|
let settled = false;
|
|
5181
5196
|
const worker = new wt.Worker(workerFile, { workerData: data });
|
|
5182
5197
|
const finish = (result) => {
|
|
@@ -5187,7 +5202,11 @@ function runWorkerAggregatePubkeys(wt, workerFile, data) {
|
|
|
5187
5202
|
resolve(result);
|
|
5188
5203
|
};
|
|
5189
5204
|
const timer = setTimeout(() => {
|
|
5190
|
-
|
|
5205
|
+
if (settled) return;
|
|
5206
|
+
settled = true;
|
|
5207
|
+
clearTimeout(timer);
|
|
5208
|
+
worker.terminate();
|
|
5209
|
+
reject(new ClusterLockValidationTimeoutError(WORKER_TIMEOUT_MS));
|
|
5191
5210
|
}, WORKER_TIMEOUT_MS);
|
|
5192
5211
|
worker.once("message", (msg) => {
|
|
5193
5212
|
finish(msg instanceof Uint8Array ? msg : null);
|
|
@@ -5203,7 +5222,7 @@ function runWorkerAggregatePubkeys(wt, workerFile, data) {
|
|
|
5203
5222
|
}
|
|
5204
5223
|
function runWorker(wt, workerFile, data) {
|
|
5205
5224
|
return __async(this, null, function* () {
|
|
5206
|
-
return yield new Promise((resolve) => {
|
|
5225
|
+
return yield new Promise((resolve, reject) => {
|
|
5207
5226
|
let settled = false;
|
|
5208
5227
|
const worker = new wt.Worker(workerFile, { workerData: data });
|
|
5209
5228
|
const finish = (result) => {
|
|
@@ -5214,7 +5233,11 @@ function runWorker(wt, workerFile, data) {
|
|
|
5214
5233
|
resolve(result);
|
|
5215
5234
|
};
|
|
5216
5235
|
const timer = setTimeout(() => {
|
|
5217
|
-
|
|
5236
|
+
if (settled) return;
|
|
5237
|
+
settled = true;
|
|
5238
|
+
clearTimeout(timer);
|
|
5239
|
+
worker.terminate();
|
|
5240
|
+
reject(new ClusterLockValidationTimeoutError(WORKER_TIMEOUT_MS));
|
|
5218
5241
|
}, WORKER_TIMEOUT_MS);
|
|
5219
5242
|
worker.once("message", (msg) => {
|
|
5220
5243
|
finish(msg === true);
|
|
@@ -5375,6 +5398,14 @@ function validateClusterLockInWorker(lock, safeRpcUrl) {
|
|
|
5375
5398
|
resolve(result);
|
|
5376
5399
|
};
|
|
5377
5400
|
worker.once("message", (msg) => {
|
|
5401
|
+
if (isValidationTimeoutReply(msg)) {
|
|
5402
|
+
if (settled) return;
|
|
5403
|
+
settled = true;
|
|
5404
|
+
clearTimeout(timer);
|
|
5405
|
+
worker.terminate();
|
|
5406
|
+
reject(new ClusterLockValidationTimeoutError(msg.validationTimeoutMs));
|
|
5407
|
+
return;
|
|
5408
|
+
}
|
|
5378
5409
|
finish(msg === true);
|
|
5379
5410
|
});
|
|
5380
5411
|
worker.once("error", () => {
|
|
@@ -14934,6 +14965,9 @@ var isValidClusterLock = (clusterLock, safeRpcUrl) => __async(null, null, functi
|
|
|
14934
14965
|
}
|
|
14935
14966
|
return true;
|
|
14936
14967
|
} catch (err) {
|
|
14968
|
+
if (err instanceof ClusterLockValidationTimeoutError) {
|
|
14969
|
+
throw err;
|
|
14970
|
+
}
|
|
14937
14971
|
return false;
|
|
14938
14972
|
}
|
|
14939
14973
|
});
|
|
@@ -19862,15 +19896,40 @@ var EOA = class {
|
|
|
19862
19896
|
}
|
|
19863
19897
|
};
|
|
19864
19898
|
|
|
19899
|
+
// src/verification/validationConcurrency.ts
|
|
19900
|
+
function getMaxConcurrentLockValidations() {
|
|
19901
|
+
const raw = process.env.OBOL_SDK_MAX_CONCURRENT_LOCK_VALIDATIONS;
|
|
19902
|
+
if (raw === "0") return 0;
|
|
19903
|
+
if (raw !== void 0 && raw !== "") {
|
|
19904
|
+
const n = Number.parseInt(raw, 10);
|
|
19905
|
+
if (Number.isFinite(n) && n > 0) return n;
|
|
19906
|
+
}
|
|
19907
|
+
return 2;
|
|
19908
|
+
}
|
|
19909
|
+
var activeValidations = 0;
|
|
19910
|
+
function withLockValidationConcurrency(fn) {
|
|
19911
|
+
return __async(this, null, function* () {
|
|
19912
|
+
const max = getMaxConcurrentLockValidations();
|
|
19913
|
+
if (max === 0) return yield fn();
|
|
19914
|
+
if (activeValidations >= max) {
|
|
19915
|
+
throw new ClusterLockValidationBusyError(max);
|
|
19916
|
+
}
|
|
19917
|
+
activeValidations++;
|
|
19918
|
+
try {
|
|
19919
|
+
return yield fn();
|
|
19920
|
+
} finally {
|
|
19921
|
+
activeValidations--;
|
|
19922
|
+
}
|
|
19923
|
+
});
|
|
19924
|
+
}
|
|
19925
|
+
|
|
19865
19926
|
// src/services.ts
|
|
19866
19927
|
var validateClusterLock = (lock, safeRpcUrl) => __async(null, null, function* () {
|
|
19867
|
-
|
|
19928
|
+
return yield withLockValidationConcurrency(() => __async(null, null, function* () {
|
|
19868
19929
|
const inWorker = yield validateClusterLockInWorker(lock, safeRpcUrl);
|
|
19869
19930
|
if (inWorker !== null) return inWorker;
|
|
19870
19931
|
return yield isValidClusterLock(lock, safeRpcUrl);
|
|
19871
|
-
}
|
|
19872
|
-
throw err;
|
|
19873
|
-
}
|
|
19932
|
+
}));
|
|
19874
19933
|
});
|
|
19875
19934
|
|
|
19876
19935
|
// src/index.ts
|
|
@@ -20469,6 +20528,7 @@ var Client = class extends Base {
|
|
|
20469
20528
|
CONFIG_VERSION,
|
|
20470
20529
|
CONFLICT_ERROR_MSG,
|
|
20471
20530
|
Client,
|
|
20531
|
+
ClusterLockValidationBusyError,
|
|
20472
20532
|
ClusterLockValidationTimeoutError,
|
|
20473
20533
|
ConflictError,
|
|
20474
20534
|
CreatorConfigHashSigningTypes,
|