@acala-network/chopsticks 0.6.2 → 0.6.4

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.
@@ -31,6 +31,8 @@ export declare class TxPool {
31
31
  get ump(): Record<number, HexString[]>;
32
32
  get dmp(): DownwardMessage[];
33
33
  get hrmp(): Record<number, HorizontalMessage[]>;
34
+ get mode(): BuildBlockMode;
35
+ set mode(mode: BuildBlockMode);
34
36
  clear(): void;
35
37
  pendingExtrinsicsBy(address: string): HexString[];
36
38
  submitExtrinsic(extrinsic: HexString): Promise<void>;
@@ -45,6 +45,12 @@ class TxPool {
45
45
  get hrmp() {
46
46
  return this.#hrmp;
47
47
  }
48
+ get mode() {
49
+ return this.#mode;
50
+ }
51
+ set mode(mode) {
52
+ this.#mode = mode;
53
+ }
48
54
  clear() {
49
55
  this.#pool.length = 0;
50
56
  for (const id of Object.keys(this.#ump)) {
package/lib/executor.d.ts CHANGED
@@ -18,7 +18,7 @@ export type RuntimeVersion = {
18
18
  stateVersion: number;
19
19
  };
20
20
  export declare const getRuntimeVersion: (code: HexString) => Promise<RuntimeVersion>;
21
- export declare const calculateStateRoot: (entries: [HexString, HexString][]) => Promise<HexString>;
21
+ export declare const calculateStateRoot: (entries: [HexString, HexString][], trie_version: number) => Promise<HexString>;
22
22
  export declare const decodeProof: (trieRootHash: HexString, keys: HexString[], nodes: HexString[]) => Promise<Record<`0x${string}`, `0x${string}` | null>>;
23
23
  export declare const createProof: (trieRootHash: HexString, nodes: HexString[], entries: [HexString, HexString | null][]) => Promise<{
24
24
  trieRootHash: `0x${string}`;
package/lib/executor.js CHANGED
@@ -17,8 +17,9 @@ const getRuntimeVersion = async (code) => {
17
17
  });
18
18
  };
19
19
  exports.getRuntimeVersion = getRuntimeVersion;
20
- const calculateStateRoot = async (entries) => {
21
- return (0, chopsticks_executor_1.calculate_state_root)(entries);
20
+ // trie_version: 0 for old trie, 1 for new trie
21
+ const calculateStateRoot = async (entries, trie_version) => {
22
+ return (0, chopsticks_executor_1.calculate_state_root)(entries, trie_version);
22
23
  };
23
24
  exports.calculateStateRoot = calculateStateRoot;
24
25
  const decodeProof = async (trieRootHash, keys, nodes) => {
@@ -23,7 +23,7 @@ class GenesisProvider {
23
23
  this.#stateRoot = (0, executor_1.calculateStateRoot)(Object.entries(this.#genesis.genesis.raw.top).reduce((accu, item) => {
24
24
  accu.push(item);
25
25
  return accu;
26
- }, []));
26
+ }, []), 1);
27
27
  this.#eventemitter = new node_events_1.EventEmitter();
28
28
  this.#isReadyPromise = new Promise((resolve, reject) => {
29
29
  this.#eventemitter.once('connected', () => {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const txpool_1 = require("../../blockchain/txpool");
3
4
  const shared_1 = require("../shared");
4
5
  const set_storage_1 = require("../../utils/set-storage");
5
6
  const logger_1 = require("../../logger");
@@ -63,5 +64,12 @@ const handlers = {
63
64
  return block.hash;
64
65
  },
65
66
  dev_dryRun: dry_run_1.dev_dryRun,
67
+ dev_setBlockBuildMode: async (context, [mode]) => {
68
+ logger.debug({ mode }, 'dev_setBlockBuildMode');
69
+ if (txpool_1.BuildBlockMode[mode] === undefined) {
70
+ throw new shared_1.ResponseError(1, `Invalid mode ${mode}`);
71
+ }
72
+ context.chain.txPool.mode = mode;
73
+ },
66
74
  };
67
75
  exports.default = handlers;
