@acala-network/chopsticks-core 0.16.0 → 0.16.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.
@@ -16,6 +16,9 @@ class SetNimbusAuthorInherent {
16
16
  if (!parent) throw new Error('parent block not found');
17
17
  const meta = await parent.meta;
18
18
  if (!meta.tx.authorInherent?.kickOffAuthorshipValidation) {
19
+ if (meta.query.authorNoting) {
20
+ newBlock.pushStorageLayer().set((0, _index.compactHex)(meta.query.authorNoting.didSetContainerAuthorData()), meta.registry.createType('bool', true).toHex());
21
+ }
19
22
  return [];
20
23
  }
21
24
  // mock author inherent data and authorities noting data
@@ -249,7 +249,7 @@ class SetValidationData {
249
249
  validationData: {
250
250
  ...extrinsic.validationData,
251
251
  relayParentStorageRoot: trieRootHash,
252
- relayParentNumber: extrinsic.validationData.relayParentNumber + relaySlotIncrease
252
+ relayParentNumber: params.relayParentNumber ?? extrinsic.validationData.relayParentNumber + relaySlotIncrease
253
253
  },
254
254
  relayChainState: {
255
255
  trieNodes: nodes
@@ -26,6 +26,7 @@ export interface BuildBlockParams {
26
26
  transactions: HexString[];
27
27
  unsafeBlockHeight?: number;
28
28
  relayChainStateOverrides?: [HexString, HexString | null][];
29
+ relayParentNumber?: number;
29
30
  }
30
31
  export declare class TxPool {
31
32
  #private;
@@ -194,6 +194,7 @@ class TxPool {
194
194
  };
195
195
  const unsafeBlockHeight = params?.unsafeBlockHeight;
196
196
  const relayChainStateOverrides = params?.relayChainStateOverrides;
197
+ const relayParentNumber = params?.relayParentNumber;
197
198
  if (!params?.upwardMessages) {
198
199
  for (const id of Object.keys(_class_private_field_get(this, _ump))){
199
200
  delete _class_private_field_get(this, _ump)[id];
@@ -211,7 +212,8 @@ class TxPool {
211
212
  downwardMessages,
212
213
  horizontalMessages,
213
214
  unsafeBlockHeight,
214
- relayChainStateOverrides
215
+ relayChainStateOverrides,
216
+ relayParentNumber
215
217
  });
216
218
  // with the latest message queue, messages could be processed in the upcoming block
217
219
  if (!_class_private_field_get(this, _chain).processQueuedMessages) return;
@@ -27,6 +27,7 @@ declare const schema: z.ZodObject<{
27
27
  transactions: z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">>;
28
28
  unsafeBlockHeight: z.ZodOptional<z.ZodNumber>;
29
29
  relayChainStateOverrides: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodNull]>], null>, "many">>;
30
+ relayParentNumber: z.ZodOptional<z.ZodNumber>;
30
31
  }, "strip", z.ZodTypeAny, {
31
32
  transactions?: `0x${string}`[] | undefined;
32
33
  unsafeBlockHeight?: number | undefined;
@@ -40,6 +41,7 @@ declare const schema: z.ZodObject<{
40
41
  sentAt: number;
41
42
  }[]> | undefined;
42
43
  relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
44
+ relayParentNumber?: number | undefined;
43
45
  count?: number | undefined;
44
46
  to?: number | undefined;
45
47
  }, {
@@ -55,6 +57,7 @@ declare const schema: z.ZodObject<{
55
57
  sentAt: number;
56
58
  }[]> | undefined;
57
59
  relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
60
+ relayParentNumber?: number | undefined;
58
61
  count?: number | undefined;
59
62
  to?: number | undefined;
60
63
  }>;
@@ -92,6 +95,10 @@ export interface NewBlockParams {
92
95
  * Build block using a custom relay chain state
93
96
  */
94
97
  relayChainStateOverrides: Params['relayChainStateOverrides'];
98
+ /**
99
+ * Build block using a custom relay parent number
100
+ */
101
+ relayParentNumber: Params['relayParentNumber'];
95
102
  }
96
103
  /**
97
104
  * Build new blocks.
@@ -34,10 +34,11 @@ const schema = _zod.z.object({
34
34
  _shared.zHex,
35
35
  _zod.z.null()
36
36
  ])
37
- ])).optional()
37
+ ])).optional(),
38
+ relayParentNumber: _zod.z.number().optional()
38
39
  });
39
40
  const dev_newBlock = async (context, [params])=>{
40
- const { count, to, hrmp, ump, dmp, transactions, unsafeBlockHeight, relayChainStateOverrides } = schema.parse(params || {});
41
+ const { count, to, hrmp, ump, dmp, transactions, unsafeBlockHeight, relayChainStateOverrides, relayParentNumber } = schema.parse(params || {});
41
42
  const now = context.chain.head.number;
42
43
  const diff = to ? to - now : count;
43
44
  const finalCount = diff !== undefined ? Math.max(diff, 1) : 1;
@@ -52,7 +53,8 @@ const dev_newBlock = async (context, [params])=>{
52
53
  upwardMessages: ump,
53
54
  downwardMessages: dmp,
54
55
  unsafeBlockHeight: i === 0 ? unsafeBlockHeight : undefined,
55
- relayChainStateOverrides: relayChainStateOverrides
56
+ relayChainStateOverrides: relayChainStateOverrides,
57
+ relayParentNumber: relayParentNumber
56
58
  }).catch((error)=>{
57
59
  throw new _shared.ResponseError(1, error.toString());
58
60
  });
@@ -7,6 +7,9 @@ export class SetNimbusAuthorInherent {
7
7
  if (!parent) throw new Error('parent block not found');
8
8
  const meta = await parent.meta;
9
9
  if (!meta.tx.authorInherent?.kickOffAuthorshipValidation) {
10
+ if (meta.query.authorNoting) {
11
+ newBlock.pushStorageLayer().set(compactHex(meta.query.authorNoting.didSetContainerAuthorData()), meta.registry.createType('bool', true).toHex());
12
+ }
10
13
  return [];
11
14
  }
12
15
  // mock author inherent data and authorities noting data
@@ -234,7 +234,7 @@ export class SetValidationData {
234
234
  validationData: {
235
235
  ...extrinsic.validationData,
236
236
  relayParentStorageRoot: trieRootHash,
237
- relayParentNumber: extrinsic.validationData.relayParentNumber + relaySlotIncrease
237
+ relayParentNumber: params.relayParentNumber ?? extrinsic.validationData.relayParentNumber + relaySlotIncrease
238
238
  },
239
239
  relayChainState: {
240
240
  trieNodes: nodes
@@ -26,6 +26,7 @@ export interface BuildBlockParams {
26
26
  transactions: HexString[];
27
27
  unsafeBlockHeight?: number;
28
28
  relayChainStateOverrides?: [HexString, HexString | null][];
29
+ relayParentNumber?: number;
29
30
  }
30
31
  export declare class TxPool {
31
32
  #private;
@@ -139,6 +139,7 @@ export class TxPool {
139
139
  };
140
140
  const unsafeBlockHeight = params?.unsafeBlockHeight;
141
141
  const relayChainStateOverrides = params?.relayChainStateOverrides;
142
+ const relayParentNumber = params?.relayParentNumber;
142
143
  if (!params?.upwardMessages) {
143
144
  for (const id of Object.keys(this.#ump)){
144
145
  delete this.#ump[id];
@@ -156,7 +157,8 @@ export class TxPool {
156
157
  downwardMessages,
157
158
  horizontalMessages,
158
159
  unsafeBlockHeight,
159
- relayChainStateOverrides
160
+ relayChainStateOverrides,
161
+ relayParentNumber
160
162
  });
161
163
  // with the latest message queue, messages could be processed in the upcoming block
162
164
  if (!this.#chain.processQueuedMessages) return;
@@ -27,6 +27,7 @@ declare const schema: z.ZodObject<{
27
27
  transactions: z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, "many">>;
28
28
  unsafeBlockHeight: z.ZodOptional<z.ZodNumber>;
29
29
  relayChainStateOverrides: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodUnion<[z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, z.ZodNull]>], null>, "many">>;
30
+ relayParentNumber: z.ZodOptional<z.ZodNumber>;
30
31
  }, "strip", z.ZodTypeAny, {
31
32
  transactions?: `0x${string}`[] | undefined;
32
33
  unsafeBlockHeight?: number | undefined;
@@ -40,6 +41,7 @@ declare const schema: z.ZodObject<{
40
41
  sentAt: number;
41
42
  }[]> | undefined;
42
43
  relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
44
+ relayParentNumber?: number | undefined;
43
45
  count?: number | undefined;
44
46
  to?: number | undefined;
45
47
  }, {
@@ -55,6 +57,7 @@ declare const schema: z.ZodObject<{
55
57
  sentAt: number;
56
58
  }[]> | undefined;
57
59
  relayChainStateOverrides?: [`0x${string}`, `0x${string}` | null][] | undefined;
60
+ relayParentNumber?: number | undefined;
58
61
  count?: number | undefined;
59
62
  to?: number | undefined;
60
63
  }>;
@@ -92,6 +95,10 @@ export interface NewBlockParams {
92
95
  * Build block using a custom relay chain state
93
96
  */
94
97
  relayChainStateOverrides: Params['relayChainStateOverrides'];
98
+ /**
99
+ * Build block using a custom relay parent number
100
+ */
101
+ relayParentNumber: Params['relayParentNumber'];
95
102
  }
96
103
  /**
97
104
  * Build new blocks.
@@ -24,7 +24,8 @@ const schema = z.object({
24
24
  zHex,
25
25
  z.null()
26
26
  ])
27
- ])).optional()
27
+ ])).optional(),
28
+ relayParentNumber: z.number().optional()
28
29
  });
29
30
  /**
30
31
  * Build new blocks.
@@ -64,7 +65,7 @@ const schema = z.object({
64
65
  * await ws.send('dev_newBlock', [{ count: 2, unsafeBlockHeight: 100000001 }])
65
66
  * ```
66
67
  */ export const dev_newBlock = async (context, [params])=>{
67
- const { count, to, hrmp, ump, dmp, transactions, unsafeBlockHeight, relayChainStateOverrides } = schema.parse(params || {});
68
+ const { count, to, hrmp, ump, dmp, transactions, unsafeBlockHeight, relayChainStateOverrides, relayParentNumber } = schema.parse(params || {});
68
69
  const now = context.chain.head.number;
69
70
  const diff = to ? to - now : count;
70
71
  const finalCount = diff !== undefined ? Math.max(diff, 1) : 1;
@@ -79,7 +80,8 @@ const schema = z.object({
79
80
  upwardMessages: ump,
80
81
  downwardMessages: dmp,
81
82
  unsafeBlockHeight: i === 0 ? unsafeBlockHeight : undefined,
82
- relayChainStateOverrides: relayChainStateOverrides
83
+ relayChainStateOverrides: relayChainStateOverrides,
84
+ relayParentNumber: relayParentNumber
83
85
  }).catch((error)=>{
84
86
  throw new ResponseError(1, error.toString());
85
87
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks-core",
3
- "version": "0.16.0",
3
+ "version": "0.16.2",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "depcheck": "npx depcheck"
12
12
  },
13
13
  "dependencies": {
14
- "@acala-network/chopsticks-executor": "0.16.0",
14
+ "@acala-network/chopsticks-executor": "0.16.2",
15
15
  "@polkadot/rpc-provider": "^12.3.1",
16
16
  "@polkadot/types": "^12.3.1",
17
17
  "@polkadot/types-codec": "^12.3.1",