@acala-network/chopsticks-core 0.9.1 → 0.9.2-2
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/dist/cjs/blockchain/block.js +0 -1
- package/dist/cjs/blockchain/inherent/parachain/validation-data.js +20 -4
- package/dist/cjs/utils/index.js +0 -33
- package/dist/cjs/utils/proof.js +7 -0
- package/dist/esm/blockchain/block.js +1 -2
- package/dist/esm/blockchain/inherent/parachain/validation-data.js +22 -6
- package/dist/esm/utils/index.js +0 -27
- package/dist/esm/utils/proof.js +4 -0
- package/dist/types/utils/index.d.ts +0 -3
- package/dist/types/utils/proof.d.ts +1 -0
- package/package.json +2 -2
|
@@ -257,7 +257,6 @@ class Block {
|
|
|
257
257
|
runtimeLogLevel: _class_private_field_get(this, _chain).runtimeLogLevel
|
|
258
258
|
}, (0, _index1.taskHandler)(this));
|
|
259
259
|
if ('Call' in response) {
|
|
260
|
-
(0, _index.printRuntimeLogs)(response.Call.runtimeLogs);
|
|
261
260
|
if (this.chain.offchainWorker) {
|
|
262
261
|
// apply offchain storage
|
|
263
262
|
for (const [key, value] of response.Call.offchainStorageDiff){
|
|
@@ -79,10 +79,20 @@ class SetValidationData {
|
|
|
79
79
|
hrmpEgressChannelIndexKey
|
|
80
80
|
], extrinsic.relayChainState.trieNodes);
|
|
81
81
|
for (const key of Object.values(_proof.WELL_KNOWN_KEYS)){
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
decoded[key]
|
|
85
|
-
|
|
82
|
+
if (key === _proof.WELL_KNOWN_KEYS.CURRENT_SLOT) {
|
|
83
|
+
// increment current slot
|
|
84
|
+
const currentSlot = meta.registry.createType('Slot', (0, _util.hexToU8a)(decoded[key])).toNumber();
|
|
85
|
+
const newSlot = meta.registry.createType('Slot', currentSlot + 2);
|
|
86
|
+
newEntries.push([
|
|
87
|
+
key,
|
|
88
|
+
(0, _util.u8aToHex)(newSlot.toU8a())
|
|
89
|
+
]);
|
|
90
|
+
} else {
|
|
91
|
+
newEntries.push([
|
|
92
|
+
key,
|
|
93
|
+
decoded[key]
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
86
96
|
}
|
|
87
97
|
newEntries.push([
|
|
88
98
|
hrmpIngressChannelIndexKey,
|
|
@@ -92,6 +102,12 @@ class SetValidationData {
|
|
|
92
102
|
hrmpEgressChannelIndexKey,
|
|
93
103
|
decoded[hrmpEgressChannelIndexKey]
|
|
94
104
|
]);
|
|
105
|
+
// inject paraHead
|
|
106
|
+
const headData = meta.registry.createType('HeadData', (await parent.header).toHex());
|
|
107
|
+
newEntries.push([
|
|
108
|
+
(0, _proof.paraHead)(paraId),
|
|
109
|
+
(0, _util.u8aToHex)(headData.toU8a())
|
|
110
|
+
]);
|
|
95
111
|
// inject downward messages
|
|
96
112
|
let dmqMqcHeadHash = decoded[dmqMqcHeadKey];
|
|
97
113
|
if (dmqMqcHeadHash) {
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -21,9 +21,6 @@ _export(exports, {
|
|
|
21
21
|
fetchKeysToArray: function() {
|
|
22
22
|
return fetchKeysToArray;
|
|
23
23
|
},
|
|
24
|
-
formatRuntimeLog: function() {
|
|
25
|
-
return formatRuntimeLog;
|
|
26
|
-
},
|
|
27
24
|
getParaId: function() {
|
|
28
25
|
return getParaId;
|
|
29
26
|
},
|
|
@@ -36,9 +33,6 @@ _export(exports, {
|
|
|
36
33
|
prefixedChildKey: function() {
|
|
37
34
|
return prefixedChildKey;
|
|
38
35
|
},
|
|
39
|
-
printRuntimeLogs: function() {
|
|
40
|
-
return printRuntimeLogs;
|
|
41
|
-
},
|
|
42
36
|
splitChildKey: function() {
|
|
43
37
|
return splitChildKey;
|
|
44
38
|
},
|
|
@@ -136,30 +130,3 @@ const stripChildPrefix = (key)=>{
|
|
|
136
130
|
if (!child) return key;
|
|
137
131
|
return storageKey;
|
|
138
132
|
};
|
|
139
|
-
const logLevels = [
|
|
140
|
-
'OFF',
|
|
141
|
-
'ERROR',
|
|
142
|
-
'WARN',
|
|
143
|
-
'INFO',
|
|
144
|
-
'DEBUG',
|
|
145
|
-
'TRACE'
|
|
146
|
-
];
|
|
147
|
-
const formatRuntimeLog = (log)=>{
|
|
148
|
-
let msg = '';
|
|
149
|
-
if (log.level != null) {
|
|
150
|
-
msg += `${logLevels[log.level]}\t `;
|
|
151
|
-
}
|
|
152
|
-
if (log.target) {
|
|
153
|
-
msg += `[${log.target}]:\t `;
|
|
154
|
-
}
|
|
155
|
-
msg += log.message;
|
|
156
|
-
return msg;
|
|
157
|
-
};
|
|
158
|
-
const printRuntimeLogs = (logs)=>{
|
|
159
|
-
if (!logs.length) return;
|
|
160
|
-
console.group('RuntimeLogs:');
|
|
161
|
-
for (const log of logs){
|
|
162
|
-
console.log(formatRuntimeLog(log));
|
|
163
|
-
}
|
|
164
|
-
console.groupEnd();
|
|
165
|
-
};
|
package/dist/cjs/utils/proof.js
CHANGED
|
@@ -24,6 +24,9 @@ _export(exports, {
|
|
|
24
24
|
hrmpIngressChannelIndex: function() {
|
|
25
25
|
return hrmpIngressChannelIndex;
|
|
26
26
|
},
|
|
27
|
+
paraHead: function() {
|
|
28
|
+
return paraHead;
|
|
29
|
+
},
|
|
27
30
|
upgradeGoAheadSignal: function() {
|
|
28
31
|
return upgradeGoAheadSignal;
|
|
29
32
|
}
|
|
@@ -61,3 +64,7 @@ const hrmpChannels = (channelId)=>{
|
|
|
61
64
|
const prefix = '0x6a0da05ca59913bc38a8630590f2627cb6604cff828a6e3f579ca6c59ace013d';
|
|
62
65
|
return hash(prefix, channelId.toU8a());
|
|
63
66
|
};
|
|
67
|
+
const paraHead = (paraId)=>{
|
|
68
|
+
const prefix = '0xcd710b30bd2eab0352ddcc26417aa1941b3c252fcb29d88eff4f3de5de4476c3';
|
|
69
|
+
return hash(prefix, paraId.toU8a());
|
|
70
|
+
};
|
|
@@ -3,7 +3,7 @@ import { expandMetadata } from '@polkadot/types/metadata';
|
|
|
3
3
|
import { getSpecExtensions, getSpecHasher, getSpecTypes } from '@polkadot/types-known/util';
|
|
4
4
|
import { hexToU8a, objectSpread, stringToHex } from '@polkadot/util';
|
|
5
5
|
import { RemoteStorageLayer, StorageLayer, StorageValueKind } from './storage-layer.js';
|
|
6
|
-
import { compactHex
|
|
6
|
+
import { compactHex } from '../utils/index.js';
|
|
7
7
|
import { getRuntimeVersion, runTask, taskHandler } from '../wasm-executor/index.js';
|
|
8
8
|
/**
|
|
9
9
|
* Block class.
|
|
@@ -247,7 +247,6 @@ import { getRuntimeVersion, runTask, taskHandler } from '../wasm-executor/index.
|
|
|
247
247
|
runtimeLogLevel: this.#chain.runtimeLogLevel
|
|
248
248
|
}, taskHandler(this));
|
|
249
249
|
if ('Call' in response) {
|
|
250
|
-
printRuntimeLogs(response.Call.runtimeLogs);
|
|
251
250
|
if (this.chain.offchainWorker) {
|
|
252
251
|
// apply offchain storage
|
|
253
252
|
for (const [key, value] of response.Call.offchainStorageDiff){
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GenericExtrinsic } from '@polkadot/types';
|
|
2
|
-
import { hexToU8a, u8aConcat } from '@polkadot/util';
|
|
2
|
+
import { hexToU8a, u8aConcat, u8aToHex } from '@polkadot/util';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import { WELL_KNOWN_KEYS, dmqMqcHead, hrmpChannels, hrmpEgressChannelIndex, hrmpIngressChannelIndex, upgradeGoAheadSignal } from '../../../utils/proof.js';
|
|
4
|
+
import { WELL_KNOWN_KEYS, dmqMqcHead, hrmpChannels, hrmpEgressChannelIndex, hrmpIngressChannelIndex, paraHead, upgradeGoAheadSignal } from '../../../utils/proof.js';
|
|
5
5
|
import { blake2AsHex, blake2AsU8a } from '@polkadot/util-crypto';
|
|
6
6
|
import { compactHex, getParaId } from '../../../utils/index.js';
|
|
7
7
|
import { createProof, decodeProof } from '../../../wasm-executor/index.js';
|
|
@@ -64,10 +64,20 @@ export class SetValidationData {
|
|
|
64
64
|
hrmpEgressChannelIndexKey
|
|
65
65
|
], extrinsic.relayChainState.trieNodes);
|
|
66
66
|
for (const key of Object.values(WELL_KNOWN_KEYS)){
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
decoded[key]
|
|
70
|
-
|
|
67
|
+
if (key === WELL_KNOWN_KEYS.CURRENT_SLOT) {
|
|
68
|
+
// increment current slot
|
|
69
|
+
const currentSlot = meta.registry.createType('Slot', hexToU8a(decoded[key])).toNumber();
|
|
70
|
+
const newSlot = meta.registry.createType('Slot', currentSlot + 2);
|
|
71
|
+
newEntries.push([
|
|
72
|
+
key,
|
|
73
|
+
u8aToHex(newSlot.toU8a())
|
|
74
|
+
]);
|
|
75
|
+
} else {
|
|
76
|
+
newEntries.push([
|
|
77
|
+
key,
|
|
78
|
+
decoded[key]
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
71
81
|
}
|
|
72
82
|
newEntries.push([
|
|
73
83
|
hrmpIngressChannelIndexKey,
|
|
@@ -77,6 +87,12 @@ export class SetValidationData {
|
|
|
77
87
|
hrmpEgressChannelIndexKey,
|
|
78
88
|
decoded[hrmpEgressChannelIndexKey]
|
|
79
89
|
]);
|
|
90
|
+
// inject paraHead
|
|
91
|
+
const headData = meta.registry.createType('HeadData', (await parent.header).toHex());
|
|
92
|
+
newEntries.push([
|
|
93
|
+
paraHead(paraId),
|
|
94
|
+
u8aToHex(headData.toU8a())
|
|
95
|
+
]);
|
|
80
96
|
// inject downward messages
|
|
81
97
|
let dmqMqcHeadHash = decoded[dmqMqcHeadKey];
|
|
82
98
|
if (dmqMqcHeadHash) {
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -79,30 +79,3 @@ export const stripChildPrefix = (key)=>{
|
|
|
79
79
|
if (!child) return key;
|
|
80
80
|
return storageKey;
|
|
81
81
|
};
|
|
82
|
-
const logLevels = [
|
|
83
|
-
'OFF',
|
|
84
|
-
'ERROR',
|
|
85
|
-
'WARN',
|
|
86
|
-
'INFO',
|
|
87
|
-
'DEBUG',
|
|
88
|
-
'TRACE'
|
|
89
|
-
];
|
|
90
|
-
export const formatRuntimeLog = (log)=>{
|
|
91
|
-
let msg = '';
|
|
92
|
-
if (log.level != null) {
|
|
93
|
-
msg += `${logLevels[log.level]}\t `;
|
|
94
|
-
}
|
|
95
|
-
if (log.target) {
|
|
96
|
-
msg += `[${log.target}]:\t `;
|
|
97
|
-
}
|
|
98
|
-
msg += log.message;
|
|
99
|
-
return msg;
|
|
100
|
-
};
|
|
101
|
-
export const printRuntimeLogs = (logs)=>{
|
|
102
|
-
if (!logs.length) return;
|
|
103
|
-
console.group('RuntimeLogs:');
|
|
104
|
-
for (const log of logs){
|
|
105
|
-
console.log(formatRuntimeLog(log));
|
|
106
|
-
}
|
|
107
|
-
console.groupEnd();
|
|
108
|
-
};
|
package/dist/esm/utils/proof.js
CHANGED
|
@@ -31,3 +31,7 @@ export const hrmpChannels = (channelId)=>{
|
|
|
31
31
|
const prefix = '0x6a0da05ca59913bc38a8630590f2627cb6604cff828a6e3f579ca6c59ace013d';
|
|
32
32
|
return hash(prefix, channelId.toU8a());
|
|
33
33
|
};
|
|
34
|
+
export const paraHead = (paraId)=>{
|
|
35
|
+
const prefix = '0xcd710b30bd2eab0352ddcc26417aa1941b3c252fcb29d88eff4f3de5de4476c3';
|
|
36
|
+
return hash(prefix, paraId.toU8a());
|
|
37
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { HexString } from '@polkadot/util/types';
|
|
2
2
|
import { StorageKey } from '@polkadot/types';
|
|
3
3
|
import { Blockchain } from '../blockchain/index.js';
|
|
4
|
-
import { RuntimeLog } from '../wasm-executor/index.js';
|
|
5
4
|
export * from './set-storage.js';
|
|
6
5
|
export * from './time-travel.js';
|
|
7
6
|
export * from './decoder.js';
|
|
@@ -22,5 +21,3 @@ export declare const prefixedChildKey: (prefix: HexString, key: HexString) => st
|
|
|
22
21
|
export declare const isPrefixedChildKey: (key: HexString) => boolean;
|
|
23
22
|
export declare const splitChildKey: (key: HexString) => never[] | [`0x${string}`, `0x${string}`];
|
|
24
23
|
export declare const stripChildPrefix: (key: HexString) => `0x${string}`;
|
|
25
|
-
export declare const formatRuntimeLog: (log: RuntimeLog) => string;
|
|
26
|
-
export declare const printRuntimeLogs: (logs: RuntimeLog[]) => void;
|
|
@@ -13,3 +13,4 @@ export declare const upgradeGoAheadSignal: (paraId: u32) => `0x${string}`;
|
|
|
13
13
|
export declare const hrmpIngressChannelIndex: (paraId: u32) => `0x${string}`;
|
|
14
14
|
export declare const hrmpEgressChannelIndex: (paraId: u32) => `0x${string}`;
|
|
15
15
|
export declare const hrmpChannels: (channelId: HrmpChannelId) => `0x${string}`;
|
|
16
|
+
export declare const paraHead: (paraId: u32) => `0x${string}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks-core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2-2",
|
|
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.
|
|
16
|
+
"@acala-network/chopsticks-executor": "0.9.2-2",
|
|
17
17
|
"@polkadot/api": "^10.10.1",
|
|
18
18
|
"@polkadot/util-crypto": "^12.5.1",
|
|
19
19
|
"comlink": "^4.4.1",
|