@acala-network/chopsticks 0.6.1 → 0.6.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.
- package/lib/blockchain/txpool.d.ts +2 -0
- package/lib/blockchain/txpool.js +6 -0
- package/lib/cli.js +44 -38
- package/lib/executor.d.ts +1 -1
- package/lib/executor.js +3 -2
- package/lib/genesis-provider.js +1 -1
- package/lib/rpc/dev/index.js +8 -0
- package/lib/utils/index.d.ts +1 -1
- package/package.json +15 -20
|
@@ -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>;
|
package/lib/blockchain/txpool.js
CHANGED
package/lib/cli.js
CHANGED
|
@@ -81,18 +81,43 @@ const defaultOptions = {
|
|
|
81
81
|
number: true,
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
|
+
const mockOptions = {
|
|
85
|
+
'import-storage': {
|
|
86
|
+
desc: 'Pre-defined JSON/YAML storage file path',
|
|
87
|
+
string: true,
|
|
88
|
+
},
|
|
89
|
+
'mock-signature-host': {
|
|
90
|
+
desc: 'Mock signature host so any signature starts with 0xdeadbeef and filled by 0xcd is considered valid',
|
|
91
|
+
boolean: true,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
84
94
|
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
85
95
|
.scriptName('chopsticks')
|
|
96
|
+
.command('*', 'Dev mode, fork off a chain', (yargs) => yargs.options({
|
|
97
|
+
...defaultOptions,
|
|
98
|
+
...mockOptions,
|
|
99
|
+
port: {
|
|
100
|
+
desc: 'Port to listen on',
|
|
101
|
+
number: true,
|
|
102
|
+
},
|
|
103
|
+
'build-block-mode': {
|
|
104
|
+
desc: 'Build block mode. Default to Batch',
|
|
105
|
+
enum: [_1.BuildBlockMode.Batch, _1.BuildBlockMode.Manual, _1.BuildBlockMode.Instant],
|
|
106
|
+
},
|
|
107
|
+
'allow-unresolved-imports': {
|
|
108
|
+
desc: 'Allow wasm unresolved imports',
|
|
109
|
+
boolean: true,
|
|
110
|
+
},
|
|
111
|
+
}), async (argv) => {
|
|
112
|
+
await (0, _1.setupWithServer)(await processArgv(argv));
|
|
113
|
+
})
|
|
86
114
|
.command('run-block', 'Replay a block', (yargs) => yargs.options({
|
|
87
115
|
...defaultOptions,
|
|
116
|
+
...mockOptions,
|
|
88
117
|
'output-path': {
|
|
89
118
|
desc: 'File path to print output',
|
|
90
119
|
string: true,
|
|
91
120
|
},
|
|
92
|
-
'import-storage': {
|
|
93
|
-
desc: 'Pre-defined JSON/YAML storage file path',
|
|
94
|
-
string: true,
|
|
95
|
-
},
|
|
96
121
|
html: {
|
|
97
122
|
desc: 'Generate html with storage diff',
|
|
98
123
|
},
|
|
@@ -158,31 +183,6 @@ const defaultOptions = {
|
|
|
158
183
|
else {
|
|
159
184
|
await (0, dry_run_1.dryRun)(config);
|
|
160
185
|
}
|
|
161
|
-
})
|
|
162
|
-
.command('dev', 'Dev mode', (yargs) => yargs.options({
|
|
163
|
-
...defaultOptions,
|
|
164
|
-
port: {
|
|
165
|
-
desc: 'Port to listen on',
|
|
166
|
-
number: true,
|
|
167
|
-
},
|
|
168
|
-
'build-block-mode': {
|
|
169
|
-
desc: 'Build block mode. Default to Batch',
|
|
170
|
-
enum: [_1.BuildBlockMode.Batch, _1.BuildBlockMode.Manual, _1.BuildBlockMode.Instant],
|
|
171
|
-
},
|
|
172
|
-
'import-storage': {
|
|
173
|
-
desc: 'Pre-defined JSON/YAML storage file path',
|
|
174
|
-
string: true,
|
|
175
|
-
},
|
|
176
|
-
'mock-signature-host': {
|
|
177
|
-
desc: 'Mock signature host so any signature starts with 0xdeadbeef and filled by 0xcd is considered valid',
|
|
178
|
-
boolean: true,
|
|
179
|
-
},
|
|
180
|
-
'allow-unresolved-imports': {
|
|
181
|
-
desc: 'Allow wasm unresolved imports',
|
|
182
|
-
boolean: true,
|
|
183
|
-
},
|
|
184
|
-
}), async (argv) => {
|
|
185
|
-
await (0, _1.setupWithServer)(await processArgv(argv));
|
|
186
186
|
})
|
|
187
187
|
.command('decode-key <key>', 'Deocde a key', (yargs) => yargs
|
|
188
188
|
.positional('key', {
|
|
@@ -202,7 +202,8 @@ const defaultOptions = {
|
|
|
202
202
|
}
|
|
203
203
|
process.exit(0);
|
|
204
204
|
})
|
|
205
|
-
.command('xcm', 'XCM setup with relaychain and parachains', (yargs) => yargs
|
|
205
|
+
.command('xcm', 'XCM setup with relaychain and parachains', (yargs) => yargs
|
|
206
|
+
.options({
|
|
206
207
|
relaychain: {
|
|
207
208
|
desc: 'Relaychain config file path',
|
|
208
209
|
string: true,
|
|
@@ -213,7 +214,9 @@ const defaultOptions = {
|
|
|
213
214
|
string: true,
|
|
214
215
|
required: true,
|
|
215
216
|
},
|
|
216
|
-
})
|
|
217
|
+
})
|
|
218
|
+
.alias('relaychain', 'r')
|
|
219
|
+
.alias('parachain', 'p'), async (argv) => {
|
|
217
220
|
const parachains = [];
|
|
218
221
|
for (const config of argv.parachain) {
|
|
219
222
|
const { chain } = await (0, _1.setupWithServer)(await processConfig(config));
|
|
@@ -228,13 +231,16 @@ const defaultOptions = {
|
|
|
228
231
|
await (0, _1.connectVertical)(relaychain, parachain);
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
|
-
})
|
|
232
|
-
.command({
|
|
233
|
-
command: '*',
|
|
234
|
-
handler() {
|
|
235
|
-
yargs_1.default.showHelp();
|
|
236
|
-
},
|
|
237
234
|
})
|
|
238
235
|
.strict()
|
|
239
236
|
.help()
|
|
240
|
-
.alias('help', 'h')
|
|
237
|
+
.alias('help', 'h')
|
|
238
|
+
.alias('version', 'v')
|
|
239
|
+
.alias('config', 'c')
|
|
240
|
+
.alias('endpoint', 'e')
|
|
241
|
+
.alias('port', 'p')
|
|
242
|
+
.alias('block', 'b')
|
|
243
|
+
.alias('import-storage', 's')
|
|
244
|
+
.alias('wasm-override', 'w')
|
|
245
|
+
.usage('Usage: $0 <command> [options]')
|
|
246
|
+
.example('$0', '-c acala').argv;
|
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
|
-
|
|
21
|
-
|
|
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) => {
|
package/lib/genesis-provider.js
CHANGED
|
@@ -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', () => {
|
package/lib/rpc/dev/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const txpool_1 = require("@acala-network/chopsticks/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;
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -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").
|
|
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.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"author": "Bryan Chen <xlchen1291@gmail.com>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": "./chopsticks.js",
|
|
@@ -8,22 +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 --
|
|
12
|
-
"dev:karura": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts --
|
|
13
|
-
"dev:acala": "cd ../..; ts-node-dev --transpile-only --inspect --notify=false packages/chopsticks/src/cli.ts --
|
|
14
|
-
"dev:
|
|
15
|
-
"dev:
|
|
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"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@acala-network/chopsticks-executor": "0.6.
|
|
19
|
-
"@polkadot/api": "^10.
|
|
20
|
-
"
|
|
21
|
-
"@polkadot/types": "^10.2.1",
|
|
22
|
-
"@polkadot/types-codec": "^10.2.1",
|
|
23
|
-
"@polkadot/types-known": "^10.2.1",
|
|
24
|
-
"@polkadot/util": "^11.1.2",
|
|
25
|
-
"@polkadot/util-crypto": "^11.1.2",
|
|
26
|
-
"axios": "^1.3.4",
|
|
19
|
+
"@acala-network/chopsticks-executor": "0.6.3",
|
|
20
|
+
"@polkadot/api": "^10.5.1",
|
|
21
|
+
"axios": "^1.4.0",
|
|
27
22
|
"js-yaml": "^4.1.0",
|
|
28
23
|
"jsondiffpatch": "^0.4.1",
|
|
29
24
|
"lodash": "^4.17.21",
|
|
@@ -31,20 +26,20 @@
|
|
|
31
26
|
"pino-pretty": "^10.0.0",
|
|
32
27
|
"reflect-metadata": "^0.1.13",
|
|
33
28
|
"sqlite3": "^5.1.6",
|
|
34
|
-
"typeorm": "^0.3.
|
|
29
|
+
"typeorm": "^0.3.15",
|
|
35
30
|
"ws": "^8.13.0",
|
|
36
|
-
"yargs": "^17.7.
|
|
31
|
+
"yargs": "^17.7.2",
|
|
37
32
|
"zod": "^3.21.4"
|
|
38
33
|
},
|
|
39
34
|
"devDependencies": {
|
|
40
35
|
"@types/js-yaml": "^4.0.5",
|
|
41
|
-
"@types/lodash": "^4.14.
|
|
42
|
-
"@types/node": "^18.
|
|
36
|
+
"@types/lodash": "^4.14.194",
|
|
37
|
+
"@types/node": "^18.16.3",
|
|
43
38
|
"@types/ws": "^8.5.4",
|
|
44
39
|
"@types/yargs": "^17.0.24",
|
|
45
40
|
"ts-node": "^10.9.1",
|
|
46
41
|
"ts-node-dev": "^2.0.0",
|
|
47
|
-
"typescript": "^5.0.
|
|
42
|
+
"typescript": "^5.0.4"
|
|
48
43
|
},
|
|
49
44
|
"files": [
|
|
50
45
|
"lib",
|