@acala-network/chopsticks-core 0.9.3-1 → 0.9.3

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.
@@ -110,7 +110,7 @@ const newHeader = async (head, unsafeBlockHeight)=>{
110
110
  },
111
111
  ...consensus.rest
112
112
  ];
113
- if (meta.query.randomness) {
113
+ if (meta.query.randomness?.notFirstBlock) {
114
114
  // TODO: shouldn't modify existing head
115
115
  // reset notFirstBlock so randomness will skip validation
116
116
  head.pushStorageLayer().set((0, _index.compactHex)(meta.query.randomness.notFirstBlock()), _storagelayer.StorageValueKind.Deleted);
@@ -349,14 +349,14 @@ const dryRunExtrinsic = async (head, inherents, extrinsic)=>{
349
349
  0xef
350
350
  ]);
351
351
  generic.signature.set(mockSignature);
352
- _logger.defaultLogger.info({
352
+ logger.debug({
353
353
  call: call.toHuman()
354
354
  }, 'dry_run_call');
355
355
  return newBlock.call('BlockBuilder_apply_extrinsic', [
356
356
  generic.toHex()
357
357
  ]);
358
358
  }
359
- _logger.defaultLogger.info({
359
+ logger.debug({
360
360
  call: registry.createType('GenericExtrinsic', (0, _util.hexToU8a)(extrinsic)).toHuman()
361
361
  }, 'dry_run_extrinsic');
362
362
  return newBlock.call('BlockBuilder_apply_extrinsic', [
@@ -17,8 +17,7 @@ const _block = require("./block.js");
17
17
  const _txpool = require("./txpool.js");
18
18
  const _headstate = require("./head-state.js");
19
19
  const _offchain = require("../offchain.js");
20
- const _index = require("../wasm-executor/index.js");
21
- const _index1 = require("../utils/index.js");
20
+ const _index = require("../utils/index.js");
22
21
  const _logger = require("../logger.js");
23
22
  const _blockbuilder = require("./block-builder.js");
24
23
  function _check_private_redeclaration(obj, privateCollection) {
@@ -373,7 +372,7 @@ class Blockchain {
373
372
  const needsDispatch = meta.registry.createType('Vec<u32>', Object.keys(ump));
374
373
  const storageValues = [
375
374
  [
376
- (0, _index1.compactHex)(meta.query.ump.needsDispatch()),
375
+ (0, _index.compactHex)(meta.query.ump.needsDispatch()),
377
376
  needsDispatch.toHex()
378
377
  ]
379
378
  ];
@@ -385,11 +384,11 @@ class Blockchain {
385
384
  upwardMessages.map((x)=>x.byteLength).reduce((s, i)=>s + i, 0)
386
385
  ]);
387
386
  storageValues.push([
388
- (0, _index1.compactHex)(meta.query.ump.relayDispatchQueues(paraId)),
387
+ (0, _index.compactHex)(meta.query.ump.relayDispatchQueues(paraId)),
389
388
  upwardMessages.toHex()
390
389
  ]);
391
390
  storageValues.push([
392
- (0, _index1.compactHex)(meta.query.ump.relayDispatchQueueSize(paraId)),
391
+ (0, _index.compactHex)(meta.query.ump.relayDispatchQueueSize(paraId)),
393
392
  queueSize.toHex()
394
393
  ]);
395
394
  }
@@ -415,9 +414,8 @@ class Blockchain {
415
414
  return inherents;
416
415
  }
417
416
  /**
418
- * Close the db and release worker.
417
+ * Close the db and disconnect api.
419
418
  */ async close() {
420
- await (0, _index.releaseWorker)();
421
419
  await this.api.disconnect();
422
420
  await this.db?.close();
423
421
  }
package/dist/cjs/setup.js CHANGED
@@ -18,7 +18,7 @@ const setup = async (options)=>{
18
18
  let provider;
19
19
  if (options.genesis) {
20
20
  provider = options.genesis;
21
- } else if (/^(https|http):\/\//.test(options.endpoint || '')) {
21
+ } else if (typeof options.endpoint === 'string' && /^(https|http):\/\//.test(options.endpoint || '')) {
22
22
  provider = new _rpcprovider.HttpProvider(options.endpoint);
23
23
  } else {
24
24
  provider = new _rpcprovider.WsProvider(options.endpoint, 3_000);
@@ -18,6 +18,9 @@ _export(exports, {
18
18
  decodeProof: function() {
19
19
  return decodeProof;
20
20
  },
21
+ destroyWorker: function() {
22
+ return destroyWorker;
23
+ },
21
24
  emptyTaskHandler: function() {
22
25
  return emptyTaskHandler;
23
26
  },
@@ -27,9 +30,6 @@ _export(exports, {
27
30
  getRuntimeVersion: function() {
28
31
  return getRuntimeVersion;
29
32
  },
30
- releaseWorker: function() {
31
- return releaseWorker;
32
- },
33
33
  runTask: function() {
34
34
  return runTask;
35
35
  },
@@ -229,12 +229,10 @@ const getAuraSlotDuration = _lodash.default.memoize(async (wasm)=>{
229
229
  if ('Error' in result) throw new Error(result.Error);
230
230
  return (0, _util.u8aToBn)((0, _util.hexToU8a)(result.Call.result).subarray(0, 8 /* u64: 8 bytes */ )).toNumber();
231
231
  });
232
- const releaseWorker = async ()=>{
232
+ const destroyWorker = async ()=>{
233
233
  if (!__executor_worker) return;
234
234
  const executor = await __executor_worker;
235
235
  executor.remote[_comlink.releaseProxy]();
236
- // this delay seems to fix hanging tests
237
- // https://github.com/vitest-dev/vitest/issues/3077
238
236
  await new Promise((resolve)=>setTimeout(resolve, 50));
239
237
  await executor.terminate();
240
238
  __executor_worker = undefined;
@@ -86,7 +86,7 @@ export const newHeader = async (head, unsafeBlockHeight)=>{
86
86
  },
87
87
  ...consensus.rest
88
88
  ];
89
- if (meta.query.randomness) {
89
+ if (meta.query.randomness?.notFirstBlock) {
90
90
  // TODO: shouldn't modify existing head
91
91
  // reset notFirstBlock so randomness will skip validation
92
92
  head.pushStorageLayer().set(compactHex(meta.query.randomness.notFirstBlock()), StorageValueKind.Deleted);
@@ -325,14 +325,14 @@ export const dryRunExtrinsic = async (head, inherents, extrinsic)=>{
325
325
  0xef
326
326
  ]);
327
327
  generic.signature.set(mockSignature);
328
- defaultLogger.info({
328
+ logger.debug({
329
329
  call: call.toHuman()
330
330
  }, 'dry_run_call');
331
331
  return newBlock.call('BlockBuilder_apply_extrinsic', [
332
332
  generic.toHex()
333
333
  ]);
334
334
  }
335
- defaultLogger.info({
335
+ logger.debug({
336
336
  call: registry.createType('GenericExtrinsic', hexToU8a(extrinsic)).toHuman()
337
337
  }, 'dry_run_extrinsic');
338
338
  return newBlock.call('BlockBuilder_apply_extrinsic', [
@@ -7,7 +7,6 @@ import { Block } from './block.js';
7
7
  import { TxPool } from './txpool.js';
8
8
  import { HeadState } from './head-state.js';
9
9
  import { OffchainWorker } from '../offchain.js';
10
- import { releaseWorker } from '../wasm-executor/index.js';
11
10
  import { compactHex } from '../utils/index.js';
12
11
  import { defaultLogger } from '../logger.js';
13
12
  import { dryRunExtrinsic, dryRunInherents } from './block-builder.js';
@@ -415,9 +414,8 @@ const logger = defaultLogger.child({
415
414
  return inherents;
416
415
  }
417
416
  /**
418
- * Close the db and release worker.
417
+ * Close the db and disconnect api.
419
418
  */ async close() {
420
- await releaseWorker();
421
419
  await this.api.disconnect();
422
420
  await this.db?.close();
423
421
  }
package/dist/esm/setup.js CHANGED
@@ -8,7 +8,7 @@ export const setup = async (options)=>{
8
8
  let provider;
9
9
  if (options.genesis) {
10
10
  provider = options.genesis;
11
- } else if (/^(https|http):\/\//.test(options.endpoint || '')) {
11
+ } else if (typeof options.endpoint === 'string' && /^(https|http):\/\//.test(options.endpoint || '')) {
12
12
  provider = new HttpProvider(options.endpoint);
13
13
  } else {
14
14
  provider = new WsProvider(options.endpoint, 3_000);
@@ -145,12 +145,10 @@ export const getAuraSlotDuration = _.memoize(async (wasm)=>{
145
145
  if ('Error' in result) throw new Error(result.Error);
146
146
  return u8aToBn(hexToU8a(result.Call.result).subarray(0, 8 /* u64: 8 bytes */ )).toNumber();
147
147
  });
148
- export const releaseWorker = async ()=>{
148
+ export const destroyWorker = async ()=>{
149
149
  if (!__executor_worker) return;
150
150
  const executor = await __executor_worker;
151
151
  executor.remote[Comlink.releaseProxy]();
152
- // this delay seems to fix hanging tests
153
- // https://github.com/vitest-dev/vitest/issues/3077
154
152
  await new Promise((resolve)=>setTimeout(resolve, 50));
155
153
  await executor.terminate();
156
154
  __executor_worker = undefined;
@@ -166,7 +166,7 @@ export declare class Blockchain {
166
166
  */
167
167
  getInherents(): Promise<HexString[]>;
168
168
  /**
169
- * Close the db and release worker.
169
+ * Close the db and disconnect api.
170
170
  */
171
171
  close(): Promise<void>;
172
172
  }
@@ -5,7 +5,7 @@ import { BuildBlockMode } from './blockchain/txpool.js';
5
5
  import { Database } from './database.js';
6
6
  import { GenesisProvider } from './genesis-provider.js';
7
7
  export type SetupOptions = {
8
- endpoint?: string;
8
+ endpoint?: string | string[];
9
9
  block?: string | number | null;
10
10
  genesis?: GenesisProvider;
11
11
  buildBlockMode?: BuildBlockMode;
@@ -71,4 +71,4 @@ export declare const emptyTaskHandler: {
71
71
  offchainSubmitTransaction: (_tx: HexString) => Promise<never>;
72
72
  };
73
73
  export declare const getAuraSlotDuration: ((wasm: HexString) => Promise<number>) & _.MemoizedFunction;
74
- export declare const releaseWorker: () => Promise<void>;
74
+ export declare const destroyWorker: () => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks-core",
3
- "version": "0.9.3-1",
3
+ "version": "0.9.3",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  "docs:prep": "typedoc"
14
14
  },
15
15
  "dependencies": {
16
- "@acala-network/chopsticks-executor": "0.9.3-1",
16
+ "@acala-network/chopsticks-executor": "0.9.3",
17
17
  "@polkadot/rpc-provider": "^10.10.1",
18
18
  "@polkadot/types": "^10.10.1",
19
19
  "@polkadot/types-codec": "^10.10.1",
@@ -34,7 +34,7 @@
34
34
  "@swc/core": "^1.3.99",
35
35
  "@types/lodash": "^4.14.202",
36
36
  "typescript": "^5.2.2",
37
- "vitest": "^0.34.6"
37
+ "vitest": "^1.0.0-beta.5"
38
38
  },
39
39
  "files": [
40
40
  "dist/esm/**",