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

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', [
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);
@@ -61,11 +61,15 @@ const createProof = async (nodes, entries)=>{
61
61
  const runTask = async (task, callback)=>{
62
62
  return _chopsticksexecutor.run_task(task, callback, 'info');
63
63
  };
64
+ const testing = async (callback, key)=>{
65
+ return _chopsticksexecutor.testing(callback, key);
66
+ };
64
67
  const wasmExecutor = {
65
68
  runTask,
66
69
  getRuntimeVersion,
67
70
  calculateStateRoot,
68
71
  createProof,
69
- decodeProof
72
+ decodeProof,
73
+ testing
70
74
  };
71
75
  _comlink.expose(wasmExecutor);
@@ -30,6 +30,9 @@ _export(exports, {
30
30
  getRuntimeVersion: function() {
31
31
  return getRuntimeVersion;
32
32
  },
33
+ getWorker: function() {
34
+ return getWorker;
35
+ },
33
36
  runTask: function() {
34
37
  return runTask;
35
38
  },
@@ -68,11 +68,15 @@ const createProof = async (nodes, entries)=>{
68
68
  const runTask = async (task, callback)=>{
69
69
  return _chopsticksexecutor.run_task(task, callback, process.env.RUST_LOG);
70
70
  };
71
+ const testing = async (callback, key)=>{
72
+ return _chopsticksexecutor.testing(callback, key);
73
+ };
71
74
  const wasmExecutor = {
72
75
  runTask,
73
76
  getRuntimeVersion,
74
77
  calculateStateRoot,
75
78
  createProof,
76
- decodeProof
79
+ decodeProof,
80
+ testing
77
81
  };
78
82
  _comlink.expose(wasmExecutor, (0, _nodeadapter.default)(_nodeworker_threads.parentPort));
@@ -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', [
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);
@@ -16,11 +16,15 @@ const createProof = async (nodes, entries)=>{
16
16
  const runTask = async (task, callback)=>{
17
17
  return pkg.run_task(task, callback, 'info');
18
18
  };
19
+ const testing = async (callback, key)=>{
20
+ return pkg.testing(callback, key);
21
+ };
19
22
  const wasmExecutor = {
20
23
  runTask,
21
24
  getRuntimeVersion,
22
25
  calculateStateRoot,
23
26
  createProof,
24
- decodeProof
27
+ decodeProof,
28
+ testing
25
29
  };
26
30
  Comlink.expose(wasmExecutor);
@@ -9,7 +9,7 @@ const logger = defaultLogger.child({
9
9
  name: 'executor'
10
10
  });
11
11
  let __executor_worker;
12
- const getWorker = async ()=>{
12
+ export const getWorker = async ()=>{
13
13
  if (__executor_worker) return __executor_worker;
14
14
  const isNode = typeof process !== 'undefined' && process?.versions?.node // true for node or bun
15
15
  ;
@@ -18,11 +18,15 @@ const createProof = async (nodes, entries)=>{
18
18
  const runTask = async (task, callback)=>{
19
19
  return pkg.run_task(task, callback, process.env.RUST_LOG);
20
20
  };
21
+ const testing = async (callback, key)=>{
22
+ return pkg.testing(callback, key);
23
+ };
21
24
  const wasmExecutor = {
22
25
  runTask,
23
26
  getRuntimeVersion,
24
27
  calculateStateRoot,
25
28
  createProof,
26
- decodeProof
29
+ decodeProof,
30
+ testing
27
31
  };
28
32
  Comlink.expose(wasmExecutor, nodeEndpoint(parentPort));
@@ -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;
@@ -1,3 +1,4 @@
1
+ import * as Comlink from 'comlink';
1
2
  import { HexString } from '@polkadot/util/types';
2
3
  import _ from 'lodash';
3
4
  import { Block } from '../blockchain/block.js';
@@ -41,7 +42,12 @@ export interface WasmExecutor {
41
42
  allowUnresolvedImports: boolean;
42
43
  runtimeLogLevel: number;
43
44
  }, callback?: JsCallback) => Promise<TaskResponse>;
45
+ testing: (callback: JsCallback, key: any) => Promise<any>;
44
46
  }
47
+ export declare const getWorker: () => Promise<{
48
+ remote: Comlink.Remote<WasmExecutor>;
49
+ terminate: () => Promise<void>;
50
+ }>;
45
51
  export declare const getRuntimeVersion: ((code: HexString) => Promise<RuntimeVersion>) & _.MemoizedFunction;
46
52
  export declare const calculateStateRoot: (entries: [HexString, HexString][], trie_version: number) => Promise<HexString>;
47
53
  export declare const decodeProof: (trieRootHash: HexString, keys: HexString[], nodes: HexString[]) => Promise<{}>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks-core",
3
- "version": "0.9.3-2",
3
+ "version": "0.9.4-1",
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-2",
16
+ "@acala-network/chopsticks-executor": "0.9.4-1",
17
17
  "@polkadot/rpc-provider": "^10.10.1",
18
18
  "@polkadot/types": "^10.10.1",
19
19
  "@polkadot/types-codec": "^10.10.1",