@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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isValidClusterLock
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import
|
|
3
|
+
} from "../chunk-L2GZF5CQ.js";
|
|
4
|
+
import {
|
|
5
|
+
ClusterLockValidationTimeoutError
|
|
6
|
+
} from "../chunk-BJWBUH75.js";
|
|
5
7
|
import "../chunk-LOSYOJC3.js";
|
|
6
8
|
|
|
7
9
|
// src/verification/clusterLockValidationWorker.ts
|
|
@@ -11,7 +13,11 @@ if (parentPort) {
|
|
|
11
13
|
const port = parentPort;
|
|
12
14
|
void isValidClusterLock(input.lock, input.safeRpcUrl).then((ok) => {
|
|
13
15
|
port.postMessage(ok);
|
|
14
|
-
}).catch(() => {
|
|
16
|
+
}).catch((err) => {
|
|
17
|
+
if (err instanceof ClusterLockValidationTimeoutError) {
|
|
18
|
+
port.postMessage({ validationTimeoutMs: err.timeoutMs });
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
15
21
|
port.postMessage(false);
|
|
16
22
|
});
|
|
17
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/verification/clusterLockValidationWorker.ts"],"sourcesContent":["// Runs isValidClusterLock in a worker thread so obol-api's main thread stays responsive.\nimport { parentPort, workerData } from 'node:worker_threads';\nimport type { ClusterLock, SafeRpcUrl } from '../types.js';\nimport { isValidClusterLock } from './common.js';\n\nconst input = workerData as {\n lock: ClusterLock;\n safeRpcUrl?: SafeRpcUrl;\n};\n\nif (parentPort) {\n const port = parentPort;\n void isValidClusterLock(input.lock, input.safeRpcUrl)\n .then(ok => {\n port.postMessage(ok);\n })\n .catch(
|
|
1
|
+
{"version":3,"sources":["../../../../src/verification/clusterLockValidationWorker.ts"],"sourcesContent":["// Runs isValidClusterLock in a worker thread so obol-api's main thread stays responsive.\nimport { parentPort, workerData } from 'node:worker_threads';\nimport { ClusterLockValidationTimeoutError } from '../errors.js';\nimport type { ClusterLock, SafeRpcUrl } from '../types.js';\nimport { isValidClusterLock } from './common.js';\n\nconst input = workerData as {\n lock: ClusterLock;\n safeRpcUrl?: SafeRpcUrl;\n};\n\nif (parentPort) {\n const port = parentPort;\n void isValidClusterLock(input.lock, input.safeRpcUrl)\n .then(ok => {\n port.postMessage(ok);\n })\n .catch(err => {\n if (err instanceof ClusterLockValidationTimeoutError) {\n port.postMessage({ validationTimeoutMs: err.timeoutMs });\n return;\n }\n port.postMessage(false);\n });\n}\n"],"mappings":";;;;;;;;;AACA,SAAS,YAAY,kBAAkB;AAKvC,IAAM,QAAQ;AAKd,IAAI,YAAY;AACd,QAAM,OAAO;AACb,OAAK,mBAAmB,MAAM,MAAM,MAAM,UAAU,EACjD,KAAK,QAAM;AACV,SAAK,YAAY,EAAE;AAAA,EACrB,CAAC,EACA,MAAM,SAAO;AACZ,QAAI,eAAe,mCAAmC;AACpD,WAAK,YAAY,EAAE,qBAAqB,IAAI,UAAU,CAAC;AACvD;AAAA,IACF;AACA,SAAK,YAAY,KAAK;AAAA,EACxB,CAAC;AACL;","names":[]}
|
|
@@ -25,24 +25,34 @@ export declare class UnsupportedChainError extends Error {
|
|
|
25
25
|
name: string;
|
|
26
26
|
constructor(chainId: number, operation: string);
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Thrown when full lock validation (`validateClusterLock` worker path) exceeds
|
|
30
|
-
* the worker time limit (large clusters). HTTP gateways should respond with
|
|
31
|
-
* **504**; this is distinct from cryptographic failure (**false** → **400**).
|
|
32
|
-
*/
|
|
33
28
|
/**
|
|
34
29
|
* Thrown when {@link Client} is constructed with a baseUrl that is not an
|
|
35
|
-
*
|
|
30
|
+
* allowed Obol API base URL (see {@link ALLOWED_OBOL_API_BASE_URLS}).
|
|
36
31
|
*/
|
|
37
32
|
export declare class InvalidBaseUrlError extends Error {
|
|
38
33
|
name: string;
|
|
39
34
|
constructor(message: string);
|
|
40
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Thrown when lock validation exceeds a worker time limit (large clusters).
|
|
38
|
+
* HTTP gateways should respond with **504**; distinct from crypto failure
|
|
39
|
+
* (`validateClusterLock` returning **false** → **400**).
|
|
40
|
+
*/
|
|
41
41
|
export declare class ClusterLockValidationTimeoutError extends Error {
|
|
42
42
|
readonly timeoutMs: number;
|
|
43
43
|
name: string;
|
|
44
44
|
/**
|
|
45
|
-
* @param timeoutMs -
|
|
45
|
+
* @param timeoutMs - Worker deadline that was exceeded (`VALIDATION_WORKER_TIMEOUT_MS`
|
|
46
|
+
* for the whole-lock worker, `WORKER_TIMEOUT_MS` for per-chunk BLS workers).
|
|
46
47
|
*/
|
|
47
48
|
constructor(timeoutMs: number);
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Thrown when too many `validateClusterLock` calls are already in flight.
|
|
52
|
+
* HTTP gateways should respond with **503**; clients should retry with backoff.
|
|
53
|
+
*/
|
|
54
|
+
export declare class ClusterLockValidationBusyError extends Error {
|
|
55
|
+
readonly maxConcurrent: number;
|
|
56
|
+
name: string;
|
|
57
|
+
constructor(maxConcurrent: number);
|
|
58
|
+
}
|
|
@@ -9,7 +9,7 @@ export * from './services.js';
|
|
|
9
9
|
export * from './verification/signature-validator.js';
|
|
10
10
|
export * from './verification/common.js';
|
|
11
11
|
export * from './constants.js';
|
|
12
|
-
export { ConflictError, ClusterLockValidationTimeoutError, InvalidBaseUrlError, SignerRequiredError, UnsupportedChainError, } from './errors.js';
|
|
12
|
+
export { ConflictError, ClusterLockValidationBusyError, ClusterLockValidationTimeoutError, InvalidBaseUrlError, SignerRequiredError, UnsupportedChainError, } from './errors.js';
|
|
13
13
|
export { ALLOWED_OBOL_API_BASE_URLS } from './base.js';
|
|
14
14
|
export { Incentives } from './incentives/incentives.js';
|
|
15
15
|
export { Exit } from './exits/exit.js';
|
|
@@ -17,9 +17,12 @@ import { type SafeRpcUrl, type ClusterLock } from './types.js';
|
|
|
17
17
|
* If omitted, falls back to the `RPC_MAINNET` / `RPC_HOODI` / etc. env vars.
|
|
18
18
|
* @returns `true` if the lock is cryptographically valid; `false` if invalid
|
|
19
19
|
* (e.g. missing keys, invalid signatures, hash mismatches).
|
|
20
|
-
* @throws
|
|
21
|
-
*
|
|
22
|
-
* this to **504 Gateway Timeout**.
|
|
20
|
+
* @throws {@link ClusterLockValidationTimeoutError} when validation exceeds a
|
|
21
|
+
* worker deadline (whole-lock or per-chunk BLS workers on large clusters).
|
|
22
|
+
* HTTP APIs should map this to **504 Gateway Timeout**, not **400**.
|
|
23
|
+
* @throws {@link ClusterLockValidationBusyError} when concurrent validations exceed
|
|
24
|
+
* `OBOL_SDK_MAX_CONCURRENT_LOCK_VALIDATIONS` (default **2**; set `0` for unlimited).
|
|
25
|
+
* HTTP APIs should map this to **503 Service Unavailable**.
|
|
23
26
|
*
|
|
24
27
|
* @example
|
|
25
28
|
* ```typescript
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { BlsSignatureCheck, ClusterLock, SafeRpcUrl } from '../types.js';
|
|
2
|
+
/** Posted from clusterLockValidationWorker when a nested BLS worker times out. */
|
|
3
|
+
export type LockValidationWorkerTimeoutReply = {
|
|
4
|
+
validationTimeoutMs: number;
|
|
5
|
+
};
|
|
2
6
|
export declare function verifySharesBinding(shares: string[][], distributedKeys: string[], threshold: number): Promise<boolean>;
|
|
3
7
|
/** Verify deposit + builder BLS signatures collected from `depositBlsCheck` / `builderBlsCheck`. */
|
|
4
8
|
export declare function verifyBlsChecksParallel(checks: BlsSignatureCheck[]): Promise<boolean>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Max in-flight `validateClusterLock` calls per process.
|
|
3
|
+
* `0` = unlimited (e.g. tests: `OBOL_SDK_MAX_CONCURRENT_LOCK_VALIDATIONS=0`).
|
|
4
|
+
* Default `2` — tune via env for host CPU (obol-api should set in `.env`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function getMaxConcurrentLockValidations(): number;
|
|
7
|
+
/**
|
|
8
|
+
* Limits parallel lock validation CPU/worker usage process-wide.
|
|
9
|
+
* Rejects immediately when at capacity (no queue — avoids memory growth under flood).
|
|
10
|
+
*/
|
|
11
|
+
export declare function withLockValidationConcurrency<T>(fn: () => Promise<T>): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../tsup.config.ts","../../src/ajv.ts","../../src/base.ts","../../src/blsUtils.ts","../../src/bytecodes.ts","../../src/constants.ts","../../src/errors.ts","../../src/index.ts","../../src/schema.ts","../../src/services.ts","../../src/types.ts","../../src/utils.ts","../../src/abi/BatchDeposit.ts","../../src/abi/MerkleDistributorWithDeadline.ts","../../src/abi/Multicall3.ts","../../src/abi/OVM.ts","../../src/abi/OWR.ts","../../src/abi/SplitMain.ts","../../src/abi/splitV2FactoryAbi.ts","../../src/eoa/eoa.ts","../../src/eoa/eoaHelpers.ts","../../src/exits/ethUtils.ts","../../src/exits/exit.ts","../../src/exits/verificationHelpers.ts","../../src/incentives/incentiveHelpers.ts","../../src/incentives/incentives.ts","../../src/splits/splitHelpers.ts","../../src/splits/splits.ts","../../src/verification/clusterLockValidationWorker.ts","../../src/verification/common.ts","../../src/verification/lockWorker.ts","../../src/verification/parallelPool.ts","../../src/verification/signature-validator.ts","../../src/verification/sszTypes.ts","../../src/verification/v1.10.0.ts","../../src/verification/v1.6.0.ts","../../src/verification/v1.7.0.ts","../../src/verification/v1.8.0.ts","../../
|
|
1
|
+
{"root":["../../tsup.config.ts","../../src/ajv.ts","../../src/base.ts","../../src/blsUtils.ts","../../src/bytecodes.ts","../../src/constants.ts","../../src/errors.ts","../../src/index.ts","../../src/schema.ts","../../src/services.ts","../../src/types.ts","../../src/utils.ts","../../src/abi/BatchDeposit.ts","../../src/abi/MerkleDistributorWithDeadline.ts","../../src/abi/Multicall3.ts","../../src/abi/OVM.ts","../../src/abi/OWR.ts","../../src/abi/SplitMain.ts","../../src/abi/splitV2FactoryAbi.ts","../../src/eoa/eoa.ts","../../src/eoa/eoaHelpers.ts","../../src/exits/ethUtils.ts","../../src/exits/exit.ts","../../src/exits/verificationHelpers.ts","../../src/incentives/incentiveHelpers.ts","../../src/incentives/incentives.ts","../../src/splits/splitHelpers.ts","../../src/splits/splits.ts","../../src/verification/clusterLockValidationWorker.ts","../../src/verification/common.ts","../../src/verification/lockWorker.ts","../../src/verification/parallelPool.ts","../../src/verification/signature-validator.ts","../../src/verification/sszTypes.ts","../../src/verification/v1.10.0.ts","../../src/verification/v1.6.0.ts","../../src/verification/v1.7.0.ts","../../src/verification/v1.8.0.ts","../../src/verification/validationConcurrency.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obolnetwork/obol-sdk",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.5",
|
|
4
4
|
"description": "A package for creating Distributed Validators using the Obol API.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/obolnetwork/obol-sdk/issues"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"build:clean": "rm -rf ./dist",
|
|
16
16
|
"build": "npm-run-all build:clean build:tsup",
|
|
17
17
|
"build:tsup": "tsup && tsc -b ./tsconfig.types.json",
|
|
18
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules jest test/**/**.spec.ts --testPathIgnorePatterns=test/sdk-package/",
|
|
18
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules OBOL_SDK_MAX_CONCURRENT_LOCK_VALIDATIONS=0 jest test/**/**.spec.ts --testPathIgnorePatterns=test/sdk-package/",
|
|
19
19
|
"generate-typedoc": "typedoc",
|
|
20
20
|
"npm:publish": "npm publish --tag latest",
|
|
21
21
|
"npm:publish:next": "npm publish --tag next",
|