@typeberry/lib 0.1.2-60899f7 → 0.1.2-753d258
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/bin/lib/index.d.ts +29 -0
- package/configs/index.d.ts +76 -0
- package/index.cjs +49 -87
- package/index.d.ts +18 -46
- package/index.js +49 -87
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * as block from "@typeberry/block";
|
|
2
|
+
export * as block_json from "@typeberry/block-json";
|
|
3
|
+
export * as bytes from "@typeberry/bytes";
|
|
4
|
+
export * as codec from "@typeberry/codec";
|
|
5
|
+
export * as collections from "@typeberry/collections";
|
|
6
|
+
export * as config from "@typeberry/config";
|
|
7
|
+
export * as config_node from "@typeberry/config-node";
|
|
8
|
+
export * as crypto from "@typeberry/crypto";
|
|
9
|
+
export * as database from "@typeberry/database";
|
|
10
|
+
export * as erasure_coding from "@typeberry/erasure-coding";
|
|
11
|
+
export * as hash from "@typeberry/hash";
|
|
12
|
+
export * as jam_host_calls from "@typeberry/jam-host-calls";
|
|
13
|
+
export * as json_parser from "@typeberry/json-parser";
|
|
14
|
+
export * as logger from "@typeberry/logger";
|
|
15
|
+
export * as mmr from "@typeberry/mmr";
|
|
16
|
+
export * as numbers from "@typeberry/numbers";
|
|
17
|
+
export * as ordering from "@typeberry/ordering";
|
|
18
|
+
export * as pvm from "@typeberry/pvm-debugger-adapter";
|
|
19
|
+
export * as pvm_host_calls from "@typeberry/pvm-host-calls";
|
|
20
|
+
export * as pvm_interpreter from "@typeberry/pvm-interpreter";
|
|
21
|
+
export * as pvm_program from "@typeberry/pvm-program";
|
|
22
|
+
export * as pvm_spi_decoder from "@typeberry/pvm-spi-decoder";
|
|
23
|
+
export * as shuffling from "@typeberry/shuffling";
|
|
24
|
+
export * as state from "@typeberry/state";
|
|
25
|
+
export * as state_json from "@typeberry/state-json";
|
|
26
|
+
export * as state_merkleization from "@typeberry/state-merkleization";
|
|
27
|
+
export * as transition from "@typeberry/transition";
|
|
28
|
+
export * as trie from "@typeberry/trie";
|
|
29
|
+
export * as utils from "@typeberry/utils";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export declare const configs: {
|
|
2
|
+
default: {
|
|
3
|
+
$schema: string;
|
|
4
|
+
version: number;
|
|
5
|
+
flavor: string;
|
|
6
|
+
authorship: {
|
|
7
|
+
omit_seal_verification: boolean;
|
|
8
|
+
};
|
|
9
|
+
chain_spec: {
|
|
10
|
+
id: string;
|
|
11
|
+
bootnodes: string[];
|
|
12
|
+
genesis_header: string;
|
|
13
|
+
genesis_state: {
|
|
14
|
+
"0b000000000000000000000000000000000000000000000000000000000000": string;
|
|
15
|
+
"04000000000000000000000000000000000000000000000000000000000000": string;
|
|
16
|
+
"08000000000000000000000000000000000000000000000000000000000000": string;
|
|
17
|
+
"07000000000000000000000000000000000000000000000000000000000000": string;
|
|
18
|
+
"00c500b600120062b94ad574028369bc6bd19a65f989134c022ea372cd4df6": string;
|
|
19
|
+
"00ad0027003e003dc43472190923b0d2a1755796224bd5684c60fd0f6872c8": string;
|
|
20
|
+
"008000c100e3000732d3152ca7f3bbf14ff40da18def60c6f78e93e4602f3d": string;
|
|
21
|
+
"00f800e700990073c506a4ae6f6c368ca2c41dd8270472e9590c9ada0b87db": string;
|
|
22
|
+
"09000000000000000000000000000000000000000000000000000000000000": string;
|
|
23
|
+
ff000000000000000000000000000000000000000000000000000000000000: string;
|
|
24
|
+
"0d000000000000000000000000000000000000000000000000000000000000": string;
|
|
25
|
+
"01000000000000000000000000000000000000000000000000000000000000": string;
|
|
26
|
+
"10000000000000000000000000000000000000000000000000000000000000": string;
|
|
27
|
+
"0c000000000000000000000000000000000000000000000000000000000000": string;
|
|
28
|
+
"06000000000000000000000000000000000000000000000000000000000000": string;
|
|
29
|
+
"0a000000000000000000000000000000000000000000000000000000000000": string;
|
|
30
|
+
"03000000000000000000000000000000000000000000000000000000000000": string;
|
|
31
|
+
"0e000000000000000000000000000000000000000000000000000000000000": string;
|
|
32
|
+
"0f000000000000000000000000000000000000000000000000000000000000": string;
|
|
33
|
+
"02000000000000000000000000000000000000000000000000000000000000": string;
|
|
34
|
+
"05000000000000000000000000000000000000000000000000000000000000": string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
database_base_path: string;
|
|
38
|
+
};
|
|
39
|
+
dev: {
|
|
40
|
+
$schema: string;
|
|
41
|
+
version: number;
|
|
42
|
+
flavor: string;
|
|
43
|
+
authorship: {
|
|
44
|
+
omit_seal_verification: boolean;
|
|
45
|
+
};
|
|
46
|
+
chain_spec: {
|
|
47
|
+
id: string;
|
|
48
|
+
bootnodes: string[];
|
|
49
|
+
genesis_header: string;
|
|
50
|
+
genesis_state: {
|
|
51
|
+
"0b000000000000000000000000000000000000000000000000000000000000": string;
|
|
52
|
+
"04000000000000000000000000000000000000000000000000000000000000": string;
|
|
53
|
+
"08000000000000000000000000000000000000000000000000000000000000": string;
|
|
54
|
+
"07000000000000000000000000000000000000000000000000000000000000": string;
|
|
55
|
+
"00c500b600120062b94ad574028369bc6bd19a65f989134c022ea372cd4df6": string;
|
|
56
|
+
"00ad0027003e003dc43472190923b0d2a1755796224bd5684c60fd0f6872c8": string;
|
|
57
|
+
"008000c100e3000732d3152ca7f3bbf14ff40da18def60c6f78e93e4602f3d": string;
|
|
58
|
+
"00f800e700990073c506a4ae6f6c368ca2c41dd8270472e9590c9ada0b87db": string;
|
|
59
|
+
"09000000000000000000000000000000000000000000000000000000000000": string;
|
|
60
|
+
ff000000000000000000000000000000000000000000000000000000000000: string;
|
|
61
|
+
"0d000000000000000000000000000000000000000000000000000000000000": string;
|
|
62
|
+
"01000000000000000000000000000000000000000000000000000000000000": string;
|
|
63
|
+
"10000000000000000000000000000000000000000000000000000000000000": string;
|
|
64
|
+
"0c000000000000000000000000000000000000000000000000000000000000": string;
|
|
65
|
+
"06000000000000000000000000000000000000000000000000000000000000": string;
|
|
66
|
+
"0a000000000000000000000000000000000000000000000000000000000000": string;
|
|
67
|
+
"03000000000000000000000000000000000000000000000000000000000000": string;
|
|
68
|
+
"0e000000000000000000000000000000000000000000000000000000000000": string;
|
|
69
|
+
"0f000000000000000000000000000000000000000000000000000000000000": string;
|
|
70
|
+
"02000000000000000000000000000000000000000000000000000000000000": string;
|
|
71
|
+
"05000000000000000000000000000000000000000000000000000000000000": string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
database_base_path: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
package/index.cjs
CHANGED
|
@@ -10,7 +10,6 @@ var GpVersion;
|
|
|
10
10
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
11
11
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
12
12
|
GpVersion["V0_7_1"] = "0.7.1-preview";
|
|
13
|
-
GpVersion["V0_7_2"] = "0.7.2-preview";
|
|
14
13
|
})(GpVersion || (GpVersion = {}));
|
|
15
14
|
var TestSuite;
|
|
16
15
|
(function (TestSuite) {
|
|
@@ -18,7 +17,7 @@ var TestSuite;
|
|
|
18
17
|
TestSuite["JAMDUNA"] = "jamduna";
|
|
19
18
|
})(TestSuite || (TestSuite = {}));
|
|
20
19
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
21
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1
|
|
20
|
+
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
22
21
|
const env$1 = typeof process === "undefined" ? {} : process.env;
|
|
23
22
|
const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
24
23
|
let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
|
|
@@ -27,26 +26,20 @@ function parseCurrentVersion(env) {
|
|
|
27
26
|
if (env === undefined) {
|
|
28
27
|
return undefined;
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
case GpVersion.V0_7_1:
|
|
34
|
-
case GpVersion.V0_7_2:
|
|
35
|
-
return env;
|
|
36
|
-
default:
|
|
37
|
-
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
29
|
+
const version = env;
|
|
30
|
+
if (!Object.values(GpVersion).includes(version)) {
|
|
31
|
+
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
38
32
|
}
|
|
33
|
+
return version;
|
|
39
34
|
}
|
|
40
35
|
function parseCurrentSuite(env) {
|
|
41
36
|
if (env === undefined)
|
|
42
37
|
return undefined;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return env;
|
|
47
|
-
default:
|
|
48
|
-
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
38
|
+
const val = env;
|
|
39
|
+
if (!Object.values(TestSuite).includes(val)) {
|
|
40
|
+
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
49
41
|
}
|
|
42
|
+
return val;
|
|
50
43
|
}
|
|
51
44
|
class Compatibility {
|
|
52
45
|
static override(version) {
|
|
@@ -5957,40 +5950,6 @@ var assurances = /*#__PURE__*/Object.freeze({
|
|
|
5957
5950
|
assurancesExtrinsicCodec: assurancesExtrinsicCodec
|
|
5958
5951
|
});
|
|
5959
5952
|
|
|
5960
|
-
/** Attempt to convert a number into `TimeSlot`. */
|
|
5961
|
-
const tryAsTimeSlot = (v) => asOpaqueType(tryAsU32(v));
|
|
5962
|
-
/** Attempt to convert a number into `ValidatorIndex`. */
|
|
5963
|
-
const tryAsValidatorIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
5964
|
-
/** Attempt to convert a number into `ServiceId`. */
|
|
5965
|
-
const tryAsServiceId = (v) => asOpaqueType(tryAsU32(v));
|
|
5966
|
-
const tryAsServiceGas = (v) => asOpaqueType(tryAsU64(v));
|
|
5967
|
-
/** Attempt to convert a number into `CoreIndex`. */
|
|
5968
|
-
const tryAsCoreIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
5969
|
-
/** Attempt to convert a number into `Epoch`. */
|
|
5970
|
-
const tryAsEpoch = (v) => asOpaqueType(tryAsU32(v));
|
|
5971
|
-
function tryAsPerValidator(array, spec) {
|
|
5972
|
-
check `
|
|
5973
|
-
${array.length === spec.validatorsCount}
|
|
5974
|
-
Invalid per-validator array length. Expected ${spec.validatorsCount}, got: ${array.length}
|
|
5975
|
-
`;
|
|
5976
|
-
return asKnownSize(array);
|
|
5977
|
-
}
|
|
5978
|
-
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
5979
|
-
return codecKnownSizeArray(val, {
|
|
5980
|
-
fixedLength: context.validatorsCount,
|
|
5981
|
-
});
|
|
5982
|
-
});
|
|
5983
|
-
function tryAsPerEpochBlock(array, spec) {
|
|
5984
|
-
check `
|
|
5985
|
-
${array.length === spec.epochLength}
|
|
5986
|
-
Invalid per-epoch-block array length. Expected ${spec.epochLength}, got: ${array.length}
|
|
5987
|
-
`;
|
|
5988
|
-
return asKnownSize(array);
|
|
5989
|
-
}
|
|
5990
|
-
const codecPerEpochBlock = (val) => codecWithContext((context) => {
|
|
5991
|
-
return codecKnownSizeArray(val, { fixedLength: context.epochLength });
|
|
5992
|
-
});
|
|
5993
|
-
|
|
5994
5953
|
/**
|
|
5995
5954
|
* Proof of signing a contradictory [`Judgement`] of a work report.
|
|
5996
5955
|
*/
|
|
@@ -6182,6 +6141,40 @@ var disputes = /*#__PURE__*/Object.freeze({
|
|
|
6182
6141
|
Verdict: Verdict
|
|
6183
6142
|
});
|
|
6184
6143
|
|
|
6144
|
+
/** Attempt to convert a number into `TimeSlot`. */
|
|
6145
|
+
const tryAsTimeSlot = (v) => asOpaqueType(tryAsU32(v));
|
|
6146
|
+
/** Attempt to convert a number into `ValidatorIndex`. */
|
|
6147
|
+
const tryAsValidatorIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
6148
|
+
/** Attempt to convert a number into `ServiceId`. */
|
|
6149
|
+
const tryAsServiceId = (v) => asOpaqueType(tryAsU32(v));
|
|
6150
|
+
const tryAsServiceGas = (v) => asOpaqueType(tryAsU64(v));
|
|
6151
|
+
/** Attempt to convert a number into `CoreIndex`. */
|
|
6152
|
+
const tryAsCoreIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
6153
|
+
/** Attempt to convert a number into `Epoch`. */
|
|
6154
|
+
const tryAsEpoch = (v) => asOpaqueType(tryAsU32(v));
|
|
6155
|
+
function tryAsPerValidator(array, spec) {
|
|
6156
|
+
check `
|
|
6157
|
+
${array.length === spec.validatorsCount}
|
|
6158
|
+
Invalid per-validator array length. Expected ${spec.validatorsCount}, got: ${array.length}
|
|
6159
|
+
`;
|
|
6160
|
+
return asKnownSize(array);
|
|
6161
|
+
}
|
|
6162
|
+
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
6163
|
+
return codecKnownSizeArray(val, {
|
|
6164
|
+
fixedLength: context.validatorsCount,
|
|
6165
|
+
});
|
|
6166
|
+
});
|
|
6167
|
+
function tryAsPerEpochBlock(array, spec) {
|
|
6168
|
+
check `
|
|
6169
|
+
${array.length === spec.epochLength}
|
|
6170
|
+
Invalid per-epoch-block array length. Expected ${spec.epochLength}, got: ${array.length}
|
|
6171
|
+
`;
|
|
6172
|
+
return asKnownSize(array);
|
|
6173
|
+
}
|
|
6174
|
+
const codecPerEpochBlock = (val) => codecWithContext((context) => {
|
|
6175
|
+
return codecKnownSizeArray(val, { fixedLength: context.epochLength });
|
|
6176
|
+
});
|
|
6177
|
+
|
|
6185
6178
|
/**
|
|
6186
6179
|
* Mapping between work package hash and root hash of it's exports.
|
|
6187
6180
|
*
|
|
@@ -7260,24 +7253,6 @@ class Block extends WithDebug {
|
|
|
7260
7253
|
this.extrinsic = extrinsic;
|
|
7261
7254
|
}
|
|
7262
7255
|
}
|
|
7263
|
-
function emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
7264
|
-
const header = Header.empty();
|
|
7265
|
-
header.timeSlotIndex = slot;
|
|
7266
|
-
return Block.create({
|
|
7267
|
-
header,
|
|
7268
|
-
extrinsic: Extrinsic.create({
|
|
7269
|
-
tickets: asKnownSize([]),
|
|
7270
|
-
preimages: [],
|
|
7271
|
-
assurances: asKnownSize([]),
|
|
7272
|
-
guarantees: asKnownSize([]),
|
|
7273
|
-
disputes: {
|
|
7274
|
-
verdicts: [],
|
|
7275
|
-
culprits: [],
|
|
7276
|
-
faults: [],
|
|
7277
|
-
},
|
|
7278
|
-
}),
|
|
7279
|
-
});
|
|
7280
|
-
}
|
|
7281
7256
|
|
|
7282
7257
|
var index$j = /*#__PURE__*/Object.freeze({
|
|
7283
7258
|
__proto__: null,
|
|
@@ -7294,7 +7269,6 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
7294
7269
|
codecPerValidator: codecPerValidator,
|
|
7295
7270
|
codecUtils: codec,
|
|
7296
7271
|
disputes: disputes,
|
|
7297
|
-
emptyBlock: emptyBlock,
|
|
7298
7272
|
encodeUnsealedHeader: encodeUnsealedHeader,
|
|
7299
7273
|
guarantees: guarantees,
|
|
7300
7274
|
headerViewWithHashCodec: headerViewWithHashCodec,
|
|
@@ -8071,8 +8045,8 @@ function print(level, levelAndName, strings, data) {
|
|
|
8071
8045
|
return;
|
|
8072
8046
|
}
|
|
8073
8047
|
const lvlText = Level[level].padEnd(5);
|
|
8074
|
-
const val = strings.map((v, idx) => `${v}${
|
|
8075
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val
|
|
8048
|
+
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
8049
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
8076
8050
|
if (level === Level.WARN) {
|
|
8077
8051
|
console.warn(msg);
|
|
8078
8052
|
}
|
|
@@ -14144,17 +14118,6 @@ class PageRange {
|
|
|
14144
14118
|
}
|
|
14145
14119
|
return new PageRange(start, length);
|
|
14146
14120
|
}
|
|
14147
|
-
/** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
|
|
14148
|
-
isWrapped() {
|
|
14149
|
-
return this.start >= this.end && !this.isEmpty();
|
|
14150
|
-
}
|
|
14151
|
-
/** Checks if given page number is within the range */
|
|
14152
|
-
isInRange(page) {
|
|
14153
|
-
if (this.isWrapped()) {
|
|
14154
|
-
return page >= this.start || page < this.end;
|
|
14155
|
-
}
|
|
14156
|
-
return page >= this.start && page < this.end;
|
|
14157
|
-
}
|
|
14158
14121
|
/** Checks if a range is empty (`length === 0`) */
|
|
14159
14122
|
isEmpty() {
|
|
14160
14123
|
return this.length === 0;
|
|
@@ -14495,11 +14458,10 @@ class MemoryBuilder {
|
|
|
14495
14458
|
startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
|
|
14496
14459
|
`;
|
|
14497
14460
|
this.ensureNotFinalized();
|
|
14498
|
-
const
|
|
14499
|
-
const
|
|
14500
|
-
const
|
|
14501
|
-
|
|
14502
|
-
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14461
|
+
const range = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14462
|
+
const pages = PageRange.fromMemoryRange(range);
|
|
14463
|
+
for (const pageNumber of pages) {
|
|
14464
|
+
if (this.initialMemory.has(pageNumber)) {
|
|
14503
14465
|
throw new IncorrectSbrkIndex();
|
|
14504
14466
|
}
|
|
14505
14467
|
}
|
package/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ declare enum GpVersion {
|
|
|
2
2
|
V0_6_7 = "0.6.7",
|
|
3
3
|
V0_7_0 = "0.7.0",
|
|
4
4
|
V0_7_1 = "0.7.1-preview",
|
|
5
|
-
V0_7_2 = "0.7.2-preview",
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
declare enum TestSuite {
|
|
@@ -12,7 +11,7 @@ declare enum TestSuite {
|
|
|
12
11
|
|
|
13
12
|
declare const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
14
13
|
|
|
15
|
-
declare const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1
|
|
14
|
+
declare const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
16
15
|
declare const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
17
16
|
declare let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
18
17
|
declare let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
@@ -21,30 +20,24 @@ declare function parseCurrentVersion(env?: string): GpVersion | undefined {
|
|
|
21
20
|
if (env === undefined) {
|
|
22
21
|
return undefined;
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return env;
|
|
30
|
-
default:
|
|
31
|
-
throw new Error(
|
|
32
|
-
`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`,
|
|
33
|
-
);
|
|
23
|
+
const version = env as GpVersion;
|
|
24
|
+
if (!Object.values(GpVersion).includes(version)) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`,
|
|
27
|
+
);
|
|
34
28
|
}
|
|
29
|
+
return version;
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
declare function parseCurrentSuite(env?: string): TestSuite | undefined {
|
|
38
33
|
if (env === undefined) return undefined;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
throw new Error(
|
|
45
|
-
`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`,
|
|
46
|
-
);
|
|
34
|
+
const val = env as TestSuite;
|
|
35
|
+
if (!Object.values(TestSuite).includes(val)) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`,
|
|
38
|
+
);
|
|
47
39
|
}
|
|
40
|
+
return val;
|
|
48
41
|
}
|
|
49
42
|
|
|
50
43
|
declare class Compatibility {
|
|
@@ -6873,25 +6866,6 @@ declare class Block extends WithDebug {
|
|
|
6873
6866
|
/** Undecoded View of a [`Block`]. */
|
|
6874
6867
|
type BlockView = DescribedBy<typeof Block.Codec.View>;
|
|
6875
6868
|
|
|
6876
|
-
declare function emptyBlock(slot: TimeSlot = tryAsTimeSlot(0)) {
|
|
6877
|
-
const header = Header.empty();
|
|
6878
|
-
header.timeSlotIndex = slot;
|
|
6879
|
-
return Block.create({
|
|
6880
|
-
header,
|
|
6881
|
-
extrinsic: Extrinsic.create({
|
|
6882
|
-
tickets: asKnownSize([]),
|
|
6883
|
-
preimages: [],
|
|
6884
|
-
assurances: asKnownSize([]),
|
|
6885
|
-
guarantees: asKnownSize([]),
|
|
6886
|
-
disputes: {
|
|
6887
|
-
verdicts: [],
|
|
6888
|
-
culprits: [],
|
|
6889
|
-
faults: [],
|
|
6890
|
-
},
|
|
6891
|
-
}),
|
|
6892
|
-
});
|
|
6893
|
-
}
|
|
6894
|
-
|
|
6895
6869
|
type index$j_Block = Block;
|
|
6896
6870
|
declare const index$j_Block: typeof Block;
|
|
6897
6871
|
type index$j_BlockView = BlockView;
|
|
@@ -6935,7 +6909,6 @@ declare const index$j_assurances: typeof assurances;
|
|
|
6935
6909
|
declare const index$j_codecPerEpochBlock: typeof codecPerEpochBlock;
|
|
6936
6910
|
declare const index$j_codecPerValidator: typeof codecPerValidator;
|
|
6937
6911
|
declare const index$j_disputes: typeof disputes;
|
|
6938
|
-
declare const index$j_emptyBlock: typeof emptyBlock;
|
|
6939
6912
|
declare const index$j_encodeUnsealedHeader: typeof encodeUnsealedHeader;
|
|
6940
6913
|
declare const index$j_guarantees: typeof guarantees;
|
|
6941
6914
|
declare const index$j_headerViewWithHashCodec: typeof headerViewWithHashCodec;
|
|
@@ -6957,7 +6930,7 @@ declare const index$j_workPackage: typeof workPackage;
|
|
|
6957
6930
|
declare const index$j_workReport: typeof workReport;
|
|
6958
6931
|
declare const index$j_workResult: typeof workResult;
|
|
6959
6932
|
declare namespace index$j {
|
|
6960
|
-
export { index$j_Block as Block, index$j_EpochMarker as EpochMarker, index$j_Extrinsic as Extrinsic, index$j_Header as Header, index$j_HeaderViewWithHash as HeaderViewWithHash, index$j_MAX_NUMBER_OF_SEGMENTS as MAX_NUMBER_OF_SEGMENTS, index$j_TicketsMarker as TicketsMarker, index$j_ValidatorKeys as ValidatorKeys, index$j_W_E as W_E, index$j_W_S as W_S, index$j_assurances as assurances, index$j_codecPerEpochBlock as codecPerEpochBlock, index$j_codecPerValidator as codecPerValidator, codec as codecUtils, index$j_disputes as disputes, index$
|
|
6933
|
+
export { index$j_Block as Block, index$j_EpochMarker as EpochMarker, index$j_Extrinsic as Extrinsic, index$j_Header as Header, index$j_HeaderViewWithHash as HeaderViewWithHash, index$j_MAX_NUMBER_OF_SEGMENTS as MAX_NUMBER_OF_SEGMENTS, index$j_TicketsMarker as TicketsMarker, index$j_ValidatorKeys as ValidatorKeys, index$j_W_E as W_E, index$j_W_S as W_S, index$j_assurances as assurances, index$j_codecPerEpochBlock as codecPerEpochBlock, index$j_codecPerValidator as codecPerValidator, codec as codecUtils, index$j_disputes as disputes, index$j_encodeUnsealedHeader as encodeUnsealedHeader, index$j_guarantees as guarantees, index$j_headerViewWithHashCodec as headerViewWithHashCodec, index$j_legacyDescriptor as legacyDescriptor, index$j_preimage as preimage, index$j_refineContext as refineContext, index$j_tickets as tickets, index$j_tryAsCoreIndex as tryAsCoreIndex, index$j_tryAsEpoch as tryAsEpoch, index$j_tryAsPerEpochBlock as tryAsPerEpochBlock, index$j_tryAsPerValidator as tryAsPerValidator, index$j_tryAsSegmentIndex as tryAsSegmentIndex, index$j_tryAsServiceGas as tryAsServiceGas, index$j_tryAsServiceId as tryAsServiceId, index$j_tryAsTimeSlot as tryAsTimeSlot, index$j_tryAsValidatorIndex as tryAsValidatorIndex, index$j_workItem as workItem, index$j_workPackage as workPackage, index$j_workReport as workReport, index$j_workResult as workResult };
|
|
6961
6934
|
export type { index$j_BlockView as BlockView, index$j_CodeHash as CodeHash, index$j_CoreIndex as CoreIndex, index$j_EntropyHash as EntropyHash, index$j_Epoch as Epoch, index$j_EpochMarkerView as EpochMarkerView, index$j_ExtrinsicHash as ExtrinsicHash, index$j_ExtrinsicView as ExtrinsicView, index$j_HeaderHash as HeaderHash, index$j_HeaderView as HeaderView, index$j_PerEpochBlock as PerEpochBlock, index$j_PerValidator as PerValidator, index$j_SEGMENT_BYTES as SEGMENT_BYTES, index$j_Segment as Segment, index$j_SegmentIndex as SegmentIndex, index$j_ServiceGas as ServiceGas, index$j_ServiceId as ServiceId, index$j_StateRootHash as StateRootHash, index$j_TicketsMarkerView as TicketsMarkerView, index$j_TimeSlot as TimeSlot, index$j_ValidatorIndex as ValidatorIndex, index$j_WorkReportHash as WorkReportHash };
|
|
6962
6935
|
}
|
|
6963
6936
|
|
|
@@ -14800,12 +14773,11 @@ declare class MemoryBuilder {
|
|
|
14800
14773
|
`;
|
|
14801
14774
|
this.ensureNotFinalized();
|
|
14802
14775
|
|
|
14803
|
-
const
|
|
14804
|
-
const
|
|
14805
|
-
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
14776
|
+
const range = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14777
|
+
const pages = PageRange.fromMemoryRange(range);
|
|
14806
14778
|
|
|
14807
|
-
for (const pageNumber of
|
|
14808
|
-
if (
|
|
14779
|
+
for (const pageNumber of pages) {
|
|
14780
|
+
if (this.initialMemory.has(pageNumber)) {
|
|
14809
14781
|
throw new IncorrectSbrkIndex();
|
|
14810
14782
|
}
|
|
14811
14783
|
}
|
package/index.js
CHANGED
|
@@ -7,7 +7,6 @@ var GpVersion;
|
|
|
7
7
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
8
8
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
9
9
|
GpVersion["V0_7_1"] = "0.7.1-preview";
|
|
10
|
-
GpVersion["V0_7_2"] = "0.7.2-preview";
|
|
11
10
|
})(GpVersion || (GpVersion = {}));
|
|
12
11
|
var TestSuite;
|
|
13
12
|
(function (TestSuite) {
|
|
@@ -15,7 +14,7 @@ var TestSuite;
|
|
|
15
14
|
TestSuite["JAMDUNA"] = "jamduna";
|
|
16
15
|
})(TestSuite || (TestSuite = {}));
|
|
17
16
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
18
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1
|
|
17
|
+
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
19
18
|
const env$1 = typeof process === "undefined" ? {} : process.env;
|
|
20
19
|
const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
21
20
|
let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
|
|
@@ -24,26 +23,20 @@ function parseCurrentVersion(env) {
|
|
|
24
23
|
if (env === undefined) {
|
|
25
24
|
return undefined;
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
case GpVersion.V0_7_1:
|
|
31
|
-
case GpVersion.V0_7_2:
|
|
32
|
-
return env;
|
|
33
|
-
default:
|
|
34
|
-
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
26
|
+
const version = env;
|
|
27
|
+
if (!Object.values(GpVersion).includes(version)) {
|
|
28
|
+
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
35
29
|
}
|
|
30
|
+
return version;
|
|
36
31
|
}
|
|
37
32
|
function parseCurrentSuite(env) {
|
|
38
33
|
if (env === undefined)
|
|
39
34
|
return undefined;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return env;
|
|
44
|
-
default:
|
|
45
|
-
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
35
|
+
const val = env;
|
|
36
|
+
if (!Object.values(TestSuite).includes(val)) {
|
|
37
|
+
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
46
38
|
}
|
|
39
|
+
return val;
|
|
47
40
|
}
|
|
48
41
|
class Compatibility {
|
|
49
42
|
static override(version) {
|
|
@@ -5954,40 +5947,6 @@ var assurances = /*#__PURE__*/Object.freeze({
|
|
|
5954
5947
|
assurancesExtrinsicCodec: assurancesExtrinsicCodec
|
|
5955
5948
|
});
|
|
5956
5949
|
|
|
5957
|
-
/** Attempt to convert a number into `TimeSlot`. */
|
|
5958
|
-
const tryAsTimeSlot = (v) => asOpaqueType(tryAsU32(v));
|
|
5959
|
-
/** Attempt to convert a number into `ValidatorIndex`. */
|
|
5960
|
-
const tryAsValidatorIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
5961
|
-
/** Attempt to convert a number into `ServiceId`. */
|
|
5962
|
-
const tryAsServiceId = (v) => asOpaqueType(tryAsU32(v));
|
|
5963
|
-
const tryAsServiceGas = (v) => asOpaqueType(tryAsU64(v));
|
|
5964
|
-
/** Attempt to convert a number into `CoreIndex`. */
|
|
5965
|
-
const tryAsCoreIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
5966
|
-
/** Attempt to convert a number into `Epoch`. */
|
|
5967
|
-
const tryAsEpoch = (v) => asOpaqueType(tryAsU32(v));
|
|
5968
|
-
function tryAsPerValidator(array, spec) {
|
|
5969
|
-
check `
|
|
5970
|
-
${array.length === spec.validatorsCount}
|
|
5971
|
-
Invalid per-validator array length. Expected ${spec.validatorsCount}, got: ${array.length}
|
|
5972
|
-
`;
|
|
5973
|
-
return asKnownSize(array);
|
|
5974
|
-
}
|
|
5975
|
-
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
5976
|
-
return codecKnownSizeArray(val, {
|
|
5977
|
-
fixedLength: context.validatorsCount,
|
|
5978
|
-
});
|
|
5979
|
-
});
|
|
5980
|
-
function tryAsPerEpochBlock(array, spec) {
|
|
5981
|
-
check `
|
|
5982
|
-
${array.length === spec.epochLength}
|
|
5983
|
-
Invalid per-epoch-block array length. Expected ${spec.epochLength}, got: ${array.length}
|
|
5984
|
-
`;
|
|
5985
|
-
return asKnownSize(array);
|
|
5986
|
-
}
|
|
5987
|
-
const codecPerEpochBlock = (val) => codecWithContext((context) => {
|
|
5988
|
-
return codecKnownSizeArray(val, { fixedLength: context.epochLength });
|
|
5989
|
-
});
|
|
5990
|
-
|
|
5991
5950
|
/**
|
|
5992
5951
|
* Proof of signing a contradictory [`Judgement`] of a work report.
|
|
5993
5952
|
*/
|
|
@@ -6179,6 +6138,40 @@ var disputes = /*#__PURE__*/Object.freeze({
|
|
|
6179
6138
|
Verdict: Verdict
|
|
6180
6139
|
});
|
|
6181
6140
|
|
|
6141
|
+
/** Attempt to convert a number into `TimeSlot`. */
|
|
6142
|
+
const tryAsTimeSlot = (v) => asOpaqueType(tryAsU32(v));
|
|
6143
|
+
/** Attempt to convert a number into `ValidatorIndex`. */
|
|
6144
|
+
const tryAsValidatorIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
6145
|
+
/** Attempt to convert a number into `ServiceId`. */
|
|
6146
|
+
const tryAsServiceId = (v) => asOpaqueType(tryAsU32(v));
|
|
6147
|
+
const tryAsServiceGas = (v) => asOpaqueType(tryAsU64(v));
|
|
6148
|
+
/** Attempt to convert a number into `CoreIndex`. */
|
|
6149
|
+
const tryAsCoreIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
6150
|
+
/** Attempt to convert a number into `Epoch`. */
|
|
6151
|
+
const tryAsEpoch = (v) => asOpaqueType(tryAsU32(v));
|
|
6152
|
+
function tryAsPerValidator(array, spec) {
|
|
6153
|
+
check `
|
|
6154
|
+
${array.length === spec.validatorsCount}
|
|
6155
|
+
Invalid per-validator array length. Expected ${spec.validatorsCount}, got: ${array.length}
|
|
6156
|
+
`;
|
|
6157
|
+
return asKnownSize(array);
|
|
6158
|
+
}
|
|
6159
|
+
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
6160
|
+
return codecKnownSizeArray(val, {
|
|
6161
|
+
fixedLength: context.validatorsCount,
|
|
6162
|
+
});
|
|
6163
|
+
});
|
|
6164
|
+
function tryAsPerEpochBlock(array, spec) {
|
|
6165
|
+
check `
|
|
6166
|
+
${array.length === spec.epochLength}
|
|
6167
|
+
Invalid per-epoch-block array length. Expected ${spec.epochLength}, got: ${array.length}
|
|
6168
|
+
`;
|
|
6169
|
+
return asKnownSize(array);
|
|
6170
|
+
}
|
|
6171
|
+
const codecPerEpochBlock = (val) => codecWithContext((context) => {
|
|
6172
|
+
return codecKnownSizeArray(val, { fixedLength: context.epochLength });
|
|
6173
|
+
});
|
|
6174
|
+
|
|
6182
6175
|
/**
|
|
6183
6176
|
* Mapping between work package hash and root hash of it's exports.
|
|
6184
6177
|
*
|
|
@@ -7257,24 +7250,6 @@ class Block extends WithDebug {
|
|
|
7257
7250
|
this.extrinsic = extrinsic;
|
|
7258
7251
|
}
|
|
7259
7252
|
}
|
|
7260
|
-
function emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
7261
|
-
const header = Header.empty();
|
|
7262
|
-
header.timeSlotIndex = slot;
|
|
7263
|
-
return Block.create({
|
|
7264
|
-
header,
|
|
7265
|
-
extrinsic: Extrinsic.create({
|
|
7266
|
-
tickets: asKnownSize([]),
|
|
7267
|
-
preimages: [],
|
|
7268
|
-
assurances: asKnownSize([]),
|
|
7269
|
-
guarantees: asKnownSize([]),
|
|
7270
|
-
disputes: {
|
|
7271
|
-
verdicts: [],
|
|
7272
|
-
culprits: [],
|
|
7273
|
-
faults: [],
|
|
7274
|
-
},
|
|
7275
|
-
}),
|
|
7276
|
-
});
|
|
7277
|
-
}
|
|
7278
7253
|
|
|
7279
7254
|
var index$j = /*#__PURE__*/Object.freeze({
|
|
7280
7255
|
__proto__: null,
|
|
@@ -7291,7 +7266,6 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
7291
7266
|
codecPerValidator: codecPerValidator,
|
|
7292
7267
|
codecUtils: codec,
|
|
7293
7268
|
disputes: disputes,
|
|
7294
|
-
emptyBlock: emptyBlock,
|
|
7295
7269
|
encodeUnsealedHeader: encodeUnsealedHeader,
|
|
7296
7270
|
guarantees: guarantees,
|
|
7297
7271
|
headerViewWithHashCodec: headerViewWithHashCodec,
|
|
@@ -8068,8 +8042,8 @@ function print(level, levelAndName, strings, data) {
|
|
|
8068
8042
|
return;
|
|
8069
8043
|
}
|
|
8070
8044
|
const lvlText = Level[level].padEnd(5);
|
|
8071
|
-
const val = strings.map((v, idx) => `${v}${
|
|
8072
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val
|
|
8045
|
+
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
8046
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
8073
8047
|
if (level === Level.WARN) {
|
|
8074
8048
|
console.warn(msg);
|
|
8075
8049
|
}
|
|
@@ -14141,17 +14115,6 @@ class PageRange {
|
|
|
14141
14115
|
}
|
|
14142
14116
|
return new PageRange(start, length);
|
|
14143
14117
|
}
|
|
14144
|
-
/** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
|
|
14145
|
-
isWrapped() {
|
|
14146
|
-
return this.start >= this.end && !this.isEmpty();
|
|
14147
|
-
}
|
|
14148
|
-
/** Checks if given page number is within the range */
|
|
14149
|
-
isInRange(page) {
|
|
14150
|
-
if (this.isWrapped()) {
|
|
14151
|
-
return page >= this.start || page < this.end;
|
|
14152
|
-
}
|
|
14153
|
-
return page >= this.start && page < this.end;
|
|
14154
|
-
}
|
|
14155
14118
|
/** Checks if a range is empty (`length === 0`) */
|
|
14156
14119
|
isEmpty() {
|
|
14157
14120
|
return this.length === 0;
|
|
@@ -14492,11 +14455,10 @@ class MemoryBuilder {
|
|
|
14492
14455
|
startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
|
|
14493
14456
|
`;
|
|
14494
14457
|
this.ensureNotFinalized();
|
|
14495
|
-
const
|
|
14496
|
-
const
|
|
14497
|
-
const
|
|
14498
|
-
|
|
14499
|
-
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14458
|
+
const range = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14459
|
+
const pages = PageRange.fromMemoryRange(range);
|
|
14460
|
+
for (const pageNumber of pages) {
|
|
14461
|
+
if (this.initialMemory.has(pageNumber)) {
|
|
14500
14462
|
throw new IncorrectSbrkIndex();
|
|
14501
14463
|
}
|
|
14502
14464
|
}
|