@acala-network/chopsticks-core 1.2.8 → 1.3.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.
- package/dist/cjs/blockchain/inherent/parachain/validation-data.js +25 -1
- package/dist/cjs/xcm/upward.d.ts +4 -0
- package/dist/cjs/xcm/upward.js +25 -4
- package/dist/esm/blockchain/inherent/parachain/validation-data.js +25 -1
- package/dist/esm/xcm/upward.d.ts +4 -0
- package/dist/esm/xcm/upward.js +19 -1
- package/package.json +3 -3
|
@@ -256,6 +256,29 @@ class SetValidationData {
|
|
|
256
256
|
const relayParentNumber = params.relayParentNumber ?? extrinsic.validationData.relayParentNumber + relaySlotIncrease;
|
|
257
257
|
if (argsLengh === 1) {
|
|
258
258
|
// old version
|
|
259
|
+
let relayParentDescendants = extrinsic.relayParentDescendants;
|
|
260
|
+
if (relayParentDescendants) {
|
|
261
|
+
let fakeParentHeader = relayParentDescendants[0];
|
|
262
|
+
if (fakeParentHeader) {
|
|
263
|
+
fakeParentHeader = {
|
|
264
|
+
...fakeParentHeader,
|
|
265
|
+
number: relayParentNumber,
|
|
266
|
+
stateRoot: trieRootHash
|
|
267
|
+
};
|
|
268
|
+
relayParentDescendants = [
|
|
269
|
+
fakeParentHeader,
|
|
270
|
+
...relayParentDescendants.slice(1)
|
|
271
|
+
];
|
|
272
|
+
let lastHeader;
|
|
273
|
+
for (const descendant of relayParentDescendants){
|
|
274
|
+
if (lastHeader) {
|
|
275
|
+
descendant.parentHash = lastHeader.hash;
|
|
276
|
+
descendant.number = lastHeader.number.toNumber() + 1;
|
|
277
|
+
}
|
|
278
|
+
lastHeader = meta.registry.createType('Header', descendant);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
259
282
|
const newData = {
|
|
260
283
|
...extrinsic,
|
|
261
284
|
downwardMessages,
|
|
@@ -267,7 +290,8 @@ class SetValidationData {
|
|
|
267
290
|
},
|
|
268
291
|
relayChainState: {
|
|
269
292
|
trieNodes: nodes
|
|
270
|
-
}
|
|
293
|
+
},
|
|
294
|
+
relayParentDescendants
|
|
271
295
|
};
|
|
272
296
|
const inherent = new _types.GenericExtrinsic(meta.registry, meta.tx.parachainSystem.setValidationData(newData));
|
|
273
297
|
return [
|
package/dist/cjs/xcm/upward.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { Blockchain } from '../blockchain/index.js';
|
|
2
|
+
/** Filter out UMP signals, keeping only XCM messages before the empty separator. */
|
|
3
|
+
export declare function filterXcmMessages<T extends {
|
|
4
|
+
length: number;
|
|
5
|
+
}>(messages: T[]): T[];
|
|
2
6
|
export declare const connectUpward: (parachain: Blockchain, relaychain: Blockchain) => Promise<void>;
|
package/dist/cjs/xcm/upward.js
CHANGED
|
@@ -2,14 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get connectUpward () {
|
|
8
13
|
return connectUpward;
|
|
14
|
+
},
|
|
15
|
+
get filterXcmMessages () {
|
|
16
|
+
return filterXcmMessages;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
11
19
|
const _util = require("@polkadot/util");
|
|
12
20
|
const _index = require("../utils/index.js");
|
|
21
|
+
const _index1 = require("./index.js");
|
|
22
|
+
function filterXcmMessages(messages) {
|
|
23
|
+
const separatorIndex = messages.findIndex((m)=>m.length === 0);
|
|
24
|
+
if (separatorIndex === -1) return messages;
|
|
25
|
+
const signalCount = messages.length - separatorIndex - 1;
|
|
26
|
+
_index1.xcmLogger.debug({
|
|
27
|
+
xcmCount: separatorIndex,
|
|
28
|
+
signalCount
|
|
29
|
+
}, 'Filtered UMP signals from upward messages');
|
|
30
|
+
return messages.slice(0, separatorIndex);
|
|
31
|
+
}
|
|
13
32
|
const connectUpward = async (parachain, relaychain)=>{
|
|
14
33
|
const meta = await parachain.head.meta;
|
|
15
34
|
const paraId = (await (0, _index.getParaId)(parachain)).toNumber();
|
|
@@ -22,6 +41,8 @@ const connectUpward = async (parachain, relaychain)=>{
|
|
|
22
41
|
const meta = await relaychain.head.meta;
|
|
23
42
|
const upwardMessages = meta.registry.createType('Vec<Bytes>', (0, _util.hexToU8a)(value));
|
|
24
43
|
if (upwardMessages.length === 0) return;
|
|
25
|
-
|
|
44
|
+
const xcmMessages = filterXcmMessages(upwardMessages.toArray());
|
|
45
|
+
if (xcmMessages.length === 0) return;
|
|
46
|
+
relaychain.submitUpwardMessages(paraId, xcmMessages.map((x)=>x.toHex()));
|
|
26
47
|
});
|
|
27
48
|
};
|
|
@@ -241,6 +241,29 @@ export class SetValidationData {
|
|
|
241
241
|
const relayParentNumber = params.relayParentNumber ?? extrinsic.validationData.relayParentNumber + relaySlotIncrease;
|
|
242
242
|
if (argsLengh === 1) {
|
|
243
243
|
// old version
|
|
244
|
+
let relayParentDescendants = extrinsic.relayParentDescendants;
|
|
245
|
+
if (relayParentDescendants) {
|
|
246
|
+
let fakeParentHeader = relayParentDescendants[0];
|
|
247
|
+
if (fakeParentHeader) {
|
|
248
|
+
fakeParentHeader = {
|
|
249
|
+
...fakeParentHeader,
|
|
250
|
+
number: relayParentNumber,
|
|
251
|
+
stateRoot: trieRootHash
|
|
252
|
+
};
|
|
253
|
+
relayParentDescendants = [
|
|
254
|
+
fakeParentHeader,
|
|
255
|
+
...relayParentDescendants.slice(1)
|
|
256
|
+
];
|
|
257
|
+
let lastHeader;
|
|
258
|
+
for (const descendant of relayParentDescendants){
|
|
259
|
+
if (lastHeader) {
|
|
260
|
+
descendant.parentHash = lastHeader.hash;
|
|
261
|
+
descendant.number = lastHeader.number.toNumber() + 1;
|
|
262
|
+
}
|
|
263
|
+
lastHeader = meta.registry.createType('Header', descendant);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
244
267
|
const newData = {
|
|
245
268
|
...extrinsic,
|
|
246
269
|
downwardMessages,
|
|
@@ -252,7 +275,8 @@ export class SetValidationData {
|
|
|
252
275
|
},
|
|
253
276
|
relayChainState: {
|
|
254
277
|
trieNodes: nodes
|
|
255
|
-
}
|
|
278
|
+
},
|
|
279
|
+
relayParentDescendants
|
|
256
280
|
};
|
|
257
281
|
const inherent = new GenericExtrinsic(meta.registry, meta.tx.parachainSystem.setValidationData(newData));
|
|
258
282
|
return [
|
package/dist/esm/xcm/upward.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { Blockchain } from '../blockchain/index.js';
|
|
2
|
+
/** Filter out UMP signals, keeping only XCM messages before the empty separator. */
|
|
3
|
+
export declare function filterXcmMessages<T extends {
|
|
4
|
+
length: number;
|
|
5
|
+
}>(messages: T[]): T[];
|
|
2
6
|
export declare const connectUpward: (parachain: Blockchain, relaychain: Blockchain) => Promise<void>;
|
package/dist/esm/xcm/upward.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { hexToU8a } from '@polkadot/util';
|
|
2
2
|
import { compactHex, getParaId } from '../utils/index.js';
|
|
3
|
+
import { xcmLogger } from './index.js';
|
|
4
|
+
// The UpwardMessages storage contains both XCM messages and UMP signals (e.g. SelectCore,
|
|
5
|
+
// ApprovedPeer for elastic scaling), separated by an empty entry (UMP_SEPARATOR).
|
|
6
|
+
// Only messages before the separator are XCM; everything after is signals for the relay
|
|
7
|
+
// chain validators. This mirrors `skip_ump_signals` in the SDK's Polkadot primitives.
|
|
8
|
+
// See: [`polkadot-sdk/polkadot/primitives/src/v9/mod.rs`](https://github.com/paritytech/polkadot-sdk/blob/ff555bbd5b397e9984a42c34a799de8e5449f19f/polkadot/primitives/src/v9/mod.rs#L2771)
|
|
9
|
+
/** Filter out UMP signals, keeping only XCM messages before the empty separator. */ export function filterXcmMessages(messages) {
|
|
10
|
+
const separatorIndex = messages.findIndex((m)=>m.length === 0);
|
|
11
|
+
if (separatorIndex === -1) return messages;
|
|
12
|
+
const signalCount = messages.length - separatorIndex - 1;
|
|
13
|
+
xcmLogger.debug({
|
|
14
|
+
xcmCount: separatorIndex,
|
|
15
|
+
signalCount
|
|
16
|
+
}, 'Filtered UMP signals from upward messages');
|
|
17
|
+
return messages.slice(0, separatorIndex);
|
|
18
|
+
}
|
|
3
19
|
export const connectUpward = async (parachain, relaychain)=>{
|
|
4
20
|
const meta = await parachain.head.meta;
|
|
5
21
|
const paraId = (await getParaId(parachain)).toNumber();
|
|
@@ -12,6 +28,8 @@ export const connectUpward = async (parachain, relaychain)=>{
|
|
|
12
28
|
const meta = await relaychain.head.meta;
|
|
13
29
|
const upwardMessages = meta.registry.createType('Vec<Bytes>', hexToU8a(value));
|
|
14
30
|
if (upwardMessages.length === 0) return;
|
|
15
|
-
|
|
31
|
+
const xcmMessages = filterXcmMessages(upwardMessages.toArray());
|
|
32
|
+
if (xcmMessages.length === 0) return;
|
|
33
|
+
relaychain.submitUpwardMessages(paraId, xcmMessages.map((x)=>x.toHex()));
|
|
16
34
|
});
|
|
17
35
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"depcheck": "npx depcheck"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@acala-network/chopsticks-executor": "1.
|
|
17
|
+
"@acala-network/chopsticks-executor": "1.3.1",
|
|
18
18
|
"@polkadot/rpc-provider": "^16.4.1",
|
|
19
19
|
"@polkadot/types": "^16.4.1",
|
|
20
20
|
"@polkadot/types-codec": "^16.4.1",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@polkadot/util-crypto": "^14.0.1",
|
|
24
24
|
"comlink": "^4.4.2",
|
|
25
25
|
"eventemitter3": "^5.0.1",
|
|
26
|
-
"lodash": "^4.
|
|
26
|
+
"lodash": "^4.18.1",
|
|
27
27
|
"lru-cache": "^11.1.0",
|
|
28
28
|
"pino": "^9.7.0",
|
|
29
29
|
"pino-pretty": "^13.0.0",
|