@typeberry/lib 0.1.2-a90b655 → 0.1.2-b25cc82
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/index.cjs +117 -520
- package/index.d.ts +677 -1197
- package/index.js +99 -501
- package/package.json +1 -1
- package/bin/lib/index.d.ts +0 -30
- package/configs/index.d.ts +0 -76
package/index.js
CHANGED
|
@@ -560,7 +560,7 @@ function isResult(x) {
|
|
|
560
560
|
* as an afterthought.
|
|
561
561
|
*/
|
|
562
562
|
|
|
563
|
-
var index$
|
|
563
|
+
var index$s = /*#__PURE__*/Object.freeze({
|
|
564
564
|
__proto__: null,
|
|
565
565
|
get CURRENT_SUITE () { return CURRENT_SUITE; },
|
|
566
566
|
get CURRENT_VERSION () { return CURRENT_VERSION; },
|
|
@@ -714,7 +714,7 @@ class Ordering {
|
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
716
|
|
|
717
|
-
var index$
|
|
717
|
+
var index$r = /*#__PURE__*/Object.freeze({
|
|
718
718
|
__proto__: null,
|
|
719
719
|
Ordering: Ordering
|
|
720
720
|
});
|
|
@@ -965,7 +965,7 @@ function u8ArraySameLengthEqual(self, other) {
|
|
|
965
965
|
}
|
|
966
966
|
const bytesBlobComparator = (a, b) => a.compare(b);
|
|
967
967
|
|
|
968
|
-
var index$
|
|
968
|
+
var index$q = /*#__PURE__*/Object.freeze({
|
|
969
969
|
__proto__: null,
|
|
970
970
|
BitVec: BitVec,
|
|
971
971
|
Bytes: Bytes,
|
|
@@ -1067,7 +1067,7 @@ const minU64 = (a, ...values) => values.reduce((min, value) => (value > min ? mi
|
|
|
1067
1067
|
/** Get the biggest value between U64 a and values given as input parameters. */
|
|
1068
1068
|
const maxU64 = (a, ...values) => values.reduce((max, value) => (value < max ? max : value), a);
|
|
1069
1069
|
|
|
1070
|
-
var index$
|
|
1070
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
1071
1071
|
__proto__: null,
|
|
1072
1072
|
isU16: isU16,
|
|
1073
1073
|
isU32: isU32,
|
|
@@ -2477,7 +2477,7 @@ function sequenceViewFixLen(type, { fixedLength }) {
|
|
|
2477
2477
|
}, skipper);
|
|
2478
2478
|
}
|
|
2479
2479
|
|
|
2480
|
-
var index$
|
|
2480
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
2481
2481
|
__proto__: null,
|
|
2482
2482
|
Decoder: Decoder,
|
|
2483
2483
|
Descriptor: Descriptor,
|
|
@@ -4916,7 +4916,7 @@ var keccak = /*#__PURE__*/Object.freeze({
|
|
|
4916
4916
|
hashBlobs: hashBlobs
|
|
4917
4917
|
});
|
|
4918
4918
|
|
|
4919
|
-
var index$
|
|
4919
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
4920
4920
|
__proto__: null,
|
|
4921
4921
|
HASH_SIZE: HASH_SIZE,
|
|
4922
4922
|
PageAllocator: PageAllocator,
|
|
@@ -4982,7 +4982,7 @@ var keyDerivation = /*#__PURE__*/Object.freeze({
|
|
|
4982
4982
|
trivialSeed: trivialSeed
|
|
4983
4983
|
});
|
|
4984
4984
|
|
|
4985
|
-
var index$
|
|
4985
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
4986
4986
|
__proto__: null,
|
|
4987
4987
|
BANDERSNATCH_KEY_BYTES: BANDERSNATCH_KEY_BYTES,
|
|
4988
4988
|
BANDERSNATCH_PROOF_BYTES: BANDERSNATCH_PROOF_BYTES,
|
|
@@ -5586,7 +5586,7 @@ class TruncatedHashDictionary {
|
|
|
5586
5586
|
}
|
|
5587
5587
|
}
|
|
5588
5588
|
|
|
5589
|
-
var index$
|
|
5589
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
5590
5590
|
__proto__: null,
|
|
5591
5591
|
FixedSizeArray: FixedSizeArray,
|
|
5592
5592
|
HashDictionary: HashDictionary,
|
|
@@ -5781,7 +5781,7 @@ class Bootnode {
|
|
|
5781
5781
|
}
|
|
5782
5782
|
}
|
|
5783
5783
|
|
|
5784
|
-
var index$
|
|
5784
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
5785
5785
|
__proto__: null,
|
|
5786
5786
|
Bootnode: Bootnode,
|
|
5787
5787
|
ChainSpec: ChainSpec,
|
|
@@ -5954,6 +5954,40 @@ var assurances = /*#__PURE__*/Object.freeze({
|
|
|
5954
5954
|
assurancesExtrinsicCodec: assurancesExtrinsicCodec
|
|
5955
5955
|
});
|
|
5956
5956
|
|
|
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
|
+
|
|
5957
5991
|
/**
|
|
5958
5992
|
* Proof of signing a contradictory [`Judgement`] of a work report.
|
|
5959
5993
|
*/
|
|
@@ -6145,40 +6179,6 @@ var disputes = /*#__PURE__*/Object.freeze({
|
|
|
6145
6179
|
Verdict: Verdict
|
|
6146
6180
|
});
|
|
6147
6181
|
|
|
6148
|
-
/** Attempt to convert a number into `TimeSlot`. */
|
|
6149
|
-
const tryAsTimeSlot = (v) => asOpaqueType(tryAsU32(v));
|
|
6150
|
-
/** Attempt to convert a number into `ValidatorIndex`. */
|
|
6151
|
-
const tryAsValidatorIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
6152
|
-
/** Attempt to convert a number into `ServiceId`. */
|
|
6153
|
-
const tryAsServiceId = (v) => asOpaqueType(tryAsU32(v));
|
|
6154
|
-
const tryAsServiceGas = (v) => asOpaqueType(tryAsU64(v));
|
|
6155
|
-
/** Attempt to convert a number into `CoreIndex`. */
|
|
6156
|
-
const tryAsCoreIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
6157
|
-
/** Attempt to convert a number into `Epoch`. */
|
|
6158
|
-
const tryAsEpoch = (v) => asOpaqueType(tryAsU32(v));
|
|
6159
|
-
function tryAsPerValidator(array, spec) {
|
|
6160
|
-
check `
|
|
6161
|
-
${array.length === spec.validatorsCount}
|
|
6162
|
-
Invalid per-validator array length. Expected ${spec.validatorsCount}, got: ${array.length}
|
|
6163
|
-
`;
|
|
6164
|
-
return asKnownSize(array);
|
|
6165
|
-
}
|
|
6166
|
-
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
6167
|
-
return codecKnownSizeArray(val, {
|
|
6168
|
-
fixedLength: context.validatorsCount,
|
|
6169
|
-
});
|
|
6170
|
-
});
|
|
6171
|
-
function tryAsPerEpochBlock(array, spec) {
|
|
6172
|
-
check `
|
|
6173
|
-
${array.length === spec.epochLength}
|
|
6174
|
-
Invalid per-epoch-block array length. Expected ${spec.epochLength}, got: ${array.length}
|
|
6175
|
-
`;
|
|
6176
|
-
return asKnownSize(array);
|
|
6177
|
-
}
|
|
6178
|
-
const codecPerEpochBlock = (val) => codecWithContext((context) => {
|
|
6179
|
-
return codecKnownSizeArray(val, { fixedLength: context.epochLength });
|
|
6180
|
-
});
|
|
6181
|
-
|
|
6182
6182
|
/**
|
|
6183
6183
|
* Mapping between work package hash and root hash of it's exports.
|
|
6184
6184
|
*
|
|
@@ -7257,8 +7257,26 @@ class Block extends WithDebug {
|
|
|
7257
7257
|
this.extrinsic = extrinsic;
|
|
7258
7258
|
}
|
|
7259
7259
|
}
|
|
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
|
+
}
|
|
7260
7278
|
|
|
7261
|
-
var index$
|
|
7279
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
7262
7280
|
__proto__: null,
|
|
7263
7281
|
Block: Block,
|
|
7264
7282
|
EpochMarker: EpochMarker,
|
|
@@ -7273,6 +7291,7 @@ var index$l = /*#__PURE__*/Object.freeze({
|
|
|
7273
7291
|
codecPerValidator: codecPerValidator,
|
|
7274
7292
|
codecUtils: codec,
|
|
7275
7293
|
disputes: disputes,
|
|
7294
|
+
emptyBlock: emptyBlock,
|
|
7276
7295
|
encodeUnsealedHeader: encodeUnsealedHeader,
|
|
7277
7296
|
guarantees: guarantees,
|
|
7278
7297
|
headerViewWithHashCodec: headerViewWithHashCodec,
|
|
@@ -7513,7 +7532,7 @@ var json;
|
|
|
7513
7532
|
json.object = object;
|
|
7514
7533
|
})(json || (json = {}));
|
|
7515
7534
|
|
|
7516
|
-
var index$
|
|
7535
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
7517
7536
|
__proto__: null,
|
|
7518
7537
|
get json () { return json; },
|
|
7519
7538
|
parseFromJson: parseFromJson
|
|
@@ -7783,7 +7802,7 @@ const blockFromJson = (spec) => json.object({
|
|
|
7783
7802
|
extrinsic: getExtrinsicFromJson(spec),
|
|
7784
7803
|
}, ({ header, extrinsic }) => Block.create({ header, extrinsic }));
|
|
7785
7804
|
|
|
7786
|
-
var index$
|
|
7805
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
7787
7806
|
__proto__: null,
|
|
7788
7807
|
blockFromJson: blockFromJson,
|
|
7789
7808
|
disputesExtrinsicFromJson: disputesExtrinsicFromJson,
|
|
@@ -8049,8 +8068,8 @@ function print(level, levelAndName, strings, data) {
|
|
|
8049
8068
|
return;
|
|
8050
8069
|
}
|
|
8051
8070
|
const lvlText = Level[level].padEnd(5);
|
|
8052
|
-
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
8053
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
8071
|
+
const val = strings.map((v, idx) => `${v}${idx < data.length ? data[idx] : ""}`);
|
|
8072
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
|
|
8054
8073
|
if (level === Level.WARN) {
|
|
8055
8074
|
console.warn(msg);
|
|
8056
8075
|
}
|
|
@@ -8281,7 +8300,7 @@ class Logger {
|
|
|
8281
8300
|
}
|
|
8282
8301
|
}
|
|
8283
8302
|
|
|
8284
|
-
var index$
|
|
8303
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
8285
8304
|
__proto__: null,
|
|
8286
8305
|
get Level () { return Level; },
|
|
8287
8306
|
Logger: Logger,
|
|
@@ -8304,7 +8323,7 @@ class AuthorshipOptions {
|
|
|
8304
8323
|
}
|
|
8305
8324
|
}
|
|
8306
8325
|
|
|
8307
|
-
const logger$
|
|
8326
|
+
const logger$4 = Logger.new(import.meta.filename, "config");
|
|
8308
8327
|
/** Development config. Will accept unsealed blocks for now. */
|
|
8309
8328
|
const DEV_CONFIG = "dev";
|
|
8310
8329
|
/** Default config file. */
|
|
@@ -8363,15 +8382,15 @@ class NodeConfiguration {
|
|
|
8363
8382
|
}
|
|
8364
8383
|
function loadConfig(configPath) {
|
|
8365
8384
|
if (configPath === DEFAULT_CONFIG) {
|
|
8366
|
-
logger$
|
|
8385
|
+
logger$4.log `🔧 Loading DEFAULT config`;
|
|
8367
8386
|
return parseFromJson(configs.default, NodeConfiguration.fromJson);
|
|
8368
8387
|
}
|
|
8369
8388
|
if (configPath === DEV_CONFIG) {
|
|
8370
|
-
logger$
|
|
8389
|
+
logger$4.log `🔧 Loading DEV config`;
|
|
8371
8390
|
return parseFromJson(configs.dev, NodeConfiguration.fromJson);
|
|
8372
8391
|
}
|
|
8373
8392
|
try {
|
|
8374
|
-
logger$
|
|
8393
|
+
logger$4.log `🔧 Loading config from ${configPath}`;
|
|
8375
8394
|
const configFile = fs.readFileSync(configPath, "utf8");
|
|
8376
8395
|
const parsed = JSON.parse(configFile);
|
|
8377
8396
|
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
@@ -8381,7 +8400,7 @@ function loadConfig(configPath) {
|
|
|
8381
8400
|
}
|
|
8382
8401
|
}
|
|
8383
8402
|
|
|
8384
|
-
var index$
|
|
8403
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
8385
8404
|
__proto__: null,
|
|
8386
8405
|
DEFAULT_CONFIG: DEFAULT_CONFIG,
|
|
8387
8406
|
DEV_CONFIG: DEV_CONFIG,
|
|
@@ -10047,7 +10066,7 @@ const serviceDataCodec = codec$1.dictionary(codec$1.u32.asOpaque(), serviceEntri
|
|
|
10047
10066
|
sortKeys: (a, b) => a - b,
|
|
10048
10067
|
});
|
|
10049
10068
|
|
|
10050
|
-
var index$
|
|
10069
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
10051
10070
|
__proto__: null,
|
|
10052
10071
|
AccumulationOutput: AccumulationOutput,
|
|
10053
10072
|
AutoAccumulate: AutoAccumulate,
|
|
@@ -11057,7 +11076,7 @@ const bitLookup = [
|
|
|
11057
11076
|
[0b00000000, 8],
|
|
11058
11077
|
];
|
|
11059
11078
|
|
|
11060
|
-
var index$
|
|
11079
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
11061
11080
|
__proto__: null,
|
|
11062
11081
|
BranchNode: BranchNode,
|
|
11063
11082
|
InMemoryTrie: InMemoryTrie,
|
|
@@ -11403,7 +11422,7 @@ function loadState(spec, entries) {
|
|
|
11403
11422
|
* hashmap of `key -> value` entries.
|
|
11404
11423
|
*/
|
|
11405
11424
|
|
|
11406
|
-
var index$
|
|
11425
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
11407
11426
|
__proto__: null,
|
|
11408
11427
|
SerializedService: SerializedService,
|
|
11409
11428
|
SerializedState: SerializedState,
|
|
@@ -11689,7 +11708,7 @@ class InMemoryStates {
|
|
|
11689
11708
|
}
|
|
11690
11709
|
}
|
|
11691
11710
|
|
|
11692
|
-
var index$
|
|
11711
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
11693
11712
|
__proto__: null,
|
|
11694
11713
|
InMemoryBlocks: InMemoryBlocks,
|
|
11695
11714
|
InMemoryStates: InMemoryStates,
|
|
@@ -12051,7 +12070,7 @@ const initEc = async () => {
|
|
|
12051
12070
|
await init.reedSolomon();
|
|
12052
12071
|
};
|
|
12053
12072
|
|
|
12054
|
-
var index$
|
|
12073
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
12055
12074
|
__proto__: null,
|
|
12056
12075
|
N_CHUNKS_REDUNDANCY: N_CHUNKS_REDUNDANCY,
|
|
12057
12076
|
N_CHUNKS_REQUIRED: N_CHUNKS_REQUIRED,
|
|
@@ -12075,439 +12094,6 @@ var index$c = /*#__PURE__*/Object.freeze({
|
|
|
12075
12094
|
unzip: unzip
|
|
12076
12095
|
});
|
|
12077
12096
|
|
|
12078
|
-
/**
|
|
12079
|
-
* Version ::= SEQUENCE {
|
|
12080
|
-
* major INTEGER (0..255),
|
|
12081
|
-
* minor INTEGER (0..255),
|
|
12082
|
-
* patch INTEGER (0..255)
|
|
12083
|
-
* }
|
|
12084
|
-
*/
|
|
12085
|
-
class Version extends WithDebug {
|
|
12086
|
-
major;
|
|
12087
|
-
minor;
|
|
12088
|
-
patch;
|
|
12089
|
-
static Codec = codec$1.Class(Version, {
|
|
12090
|
-
major: codec$1.u8,
|
|
12091
|
-
minor: codec$1.u8,
|
|
12092
|
-
patch: codec$1.u8,
|
|
12093
|
-
});
|
|
12094
|
-
static tryFromString(str) {
|
|
12095
|
-
const parse = (v) => tryAsU8(Number(v));
|
|
12096
|
-
try {
|
|
12097
|
-
const [major, minor, patch] = str.trim().split(".").map(parse);
|
|
12098
|
-
return Version.create({
|
|
12099
|
-
major,
|
|
12100
|
-
minor,
|
|
12101
|
-
patch,
|
|
12102
|
-
});
|
|
12103
|
-
}
|
|
12104
|
-
catch (e) {
|
|
12105
|
-
throw new Error(`Unable to parse ${str} as Version: ${e}`);
|
|
12106
|
-
}
|
|
12107
|
-
}
|
|
12108
|
-
static create({ major, minor, patch }) {
|
|
12109
|
-
return new Version(major, minor, patch);
|
|
12110
|
-
}
|
|
12111
|
-
constructor(major, minor, patch) {
|
|
12112
|
-
super();
|
|
12113
|
-
this.major = major;
|
|
12114
|
-
this.minor = minor;
|
|
12115
|
-
this.patch = patch;
|
|
12116
|
-
}
|
|
12117
|
-
}
|
|
12118
|
-
/**
|
|
12119
|
-
* Fuzzer Protocol V1
|
|
12120
|
-
* Reference: https://github.com/davxy/jam-conformance/blob/main/fuzz-proto/fuzz.asn
|
|
12121
|
-
*/
|
|
12122
|
-
// Feature bit constants
|
|
12123
|
-
var Features;
|
|
12124
|
-
(function (Features) {
|
|
12125
|
-
Features[Features["Ancestry"] = 1] = "Ancestry";
|
|
12126
|
-
Features[Features["Fork"] = 2] = "Fork";
|
|
12127
|
-
Features[Features["Reserved"] = 2147483648] = "Reserved";
|
|
12128
|
-
})(Features || (Features = {}));
|
|
12129
|
-
/**
|
|
12130
|
-
* PeerInfo ::= SEQUENCE {
|
|
12131
|
-
* fuzz-version U8,
|
|
12132
|
-
* features Features,
|
|
12133
|
-
* jam-version Version,
|
|
12134
|
-
* app-version Version,
|
|
12135
|
-
* name UTF8String
|
|
12136
|
-
* }
|
|
12137
|
-
*/
|
|
12138
|
-
class PeerInfo extends WithDebug {
|
|
12139
|
-
fuzzVersion;
|
|
12140
|
-
features;
|
|
12141
|
-
jamVersion;
|
|
12142
|
-
appVersion;
|
|
12143
|
-
name;
|
|
12144
|
-
static Codec = codec$1.Class(PeerInfo, {
|
|
12145
|
-
fuzzVersion: codec$1.u8,
|
|
12146
|
-
features: codec$1.u32,
|
|
12147
|
-
jamVersion: Version.Codec,
|
|
12148
|
-
appVersion: Version.Codec,
|
|
12149
|
-
name: codec$1.string,
|
|
12150
|
-
});
|
|
12151
|
-
static create({ fuzzVersion, features, appVersion, jamVersion, name }) {
|
|
12152
|
-
return new PeerInfo(fuzzVersion, features, jamVersion, appVersion, name);
|
|
12153
|
-
}
|
|
12154
|
-
constructor(fuzzVersion, features, jamVersion, appVersion, name) {
|
|
12155
|
-
super();
|
|
12156
|
-
this.fuzzVersion = fuzzVersion;
|
|
12157
|
-
this.features = features;
|
|
12158
|
-
this.jamVersion = jamVersion;
|
|
12159
|
-
this.appVersion = appVersion;
|
|
12160
|
-
this.name = name;
|
|
12161
|
-
}
|
|
12162
|
-
}
|
|
12163
|
-
/**
|
|
12164
|
-
* AncestryItem ::= SEQUENCE {
|
|
12165
|
-
* slot TimeSlot,
|
|
12166
|
-
* header-hash HeaderHash
|
|
12167
|
-
* }
|
|
12168
|
-
*/
|
|
12169
|
-
class AncestryItem extends WithDebug {
|
|
12170
|
-
slot;
|
|
12171
|
-
headerHash;
|
|
12172
|
-
static Codec = codec$1.Class(AncestryItem, {
|
|
12173
|
-
slot: codec$1.u32.asOpaque(),
|
|
12174
|
-
headerHash: codec$1.bytes(HASH_SIZE).asOpaque(),
|
|
12175
|
-
});
|
|
12176
|
-
static create({ slot, headerHash }) {
|
|
12177
|
-
return new AncestryItem(slot, headerHash);
|
|
12178
|
-
}
|
|
12179
|
-
constructor(slot, headerHash) {
|
|
12180
|
-
super();
|
|
12181
|
-
this.slot = slot;
|
|
12182
|
-
this.headerHash = headerHash;
|
|
12183
|
-
}
|
|
12184
|
-
}
|
|
12185
|
-
/**
|
|
12186
|
-
* KeyValue ::= SEQUENCE {
|
|
12187
|
-
* key TrieKey,
|
|
12188
|
-
* value OCTET STRING
|
|
12189
|
-
* }
|
|
12190
|
-
*/
|
|
12191
|
-
class KeyValue extends WithDebug {
|
|
12192
|
-
key;
|
|
12193
|
-
value;
|
|
12194
|
-
static Codec = codec$1.Class(KeyValue, {
|
|
12195
|
-
key: codec$1.bytes(TRUNCATED_HASH_SIZE),
|
|
12196
|
-
value: codec$1.blob,
|
|
12197
|
-
});
|
|
12198
|
-
static create({ key, value }) {
|
|
12199
|
-
return new KeyValue(key, value);
|
|
12200
|
-
}
|
|
12201
|
-
constructor(key, value) {
|
|
12202
|
-
super();
|
|
12203
|
-
this.key = key;
|
|
12204
|
-
this.value = value;
|
|
12205
|
-
}
|
|
12206
|
-
}
|
|
12207
|
-
/** State ::= SEQUENCE OF KeyValue */
|
|
12208
|
-
const stateCodec = codec$1.sequenceVarLen(KeyValue.Codec);
|
|
12209
|
-
/**
|
|
12210
|
-
* Ancestry ::= SEQUENCE (SIZE(0..24)) OF AncestryItem
|
|
12211
|
-
* Empty when `feature-ancestry` is not supported by both parties
|
|
12212
|
-
*/
|
|
12213
|
-
const ancestryCodec = codec$1.sequenceVarLen(AncestryItem.Codec, {
|
|
12214
|
-
minLength: 0,
|
|
12215
|
-
maxLength: 24,
|
|
12216
|
-
});
|
|
12217
|
-
/**
|
|
12218
|
-
* Initialize ::= SEQUENCE {
|
|
12219
|
-
* header Header,
|
|
12220
|
-
* keyvals State,
|
|
12221
|
-
* ancestry Ancestry
|
|
12222
|
-
* }
|
|
12223
|
-
*/
|
|
12224
|
-
class Initialize extends WithDebug {
|
|
12225
|
-
header;
|
|
12226
|
-
keyvals;
|
|
12227
|
-
ancestry;
|
|
12228
|
-
static Codec = codec$1.Class(Initialize, {
|
|
12229
|
-
header: Header.Codec,
|
|
12230
|
-
keyvals: stateCodec,
|
|
12231
|
-
ancestry: ancestryCodec,
|
|
12232
|
-
});
|
|
12233
|
-
static create({ header, keyvals, ancestry }) {
|
|
12234
|
-
return new Initialize(header, keyvals, ancestry);
|
|
12235
|
-
}
|
|
12236
|
-
constructor(header, keyvals, ancestry) {
|
|
12237
|
-
super();
|
|
12238
|
-
this.header = header;
|
|
12239
|
-
this.keyvals = keyvals;
|
|
12240
|
-
this.ancestry = ancestry;
|
|
12241
|
-
}
|
|
12242
|
-
}
|
|
12243
|
-
/** GetState ::= HeaderHash */
|
|
12244
|
-
const getStateCodec = codec$1.bytes(HASH_SIZE).asOpaque();
|
|
12245
|
-
/** StateRoot ::= StateRootHash */
|
|
12246
|
-
const stateRootCodec = codec$1.bytes(HASH_SIZE).asOpaque();
|
|
12247
|
-
/** Error ::= UTF8String */
|
|
12248
|
-
class ErrorMessage extends WithDebug {
|
|
12249
|
-
message;
|
|
12250
|
-
static Codec = codec$1.Class(ErrorMessage, {
|
|
12251
|
-
message: codec$1.string,
|
|
12252
|
-
});
|
|
12253
|
-
static create({ message }) {
|
|
12254
|
-
return new ErrorMessage(message);
|
|
12255
|
-
}
|
|
12256
|
-
constructor(message) {
|
|
12257
|
-
super();
|
|
12258
|
-
this.message = message;
|
|
12259
|
-
}
|
|
12260
|
-
}
|
|
12261
|
-
/** Message choice type tags */
|
|
12262
|
-
var MessageType;
|
|
12263
|
-
(function (MessageType) {
|
|
12264
|
-
MessageType[MessageType["PeerInfo"] = 0] = "PeerInfo";
|
|
12265
|
-
MessageType[MessageType["Initialize"] = 1] = "Initialize";
|
|
12266
|
-
MessageType[MessageType["StateRoot"] = 2] = "StateRoot";
|
|
12267
|
-
MessageType[MessageType["ImportBlock"] = 3] = "ImportBlock";
|
|
12268
|
-
MessageType[MessageType["GetState"] = 4] = "GetState";
|
|
12269
|
-
MessageType[MessageType["State"] = 5] = "State";
|
|
12270
|
-
MessageType[MessageType["Error"] = 255] = "Error";
|
|
12271
|
-
})(MessageType || (MessageType = {}));
|
|
12272
|
-
/**
|
|
12273
|
-
* Message ::= CHOICE {
|
|
12274
|
-
* peer-info [0] PeerInfo,
|
|
12275
|
-
* initialize [1] Initialize,
|
|
12276
|
-
* state-root [2] StateRoot,
|
|
12277
|
-
* import-block [3] ImportBlock,
|
|
12278
|
-
* get-state [4] GetState,
|
|
12279
|
-
* state [5] State,
|
|
12280
|
-
* error [255] Error
|
|
12281
|
-
* }
|
|
12282
|
-
*/
|
|
12283
|
-
const messageCodec = codec$1.custom({
|
|
12284
|
-
name: "Message",
|
|
12285
|
-
sizeHint: { bytes: 1, isExact: false },
|
|
12286
|
-
}, (e, msg) => {
|
|
12287
|
-
e.i8(msg.type);
|
|
12288
|
-
switch (msg.type) {
|
|
12289
|
-
case MessageType.PeerInfo:
|
|
12290
|
-
PeerInfo.Codec.encode(e, msg.value);
|
|
12291
|
-
break;
|
|
12292
|
-
case MessageType.Initialize:
|
|
12293
|
-
Initialize.Codec.encode(e, msg.value);
|
|
12294
|
-
break;
|
|
12295
|
-
case MessageType.StateRoot:
|
|
12296
|
-
stateRootCodec.encode(e, msg.value);
|
|
12297
|
-
break;
|
|
12298
|
-
case MessageType.ImportBlock:
|
|
12299
|
-
Block.Codec.View.encode(e, msg.value);
|
|
12300
|
-
break;
|
|
12301
|
-
case MessageType.GetState:
|
|
12302
|
-
getStateCodec.encode(e, msg.value);
|
|
12303
|
-
break;
|
|
12304
|
-
case MessageType.State:
|
|
12305
|
-
stateCodec.encode(e, msg.value);
|
|
12306
|
-
break;
|
|
12307
|
-
case MessageType.Error:
|
|
12308
|
-
ErrorMessage.Codec.encode(e, msg.value);
|
|
12309
|
-
break;
|
|
12310
|
-
default:
|
|
12311
|
-
throw new Error(`Unknown message type: ${msg}`);
|
|
12312
|
-
}
|
|
12313
|
-
}, (d) => {
|
|
12314
|
-
const type = d.u8();
|
|
12315
|
-
switch (type) {
|
|
12316
|
-
case MessageType.PeerInfo:
|
|
12317
|
-
return { type: MessageType.PeerInfo, value: PeerInfo.Codec.decode(d) };
|
|
12318
|
-
case MessageType.Initialize:
|
|
12319
|
-
return { type: MessageType.Initialize, value: Initialize.Codec.decode(d) };
|
|
12320
|
-
case MessageType.StateRoot:
|
|
12321
|
-
return { type: MessageType.StateRoot, value: stateRootCodec.decode(d) };
|
|
12322
|
-
case MessageType.ImportBlock:
|
|
12323
|
-
return { type: MessageType.ImportBlock, value: Block.Codec.View.decode(d) };
|
|
12324
|
-
case MessageType.GetState:
|
|
12325
|
-
return { type: MessageType.GetState, value: getStateCodec.decode(d) };
|
|
12326
|
-
case MessageType.State:
|
|
12327
|
-
return { type: MessageType.State, value: stateCodec.decode(d) };
|
|
12328
|
-
case MessageType.Error:
|
|
12329
|
-
return { type: MessageType.Error, value: ErrorMessage.Codec.decode(d) };
|
|
12330
|
-
default:
|
|
12331
|
-
throw new Error(`Unknown message type: ${type}`);
|
|
12332
|
-
}
|
|
12333
|
-
}, (s) => {
|
|
12334
|
-
const type = s.decoder.u8();
|
|
12335
|
-
switch (type) {
|
|
12336
|
-
case MessageType.PeerInfo:
|
|
12337
|
-
PeerInfo.Codec.View.skip(s);
|
|
12338
|
-
break;
|
|
12339
|
-
case MessageType.Initialize:
|
|
12340
|
-
Initialize.Codec.View.skip(s);
|
|
12341
|
-
break;
|
|
12342
|
-
case MessageType.StateRoot:
|
|
12343
|
-
stateRootCodec.View.skip(s);
|
|
12344
|
-
break;
|
|
12345
|
-
case MessageType.ImportBlock:
|
|
12346
|
-
Block.Codec.View.skip(s);
|
|
12347
|
-
break;
|
|
12348
|
-
case MessageType.GetState:
|
|
12349
|
-
getStateCodec.View.skip(s);
|
|
12350
|
-
break;
|
|
12351
|
-
case MessageType.State:
|
|
12352
|
-
stateCodec.View.skip(s);
|
|
12353
|
-
break;
|
|
12354
|
-
case MessageType.Error:
|
|
12355
|
-
ErrorMessage.Codec.View.skip(s);
|
|
12356
|
-
break;
|
|
12357
|
-
default:
|
|
12358
|
-
throw new Error(`Unknown message type: ${type}`);
|
|
12359
|
-
}
|
|
12360
|
-
});
|
|
12361
|
-
|
|
12362
|
-
const logger$4 = Logger.new(import.meta.filename, "ext-ipc-fuzz-v1");
|
|
12363
|
-
class FuzzTarget {
|
|
12364
|
-
msgHandler;
|
|
12365
|
-
sender;
|
|
12366
|
-
spec;
|
|
12367
|
-
sessionFeatures = 0;
|
|
12368
|
-
constructor(msgHandler, sender, spec) {
|
|
12369
|
-
this.msgHandler = msgHandler;
|
|
12370
|
-
this.sender = sender;
|
|
12371
|
-
this.spec = spec;
|
|
12372
|
-
}
|
|
12373
|
-
async onSocketMessage(msg) {
|
|
12374
|
-
// attempt to decode the messsage
|
|
12375
|
-
try {
|
|
12376
|
-
const message = Decoder.decodeObject(messageCodec, msg, this.spec);
|
|
12377
|
-
logger$4.log `[${message.type}] incoming message`;
|
|
12378
|
-
await this.processAndRespond(message);
|
|
12379
|
-
}
|
|
12380
|
-
catch (e) {
|
|
12381
|
-
logger$4.error `Error while processing fuzz v1 message: ${e}`;
|
|
12382
|
-
logger$4.error `${e}`;
|
|
12383
|
-
if (e instanceof Error) {
|
|
12384
|
-
logger$4.error `${e.stack ?? ""}`;
|
|
12385
|
-
}
|
|
12386
|
-
this.sender.close();
|
|
12387
|
-
}
|
|
12388
|
-
}
|
|
12389
|
-
async processAndRespond(message) {
|
|
12390
|
-
let response = null;
|
|
12391
|
-
switch (message.type) {
|
|
12392
|
-
case MessageType.PeerInfo: {
|
|
12393
|
-
// only support V1
|
|
12394
|
-
if (message.value.fuzzVersion !== 1) {
|
|
12395
|
-
logger$4.warn `Unsupported fuzzer protocol version: ${message.value.fuzzVersion}. Closing`;
|
|
12396
|
-
this.sender.close();
|
|
12397
|
-
return;
|
|
12398
|
-
}
|
|
12399
|
-
// Handle handshake
|
|
12400
|
-
const ourPeerInfo = await this.msgHandler.getPeerInfo(message.value);
|
|
12401
|
-
// Calculate session features (intersection of both peer features)
|
|
12402
|
-
this.sessionFeatures = message.value.features & ourPeerInfo.features;
|
|
12403
|
-
logger$4.info `Handshake completed. Shared features: 0b${this.sessionFeatures.toString(2)}`;
|
|
12404
|
-
logger$4.log `Feature ancestry: ${(this.sessionFeatures & Features.Ancestry) !== 0}`;
|
|
12405
|
-
logger$4.log `Feature fork: ${(this.sessionFeatures & Features.Fork) !== 0}`;
|
|
12406
|
-
response = {
|
|
12407
|
-
type: MessageType.PeerInfo,
|
|
12408
|
-
value: ourPeerInfo,
|
|
12409
|
-
};
|
|
12410
|
-
break;
|
|
12411
|
-
}
|
|
12412
|
-
case MessageType.Initialize: {
|
|
12413
|
-
const stateRoot = await this.msgHandler.initialize(message.value);
|
|
12414
|
-
response = {
|
|
12415
|
-
type: MessageType.StateRoot,
|
|
12416
|
-
value: stateRoot,
|
|
12417
|
-
};
|
|
12418
|
-
break;
|
|
12419
|
-
}
|
|
12420
|
-
case MessageType.ImportBlock: {
|
|
12421
|
-
const result = await this.msgHandler.importBlock(message.value);
|
|
12422
|
-
if (result.isOk) {
|
|
12423
|
-
response = {
|
|
12424
|
-
type: MessageType.StateRoot,
|
|
12425
|
-
value: result.ok,
|
|
12426
|
-
};
|
|
12427
|
-
}
|
|
12428
|
-
else {
|
|
12429
|
-
response = {
|
|
12430
|
-
type: MessageType.Error,
|
|
12431
|
-
value: result.error,
|
|
12432
|
-
};
|
|
12433
|
-
}
|
|
12434
|
-
break;
|
|
12435
|
-
}
|
|
12436
|
-
case MessageType.GetState: {
|
|
12437
|
-
const state = await this.msgHandler.getSerializedState(message.value);
|
|
12438
|
-
response = {
|
|
12439
|
-
type: MessageType.State,
|
|
12440
|
-
value: state,
|
|
12441
|
-
};
|
|
12442
|
-
break;
|
|
12443
|
-
}
|
|
12444
|
-
case MessageType.StateRoot: {
|
|
12445
|
-
logger$4.log `--> Received unexpected 'StateRoot' message from the fuzzer. Closing.`;
|
|
12446
|
-
this.sender.close();
|
|
12447
|
-
return;
|
|
12448
|
-
}
|
|
12449
|
-
case MessageType.State: {
|
|
12450
|
-
logger$4.log `--> Received unexpected 'State' message from the fuzzer. Closing.`;
|
|
12451
|
-
this.sender.close();
|
|
12452
|
-
return;
|
|
12453
|
-
}
|
|
12454
|
-
case MessageType.Error: {
|
|
12455
|
-
logger$4.log `--> Received unexpected 'Error' message from the fuzzer. Closing.`;
|
|
12456
|
-
this.sender.close();
|
|
12457
|
-
return;
|
|
12458
|
-
}
|
|
12459
|
-
default: {
|
|
12460
|
-
logger$4.log `--> Received unexpected message type ${JSON.stringify(message)} from the fuzzer. Closing.`;
|
|
12461
|
-
this.sender.close();
|
|
12462
|
-
try {
|
|
12463
|
-
assertNever(message);
|
|
12464
|
-
}
|
|
12465
|
-
catch {
|
|
12466
|
-
return;
|
|
12467
|
-
}
|
|
12468
|
-
}
|
|
12469
|
-
}
|
|
12470
|
-
if (response !== null) {
|
|
12471
|
-
logger$4.trace `<-- responding with: ${response.type}`;
|
|
12472
|
-
const encoded = Encoder.encodeObject(messageCodec, response, this.spec);
|
|
12473
|
-
this.sender.send(encoded);
|
|
12474
|
-
}
|
|
12475
|
-
else {
|
|
12476
|
-
logger$4.warn `<-- no response generated for: ${message.type}`;
|
|
12477
|
-
}
|
|
12478
|
-
}
|
|
12479
|
-
onClose({ error }) {
|
|
12480
|
-
logger$4.log `Closing the v1 handler. Reason: ${error !== undefined ? error.message : "close"}.`;
|
|
12481
|
-
}
|
|
12482
|
-
/** Check if a specific feature is enabled in the session */
|
|
12483
|
-
hasFeature(feature) {
|
|
12484
|
-
return (this.sessionFeatures & feature) !== 0;
|
|
12485
|
-
}
|
|
12486
|
-
}
|
|
12487
|
-
|
|
12488
|
-
var index$b = /*#__PURE__*/Object.freeze({
|
|
12489
|
-
__proto__: null,
|
|
12490
|
-
AncestryItem: AncestryItem,
|
|
12491
|
-
ErrorMessage: ErrorMessage,
|
|
12492
|
-
get Features () { return Features; },
|
|
12493
|
-
FuzzTarget: FuzzTarget,
|
|
12494
|
-
Initialize: Initialize,
|
|
12495
|
-
KeyValue: KeyValue,
|
|
12496
|
-
get MessageType () { return MessageType; },
|
|
12497
|
-
PeerInfo: PeerInfo,
|
|
12498
|
-
Version: Version,
|
|
12499
|
-
ancestryCodec: ancestryCodec,
|
|
12500
|
-
getStateCodec: getStateCodec,
|
|
12501
|
-
messageCodec: messageCodec,
|
|
12502
|
-
stateCodec: stateCodec,
|
|
12503
|
-
stateRootCodec: stateRootCodec
|
|
12504
|
-
});
|
|
12505
|
-
|
|
12506
|
-
var index$a = /*#__PURE__*/Object.freeze({
|
|
12507
|
-
__proto__: null,
|
|
12508
|
-
v1: index$b
|
|
12509
|
-
});
|
|
12510
|
-
|
|
12511
12097
|
/** Size of the transfer memo. */
|
|
12512
12098
|
const TRANSFER_MEMO_BYTES = W_T;
|
|
12513
12099
|
/**
|
|
@@ -14555,6 +14141,17 @@ class PageRange {
|
|
|
14555
14141
|
}
|
|
14556
14142
|
return new PageRange(start, length);
|
|
14557
14143
|
}
|
|
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
|
+
}
|
|
14558
14155
|
/** Checks if a range is empty (`length === 0`) */
|
|
14559
14156
|
isEmpty() {
|
|
14560
14157
|
return this.length === 0;
|
|
@@ -14895,10 +14492,11 @@ class MemoryBuilder {
|
|
|
14895
14492
|
startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
|
|
14896
14493
|
`;
|
|
14897
14494
|
this.ensureNotFinalized();
|
|
14898
|
-
const
|
|
14899
|
-
const
|
|
14900
|
-
|
|
14901
|
-
|
|
14495
|
+
const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14496
|
+
const heapPagesRange = PageRange.fromMemoryRange(heapRange);
|
|
14497
|
+
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
14498
|
+
for (const pageNumber of initializedPageNumbers) {
|
|
14499
|
+
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14902
14500
|
throw new IncorrectSbrkIndex();
|
|
14903
14501
|
}
|
|
14904
14502
|
}
|
|
@@ -17338,8 +16936,8 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
17338
16936
|
asOpaqueType: asOpaqueType,
|
|
17339
16937
|
assertEmpty: assertEmpty,
|
|
17340
16938
|
assertNever: assertNever,
|
|
17341
|
-
block: index$
|
|
17342
|
-
bytes: index$
|
|
16939
|
+
block: index$j,
|
|
16940
|
+
bytes: index$q,
|
|
17343
16941
|
check: check,
|
|
17344
16942
|
clampU64ToU32: clampU64ToU32,
|
|
17345
16943
|
createResults: createResults,
|
|
@@ -17347,13 +16945,13 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
17347
16945
|
extractCodeAndMetadata: extractCodeAndMetadata,
|
|
17348
16946
|
getServiceId: getServiceId,
|
|
17349
16947
|
getServiceIdOrCurrent: getServiceIdOrCurrent,
|
|
17350
|
-
hash: index$
|
|
16948
|
+
hash: index$n,
|
|
17351
16949
|
inspect: inspect,
|
|
17352
16950
|
instructionArgumentTypeMap: instructionArgumentTypeMap,
|
|
17353
16951
|
interpreter: index$7,
|
|
17354
16952
|
isBrowser: isBrowser,
|
|
17355
16953
|
measure: measure,
|
|
17356
|
-
numbers: index$
|
|
16954
|
+
numbers: index$p,
|
|
17357
16955
|
resultToString: resultToString,
|
|
17358
16956
|
seeThrough: seeThrough,
|
|
17359
16957
|
slotsToPreimageStatus: slotsToPreimageStatus,
|
|
@@ -18067,4 +17665,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
18067
17665
|
WorkPackageExecutor: WorkPackageExecutor
|
|
18068
17666
|
});
|
|
18069
17667
|
|
|
18070
|
-
export { index$
|
|
17668
|
+
export { index$j as block, index$h as block_json, index$q as bytes, index$o as codec, index$l as collections, index$k as config, index$f as config_node, index$m as crypto, index$b as database, index$a as erasure_coding, index$n as hash, index$9 as jam_host_calls, index$i as json_parser, index$g as logger, index$8 as mmr, index$p as numbers, index$r as ordering, index$3 as pvm, index$6 as pvm_host_calls, index$7 as pvm_interpreter, index$4 as pvm_program, index$5 as pvm_spi_decoder, index$2 as shuffling, index$e as state, index$1 as state_json, index$c as state_merkleization, index as transition, index$d as trie, index$s as utils };
|