@acala-network/chopsticks-core 1.2.8 → 1.3.0
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/xcm/upward.d.ts +4 -0
- package/dist/cjs/xcm/upward.js +25 -4
- package/dist/esm/xcm/upward.d.ts +4 -0
- package/dist/esm/xcm/upward.js +19 -1
- package/package.json +2 -2
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
|
};
|
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.0",
|
|
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.0",
|
|
18
18
|
"@polkadot/rpc-provider": "^16.4.1",
|
|
19
19
|
"@polkadot/types": "^16.4.1",
|
|
20
20
|
"@polkadot/types-codec": "^16.4.1",
|