@@ -6,7 +6,7 @@ export type ProcessKey = (key: StorageKey<any>) => any;
6
6
  export declare function fetchKeys(getKeys: GetKeys, processKey: ProcessKey): Promise<void>;
7
7
  export declare function fetchKeysToArray(getKeys: GetKeys): Promise<StorageKey<any>[]>;
8
8
  export declare const compactHex: (value: Uint8Array) => HexString;
9
- export declare const getParaId: (chain: Blockchain) => Promise<import("@polkadot/types").u32>;
9
+ export declare const getParaId: (chain: Blockchain) => Promise<import("@polkadot/types").U32>;
10
10
  export declare const isUrl: (url: string) => boolean;
11
11
  export type Deferred<T> = {
12
12
  resolve: (value: T | PromiseLike<T>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "author": "Bryan Chen <xlchen1291@gmail.com>",
5
5
  "license": "Apache-2.0",
6
6
  "bin": "./chopsticks.js",
@@ -8,23 +8,17 @@
8
8
  "clean": "rm -rf lib tsconfig.tsbuildinfo",
9
9
  "build": "tsc -p ./tsconfig.json",
10
10
  "script:start": "cd ../..; ts-node --transpile-only packages/chopsticks/src/cli.ts",
11
- "script:run": "cd ../..; LOG_LEVEL=trace ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- dev --config=configs/dev.yml",
12
- "dev:karura": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- dev --config=configs/karura.yml",
13
- "dev:acala": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- dev --config=configs/acala.yml",
14
- "dev:polkadot": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- dev --config=configs/polkadot.yml",
15
- "dev:moonriver": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- dev --config=configs/moonriver.yml",
16
- "dev:moonbeam": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- dev --config=configs/moonbeam.yml"
11
+ "script:run": "cd ../..; LOG_LEVEL=trace ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- --config=configs/dev.yml",
12
+ "dev:karura": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- --config=configs/karura.yml",
13
+ "dev:acala": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- --config=configs/acala.yml",
14
+ "dev:polkadot": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- --config=configs/polkadot.yml",
15
+ "dev:moonriver": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- --config=configs/moonriver.yml",
16
+ "dev:moonbeam": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts -- --config=configs/moonbeam.yml"
17
17
  },
18
18
  "dependencies": {
19
- "@acala-network/chopsticks-executor": "0.6.2",
20
- "@polkadot/api": "^10.2.1",
21
- "@polkadot/rpc-provider": "^10.2.1",
22
- "@polkadot/types": "^10.2.1",
23
- "@polkadot/types-codec": "^10.2.1",
24
- "@polkadot/types-known": "^10.2.1",
25
- "@polkadot/util": "^11.1.2",
26
- "@polkadot/util-crypto": "^11.1.2",
27
- "axios": "^1.3.4",
19
+ "@acala-network/chopsticks-executor": "0.6.4",
20
+ "@polkadot/api": "^10.5.1",
21
+ "axios": "^1.4.0",
28
22
  "js-yaml": "^4.1.0",
29
23
  "jsondiffpatch": "^0.4.1",
30
24
  "lodash": "^4.17.21",
@@ -32,20 +26,20 @@
32
26
  "pino-pretty": "^10.0.0",
33
27
  "reflect-metadata": "^0.1.13",
34
28
  "sqlite3": "^5.1.6",
35
- "typeorm": "^0.3.12",
29
+ "typeorm": "^0.3.15",
36
30
  "ws": "^8.13.0",
37
- "yargs": "^17.7.1",
31
+ "yargs": "^17.7.2",
38
32
  "zod": "^3.21.4"
39
33
  },
40
34
  "devDependencies": {
41
35
  "@types/js-yaml": "^4.0.5",
42
- "@types/lodash": "^4.14.192",
43
- "@types/node": "^18.15.11",
36
+ "@types/lodash": "^4.14.194",
37
+ "@types/node": "^18.16.3",
44
38
  "@types/ws": "^8.5.4",
45
39
  "@types/yargs": "^17.0.24",
46
40
  "ts-node": "^10.9.1",
47
41
  "ts-node-dev": "^2.0.0",
48
- "typescript": "^5.0.3"
42
+ "typescript": "^5.0.4"
49
43
  },
50
44
  "files": [
51
45
  "lib",