smoldot 2.0.40 → 3.0.1-dev.0

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.
@@ -295,11 +295,23 @@ export function start(options, wasmModule, platformBindings) {
295
295
  if (jsonRpcMaxSubscriptions > 0xffffffff) {
296
296
  jsonRpcMaxSubscriptions = 0xffffffff;
297
297
  }
298
+ // Sanitize `statementStore`.
299
+ let statementStoreMaxSeenStatements = 0;
300
+ if (options.statementStore !== undefined) {
301
+ statementStoreMaxSeenStatements = options.statementStore.maxSeenStatements === undefined ? 65536 : options.statementStore.maxSeenStatements;
302
+ statementStoreMaxSeenStatements = Math.floor(statementStoreMaxSeenStatements);
303
+ if (statementStoreMaxSeenStatements <= 0 || isNaN(statementStoreMaxSeenStatements)) {
304
+ throw new AddChainError("Invalid value for `statementStore.maxSeenStatements`");
305
+ }
306
+ if (statementStoreMaxSeenStatements > 0xffffffff) {
307
+ statementStoreMaxSeenStatements = 0xffffffff;
308
+ }
309
+ }
298
310
  // Sanitize `databaseContent`.
299
311
  if (options.databaseContent !== undefined && typeof options.databaseContent !== 'string')
300
312
  throw new AddChainError("`databaseContent` is not a string");
301
313
  const promise = new Promise((resolve) => state.addChainIdAllocations.push(resolve));
302
- state.instance.instance.addChain(options.chainSpec, options.databaseContent || "", potentialRelayChainsIds, !!options.disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions);
314
+ state.instance.instance.addChain(options.chainSpec, options.databaseContent || "", potentialRelayChainsIds, !!options.disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, statementStoreMaxSeenStatements);
303
315
  const outcome = yield promise;
304
316
  if (!outcome.success)
305
317
  throw new AddChainError(outcome.error);
@@ -105,7 +105,7 @@ export interface Instance {
105
105
  * indicate whether the initialization was actually successful. If `success` is `false`, then
106
106
  * the `chainId` becomes unallocated.
107
107
  */
108
- addChain: (chainSpec: string, databaseContent: string, potentialRelayChains: number[], disableJsonRpc: boolean, jsonRpcMaxPendingRequests: number, jsonRpcMaxSubscriptions: number) => void;
108
+ addChain: (chainSpec: string, databaseContent: string, potentialRelayChains: number[], disableJsonRpc: boolean, jsonRpcMaxPendingRequests: number, jsonRpcMaxSubscriptions: number, statementStoreMaxSeenStatements: number) => void;
109
109
  removeChain: (chainId: number) => void;
110
110
  /**
111
111
  * Notifies the background executor that it should stop. Once it has effectively stopped,
@@ -383,7 +383,7 @@ export function startLocalInstance(config, wasmModule, eventCallback) {
383
383
  return null;
384
384
  }
385
385
  },
386
- addChain: (chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions) => {
386
+ addChain: (chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, statementStoreMaxSeenStatements) => {
387
387
  if (!state.instance) {
388
388
  eventCallback({ ty: "add-chain-id-allocated", chainId: 0 });
389
389
  eventCallback({ ty: "add-chain-result", chainId: 0, success: false, error: "Smoldot has crashed" });
@@ -403,7 +403,7 @@ export function startLocalInstance(config, wasmModule, eventCallback) {
403
403
  state.bufferIndices[2] = potentialRelayChainsEncoded;
404
404
  let chainId;
405
405
  try {
406
- chainId = state.instance.exports.add_chain(0, 1, disableJsonRpc ? 0 : jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, 2);
406
+ chainId = state.instance.exports.add_chain(0, 1, disableJsonRpc ? 0 : jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, 2, statementStoreMaxSeenStatements);
407
407
  }
408
408
  catch (_error) {
409
409
  eventCallback({ ty: "add-chain-id-allocated", chainId: 0 });
@@ -144,9 +144,9 @@ export function connectToInstanceServer(config) {
144
144
  config.eventCallback(message);
145
145
  };
146
146
  return {
147
- addChain(chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions) {
147
+ addChain(chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, statementStoreMaxSeenStatements) {
148
148
  return __awaiter(this, void 0, void 0, function* () {
149
- const msg = { ty: "add-chain", chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions };
149
+ const msg = { ty: "add-chain", chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, statementStoreMaxSeenStatements };
150
150
  portToServer.postMessage(msg);
151
151
  });
152
152
  },
@@ -283,7 +283,7 @@ export function startInstanceServer(config, initPortToClient) {
283
283
  const message = messageEvent.data;
284
284
  switch (message.ty) {
285
285
  case "add-chain": {
286
- state.instance.addChain(message.chainSpec, message.databaseContent, message.potentialRelayChains, message.disableJsonRpc, message.jsonRpcMaxPendingRequests, message.jsonRpcMaxSubscriptions);
286
+ state.instance.addChain(message.chainSpec, message.databaseContent, message.potentialRelayChains, message.disableJsonRpc, message.jsonRpcMaxPendingRequests, message.jsonRpcMaxSubscriptions, message.statementStoreMaxSeenStatements);
287
287
  break;
288
288
  }
289
289
  case "remove-chain": {
@@ -398,4 +398,12 @@ export interface AddChainOptions {
398
398
  * If this value is not set, it means that there is no maximum.
399
399
  */
400
400
  jsonRpcMaxSubscriptions?: number;
401
+ /**
402
+ * If set, enables the Statement Store protocol on this chain.
403
+ *
404
+ * `maxSeenStatements` is the maximum number of seen statements to cache. Defaults to 65536.
405
+ */
406
+ statementStore?: {
407
+ maxSeenStatements?: number;
408
+ };
401
409
  }
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "smoldot",
3
- "version": "2.0.40",
3
+ "version": "3.0.1-dev.0",
4
4
  "description": "Light client that connects to Polkadot and Substrate-based blockchains",
5
5
  "contributors": [
6
6
  "Parity Technologies <admin@parity.io>",
7
7
  "Pierre Krieger <pierre.krieger1708@gmail.com>"
8
8
  ],
9
9
  "license": "GPL-3.0-or-later WITH Classpath-exception-2.0",
10
- "homepage": "https://github.com/smol-dot/smoldot",
10
+ "homepage": "https://github.com/paritytech/smoldot",
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git+https://github.com/smol-dot/smoldot.git"
13
+ "url": "git+https://github.com/paritytech/smoldot.git"
14
14
  },
