@acala-network/chopsticks-core 1.4.0 → 1.4.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/inherent/index.d.ts +2 -1
- package/dist/cjs/blockchain/inherent/index.js +3 -1
- package/dist/cjs/blockchain/inherent/transaction-storage.d.ts +6 -0
- package/dist/cjs/blockchain/inherent/transaction-storage.js +34 -0
- package/dist/esm/blockchain/inherent/index.d.ts +2 -1
- package/dist/esm/blockchain/inherent/index.js +3 -1
- package/dist/esm/blockchain/inherent/transaction-storage.d.ts +6 -0
- package/dist/esm/blockchain/inherent/transaction-storage.js +24 -0
- package/package.json +3 -3
|
@@ -6,7 +6,8 @@ import { SetBabeRandomness } from './parachain/babe-randomness.js';
|
|
|
6
6
|
import { SetNimbusAuthorInherent } from './parachain/nimbus-author-inherent.js';
|
|
7
7
|
import { SetValidationData } from './parachain/validation-data.js';
|
|
8
8
|
import { SetTimestamp } from './timestamp.js';
|
|
9
|
+
import { SetTransactionStorageProof } from './transaction-storage.js';
|
|
9
10
|
export interface InherentProvider {
|
|
10
11
|
createInherents(newBlock: Block, params: BuildBlockParams): Promise<HexString[]>;
|
|
11
12
|
}
|
|
12
|
-
export declare const inherentProviders: (ParaInherentEnter | SetBabeRandomness | SetNimbusAuthorInherent | SetValidationData | SetTimestamp)[];
|
|
13
|
+
export declare const inherentProviders: (ParaInherentEnter | SetBabeRandomness | SetNimbusAuthorInherent | SetValidationData | SetTimestamp | SetTransactionStorageProof)[];
|
|
@@ -13,10 +13,12 @@ const _baberandomness = require("./parachain/babe-randomness.js");
|
|
|
13
13
|
const _nimbusauthorinherent = require("./parachain/nimbus-author-inherent.js");
|
|
14
14
|
const _validationdata = require("./parachain/validation-data.js");
|
|
15
15
|
const _timestamp = require("./timestamp.js");
|
|
16
|
+
const _transactionstorage = require("./transaction-storage.js");
|
|
16
17
|
const inherentProviders = [
|
|
17
18
|
new _timestamp.SetTimestamp(),
|
|
18
19
|
new _validationdata.SetValidationData(),
|
|
19
20
|
new _paraenter.ParaInherentEnter(),
|
|
20
21
|
new _nimbusauthorinherent.SetNimbusAuthorInherent(),
|
|
21
|
-
new _baberandomness.SetBabeRandomness()
|
|
22
|
+
new _baberandomness.SetBabeRandomness(),
|
|
23
|
+
new _transactionstorage.SetTransactionStorageProof()
|
|
22
24
|
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { Block } from '../block.js';
|
|
3
|
+
import type { InherentProvider } from './index.js';
|
|
4
|
+
export declare class SetTransactionStorageProof implements InherentProvider {
|
|
5
|
+
createInherents(newBlock: Block): Promise<HexString[]>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "SetTransactionStorageProof", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return SetTransactionStorageProof;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _types = require("@polkadot/types");
|
|
12
|
+
const _index = require("../../utils/index.js");
|
|
13
|
+
class SetTransactionStorageProof {
|
|
14
|
+
async createInherents(newBlock) {
|
|
15
|
+
const parent = await newBlock.parentBlock;
|
|
16
|
+
if (!parent) throw new Error('parent block not found');
|
|
17
|
+
const meta = await parent.meta;
|
|
18
|
+
if (!meta.tx.transactionStorage?.applyBlockInherents) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
// The runtime's on_finalize asserts ProofChecked was set when stored
|
|
22
|
+
// transactions exist at (block - RetentionPeriod). Generating a real
|
|
23
|
+
// proof requires the original chunk data Chopsticks doesn't have, so
|
|
24
|
+
// we force the flag via storage override instead.
|
|
25
|
+
if (meta.query.transactionStorage?.proofChecked) {
|
|
26
|
+
const key = (0, _index.compactHex)(meta.query.transactionStorage.proofChecked());
|
|
27
|
+
newBlock.pushStorageLayer().set(key, '0x01');
|
|
28
|
+
}
|
|
29
|
+
const inherent = new _types.GenericExtrinsic(meta.registry, meta.tx.transactionStorage.applyBlockInherents(null));
|
|
30
|
+
return [
|
|
31
|
+
inherent.toHex()
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -6,7 +6,8 @@ import { SetBabeRandomness } from './parachain/babe-randomness.js';
|
|
|
6
6
|
import { SetNimbusAuthorInherent } from './parachain/nimbus-author-inherent.js';
|
|
7
7
|
import { SetValidationData } from './parachain/validation-data.js';
|
|
8
8
|
import { SetTimestamp } from './timestamp.js';
|
|
9
|
+
import { SetTransactionStorageProof } from './transaction-storage.js';
|
|
9
10
|
export interface InherentProvider {
|
|
10
11
|
createInherents(newBlock: Block, params: BuildBlockParams): Promise<HexString[]>;
|
|
11
12
|
}
|
|
12
|
-
export declare const inherentProviders: (ParaInherentEnter | SetBabeRandomness | SetNimbusAuthorInherent | SetValidationData | SetTimestamp)[];
|
|
13
|
+
export declare const inherentProviders: (ParaInherentEnter | SetBabeRandomness | SetNimbusAuthorInherent | SetValidationData | SetTimestamp | SetTransactionStorageProof)[];
|
|
@@ -3,10 +3,12 @@ import { SetBabeRandomness } from './parachain/babe-randomness.js';
|
|
|
3
3
|
import { SetNimbusAuthorInherent } from './parachain/nimbus-author-inherent.js';
|
|
4
4
|
import { SetValidationData } from './parachain/validation-data.js';
|
|
5
5
|
import { SetTimestamp } from './timestamp.js';
|
|
6
|
+
import { SetTransactionStorageProof } from './transaction-storage.js';
|
|
6
7
|
export const inherentProviders = [
|
|
7
8
|
new SetTimestamp(),
|
|
8
9
|
new SetValidationData(),
|
|
9
10
|
new ParaInherentEnter(),
|
|
10
11
|
new SetNimbusAuthorInherent(),
|
|
11
|
-
new SetBabeRandomness()
|
|
12
|
+
new SetBabeRandomness(),
|
|
13
|
+
new SetTransactionStorageProof()
|
|
12
14
|
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { Block } from '../block.js';
|
|
3
|
+
import type { InherentProvider } from './index.js';
|
|
4
|
+
export declare class SetTransactionStorageProof implements InherentProvider {
|
|
5
|
+
createInherents(newBlock: Block): Promise<HexString[]>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GenericExtrinsic } from '@polkadot/types';
|
|
2
|
+
import { compactHex } from '../../utils/index.js';
|
|
3
|
+
export class SetTransactionStorageProof {
|
|
4
|
+
async createInherents(newBlock) {
|
|
5
|
+
const parent = await newBlock.parentBlock;
|
|
6
|
+
if (!parent) throw new Error('parent block not found');
|
|
7
|
+
const meta = await parent.meta;
|
|
8
|
+
if (!meta.tx.transactionStorage?.applyBlockInherents) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
// The runtime's on_finalize asserts ProofChecked was set when stored
|
|
12
|
+
// transactions exist at (block - RetentionPeriod). Generating a real
|
|
13
|
+
// proof requires the original chunk data Chopsticks doesn't have, so
|
|
14
|
+
// we force the flag via storage override instead.
|
|
15
|
+
if (meta.query.transactionStorage?.proofChecked) {
|
|
16
|
+
const key = compactHex(meta.query.transactionStorage.proofChecked());
|
|
17
|
+
newBlock.pushStorageLayer().set(key, '0x01');
|
|
18
|
+
}
|
|
19
|
+
const inherent = new GenericExtrinsic(meta.registry, meta.tx.transactionStorage.applyBlockInherents(null));
|
|
20
|
+
return [
|
|
21
|
+
inherent.toHex()
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks-core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
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.4.
|
|
17
|
+
"@acala-network/chopsticks-executor": "1.4.2",
|
|
18
18
|
"@polkadot/rpc-provider": "^16.4.1",
|
|
19
19
|
"@polkadot/types": "^16.4.1",
|
|
20
20
|
"@polkadot/types-codec": "^16.4.1",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@swc/core": "^1.12.14",
|
|
36
36
|
"@types/lodash": "^4.17.20",
|
|
37
37
|
"typescript": "^5.8.3",
|
|
38
|
-
"vitest": "^4.0
|
|
38
|
+
"vitest": "^4.1.0"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"dist/esm/**",
|