@typeberry/lib 0.10.0 → 0.11.0-829b7ea
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/package.json +3 -5
- package/packages/configs/index.d.ts +9 -0
- package/packages/configs/index.d.ts.map +1 -1
- package/packages/configs/typeberry-default.json +4 -1
- package/packages/configs/typeberry-dev-full.json +3 -0
- package/packages/configs/typeberry-dev-tiny.json +3 -0
- package/packages/jam/config-node/index.d.ts +1 -0
- package/packages/jam/config-node/index.d.ts.map +1 -1
- package/packages/jam/config-node/index.js +1 -0
- package/packages/jam/config-node/node-config.d.ts +5 -11
- package/packages/jam/config-node/node-config.d.ts.map +1 -1
- package/packages/jam/config-node/node-config.js +9 -25
- package/packages/jam/config-node/node-config.test.js +11 -6
- package/packages/jam/config-node/rpc.d.ts +11 -0
- package/packages/jam/config-node/rpc.d.ts.map +1 -0
- package/packages/jam/config-node/rpc.js +16 -0
- package/packages/jam/database/states.d.ts +1 -8
- package/packages/jam/database/states.d.ts.map +1 -1
- package/packages/jam/database/value-refs.d.ts +4 -5
- package/packages/jam/database/value-refs.d.ts.map +1 -1
- package/packages/jam/node/export.d.ts.map +1 -1
- package/packages/jam/node/export.js +8 -17
- package/packages/jam/node/jam-config.d.ts +5 -1
- package/packages/jam/node/jam-config.d.ts.map +1 -1
- package/packages/jam/node/jam-config.js +6 -2
- package/packages/jam/node/main-fuzz.d.ts.map +1 -1
- package/packages/jam/node/main-fuzz.js +32 -19
- package/packages/jam/node/main-importer.d.ts +2 -6
- package/packages/jam/node/main-importer.d.ts.map +1 -1
- package/packages/jam/node/main-importer.js +13 -28
- package/packages/jam/node/main.d.ts.map +1 -1
- package/packages/jam/node/main.js +6 -16
- package/packages/jam/rpc/index.d.ts +3 -0
- package/packages/jam/rpc/index.d.ts.map +1 -0
- package/packages/jam/rpc/index.js +2 -0
- package/packages/jam/rpc/src/handlers/best-block.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/best-block.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/best-block.js +15 -0
- package/packages/jam/rpc/src/handlers/finalized-block.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/finalized-block.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/finalized-block.js +7 -0
- package/packages/jam/rpc/src/handlers/list-services.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/list-services.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/list-services.js +15 -0
- package/packages/jam/rpc/src/handlers/not-implemented.d.ts +4 -0
- package/packages/jam/rpc/src/handlers/not-implemented.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/not-implemented.js +4 -0
- package/packages/jam/rpc/src/handlers/parameters.d.ts +7 -0
- package/packages/jam/rpc/src/handlers/parameters.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/parameters.js +53 -0
- package/packages/jam/rpc/src/handlers/parent.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/parent.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/parent.js +25 -0
- package/packages/jam/rpc/src/handlers/service-data.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/service-data.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/service-data.js +21 -0
- package/packages/jam/rpc/src/handlers/service-preimage.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/service-preimage.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/service-preimage.js +23 -0
- package/packages/jam/rpc/src/handlers/service-request.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/service-request.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/service-request.js +23 -0
- package/packages/jam/rpc/src/handlers/service-value.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/service-value.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/service-value.js +23 -0
- package/packages/jam/rpc/src/handlers/state-root.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/state-root.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/state-root.js +14 -0
- package/packages/jam/rpc/src/handlers/statistics.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/statistics.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/statistics.js +16 -0
- package/packages/jam/rpc/src/handlers/subscribe-best-block.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/subscribe-best-block.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/subscribe-best-block.js +8 -0
- package/packages/jam/rpc/src/handlers/subscribe-finalized-block.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/subscribe-finalized-block.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/subscribe-finalized-block.js +8 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-data.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-data.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-data.js +13 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-preimage.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-preimage.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-preimage.js +13 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-request.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-request.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-request.js +13 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-value.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-value.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/subscribe-service-value.js +13 -0
- package/packages/jam/rpc/src/handlers/subscribe-statistics.d.ts +6 -0
- package/packages/jam/rpc/src/handlers/subscribe-statistics.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/subscribe-statistics.js +13 -0
- package/packages/jam/rpc/src/handlers/typeberry/refine-work-package.d.ts +8 -0
- package/packages/jam/rpc/src/handlers/typeberry/refine-work-package.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/typeberry/refine-work-package.js +68 -0
- package/packages/jam/rpc/src/handlers/unsubscribe.d.ts +4 -0
- package/packages/jam/rpc/src/handlers/unsubscribe.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers/unsubscribe.js +3 -0
- package/packages/jam/rpc/src/handlers.d.ts +3 -0
- package/packages/jam/rpc/src/handlers.d.ts.map +1 -0
- package/packages/jam/rpc/src/handlers.js +60 -0
- package/packages/jam/rpc/src/server.d.ts +31 -0
- package/packages/jam/rpc/src/server.d.ts.map +1 -0
- package/packages/jam/rpc/src/server.js +179 -0
- package/packages/jam/rpc/src/subscription-manager.d.ts +20 -0
- package/packages/jam/rpc/src/subscription-manager.d.ts.map +1 -0
- package/packages/jam/rpc/src/subscription-manager.js +74 -0
- package/packages/jam/rpc/test/e2e-server.d.ts +3 -0
- package/packages/jam/rpc/test/e2e-server.d.ts.map +1 -0
- package/packages/jam/rpc/test/e2e-server.js +30 -0
- package/packages/jam/rpc/test/e2e-setup.d.ts +2 -0
- package/packages/jam/rpc/test/e2e-setup.d.ts.map +1 -0
- package/packages/jam/rpc/test/e2e-setup.js +126 -0
- package/packages/jam/rpc/test/e2e.d.ts +2 -0
- package/packages/jam/rpc/test/e2e.d.ts.map +1 -0
- package/packages/jam/rpc/test/e2e.js +326 -0
- package/packages/jam/state-merkleization/index.d.ts +1 -1
- package/packages/jam/state-merkleization/index.js +1 -1
- package/packages/workers/api-node/config.d.ts +6 -40
- package/packages/workers/api-node/config.d.ts.map +1 -1
- package/packages/workers/api-node/config.js +6 -82
- package/packages/workers/api-node/config.test.js +26 -63
- package/packages/workers/importer/main.d.ts +2 -0
- package/packages/workers/importer/main.d.ts.map +1 -1
- package/packages/workers/importer/main.js +1 -1
- package/packages/jam/database-lmdb/blocks.d.ts +0 -24
- package/packages/jam/database-lmdb/blocks.d.ts.map +0 -1
- package/packages/jam/database-lmdb/blocks.js +0 -82
- package/packages/jam/database-lmdb/hybrid-states.d.ts +0 -56
- package/packages/jam/database-lmdb/hybrid-states.d.ts.map +0 -1
- package/packages/jam/database-lmdb/hybrid-states.js +0 -149
- package/packages/jam/database-lmdb/hybrid-states.test.d.ts +0 -2
- package/packages/jam/database-lmdb/hybrid-states.test.d.ts.map +0 -1
- package/packages/jam/database-lmdb/hybrid-states.test.js +0 -180
- package/packages/jam/database-lmdb/index.d.ts +0 -5
- package/packages/jam/database-lmdb/index.d.ts.map +0 -1
- package/packages/jam/database-lmdb/index.js +0 -4
- package/packages/jam/database-lmdb/root.d.ts +0 -26
- package/packages/jam/database-lmdb/root.d.ts.map +0 -1
- package/packages/jam/database-lmdb/root.js +0 -53
- package/packages/jam/database-lmdb/states.d.ts +0 -76
- package/packages/jam/database-lmdb/states.d.ts.map +0 -1
- package/packages/jam/database-lmdb/states.js +0 -145
- package/packages/jam/database-lmdb/states.test.d.ts +0 -2
- package/packages/jam/database-lmdb/states.test.d.ts.map +0 -1
- package/packages/jam/database-lmdb/states.test.js +0 -202
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { type FjallValuesSession } from "#@typeberry/workers-api-node";
|
|
2
2
|
import type { JamConfig } from "./jam-config.js";
|
|
3
3
|
import type { NodeApi } from "./main.js";
|
|
4
|
-
export type StateBackend = "
|
|
4
|
+
export type StateBackend = "fjall" | "fjall-hybrid";
|
|
5
5
|
export type ImporterOptions = {
|
|
6
6
|
initGenesisFromAncestry?: boolean;
|
|
7
7
|
dummyFinalityDepth?: number;
|
|
8
8
|
pruneBlocks?: boolean;
|
|
9
9
|
/** Open the database without fsync/compression. Only safe for throwaway dbs (e.g. fuzzing). */
|
|
10
10
|
ephemeral?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Persistent backend used when `databaseBasePath` is set. Defaults to config's backend (fjall unless overridden).
|
|
13
|
-
*
|
|
14
|
-
* lmdb and lmdb-hybrid are deprecated and retained as explicit fallbacks.
|
|
15
|
-
*/
|
|
11
|
+
/** Persistent backend used when `databaseBasePath` is set. Defaults to fjall. */
|
|
16
12
|
stateBackend?: StateBackend;
|
|
17
13
|
/**
|
|
18
14
|
* Reuse an already-open fjall values session instead of opening a fresh
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main-importer.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/node/main-importer.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"main-importer.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/node/main-importer.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,cAAc,CAAC;AAEpD,MAAM,MAAM,eAAe,GAAG;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+FAA+F;IAC/F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iFAAiF;IACjF,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAClC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAoGlB"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Bytes } from "#@typeberry/bytes";
|
|
2
2
|
import { PvmBackend } from "#@typeberry/config";
|
|
3
|
-
import { KnownChainSpec
|
|
3
|
+
import { KnownChainSpec } from "#@typeberry/config-node";
|
|
4
4
|
import { bandersnatch, initWasm } from "#@typeberry/crypto";
|
|
5
5
|
import { Blake2b, HASH_SIZE } from "#@typeberry/hash";
|
|
6
6
|
import { createImporter, ImporterConfig } from "#@typeberry/importer";
|
|
7
7
|
import { tryAsU16 } from "#@typeberry/numbers";
|
|
8
8
|
import { CURRENT_SUITE, CURRENT_VERSION, Result, resultToString, version } from "#@typeberry/utils";
|
|
9
|
-
import { FjallWorkerConfig, HybridWorkerConfig, InMemWorkerConfig,
|
|
9
|
+
import { FjallWorkerConfig, HybridWorkerConfig, InMemWorkerConfig, } from "#@typeberry/workers-api-node";
|
|
10
10
|
import { getChainSpec, getDatabasePath, initializeDatabase, logger } from "./common.js";
|
|
11
11
|
const zeroHash = Bytes.zero(HASH_SIZE).asOpaque();
|
|
12
12
|
export async function mainImporter(config, withRelPath, options = {}) {
|
|
@@ -18,13 +18,8 @@ export async function mainImporter(config, withRelPath, options = {}) {
|
|
|
18
18
|
logger.info `🐇 Bandersnatch ${bandesnatchNative.isOk ? "native 🚀" : `using wasm: ${bandesnatchNative.error}`}`;
|
|
19
19
|
// Single source of truth for the states db backend: drives both the log line
|
|
20
20
|
// below and the worker config picked further down.
|
|
21
|
-
const dbBackend = config.node.databaseBasePath === undefined
|
|
22
|
-
? "in-memory"
|
|
23
|
-
: (options.stateBackend ?? config.node.stateBackend ?? RegularStateBackend.Fjall);
|
|
21
|
+
const dbBackend = config.node.databaseBasePath === undefined ? "in-memory" : (options.stateBackend ?? "fjall");
|
|
24
22
|
logger.info `🗄️ States DB: ${dbBackend}.`;
|
|
25
|
-
if (dbBackend === "lmdb" || dbBackend === "lmdb-hybrid") {
|
|
26
|
-
logger.warn `🗄️ The ${dbBackend} state backend is deprecated. Use fjall unless you need a temporary fallback.`;
|
|
27
|
-
}
|
|
28
23
|
const chainSpec = getChainSpec(config.node.flavor);
|
|
29
24
|
const blake2b = await Blake2b.createHasher();
|
|
30
25
|
const nodeName = config.nodeName;
|
|
@@ -44,7 +39,7 @@ export async function mainImporter(config, withRelPath, options = {}) {
|
|
|
44
39
|
blake2b,
|
|
45
40
|
workerParams,
|
|
46
41
|
})
|
|
47
|
-
: dbBackend === "
|
|
42
|
+
: dbBackend === "fjall-hybrid"
|
|
48
43
|
? await HybridWorkerConfig.new({
|
|
49
44
|
nodeName,
|
|
50
45
|
chainSpec,
|
|
@@ -53,35 +48,25 @@ export async function mainImporter(config, withRelPath, options = {}) {
|
|
|
53
48
|
workerParams,
|
|
54
49
|
ephemeral,
|
|
55
50
|
compression,
|
|
56
|
-
backend: dbBackend === "lmdb-hybrid" ? "lmdb" : "fjall",
|
|
57
51
|
sharedFjallSession: options.sharedFjallSession,
|
|
58
52
|
})
|
|
59
|
-
:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})
|
|
68
|
-
: LmdbWorkerConfig.new({
|
|
69
|
-
nodeName,
|
|
70
|
-
chainSpec,
|
|
71
|
-
blake2b,
|
|
72
|
-
dbPath,
|
|
73
|
-
workerParams,
|
|
74
|
-
ephemeral,
|
|
75
|
-
});
|
|
53
|
+
: FjallWorkerConfig.new({
|
|
54
|
+
nodeName,
|
|
55
|
+
chainSpec,
|
|
56
|
+
blake2b,
|
|
57
|
+
dbPath,
|
|
58
|
+
workerParams,
|
|
59
|
+
ephemeral,
|
|
60
|
+
});
|
|
76
61
|
// Initialize the database with genesis state and block if there isn't one.
|
|
77
62
|
logger.info `🛢️ Opening database at ${dbPath}`;
|
|
78
63
|
const rootDb = await workerConfig.openDatabase({ readonly: false });
|
|
79
64
|
await initializeDatabase(chainSpec, blake2b, genesisHeaderHash, rootDb, config.node.chainSpec, config.ancestry, {
|
|
80
65
|
initGenesisFromAncestry: options.initGenesisFromAncestry,
|
|
81
66
|
});
|
|
82
|
-
await rootDb.close();
|
|
83
67
|
const { db, importer } = await createImporter(workerConfig, {
|
|
84
68
|
initGenesisFromAncestry: options.initGenesisFromAncestry,
|
|
69
|
+
db: rootDb,
|
|
85
70
|
});
|
|
86
71
|
await importer.prepareForNextEpoch();
|
|
87
72
|
const api = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/node/main.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAc,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/node/main.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAc,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,mBAAmB,CAAC;AAe/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAkC,MAAM,EAAW,MAAM,kBAAkB,CAAC;AAWnF,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAWhE,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAChE,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;IACtE,oBAAoB,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAEF,wBAAsB,IAAI,CACxB,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAClC,SAAS,EAAE,SAAS,GAAG,IAAI,GAC1B,OAAO,CAAC,OAAO,CAAC,CAuLlB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isMainThread } from "node:worker_threads";
|
|
2
2
|
import { AUTHORSHIP_NETWORK_PORT } from "#@typeberry/comms-authorship-network";
|
|
3
3
|
import { PvmBackend } from "#@typeberry/config";
|
|
4
|
-
import { RegularStateBackend } from "#@typeberry/config-node";
|
|
5
4
|
import { initWasm } from "#@typeberry/crypto";
|
|
6
5
|
import { deriveBandersnatchSecretKey, deriveEd25519SecretKey, trivialSeed, } from "#@typeberry/crypto/key-derivation.js";
|
|
7
6
|
import { Blake2b } from "#@typeberry/hash";
|
|
@@ -11,7 +10,7 @@ import { Listener } from "#@typeberry/listener";
|
|
|
11
10
|
import { tryAsU16, tryAsU32 } from "#@typeberry/numbers";
|
|
12
11
|
import { CURRENT_SUITE, CURRENT_VERSION, Result, version } from "#@typeberry/utils";
|
|
13
12
|
import { DirectPort, DirectWorkerConfig } from "#@typeberry/workers-api";
|
|
14
|
-
import { FjallWorkerConfig, InMemWorkerConfig,
|
|
13
|
+
import { FjallWorkerConfig, InMemWorkerConfig, logHostEnvironment, ThreadPort, } from "#@typeberry/workers-api-node";
|
|
15
14
|
import { getChainSpec, getDatabasePath, initializeDatabase, logger } from "./common.js";
|
|
16
15
|
import { initializeExtensions } from "./extensions.js";
|
|
17
16
|
import * as metrics from "./metrics.js";
|
|
@@ -30,12 +29,9 @@ export async function main(config, withRelPath, telemetry) {
|
|
|
30
29
|
const blake2b = await Blake2b.createHasher();
|
|
31
30
|
const nodeName = config.nodeName;
|
|
32
31
|
const isInMemory = config.node.databaseBasePath === undefined;
|
|
33
|
-
logger.info `🗄️ States DB: ${isInMemory ? "in-memory" :
|
|
34
|
-
if (!isInMemory && config.node.stateBackend === RegularStateBackend.Lmdb) {
|
|
35
|
-
logger.warn `🗄️ The lmdb state backend is deprecated. Use state_backend="fjall" unless you need a temporary fallback.`;
|
|
36
|
-
}
|
|
32
|
+
logger.info `🗄️ States DB: ${isInMemory ? "in-memory" : "fjall"}.`;
|
|
37
33
|
const { dbPath, genesisHeaderHash } = getDatabasePath(blake2b, nodeName, config.node.chainSpec.genesisHeader, withRelPath(config.node.databaseBasePath ?? "<in-memory>"));
|
|
38
|
-
const baseConfig = { nodeName, chainSpec, blake2b, dbPath
|
|
34
|
+
const baseConfig = { nodeName, chainSpec, blake2b, dbPath };
|
|
39
35
|
const importerParams = {
|
|
40
36
|
...baseConfig,
|
|
41
37
|
workerParams: ImporterConfig.create({
|
|
@@ -63,9 +59,8 @@ export async function main(config, withRelPath, telemetry) {
|
|
|
63
59
|
throw e;
|
|
64
60
|
}
|
|
65
61
|
// fjall-js shares the engine explicitly and requires every handle to close.
|
|
66
|
-
// Keep lmdb's historical main-thread handle open until shutdown.
|
|
67
62
|
let mainRootDb = rootDb;
|
|
68
|
-
if (!importerConfig.isInMemory
|
|
63
|
+
if (!importerConfig.isInMemory) {
|
|
69
64
|
await rootDb.close();
|
|
70
65
|
mainRootDb = null;
|
|
71
66
|
}
|
|
@@ -241,11 +236,6 @@ const initNetwork = async (importer, params, baseConfig, genesisHeaderHash, netw
|
|
|
241
236
|
});
|
|
242
237
|
return { closeNetwork: finish, networkApi: network, networkWorker: worker };
|
|
243
238
|
};
|
|
244
|
-
function createPersistentWorkerConfig(
|
|
245
|
-
|
|
246
|
-
case RegularStateBackend.Fjall:
|
|
247
|
-
return FjallWorkerConfig.new(params);
|
|
248
|
-
case RegularStateBackend.Lmdb:
|
|
249
|
-
return LmdbWorkerConfig.new(params);
|
|
250
|
-
}
|
|
239
|
+
function createPersistentWorkerConfig(params) {
|
|
240
|
+
return FjallWorkerConfig.new(params);
|
|
251
241
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#bestblock
|
|
4
|
+
*/
|
|
5
|
+
export declare const bestBlock: Handler<"bestBlock">;
|
|
6
|
+
//# sourceMappingURL=best-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"best-block.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/best-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAsC,MAAM,2BAA2B,CAAC;AAE7F;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,WAAW,CAgB1C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RpcError, RpcErrorCode, validation } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#bestblock
|
|
4
|
+
*/
|
|
5
|
+
export const bestBlock = async (_params, { db }) => {
|
|
6
|
+
const headerHash = db.blocks.getBestHeaderHash();
|
|
7
|
+
const header = db.blocks.getHeader(headerHash);
|
|
8
|
+
if (header === null) {
|
|
9
|
+
throw new RpcError(RpcErrorCode.BlockUnavailable, `Best header not found with hash: ${headerHash.toString()}`, validation.hash.encode(headerHash.raw));
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
header_hash: headerHash.raw,
|
|
13
|
+
slot: header.timeSlotIndex.materialize(),
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#finalizedblock
|
|
4
|
+
*/
|
|
5
|
+
export declare const finalizedBlock: Handler<"finalizedBlock">;
|
|
6
|
+
//# sourceMappingURL=finalized-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalized-block.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/finalized-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGzD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,gBAAgB,CAEpD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { bestBlock } from "./best-block.js";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#finalizedblock
|
|
4
|
+
*/
|
|
5
|
+
export const finalizedBlock = async (params, context) => {
|
|
6
|
+
return bestBlock(params, context); // todo [seko] implement finalized block logic once finality is there
|
|
7
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#listservicesheader_hash
|
|
4
|
+
*/
|
|
5
|
+
export declare const listServices: Handler<"listServices">;
|
|
6
|
+
//# sourceMappingURL=list-services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-services.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/list-services.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAA0B,MAAM,2BAA2B,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,cAAc,CAWhD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Bytes } from "#@typeberry/bytes";
|
|
2
|
+
import { HASH_SIZE } from "#@typeberry/hash";
|
|
3
|
+
import { RpcError, RpcErrorCode } from "#@typeberry/rpc-validation";
|
|
4
|
+
/**
|
|
5
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#listservicesheader_hash
|
|
6
|
+
*/
|
|
7
|
+
export const listServices = async ([headerHash], { db }) => {
|
|
8
|
+
const hashOpaque = Bytes.fromBlob(headerHash, HASH_SIZE).asOpaque();
|
|
9
|
+
const state = db.states.getState(hashOpaque);
|
|
10
|
+
if (state === null) {
|
|
11
|
+
throw new RpcError(RpcErrorCode.Other, `Posterior state not found for block: ${hashOpaque.toString()}`);
|
|
12
|
+
}
|
|
13
|
+
const serviceIds = state.recentServiceIds();
|
|
14
|
+
return [...serviceIds];
|
|
15
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type GenericHandler, type validation } from "#@typeberry/rpc-validation";
|
|
2
|
+
import type z from "zod";
|
|
3
|
+
export declare const notImplemented: GenericHandler<z.infer<typeof validation.notImplementedSchema.input>, z.infer<typeof validation.notImplementedSchema.output>>;
|
|
4
|
+
//# sourceMappingURL=not-implemented.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-implemented.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/not-implemented.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAA0B,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACzG,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,eAAO,MAAM,cAAc,EAAE,cAAc,CACzC,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,oBAAoB,CAAC,KAAK,CAAC,EACrD,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAGvD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/77cba2dcc1887233d4b19371c05284ff761a5fa6/JIP-2.md#chain-parameters
|
|
4
|
+
* Returns the parameters of the current node/chain.
|
|
5
|
+
*/
|
|
6
|
+
export declare const parameters: Handler<"parameters">;
|
|
7
|
+
//# sourceMappingURL=parameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/parameters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAUzD;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,OAAO,CAAC,YAAY,CA0C5C,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { W_E } from "#@typeberry/block";
|
|
2
|
+
import { G_I, MAX_REPORT_DEPENDENCIES, O, Q, T, W_B, W_C, W_T } from "#@typeberry/block/gp-constants.js";
|
|
3
|
+
import { MAX_NUMBER_OF_WORK_ITEMS } from "#@typeberry/block/work-package.js";
|
|
4
|
+
import { BASE_SERVICE_BALANCE, ELECTIVE_BYTE_BALANCE, ELECTIVE_ITEM_BALANCE, MAX_RECENT_HISTORY, } from "#@typeberry/state";
|
|
5
|
+
import { REPORT_TIMEOUT_GRACE_PERIOD } from "#@typeberry/transition/assurances.js";
|
|
6
|
+
import { G_A } from "#@typeberry/transition/reports/verify-post-signature.js";
|
|
7
|
+
/**
|
|
8
|
+
* https://github.com/polkadot-fellows/JIPs/blob/77cba2dcc1887233d4b19371c05284ff761a5fa6/JIP-2.md#chain-parameters
|
|
9
|
+
* Returns the parameters of the current node/chain.
|
|
10
|
+
*/
|
|
11
|
+
export const parameters = async (_params, { chainSpec }) => {
|
|
12
|
+
return {
|
|
13
|
+
V1: {
|
|
14
|
+
deposit_per_account: Number(BASE_SERVICE_BALANCE),
|
|
15
|
+
deposit_per_item: Number(ELECTIVE_ITEM_BALANCE),
|
|
16
|
+
deposit_per_byte: Number(ELECTIVE_BYTE_BALANCE),
|
|
17
|
+
min_turnaround_period: 32,
|
|
18
|
+
epoch_period: chainSpec.epochLength,
|
|
19
|
+
max_accumulate_gas: G_A,
|
|
20
|
+
max_is_authorized_gas: G_I,
|
|
21
|
+
max_refine_gas: Number(chainSpec.maxRefineGas),
|
|
22
|
+
block_gas_limit: Number(chainSpec.maxBlockGas),
|
|
23
|
+
recent_block_count: MAX_RECENT_HISTORY,
|
|
24
|
+
max_work_items: MAX_NUMBER_OF_WORK_ITEMS,
|
|
25
|
+
max_dependencies: MAX_REPORT_DEPENDENCIES,
|
|
26
|
+
max_tickets_per_block: chainSpec.maxTicketsPerExtrinsic,
|
|
27
|
+
max_lookup_anchor_age: chainSpec.maxLookupAnchorAge,
|
|
28
|
+
tickets_attempts_number: chainSpec.ticketsPerValidator,
|
|
29
|
+
auth_window: O,
|
|
30
|
+
auth_queue_len: Q,
|
|
31
|
+
rotation_period: chainSpec.rotationPeriod,
|
|
32
|
+
max_extrinsics: T,
|
|
33
|
+
availability_timeout: REPORT_TIMEOUT_GRACE_PERIOD,
|
|
34
|
+
val_count: chainSpec.validatorsCount,
|
|
35
|
+
max_input: W_B,
|
|
36
|
+
max_refine_code_size: W_C,
|
|
37
|
+
basic_piece_len: W_E,
|
|
38
|
+
max_imports: 3072,
|
|
39
|
+
max_is_authorized_code_size: 64000,
|
|
40
|
+
max_exports: 3072,
|
|
41
|
+
max_refine_memory: 4096,
|
|
42
|
+
max_is_authorized_memory: 4096,
|
|
43
|
+
segment_piece_count: chainSpec.numberECPiecesPerSegment,
|
|
44
|
+
max_report_elective_data: 49152,
|
|
45
|
+
transfer_memo_size: W_T,
|
|
46
|
+
epoch_tail_start: chainSpec.contestLength,
|
|
47
|
+
core_count: chainSpec.coresCount,
|
|
48
|
+
slot_period_sec: chainSpec.slotDuration,
|
|
49
|
+
max_authorizer_code_size: 64000,
|
|
50
|
+
max_service_code_size: 4000000,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#parentheader_hash
|
|
4
|
+
*/
|
|
5
|
+
export declare const parent: Handler<"parent">;
|
|
6
|
+
//# sourceMappingURL=parent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parent.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/parent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAsC,MAAM,2BAA2B,CAAC;AAE7F;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,CAAC,QAAQ,CA6BpC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Bytes } from "#@typeberry/bytes";
|
|
2
|
+
import { HASH_SIZE } from "#@typeberry/hash";
|
|
3
|
+
import { RpcError, RpcErrorCode, validation } from "#@typeberry/rpc-validation";
|
|
4
|
+
/**
|
|
5
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#parentheader_hash
|
|
6
|
+
*/
|
|
7
|
+
export const parent = async ([headerHash], { db }) => {
|
|
8
|
+
const hashOpaque = Bytes.fromBlob(headerHash, HASH_SIZE).asOpaque();
|
|
9
|
+
const header = db.blocks.getHeader(hashOpaque);
|
|
10
|
+
if (header === null) {
|
|
11
|
+
throw new RpcError(RpcErrorCode.BlockUnavailable, `Block unavailable: ${hashOpaque.toString()}`, validation.hash.encode(hashOpaque.raw));
|
|
12
|
+
}
|
|
13
|
+
const parentHash = header.parentHeaderHash.materialize();
|
|
14
|
+
if (parentHash.isEqualTo(Bytes.zero(HASH_SIZE).asOpaque())) {
|
|
15
|
+
throw new RpcError(RpcErrorCode.Other, `Parent not found for block: ${hashOpaque.toString()}`);
|
|
16
|
+
}
|
|
17
|
+
const parentHeader = db.blocks.getHeader(parentHash);
|
|
18
|
+
if (parentHeader === null) {
|
|
19
|
+
throw new RpcError(RpcErrorCode.Other, `The hash of parent was found (${parentHash}) but its header doesn't exist in the database.`);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
header_hash: parentHash.raw,
|
|
23
|
+
slot: parentHeader.timeSlotIndex.materialize(),
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#servicedataheader_hash-id
|
|
4
|
+
*/
|
|
5
|
+
export declare const serviceData: Handler<"serviceData">;
|
|
6
|
+
//# sourceMappingURL=service-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-data.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/service-data.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAA0B,MAAM,2BAA2B,CAAC;AAGjF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,aAAa,CAe9C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { tryAsServiceId } from "#@typeberry/block";
|
|
2
|
+
import { Bytes } from "#@typeberry/bytes";
|
|
3
|
+
import { Encoder } from "#@typeberry/codec";
|
|
4
|
+
import { HASH_SIZE } from "#@typeberry/hash";
|
|
5
|
+
import { RpcError, RpcErrorCode } from "#@typeberry/rpc-validation";
|
|
6
|
+
import { ServiceAccountInfo } from "#@typeberry/state";
|
|
7
|
+
/**
|
|
8
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#servicedataheader_hash-id
|
|
9
|
+
*/
|
|
10
|
+
export const serviceData = async ([headerHash, serviceId], { db, chainSpec }) => {
|
|
11
|
+
const hashOpaque = Bytes.fromBlob(headerHash, HASH_SIZE).asOpaque();
|
|
12
|
+
const state = db.states.getState(hashOpaque);
|
|
13
|
+
if (state === null) {
|
|
14
|
+
throw new RpcError(RpcErrorCode.Other, `State not found for block: ${hashOpaque.toString()}`);
|
|
15
|
+
}
|
|
16
|
+
const serviceData = state.getService(tryAsServiceId(serviceId));
|
|
17
|
+
if (serviceData === null) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return Encoder.encodeObject(ServiceAccountInfo.Codec, serviceData.getInfo(), chainSpec).raw;
|
|
21
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#servicepreimageheader_hash-id-hash
|
|
4
|
+
*/
|
|
5
|
+
export declare const servicePreimage: Handler<"servicePreimage">;
|
|
6
|
+
//# sourceMappingURL=service-preimage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-preimage.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/service-preimage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAA0B,MAAM,2BAA2B,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,iBAAiB,CAqBtD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { tryAsServiceId } from "#@typeberry/block";
|
|
2
|
+
import { Bytes } from "#@typeberry/bytes";
|
|
3
|
+
import { HASH_SIZE } from "#@typeberry/hash";
|
|
4
|
+
import { RpcError, RpcErrorCode } from "#@typeberry/rpc-validation";
|
|
5
|
+
/**
|
|
6
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#servicepreimageheader_hash-id-hash
|
|
7
|
+
*/
|
|
8
|
+
export const servicePreimage = async ([headerHash, serviceId, preimageHash], { db }) => {
|
|
9
|
+
const hashOpaque = Bytes.fromBlob(headerHash, HASH_SIZE).asOpaque();
|
|
10
|
+
const state = db.states.getState(hashOpaque);
|
|
11
|
+
if (state === null) {
|
|
12
|
+
throw new RpcError(RpcErrorCode.Other, `State not found for block: ${hashOpaque.toString()}`);
|
|
13
|
+
}
|
|
14
|
+
const service = state.getService(tryAsServiceId(serviceId));
|
|
15
|
+
if (service === null) {
|
|
16
|
+
throw new RpcError(RpcErrorCode.Other, `Service not found: ${serviceId.toString()}`);
|
|
17
|
+
}
|
|
18
|
+
const preimage = service.getPreimage(Bytes.fromBlob(preimageHash, HASH_SIZE).asOpaque());
|
|
19
|
+
if (preimage === null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return preimage.raw;
|
|
23
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#servicerequestheader_hash-id-hash-len
|
|
4
|
+
*/
|
|
5
|
+
export declare const serviceRequest: Handler<"serviceRequest">;
|
|
6
|
+
//# sourceMappingURL=service-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-request.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/service-request.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC,gBAAgB,CAqBpD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { tryAsServiceId } from "#@typeberry/block";
|
|
2
|
+
import { Bytes } from "#@typeberry/bytes";
|
|
3
|
+
import { HASH_SIZE } from "#@typeberry/hash";
|
|
4
|
+
import { tryAsU32 } from "#@typeberry/numbers";
|
|
5
|
+
/**
|
|
6
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#servicerequestheader_hash-id-hash-len
|
|
7
|
+
*/
|
|
8
|
+
export const serviceRequest = async ([headerHash, serviceId, preimageHash, preimageLength], { db }) => {
|
|
9
|
+
const hashOpaque = Bytes.fromBlob(headerHash, HASH_SIZE).asOpaque();
|
|
10
|
+
const state = db.states.getState(hashOpaque);
|
|
11
|
+
if (state === null) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const service = state.getService(tryAsServiceId(serviceId));
|
|
15
|
+
if (service === null) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const slots = service.getLookupHistory(Bytes.fromBlob(preimageHash, HASH_SIZE).asOpaque(), tryAsU32(preimageLength));
|
|
19
|
+
if (slots === null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return slots;
|
|
23
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#servicevalueheader_hash-id-key
|
|
4
|
+
*/
|
|
5
|
+
export declare const serviceValue: Handler<"serviceValue">;
|
|
6
|
+
//# sourceMappingURL=service-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-value.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/service-value.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAA0B,MAAM,2BAA2B,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC,cAAc,CAqBhD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { tryAsServiceId } from "#@typeberry/block";
|
|
2
|
+
import { Bytes } from "#@typeberry/bytes";
|
|
3
|
+
import { HASH_SIZE } from "#@typeberry/hash";
|
|
4
|
+
import { RpcError, RpcErrorCode } from "#@typeberry/rpc-validation";
|
|
5
|
+
/**
|
|
6
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#servicevalueheader_hash-id-key
|
|
7
|
+
*/
|
|
8
|
+
export const serviceValue = async ([headerHash, serviceId, key], { db }) => {
|
|
9
|
+
const hashOpaque = Bytes.fromBlob(headerHash, HASH_SIZE).asOpaque();
|
|
10
|
+
const state = db.states.getState(hashOpaque);
|
|
11
|
+
if (state === null) {
|
|
12
|
+
throw new RpcError(RpcErrorCode.Other, `State not found for block: ${hashOpaque.toString()}`);
|
|
13
|
+
}
|
|
14
|
+
const service = state.getService(tryAsServiceId(serviceId));
|
|
15
|
+
if (service === null) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const storageValue = service.getStorage(Bytes.fromBlob(key, key.length).asOpaque());
|
|
19
|
+
if (storageValue === null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return storageValue.raw;
|
|
23
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#staterootheader_hash
|
|
4
|
+
*/
|
|
5
|
+
export declare const stateRoot: Handler<"stateRoot">;
|
|
6
|
+
//# sourceMappingURL=state-root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-root.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/state-root.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAA0B,MAAM,2BAA2B,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,WAAW,CAU1C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Bytes } from "#@typeberry/bytes";
|
|
2
|
+
import { HASH_SIZE } from "#@typeberry/hash";
|
|
3
|
+
import { RpcError, RpcErrorCode } from "#@typeberry/rpc-validation";
|
|
4
|
+
/**
|
|
5
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#staterootheader_hash
|
|
6
|
+
*/
|
|
7
|
+
export const stateRoot = async ([headerHash], { db }) => {
|
|
8
|
+
const hashOpaque = Bytes.fromBlob(headerHash, HASH_SIZE).asOpaque();
|
|
9
|
+
const stateRoot = db.blocks.getPostStateRoot(hashOpaque);
|
|
10
|
+
if (stateRoot === null) {
|
|
11
|
+
throw new RpcError(RpcErrorCode.BlockUnavailable, `Block unavailable: ${hashOpaque.toString()}`, hashOpaque.raw);
|
|
12
|
+
}
|
|
13
|
+
return stateRoot.raw;
|
|
14
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#statisticsheader_hash
|
|
4
|
+
*/
|
|
5
|
+
export declare const statistics: Handler<"statistics">;
|
|
6
|
+
//# sourceMappingURL=statistics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,OAAO,EAA0B,MAAM,2BAA2B,CAAC;AAGjF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,OAAO,CAAC,YAAY,CAS5C,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Bytes } from "#@typeberry/bytes";
|
|
2
|
+
import { Encoder } from "#@typeberry/codec";
|
|
3
|
+
import { HASH_SIZE } from "#@typeberry/hash";
|
|
4
|
+
import { RpcError, RpcErrorCode } from "#@typeberry/rpc-validation";
|
|
5
|
+
import { StatisticsData } from "#@typeberry/state";
|
|
6
|
+
/**
|
|
7
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#statisticsheader_hash
|
|
8
|
+
*/
|
|
9
|
+
export const statistics = async ([headerHash], { db, chainSpec }) => {
|
|
10
|
+
const hashOpaque = Bytes.fromBlob(headerHash, HASH_SIZE).asOpaque();
|
|
11
|
+
const state = db.states.getState(hashOpaque);
|
|
12
|
+
if (state === null) {
|
|
13
|
+
throw new RpcError(RpcErrorCode.Other, `State not found for block: ${hashOpaque.toString()}`);
|
|
14
|
+
}
|
|
15
|
+
return Encoder.encodeObject(StatisticsData.Codec, state.statistics, chainSpec).raw;
|
|
16
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#subscribebestblock
|
|
4
|
+
*/
|
|
5
|
+
export declare const subscribeBestBlock: Handler<"subscribeBestBlock">;
|
|
6
|
+
//# sourceMappingURL=subscribe-best-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe-best-block.d.ts","sourceRoot":"","sources":["../../../../../../../packages/jam/rpc/src/handlers/subscribe-best-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,2BAA2B,CAAC;AAGrE;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,oBAAoB,CAE5D,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { validation } from "#@typeberry/rpc-validation";
|
|
2
|
+
import { bestBlock } from "./best-block.js";
|
|
3
|
+
/**
|
|
4
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#subscribebestblock
|
|
5
|
+
*/
|
|
6
|
+
export const subscribeBestBlock = async (params, { subscription }) => {
|
|
7
|
+
return subscription.subscribe("subscribeBestBlock", bestBlock, validation.schemas.bestBlock.output, params);
|
|
8
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Handler } from "#@typeberry/rpc-validation";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/polkadot-fellows/JIPs/blob/772ce90bfc33f4e1de9de3bbe10c561753cc0d41/JIP-2.md#subscribefinalizedblock
|
|
4
|
+
*/
|
|
5
|
+
export declare const subscribeFinalizedBlock: Handler<"subscribeFinalizedBlock">;
|
|
6
|
+
//# sourceMappingURL=subscribe-finalized-block.d.ts.map
|