15
15
  "bugs": {
16
- "url": "https://github.com/smol-dot/smoldot/issues"
16
+ "url": "https://github.com/paritytech/smoldot/issues"
17
17
  },
18
18
  "files": [
19
19
  "dist"
@@ -65,8 +65,10 @@
65
65
  },
66
66
  "scripts": {
67
67
  "buildModules": "tsc -p tsconfig-mjs.json && tsc -p tsconfig-cjs.json && bash fix-package-type.sh",
68
- "prepublishOnly": "node prepare.mjs --release && rm -rf ./dist && npm run buildModules",
68
+ "prepack": "node prepare.mjs --release && rm -rf ./dist && npm run buildModules",
69
69
  "build": "node prepare.mjs --release && rm -rf ./dist && npm run buildModules",
70
+ "probe:parachain-restart": "node ./scripts/parachain-finalized-database-probe.mjs",
71
+ "probe:parachain-restart:bench": "node ./scripts/parachain-finalized-database-benchmark.mjs",
70
72
  "start": "node prepare.mjs --debug && rm -rf ./dist && npm run buildModules && node demo/demo.mjs",
71
73
  "test": "node prepare.mjs --debug && rm -rf ./dist && npm run buildModules && deno run ./dist/mjs/index-deno.js && ava --timeout=2m --concurrency 2 --no-worker-threads",
72
74
  "doc": "node prepare.mjs --debug && typedoc --basePath ./src --out ./dist/doc --treatWarningsAsErrors ./src/index-browser.ts"