@typeberry/convert 0.4.1-69ce381 → 0.4.1-818bae8
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/README.md +22 -0
- package/index.js +510 -509
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4239,7 +4239,11 @@ class Logger {
|
|
|
4239
4239
|
}
|
|
4240
4240
|
}
|
|
4241
4241
|
|
|
4242
|
+
;// CONCATENATED MODULE: ./packages/core/utils/env.ts
|
|
4243
|
+
const env = typeof process === "undefined" ? {} : process.env;
|
|
4244
|
+
|
|
4242
4245
|
;// CONCATENATED MODULE: ./packages/core/utils/compatibility.ts
|
|
4246
|
+
|
|
4243
4247
|
var GpVersion;
|
|
4244
4248
|
(function (GpVersion) {
|
|
4245
4249
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
@@ -4259,7 +4263,6 @@ const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
|
4259
4263
|
* Since we are currently at 0.7.1 not 0.7.2, we set our default version accordingly.
|
|
4260
4264
|
*/
|
|
4261
4265
|
const DEFAULT_VERSION = GpVersion.V0_7_1;
|
|
4262
|
-
const env = typeof process === "undefined" ? {} : process.env;
|
|
4263
4266
|
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
4264
4267
|
let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
4265
4268
|
function parseCurrentVersion(env) {
|
|
@@ -4452,7 +4455,7 @@ function lazyInspect(obj) {
|
|
|
4452
4455
|
}
|
|
4453
4456
|
|
|
4454
4457
|
;// CONCATENATED MODULE: ./packages/core/utils/dev.ts
|
|
4455
|
-
|
|
4458
|
+
|
|
4456
4459
|
/**
|
|
4457
4460
|
* The function will produce relative path resolver that is adjusted
|
|
4458
4461
|
* for package location within the workspace.
|
|
@@ -4470,7 +4473,7 @@ const dev_env = typeof process === "undefined" ? {} : process.env;
|
|
|
4470
4473
|
* NOTE: the translation happens only for development build! When
|
|
4471
4474
|
* we build a single library from our project, we no longer mangle the paths.
|
|
4472
4475
|
*/
|
|
4473
|
-
const workspacePathFix =
|
|
4476
|
+
const workspacePathFix = env.NODE_ENV === "development"
|
|
4474
4477
|
? (workspacePath) => (p) => {
|
|
4475
4478
|
if (p.startsWith("/")) {
|
|
4476
4479
|
return p;
|
|
@@ -6482,213 +6485,209 @@ function exactHint(bytes) {
|
|
|
6482
6485
|
isExact: true,
|
|
6483
6486
|
};
|
|
6484
6487
|
}
|
|
6485
|
-
/**
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
cache.set(len, ret);
|
|
6496
|
-
}
|
|
6497
|
-
return ret;
|
|
6498
|
-
};
|
|
6499
|
-
})();
|
|
6500
|
-
/** Zero-size `void` value. */
|
|
6501
|
-
codec.nothing = Descriptor.new("void", { bytes: 0, isExact: true }, (_e, _v) => { }, (_d) => { }, (_s) => { });
|
|
6502
|
-
/** Variable-length U32. */
|
|
6503
|
-
codec.varU32 = Descriptor.new("var_u32", { bytes: 4, isExact: false }, (e, v) => e.varU32(v), (d) => d.varU32(), (d) => d.varU32());
|
|
6504
|
-
/** Variable-length U64. */
|
|
6505
|
-
codec.varU64 = Descriptor.new("var_u64", { bytes: 8, isExact: false }, (e, v) => e.varU64(v), (d) => d.varU64(), (d) => d.varU64());
|
|
6506
|
-
/** Unsigned 64-bit number. */
|
|
6507
|
-
codec.u64 = Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.u64(), (d) => d.u64(), codec.bytes(8));
|
|
6508
|
-
/** Unsigned 32-bit number. */
|
|
6509
|
-
codec.u32 = Descriptor.withView("u32", exactHint(4), (e, v) => e.i32(v), (d) => d.u32(), (d) => d.u32(), codec.bytes(4));
|
|
6510
|
-
/** Unsigned 24-bit number. */
|
|
6511
|
-
codec.u24 = Descriptor.withView("u24", exactHint(3), (e, v) => e.i24(v), (d) => d.u24(), (d) => d.u24(), codec.bytes(3));
|
|
6512
|
-
/** Unsigned 16-bit number. */
|
|
6513
|
-
codec.u16 = Descriptor.withView("u16", exactHint(2), (e, v) => e.i16(v), (d) => d.u16(), (d) => d.u16(), codec.bytes(2));
|
|
6514
|
-
/** Unsigned 8-bit number. */
|
|
6515
|
-
codec.u8 = Descriptor.new("u8", exactHint(1), (e, v) => e.i8(v), (d) => d.u8(), (d) => d.u8());
|
|
6516
|
-
/** Signed 64-bit number. */
|
|
6517
|
-
codec.i64 = Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.i64(), (s) => s.u64(), codec.bytes(8));
|
|
6518
|
-
/** Signed 32-bit number. */
|
|
6519
|
-
codec.i32 = Descriptor.withView("i32", exactHint(4), (e, v) => e.i32(v), (d) => d.i32(), (s) => s.u32(), codec.bytes(4));
|
|
6520
|
-
/** Signed 24-bit number. */
|
|
6521
|
-
codec.i24 = Descriptor.withView("i24", exactHint(3), (e, v) => e.i24(v), (d) => d.i24(), (s) => s.u24(), codec.bytes(3));
|
|
6522
|
-
/** Signed 16-bit number. */
|
|
6523
|
-
codec.i16 = Descriptor.withView("i16", exactHint(2), (e, v) => e.i16(v), (d) => d.i16(), (s) => s.u16(), codec.bytes(2));
|
|
6524
|
-
/** Signed 8-bit number. */
|
|
6525
|
-
codec.i8 = Descriptor.new("i8", exactHint(1), (e, v) => e.i8(v), (d) => d.i8(), (s) => s.u8());
|
|
6526
|
-
/** 1-byte boolean value. */
|
|
6527
|
-
codec.bool = Descriptor.new("bool", exactHint(1), (e, v) => e.bool(v), (d) => d.bool(), (s) => s.bool());
|
|
6528
|
-
/** Variable-length bytes blob. */
|
|
6529
|
-
codec.blob = Descriptor.new("BytesBlob", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(v), (d) => d.bytesBlob(), (s) => s.bytesBlob());
|
|
6530
|
-
/** String encoded as variable-length bytes blob. */
|
|
6531
|
-
codec.string = Descriptor.withView("string", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(bytes_BytesBlob.blobFrom(new TextEncoder().encode(v))), (d) => new TextDecoder("utf8", { fatal: true }).decode(d.bytesBlob().raw), (s) => s.bytesBlob(), codec.blob);
|
|
6532
|
-
/** Variable-length bit vector. */
|
|
6533
|
-
codec.bitVecVarLen = Descriptor.new("BitVec[?]", { bytes: TYPICAL_SEQUENCE_LENGTH >>> 3, isExact: false }, (e, v) => e.bitVecVarLen(v), (d) => d.bitVecVarLen(), (s) => s.bitVecVarLen());
|
|
6534
|
-
/** Fixed-length bit vector. */
|
|
6535
|
-
codec.bitVecFixLen = (bitLen) => Descriptor.new(`BitVec[${bitLen}]`, exactHint(bitLen >>> 3), (e, v) => e.bitVecFixLen(v), (d) => d.bitVecFixLen(bitLen), (s) => s.bitVecFixLen(bitLen));
|
|
6536
|
-
/** Optionality wrapper for given type. */
|
|
6537
|
-
codec.optional = (type) => {
|
|
6538
|
-
const self = Descriptor.new(`Optional<${type.name}>`, addSizeHints({ bytes: 1, isExact: false }, type.sizeHint), (e, v) => e.optional(type, v), (d) => d.optional(type), (s) => s.optional(type));
|
|
6539
|
-
if (hasUniqueView(type)) {
|
|
6540
|
-
return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, codec.optional(type.View));
|
|
6541
|
-
}
|
|
6542
|
-
return self;
|
|
6543
|
-
};
|
|
6544
|
-
/** Variable-length sequence of given type. */
|
|
6545
|
-
codec.sequenceVarLen = (type, options = {
|
|
6546
|
-
minLength: 0,
|
|
6547
|
-
maxLength: 2 ** 32 - 1,
|
|
6548
|
-
}) => {
|
|
6549
|
-
const name = `Sequence<${type.name}>[?]`;
|
|
6550
|
-
const typicalLength = options.typicalLength ?? TYPICAL_SEQUENCE_LENGTH;
|
|
6551
|
-
return Descriptor.withView(name, { bytes: typicalLength * type.sizeHint.bytes, isExact: false }, (e, v) => {
|
|
6552
|
-
validateLength(options, v.length, name);
|
|
6553
|
-
e.sequenceVarLen(type, v);
|
|
6554
|
-
}, (d) => {
|
|
6555
|
-
const len = d.varU32();
|
|
6556
|
-
validateLength(options, len, name);
|
|
6557
|
-
return d.sequenceFixLen(type, len);
|
|
6558
|
-
}, (s) => {
|
|
6559
|
-
const len = s.decoder.varU32();
|
|
6560
|
-
validateLength(options, len, name);
|
|
6561
|
-
return s.sequenceFixLen(type, len);
|
|
6562
|
-
}, sequenceViewVarLen(type, options));
|
|
6488
|
+
/** Fixed-length bytes sequence. */
|
|
6489
|
+
const bytes = (() => {
|
|
6490
|
+
const cache = new Map();
|
|
6491
|
+
return (len) => {
|
|
6492
|
+
let ret = cache.get(len);
|
|
6493
|
+
if (ret === undefined) {
|
|
6494
|
+
ret = Descriptor.new(`Bytes<${len}>`, exactHint(len), (e, v) => e.bytes(v), (d) => d.bytes(len), (s) => s.bytes(len));
|
|
6495
|
+
cache.set(len, ret);
|
|
6496
|
+
}
|
|
6497
|
+
return ret;
|
|
6563
6498
|
};
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6499
|
+
})();
|
|
6500
|
+
/** Zero-size `void` value. */
|
|
6501
|
+
const nothing = Descriptor.new("void", { bytes: 0, isExact: true }, (_e, _v) => { }, (_d) => { }, (_s) => { });
|
|
6502
|
+
/** Variable-length U32. */
|
|
6503
|
+
const varU32 = Descriptor.new("var_u32", { bytes: 4, isExact: false }, (e, v) => e.varU32(v), (d) => d.varU32(), (d) => d.varU32());
|
|
6504
|
+
/** Variable-length U64. */
|
|
6505
|
+
const varU64 = Descriptor.new("var_u64", { bytes: 8, isExact: false }, (e, v) => e.varU64(v), (d) => d.varU64(), (d) => d.varU64());
|
|
6506
|
+
/** Unsigned 64-bit number. */
|
|
6507
|
+
const u64 = Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.u64(), (d) => d.u64(), bytes(8));
|
|
6508
|
+
/** Unsigned 32-bit number. */
|
|
6509
|
+
const u32 = Descriptor.withView("u32", exactHint(4), (e, v) => e.i32(v), (d) => d.u32(), (d) => d.u32(), bytes(4));
|
|
6510
|
+
/** Unsigned 24-bit number. */
|
|
6511
|
+
const u24 = Descriptor.withView("u24", exactHint(3), (e, v) => e.i24(v), (d) => d.u24(), (d) => d.u24(), bytes(3));
|
|
6512
|
+
/** Unsigned 16-bit number. */
|
|
6513
|
+
const u16 = Descriptor.withView("u16", exactHint(2), (e, v) => e.i16(v), (d) => d.u16(), (d) => d.u16(), bytes(2));
|
|
6514
|
+
/** Unsigned 8-bit number. */
|
|
6515
|
+
const u8 = Descriptor.new("u8", exactHint(1), (e, v) => e.i8(v), (d) => d.u8(), (d) => d.u8());
|
|
6516
|
+
/** Signed 64-bit number. */
|
|
6517
|
+
const i64 = Descriptor.withView("i64", exactHint(8), (e, v) => e.i64(v), (d) => d.i64(), (s) => s.u64(), bytes(8));
|
|
6518
|
+
/** Signed 32-bit number. */
|
|
6519
|
+
const i32 = Descriptor.withView("i32", exactHint(4), (e, v) => e.i32(v), (d) => d.i32(), (s) => s.u32(), bytes(4));
|
|
6520
|
+
/** Signed 24-bit number. */
|
|
6521
|
+
const i24 = Descriptor.withView("i24", exactHint(3), (e, v) => e.i24(v), (d) => d.i24(), (s) => s.u24(), bytes(3));
|
|
6522
|
+
/** Signed 16-bit number. */
|
|
6523
|
+
const i16 = Descriptor.withView("i16", exactHint(2), (e, v) => e.i16(v), (d) => d.i16(), (s) => s.u16(), bytes(2));
|
|
6524
|
+
/** Signed 8-bit number. */
|
|
6525
|
+
const i8 = Descriptor.new("i8", exactHint(1), (e, v) => e.i8(v), (d) => d.i8(), (s) => s.u8());
|
|
6526
|
+
/** 1-byte boolean value. */
|
|
6527
|
+
const bool = Descriptor.new("bool", exactHint(1), (e, v) => e.bool(v), (d) => d.bool(), (s) => s.bool());
|
|
6528
|
+
/** Variable-length bytes blob. */
|
|
6529
|
+
const blob = Descriptor.new("BytesBlob", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(v), (d) => d.bytesBlob(), (s) => s.bytesBlob());
|
|
6530
|
+
/** String encoded as variable-length bytes blob. */
|
|
6531
|
+
const string = Descriptor.withView("string", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(bytes_BytesBlob.blobFrom(new TextEncoder().encode(v))), (d) => new TextDecoder("utf8", { fatal: true }).decode(d.bytesBlob().raw), (s) => s.bytesBlob(), blob);
|
|
6532
|
+
/** Variable-length bit vector. */
|
|
6533
|
+
const bitVecVarLen = Descriptor.new("BitVec[?]", { bytes: TYPICAL_SEQUENCE_LENGTH >>> 3, isExact: false }, (e, v) => e.bitVecVarLen(v), (d) => d.bitVecVarLen(), (s) => s.bitVecVarLen());
|
|
6534
|
+
/** Fixed-length bit vector. */
|
|
6535
|
+
const bitVecFixLen = (bitLen) => Descriptor.new(`BitVec[${bitLen}]`, exactHint(bitLen >>> 3), (e, v) => e.bitVecFixLen(v), (d) => d.bitVecFixLen(bitLen), (s) => s.bitVecFixLen(bitLen));
|
|
6536
|
+
/** Optionality wrapper for given type. */
|
|
6537
|
+
const optional = (type) => {
|
|
6538
|
+
const self = Descriptor.new(`Optional<${type.name}>`, addSizeHints({ bytes: 1, isExact: false }, type.sizeHint), (e, v) => e.optional(type, v), (d) => d.optional(type), (s) => s.optional(type));
|
|
6539
|
+
if (hasUniqueView(type)) {
|
|
6540
|
+
return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, optional(type.View));
|
|
6541
|
+
}
|
|
6542
|
+
return self;
|
|
6543
|
+
};
|
|
6544
|
+
/** Variable-length sequence of given type. */
|
|
6545
|
+
const sequenceVarLen = (type, options = {
|
|
6546
|
+
minLength: 0,
|
|
6547
|
+
maxLength: 2 ** 32 - 1,
|
|
6548
|
+
}) => {
|
|
6549
|
+
const name = `Sequence<${type.name}>[?]`;
|
|
6550
|
+
const typicalLength = options.typicalLength ?? TYPICAL_SEQUENCE_LENGTH;
|
|
6551
|
+
return Descriptor.withView(name, { bytes: typicalLength * type.sizeHint.bytes, isExact: false }, (e, v) => {
|
|
6552
|
+
validateLength(options, v.length, name);
|
|
6553
|
+
e.sequenceVarLen(type, v);
|
|
6554
|
+
}, (d) => {
|
|
6555
|
+
const len = d.varU32();
|
|
6556
|
+
validateLength(options, len, name);
|
|
6557
|
+
return d.sequenceFixLen(type, len);
|
|
6558
|
+
}, (s) => {
|
|
6559
|
+
const len = s.decoder.varU32();
|
|
6560
|
+
validateLength(options, len, name);
|
|
6561
|
+
return s.sequenceFixLen(type, len);
|
|
6562
|
+
}, sequenceViewVarLen(type, options));
|
|
6563
|
+
};
|
|
6564
|
+
/** Fixed-length sequence of given type. */
|
|
6565
|
+
const sequenceFixLen = (type, len) => Descriptor.withView(`Sequence<${type.name}>[${len}]`, { bytes: len * type.sizeHint.bytes, isExact: type.sizeHint.isExact }, (e, v) => e.sequenceFixLen(type, v), (d) => d.sequenceFixLen(type, len), (s) => s.sequenceFixLen(type, len), sequenceViewFixLen(type, { fixedLength: len }));
|
|
6566
|
+
/** Small dictionary codec. */
|
|
6567
|
+
const dictionary = (key, value, { sortKeys, fixedLength, }) => {
|
|
6568
|
+
const self = Descriptor.new(`Dictionary<${key.name}, ${value.name}>[${fixedLength ?? "?"}]`, {
|
|
6569
|
+
bytes: fixedLength !== undefined
|
|
6570
|
+
? fixedLength * addSizeHints(key.sizeHint, value.sizeHint).bytes
|
|
6571
|
+
: TYPICAL_DICTIONARY_LENGTH * (addSizeHints(key.sizeHint, value.sizeHint).bytes ?? 0),
|
|
6572
|
+
isExact: fixedLength !== undefined ? key.sizeHint.isExact && value.sizeHint.isExact : false,
|
|
6573
|
+
}, (e, v) => {
|
|
6574
|
+
const data = Array.from(v.entries());
|
|
6575
|
+
data.sort((a, b) => sortKeys(a[0], b[0]));
|
|
6576
|
+
// length prefix
|
|
6577
|
+
if (fixedLength === undefined) {
|
|
6578
|
+
e.varU32(numbers_tryAsU32(data.length));
|
|
6579
|
+
}
|
|
6580
|
+
for (const [k, v] of data) {
|
|
6581
|
+
key.encode(e, k);
|
|
6582
|
+
value.encode(e, v);
|
|
6583
|
+
}
|
|
6584
|
+
}, (d) => {
|
|
6585
|
+
const map = new Map();
|
|
6586
|
+
const len = fixedLength ?? d.varU32();
|
|
6587
|
+
let prevKey = null;
|
|
6588
|
+
for (let i = 0; i < len; i += 1) {
|
|
6589
|
+
const k = key.decode(d);
|
|
6590
|
+
const v = value.decode(d);
|
|
6591
|
+
if (map.has(k)) {
|
|
6592
|
+
throw new Error(`Duplicate item in the dictionary encoding: "${k}"!`);
|
|
6583
6593
|
}
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
const len = fixedLength ?? d.varU32();
|
|
6587
|
-
let prevKey = null;
|
|
6588
|
-
for (let i = 0; i < len; i += 1) {
|
|
6589
|
-
const k = key.decode(d);
|
|
6590
|
-
const v = value.decode(d);
|
|
6591
|
-
if (map.has(k)) {
|
|
6592
|
-
throw new Error(`Duplicate item in the dictionary encoding: "${k}"!`);
|
|
6593
|
-
}
|
|
6594
|
-
if (prevKey !== null && sortKeys(prevKey, k) >= 0) {
|
|
6595
|
-
throw new Error(`The keys in dictionary encoding are not sorted "${prevKey}" >= "${k}"!`);
|
|
6596
|
-
}
|
|
6597
|
-
map.set(k, v);
|
|
6598
|
-
prevKey = k;
|
|
6594
|
+
if (prevKey !== null && sortKeys(prevKey, k) >= 0) {
|
|
6595
|
+
throw new Error(`The keys in dictionary encoding are not sorted "${prevKey}" >= "${k}"!`);
|
|
6599
6596
|
}
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
const len = fixedLength ?? s.decoder.varU32();
|
|
6603
|
-
s.sequenceFixLen(key, len);
|
|
6604
|
-
s.sequenceFixLen(value, len);
|
|
6605
|
-
});
|
|
6606
|
-
if (hasUniqueView(value)) {
|
|
6607
|
-
return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, codec.dictionary(key, value.View, { sortKeys, fixedLength }));
|
|
6597
|
+
map.set(k, v);
|
|
6598
|
+
prevKey = k;
|
|
6608
6599
|
}
|
|
6609
|
-
return
|
|
6610
|
-
}
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6618
|
-
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6600
|
+
return map;
|
|
6601
|
+
}, (s) => {
|
|
6602
|
+
const len = fixedLength ?? s.decoder.varU32();
|
|
6603
|
+
s.sequenceFixLen(key, len);
|
|
6604
|
+
s.sequenceFixLen(value, len);
|
|
6605
|
+
});
|
|
6606
|
+
if (hasUniqueView(value)) {
|
|
6607
|
+
return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, dictionary(key, value.View, { sortKeys, fixedLength }));
|
|
6608
|
+
}
|
|
6609
|
+
return self;
|
|
6610
|
+
};
|
|
6611
|
+
/** Encoding of pair of two values. */
|
|
6612
|
+
const pair = (a, b) => {
|
|
6613
|
+
const self = Descriptor.new(`Pair<${a.name}, ${b.name}>`, addSizeHints(a.sizeHint, b.sizeHint), (e, elem) => {
|
|
6614
|
+
a.encode(e, elem[0]);
|
|
6615
|
+
b.encode(e, elem[1]);
|
|
6616
|
+
}, (d) => {
|
|
6617
|
+
const aValue = a.decode(d);
|
|
6618
|
+
const bValue = b.decode(d);
|
|
6619
|
+
return [aValue, bValue];
|
|
6620
|
+
}, (s) => {
|
|
6621
|
+
a.skip(s);
|
|
6622
|
+
b.skip(s);
|
|
6623
|
+
});
|
|
6624
|
+
if (hasUniqueView(a) && hasUniqueView(b)) {
|
|
6625
|
+
return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, pair(a.View, b.View));
|
|
6626
|
+
}
|
|
6627
|
+
return self;
|
|
6628
|
+
};
|
|
6629
|
+
/** Custom encoding / decoding logic. */
|
|
6630
|
+
const custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
6631
|
+
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
6632
|
+
const descriptors_select = ({ name, sizeHint, }, chooser) => {
|
|
6633
|
+
const Self = chooser(null);
|
|
6634
|
+
return Descriptor.withView(name, sizeHint, (e, x) => chooser(e.getContext()).encode(e, x), (d) => chooser(d.getContext()).decode(d), (s) => chooser(s.decoder.getContext()).skip(s), hasUniqueView(Self)
|
|
6635
|
+
? descriptors_select({
|
|
6636
|
+
name: Self.View.name,
|
|
6637
|
+
sizeHint: Self.View.sizeHint,
|
|
6638
|
+
}, (ctx) => chooser(ctx).View)
|
|
6639
|
+
: Self.View);
|
|
6640
|
+
};
|
|
6641
|
+
/**
|
|
6642
|
+
* A descriptor for a more complex POJO.
|
|
6643
|
+
*
|
|
6644
|
+
* This descriptor is very similar to `Class`, but it DOES NOT maintain the
|
|
6645
|
+
* prototype chain of the resulting object - we only care about the shape of
|
|
6646
|
+
* the object here.
|
|
6647
|
+
*/
|
|
6648
|
+
const object = (descriptors, name = "object", create = (o) => o) => {
|
|
6649
|
+
return Class({ name, create }, descriptors);
|
|
6650
|
+
};
|
|
6651
|
+
/**
|
|
6652
|
+
* A descriptor for a more complex class type.
|
|
6653
|
+
*
|
|
6654
|
+
* The resulting descriptor is able to encode & decode all of the public fields of
|
|
6655
|
+
* the class, given the map of descriptors for each one of them.
|
|
6656
|
+
*
|
|
6657
|
+
* The resulting decoded object will be an instance of given `Class` unlike simpler,
|
|
6658
|
+
* shape-based `object` method.
|
|
6659
|
+
*/
|
|
6660
|
+
const Class = (Class, descriptors) => {
|
|
6661
|
+
// Calculate a size hint for this class.
|
|
6662
|
+
let sizeHint = exactHint(0);
|
|
6663
|
+
forEachDescriptor(descriptors, (_k, val) => {
|
|
6664
|
+
sizeHint = addSizeHints(sizeHint, val.sizeHint);
|
|
6665
|
+
});
|
|
6666
|
+
const skipper = (s) => {
|
|
6667
|
+
// optimized case for fixed size complex values.
|
|
6668
|
+
if (sizeHint.isExact) {
|
|
6669
|
+
return s.decoder.skip(sizeHint.bytes);
|
|
6626
6670
|
}
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
/** Custom encoding / decoding logic. */
|
|
6630
|
-
codec.custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
6631
|
-
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
6632
|
-
codec.select = ({ name, sizeHint, }, chooser) => {
|
|
6633
|
-
const Self = chooser(null);
|
|
6634
|
-
return Descriptor.withView(name, sizeHint, (e, x) => chooser(e.getContext()).encode(e, x), (d) => chooser(d.getContext()).decode(d), (s) => chooser(s.decoder.getContext()).skip(s), hasUniqueView(Self)
|
|
6635
|
-
? codec.select({
|
|
6636
|
-
name: Self.View.name,
|
|
6637
|
-
sizeHint: Self.View.sizeHint,
|
|
6638
|
-
}, (ctx) => chooser(ctx).View)
|
|
6639
|
-
: Self.View);
|
|
6640
|
-
};
|
|
6641
|
-
/**
|
|
6642
|
-
* A descriptor for a more complex POJO.
|
|
6643
|
-
*
|
|
6644
|
-
* This descriptor is very similar to `Class`, but it DOES NOT maintain the
|
|
6645
|
-
* prototype chain of the resulting object - we only care about the shape of
|
|
6646
|
-
* the object here.
|
|
6647
|
-
*/
|
|
6648
|
-
codec.object = (descriptors, name = "object", create = (o) => o) => {
|
|
6649
|
-
return codec.Class({ name, create }, descriptors);
|
|
6650
|
-
};
|
|
6651
|
-
/**
|
|
6652
|
-
* A descriptor for a more complex class type.
|
|
6653
|
-
*
|
|
6654
|
-
* The resulting descriptor is able to encode & decode all of the public fields of
|
|
6655
|
-
* the class, given the map of descriptors for each one of them.
|
|
6656
|
-
*
|
|
6657
|
-
* The resulting decoded object will be an instance of given `Class` unlike simpler,
|
|
6658
|
-
* shape-based `object` method.
|
|
6659
|
-
*/
|
|
6660
|
-
codec.Class = (Class, descriptors) => {
|
|
6661
|
-
// Calculate a size hint for this class.
|
|
6662
|
-
let sizeHint = exactHint(0);
|
|
6663
|
-
forEachDescriptor(descriptors, (_k, val) => {
|
|
6664
|
-
sizeHint = addSizeHints(sizeHint, val.sizeHint);
|
|
6671
|
+
forEachDescriptor(descriptors, (_key, descriptor) => {
|
|
6672
|
+
descriptor.skip(s);
|
|
6665
6673
|
});
|
|
6666
|
-
const skipper = (s) => {
|
|
6667
|
-
// optimized case for fixed size complex values.
|
|
6668
|
-
if (sizeHint.isExact) {
|
|
6669
|
-
return s.decoder.skip(sizeHint.bytes);
|
|
6670
|
-
}
|
|
6671
|
-
forEachDescriptor(descriptors, (_key, descriptor) => {
|
|
6672
|
-
descriptor.skip(s);
|
|
6673
|
-
});
|
|
6674
|
-
};
|
|
6675
|
-
const view = objectView(Class, descriptors, sizeHint, skipper);
|
|
6676
|
-
// and create the descriptor for the entire class.
|
|
6677
|
-
return Descriptor.withView(Class.name, sizeHint, (e, t) => {
|
|
6678
|
-
forEachDescriptor(descriptors, (key, descriptor) => {
|
|
6679
|
-
const value = t[key];
|
|
6680
|
-
descriptor.encode(e, value);
|
|
6681
|
-
});
|
|
6682
|
-
}, (d) => {
|
|
6683
|
-
const constructorParams = {};
|
|
6684
|
-
forEachDescriptor(descriptors, (key, descriptor) => {
|
|
6685
|
-
const value = descriptor.decode(d);
|
|
6686
|
-
constructorParams[key] = value;
|
|
6687
|
-
});
|
|
6688
|
-
return Class.create(constructorParams);
|
|
6689
|
-
}, skipper, view);
|
|
6690
6674
|
};
|
|
6691
|
-
|
|
6675
|
+
const view = objectView(Class, descriptors, sizeHint, skipper);
|
|
6676
|
+
// and create the descriptor for the entire class.
|
|
6677
|
+
return Descriptor.withView(Class.name, sizeHint, (e, t) => {
|
|
6678
|
+
forEachDescriptor(descriptors, (key, descriptor) => {
|
|
6679
|
+
const value = t[key];
|
|
6680
|
+
descriptor.encode(e, value);
|
|
6681
|
+
});
|
|
6682
|
+
}, (d) => {
|
|
6683
|
+
const constructorParams = {};
|
|
6684
|
+
forEachDescriptor(descriptors, (key, descriptor) => {
|
|
6685
|
+
const value = descriptor.decode(d);
|
|
6686
|
+
constructorParams[key] = value;
|
|
6687
|
+
});
|
|
6688
|
+
return Class.create(constructorParams);
|
|
6689
|
+
}, skipper, view);
|
|
6690
|
+
};
|
|
6692
6691
|
/** Typesafe iteration of every descriptor in the record object. */
|
|
6693
6692
|
function forEachDescriptor(descriptors, f) {
|
|
6694
6693
|
for (const key in descriptors) {
|
|
@@ -9003,7 +9002,7 @@ var PvmBackend;
|
|
|
9003
9002
|
|
|
9004
9003
|
|
|
9005
9004
|
|
|
9006
|
-
;// CONCATENATED MODULE: ./packages/jam/block/codec.ts
|
|
9005
|
+
;// CONCATENATED MODULE: ./packages/jam/block/codec-utils.ts
|
|
9007
9006
|
|
|
9008
9007
|
|
|
9009
9008
|
|
|
@@ -9018,7 +9017,7 @@ function codecWithContext(chooser) {
|
|
|
9018
9017
|
const defaultContext = chain_spec_fullChainSpec;
|
|
9019
9018
|
const { name, sizeHint } = chooser(defaultContext);
|
|
9020
9019
|
const cache = new Map();
|
|
9021
|
-
return
|
|
9020
|
+
return descriptors_select({
|
|
9022
9021
|
name,
|
|
9023
9022
|
sizeHint: { bytes: sizeHint.bytes, isExact: false },
|
|
9024
9023
|
}, (context) => {
|
|
@@ -9045,9 +9044,9 @@ function codecWithContext(chooser) {
|
|
|
9045
9044
|
/** Codec for a known-size array with length validation. */
|
|
9046
9045
|
const codecKnownSizeArray = (val, options, _id) => {
|
|
9047
9046
|
if ("fixedLength" in options) {
|
|
9048
|
-
return readonlyArray(
|
|
9047
|
+
return readonlyArray(sequenceFixLen(val, options.fixedLength)).convert(seeThrough, sized_array_asKnownSize);
|
|
9049
9048
|
}
|
|
9050
|
-
return readonlyArray(
|
|
9049
|
+
return readonlyArray(sequenceVarLen(val, options)).convert(seeThrough, sized_array_asKnownSize);
|
|
9051
9050
|
};
|
|
9052
9051
|
/** Codec for a fixed-size array with length validation. */
|
|
9053
9052
|
const codecFixedSizeArray = (val, len) => {
|
|
@@ -9056,7 +9055,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
9056
9055
|
throw new Error(`[${val.name}] Invalid size of fixed-size array. Got ${actual}, expected: ${len}`);
|
|
9057
9056
|
}
|
|
9058
9057
|
};
|
|
9059
|
-
return
|
|
9058
|
+
return sequenceFixLen(val, len).convert((i) => {
|
|
9060
9059
|
checkLength(i.length);
|
|
9061
9060
|
return i;
|
|
9062
9061
|
}, (o) => {
|
|
@@ -9117,13 +9116,13 @@ class AvailabilityAssurance extends WithDebug {
|
|
|
9117
9116
|
bitfield;
|
|
9118
9117
|
validatorIndex;
|
|
9119
9118
|
signature;
|
|
9120
|
-
static Codec =
|
|
9121
|
-
anchor:
|
|
9119
|
+
static Codec = Class(AvailabilityAssurance, {
|
|
9120
|
+
anchor: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9122
9121
|
bitfield: codecWithContext((context) => {
|
|
9123
|
-
return
|
|
9122
|
+
return bitVecFixLen(context.coresCount);
|
|
9124
9123
|
}),
|
|
9125
|
-
validatorIndex:
|
|
9126
|
-
signature:
|
|
9124
|
+
validatorIndex: u16.asOpaque(),
|
|
9125
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9127
9126
|
});
|
|
9128
9127
|
static create({ anchor, bitfield, validatorIndex, signature }) {
|
|
9129
9128
|
return new AvailabilityAssurance(anchor, bitfield, validatorIndex, signature);
|
|
@@ -9215,11 +9214,11 @@ class Fault extends WithDebug {
|
|
|
9215
9214
|
wasConsideredValid;
|
|
9216
9215
|
key;
|
|
9217
9216
|
signature;
|
|
9218
|
-
static Codec =
|
|
9219
|
-
workReportHash:
|
|
9220
|
-
wasConsideredValid:
|
|
9221
|
-
key:
|
|
9222
|
-
signature:
|
|
9217
|
+
static Codec = Class(Fault, {
|
|
9218
|
+
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9219
|
+
wasConsideredValid: bool,
|
|
9220
|
+
key: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
9221
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9223
9222
|
});
|
|
9224
9223
|
static create({ workReportHash, wasConsideredValid, key, signature }) {
|
|
9225
9224
|
return new Fault(workReportHash, wasConsideredValid, key, signature);
|
|
@@ -9247,10 +9246,10 @@ class Culprit extends WithDebug {
|
|
|
9247
9246
|
workReportHash;
|
|
9248
9247
|
key;
|
|
9249
9248
|
signature;
|
|
9250
|
-
static Codec =
|
|
9251
|
-
workReportHash:
|
|
9252
|
-
key:
|
|
9253
|
-
signature:
|
|
9249
|
+
static Codec = Class(Culprit, {
|
|
9250
|
+
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9251
|
+
key: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
9252
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9254
9253
|
});
|
|
9255
9254
|
static create({ workReportHash, key, signature }) {
|
|
9256
9255
|
return new Culprit(workReportHash, key, signature);
|
|
@@ -9275,10 +9274,10 @@ class Judgement extends WithDebug {
|
|
|
9275
9274
|
isWorkReportValid;
|
|
9276
9275
|
index;
|
|
9277
9276
|
signature;
|
|
9278
|
-
static Codec =
|
|
9279
|
-
isWorkReportValid:
|
|
9280
|
-
index:
|
|
9281
|
-
signature:
|
|
9277
|
+
static Codec = Class(Judgement, {
|
|
9278
|
+
isWorkReportValid: bool,
|
|
9279
|
+
index: u16.asOpaque(),
|
|
9280
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9282
9281
|
});
|
|
9283
9282
|
static create({ isWorkReportValid, index, signature }) {
|
|
9284
9283
|
return new Judgement(isWorkReportValid, index, signature);
|
|
@@ -9307,11 +9306,12 @@ class Verdict extends WithDebug {
|
|
|
9307
9306
|
workReportHash;
|
|
9308
9307
|
votesEpoch;
|
|
9309
9308
|
votes;
|
|
9310
|
-
static Codec =
|
|
9311
|
-
workReportHash:
|
|
9312
|
-
votesEpoch:
|
|
9309
|
+
static Codec = Class(Verdict, {
|
|
9310
|
+
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9311
|
+
votesEpoch: u32.asOpaque(),
|
|
9313
9312
|
votes: codecWithContext((context) => {
|
|
9314
|
-
return readonlyArray(
|
|
9313
|
+
return readonlyArray(sequenceFixLen(Judgement.Codec, context.validatorsSuperMajority))
|
|
9314
|
+
.convert(seeThrough, sized_array_asKnownSize);
|
|
9315
9315
|
}),
|
|
9316
9316
|
});
|
|
9317
9317
|
static create({ workReportHash, votesEpoch, votes }) {
|
|
@@ -9352,10 +9352,10 @@ class DisputesExtrinsic extends WithDebug {
|
|
|
9352
9352
|
verdicts;
|
|
9353
9353
|
culprits;
|
|
9354
9354
|
faults;
|
|
9355
|
-
static Codec =
|
|
9356
|
-
verdicts:
|
|
9357
|
-
culprits:
|
|
9358
|
-
faults:
|
|
9355
|
+
static Codec = Class(DisputesExtrinsic, {
|
|
9356
|
+
verdicts: sequenceVarLen(Verdict.Codec),
|
|
9357
|
+
culprits: sequenceVarLen(Culprit.Codec),
|
|
9358
|
+
faults: sequenceVarLen(Fault.Codec),
|
|
9359
9359
|
});
|
|
9360
9360
|
static create({ verdicts, culprits, faults }) {
|
|
9361
9361
|
return new DisputesExtrinsic(verdicts, culprits, faults);
|
|
@@ -9401,9 +9401,9 @@ class DisputesExtrinsic extends WithDebug {
|
|
|
9401
9401
|
class WorkPackageInfo extends WithDebug {
|
|
9402
9402
|
workPackageHash;
|
|
9403
9403
|
segmentTreeRoot;
|
|
9404
|
-
static Codec =
|
|
9405
|
-
workPackageHash:
|
|
9406
|
-
segmentTreeRoot:
|
|
9404
|
+
static Codec = Class(WorkPackageInfo, {
|
|
9405
|
+
workPackageHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9406
|
+
segmentTreeRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9407
9407
|
});
|
|
9408
9408
|
constructor(
|
|
9409
9409
|
/** Hash of the described work package. */
|
|
@@ -9431,13 +9431,13 @@ class RefineContext extends WithDebug {
|
|
|
9431
9431
|
lookupAnchor;
|
|
9432
9432
|
lookupAnchorSlot;
|
|
9433
9433
|
prerequisites;
|
|
9434
|
-
static Codec =
|
|
9435
|
-
anchor:
|
|
9436
|
-
stateRoot:
|
|
9437
|
-
beefyRoot:
|
|
9438
|
-
lookupAnchor:
|
|
9439
|
-
lookupAnchorSlot:
|
|
9440
|
-
prerequisites:
|
|
9434
|
+
static Codec = Class(RefineContext, {
|
|
9435
|
+
anchor: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9436
|
+
stateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9437
|
+
beefyRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9438
|
+
lookupAnchor: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9439
|
+
lookupAnchorSlot: u32.asOpaque(),
|
|
9440
|
+
prerequisites: sequenceVarLen(bytes(hash_HASH_SIZE).asOpaque()),
|
|
9441
9441
|
});
|
|
9442
9442
|
static create({ anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites, }) {
|
|
9443
9443
|
return new RefineContext(anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites);
|
|
@@ -9494,9 +9494,9 @@ const tryAsSegmentIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
|
9494
9494
|
class ImportSpec extends WithDebug {
|
|
9495
9495
|
treeRoot;
|
|
9496
9496
|
index;
|
|
9497
|
-
static Codec =
|
|
9498
|
-
treeRoot:
|
|
9499
|
-
index:
|
|
9497
|
+
static Codec = Class(ImportSpec, {
|
|
9498
|
+
treeRoot: bytes(hash_HASH_SIZE),
|
|
9499
|
+
index: u16.asOpaque(),
|
|
9500
9500
|
});
|
|
9501
9501
|
static create({ treeRoot, index }) {
|
|
9502
9502
|
return new ImportSpec(treeRoot, index);
|
|
@@ -9518,9 +9518,9 @@ class ImportSpec extends WithDebug {
|
|
|
9518
9518
|
class WorkItemExtrinsicSpec extends WithDebug {
|
|
9519
9519
|
hash;
|
|
9520
9520
|
len;
|
|
9521
|
-
static Codec =
|
|
9522
|
-
hash:
|
|
9523
|
-
len:
|
|
9521
|
+
static Codec = Class(WorkItemExtrinsicSpec, {
|
|
9522
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9523
|
+
len: u32,
|
|
9524
9524
|
});
|
|
9525
9525
|
static create({ hash, len }) {
|
|
9526
9526
|
return new WorkItemExtrinsicSpec(hash, len);
|
|
@@ -9581,33 +9581,33 @@ class work_item_WorkItem extends WithDebug {
|
|
|
9581
9581
|
extrinsic;
|
|
9582
9582
|
exportCount;
|
|
9583
9583
|
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
9584
|
-
?
|
|
9585
|
-
service:
|
|
9586
|
-
codeHash:
|
|
9587
|
-
refineGasLimit:
|
|
9588
|
-
accumulateGasLimit:
|
|
9589
|
-
exportCount:
|
|
9590
|
-
payload:
|
|
9584
|
+
? Class(work_item_WorkItem, {
|
|
9585
|
+
service: u32.asOpaque(),
|
|
9586
|
+
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9587
|
+
refineGasLimit: u64.asOpaque(),
|
|
9588
|
+
accumulateGasLimit: u64.asOpaque(),
|
|
9589
|
+
exportCount: u16,
|
|
9590
|
+
payload: blob,
|
|
9591
9591
|
importSegments: codecKnownSizeArray(ImportSpec.Codec, {
|
|
9592
9592
|
minLength: 0,
|
|
9593
9593
|
maxLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9594
9594
|
typicalLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9595
9595
|
}),
|
|
9596
|
-
extrinsic:
|
|
9596
|
+
extrinsic: sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
9597
9597
|
})
|
|
9598
|
-
:
|
|
9599
|
-
service:
|
|
9600
|
-
codeHash:
|
|
9601
|
-
payload:
|
|
9602
|
-
refineGasLimit:
|
|
9603
|
-
accumulateGasLimit:
|
|
9598
|
+
: Class(work_item_WorkItem, {
|
|
9599
|
+
service: u32.asOpaque(),
|
|
9600
|
+
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9601
|
+
payload: blob,
|
|
9602
|
+
refineGasLimit: u64.asOpaque(),
|
|
9603
|
+
accumulateGasLimit: u64.asOpaque(),
|
|
9604
9604
|
importSegments: codecKnownSizeArray(ImportSpec.Codec, {
|
|
9605
9605
|
minLength: 0,
|
|
9606
9606
|
maxLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9607
9607
|
typicalLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9608
9608
|
}),
|
|
9609
|
-
extrinsic:
|
|
9610
|
-
exportCount:
|
|
9609
|
+
extrinsic: sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
9610
|
+
exportCount: u16,
|
|
9611
9611
|
});
|
|
9612
9612
|
static create({ service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount, }) {
|
|
9613
9613
|
return new work_item_WorkItem(service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount);
|
|
@@ -9681,21 +9681,21 @@ class work_package_WorkPackage extends WithDebug {
|
|
|
9681
9681
|
context;
|
|
9682
9682
|
items;
|
|
9683
9683
|
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
9684
|
-
?
|
|
9685
|
-
authCodeHost:
|
|
9686
|
-
authCodeHash:
|
|
9684
|
+
? Class(work_package_WorkPackage, {
|
|
9685
|
+
authCodeHost: u32.asOpaque(),
|
|
9686
|
+
authCodeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9687
9687
|
context: RefineContext.Codec,
|
|
9688
|
-
authorization:
|
|
9689
|
-
parametrization:
|
|
9690
|
-
items:
|
|
9688
|
+
authorization: blob,
|
|
9689
|
+
parametrization: blob,
|
|
9690
|
+
items: sequenceVarLen(work_item_WorkItem.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
9691
9691
|
})
|
|
9692
|
-
:
|
|
9693
|
-
authorization:
|
|
9694
|
-
authCodeHost:
|
|
9695
|
-
authCodeHash:
|
|
9696
|
-
parametrization:
|
|
9692
|
+
: Class(work_package_WorkPackage, {
|
|
9693
|
+
authorization: blob,
|
|
9694
|
+
authCodeHost: u32.asOpaque(),
|
|
9695
|
+
authCodeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9696
|
+
parametrization: blob,
|
|
9697
9697
|
context: RefineContext.Codec,
|
|
9698
|
-
items:
|
|
9698
|
+
items: sequenceVarLen(work_item_WorkItem.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
9699
9699
|
});
|
|
9700
9700
|
static create({ authorization, authCodeHost, authCodeHash, parametrization, context, items, }) {
|
|
9701
9701
|
return new work_package_WorkPackage(authorization, authCodeHost, authCodeHash, parametrization, context, items);
|
|
@@ -9755,7 +9755,7 @@ var WorkExecResultKind;
|
|
|
9755
9755
|
class WorkExecResult extends WithDebug {
|
|
9756
9756
|
kind;
|
|
9757
9757
|
okBlob;
|
|
9758
|
-
static Codec =
|
|
9758
|
+
static Codec = custom({
|
|
9759
9759
|
name: "WorkExecResult",
|
|
9760
9760
|
sizeHint: { bytes: 1, isExact: false },
|
|
9761
9761
|
}, (e, x) => {
|
|
@@ -9802,12 +9802,12 @@ class WorkRefineLoad extends WithDebug {
|
|
|
9802
9802
|
extrinsicCount;
|
|
9803
9803
|
extrinsicSize;
|
|
9804
9804
|
exportedSegments;
|
|
9805
|
-
static Codec =
|
|
9806
|
-
gasUsed:
|
|
9807
|
-
importedSegments:
|
|
9808
|
-
extrinsicCount:
|
|
9809
|
-
extrinsicSize:
|
|
9810
|
-
exportedSegments:
|
|
9805
|
+
static Codec = Class(WorkRefineLoad, {
|
|
9806
|
+
gasUsed: varU64.asOpaque(),
|
|
9807
|
+
importedSegments: varU32,
|
|
9808
|
+
extrinsicCount: varU32,
|
|
9809
|
+
extrinsicSize: varU32,
|
|
9810
|
+
exportedSegments: varU32,
|
|
9811
9811
|
});
|
|
9812
9812
|
static create({ gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments, }) {
|
|
9813
9813
|
return new WorkRefineLoad(gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments);
|
|
@@ -9843,11 +9843,11 @@ class WorkResult {
|
|
|
9843
9843
|
gas;
|
|
9844
9844
|
result;
|
|
9845
9845
|
load;
|
|
9846
|
-
static Codec =
|
|
9847
|
-
serviceId:
|
|
9848
|
-
codeHash:
|
|
9849
|
-
payloadHash:
|
|
9850
|
-
gas:
|
|
9846
|
+
static Codec = Class(WorkResult, {
|
|
9847
|
+
serviceId: u32.asOpaque(),
|
|
9848
|
+
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9849
|
+
payloadHash: bytes(hash_HASH_SIZE),
|
|
9850
|
+
gas: u64.asOpaque(),
|
|
9851
9851
|
result: WorkExecResult.Codec,
|
|
9852
9852
|
load: WorkRefineLoad.Codec,
|
|
9853
9853
|
});
|
|
@@ -9914,12 +9914,12 @@ class WorkPackageSpec extends WithDebug {
|
|
|
9914
9914
|
erasureRoot;
|
|
9915
9915
|
exportsRoot;
|
|
9916
9916
|
exportsCount;
|
|
9917
|
-
static Codec =
|
|
9918
|
-
hash:
|
|
9919
|
-
length:
|
|
9920
|
-
erasureRoot:
|
|
9921
|
-
exportsRoot:
|
|
9922
|
-
exportsCount:
|
|
9917
|
+
static Codec = Class(WorkPackageSpec, {
|
|
9918
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9919
|
+
length: u32,
|
|
9920
|
+
erasureRoot: bytes(hash_HASH_SIZE),
|
|
9921
|
+
exportsRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9922
|
+
exportsCount: u16,
|
|
9923
9923
|
});
|
|
9924
9924
|
static create({ hash, length, erasureRoot, exportsRoot, exportsCount }) {
|
|
9925
9925
|
return new WorkPackageSpec(hash, length, erasureRoot, exportsRoot, exportsCount);
|
|
@@ -9991,35 +9991,35 @@ class WorkReportNoCodec extends WithDebug {
|
|
|
9991
9991
|
this.authorizationGasUsed = authorizationGasUsed;
|
|
9992
9992
|
}
|
|
9993
9993
|
}
|
|
9994
|
-
const WorkReportCodec =
|
|
9994
|
+
const WorkReportCodec = Class(WorkReportNoCodec, {
|
|
9995
9995
|
workPackageSpec: WorkPackageSpec.Codec,
|
|
9996
9996
|
context: RefineContext.Codec,
|
|
9997
|
-
coreIndex:
|
|
9997
|
+
coreIndex: varU32.convert((o) => numbers_tryAsU32(o), (i) => {
|
|
9998
9998
|
if (!isU16(i)) {
|
|
9999
9999
|
throw new Error(`Core index exceeds U16: ${i}`);
|
|
10000
10000
|
}
|
|
10001
10001
|
return tryAsCoreIndex(i);
|
|
10002
10002
|
}),
|
|
10003
|
-
authorizerHash:
|
|
10004
|
-
authorizationGasUsed:
|
|
10005
|
-
authorizationOutput:
|
|
10006
|
-
segmentRootLookup: readonlyArray(
|
|
10007
|
-
results:
|
|
10003
|
+
authorizerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10004
|
+
authorizationGasUsed: varU64.asOpaque(),
|
|
10005
|
+
authorizationOutput: blob,
|
|
10006
|
+
segmentRootLookup: readonlyArray(sequenceVarLen(WorkPackageInfo.Codec)),
|
|
10007
|
+
results: sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
10008
10008
|
});
|
|
10009
|
-
const WorkReportCodecPre070 =
|
|
10009
|
+
const WorkReportCodecPre070 = Class(WorkReportNoCodec, {
|
|
10010
10010
|
workPackageSpec: WorkPackageSpec.Codec,
|
|
10011
10011
|
context: RefineContext.Codec,
|
|
10012
|
-
coreIndex:
|
|
10012
|
+
coreIndex: varU32.convert((o) => numbers_tryAsU32(o), (i) => {
|
|
10013
10013
|
if (!isU16(i)) {
|
|
10014
10014
|
throw new Error(`Core index exceeds U16: ${i}`);
|
|
10015
10015
|
}
|
|
10016
10016
|
return tryAsCoreIndex(i);
|
|
10017
10017
|
}),
|
|
10018
|
-
authorizerHash:
|
|
10019
|
-
authorizationOutput:
|
|
10020
|
-
segmentRootLookup: readonlyArray(
|
|
10021
|
-
results:
|
|
10022
|
-
authorizationGasUsed:
|
|
10018
|
+
authorizerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10019
|
+
authorizationOutput: blob,
|
|
10020
|
+
segmentRootLookup: readonlyArray(sequenceVarLen(WorkPackageInfo.Codec)),
|
|
10021
|
+
results: sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
10022
|
+
authorizationGasUsed: varU64.asOpaque(),
|
|
10023
10023
|
});
|
|
10024
10024
|
class WorkReport extends WorkReportNoCodec {
|
|
10025
10025
|
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
@@ -10038,9 +10038,9 @@ const REQUIRED_CREDENTIALS_RANGE = [2, 3];
|
|
|
10038
10038
|
class Credential extends WithDebug {
|
|
10039
10039
|
validatorIndex;
|
|
10040
10040
|
signature;
|
|
10041
|
-
static Codec =
|
|
10042
|
-
validatorIndex:
|
|
10043
|
-
signature:
|
|
10041
|
+
static Codec = Class(Credential, {
|
|
10042
|
+
validatorIndex: u16.asOpaque(),
|
|
10043
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
10044
10044
|
});
|
|
10045
10045
|
static create({ validatorIndex, signature }) {
|
|
10046
10046
|
return new Credential(validatorIndex, signature);
|
|
@@ -10064,9 +10064,9 @@ class ReportGuarantee extends WithDebug {
|
|
|
10064
10064
|
report;
|
|
10065
10065
|
slot;
|
|
10066
10066
|
credentials;
|
|
10067
|
-
static Codec =
|
|
10067
|
+
static Codec = Class(ReportGuarantee, {
|
|
10068
10068
|
report: WorkReport.Codec,
|
|
10069
|
-
slot:
|
|
10069
|
+
slot: u32.asOpaque(),
|
|
10070
10070
|
credentials: codecKnownSizeArray(Credential.Codec, {
|
|
10071
10071
|
minLength: REQUIRED_CREDENTIALS_RANGE[0],
|
|
10072
10072
|
maxLength: REQUIRED_CREDENTIALS_RANGE[1],
|
|
@@ -10116,10 +10116,10 @@ function tryAsTicketAttempt(x) {
|
|
|
10116
10116
|
class SignedTicket extends WithDebug {
|
|
10117
10117
|
attempt;
|
|
10118
10118
|
signature;
|
|
10119
|
-
static Codec =
|
|
10119
|
+
static Codec = Class(SignedTicket, {
|
|
10120
10120
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
10121
|
-
attempt:
|
|
10122
|
-
signature:
|
|
10121
|
+
attempt: u8.asOpaque(),
|
|
10122
|
+
signature: bytes(BANDERSNATCH_PROOF_BYTES).asOpaque(),
|
|
10123
10123
|
});
|
|
10124
10124
|
static create({ attempt, signature }) {
|
|
10125
10125
|
return new SignedTicket(attempt, signature);
|
|
@@ -10138,10 +10138,10 @@ class SignedTicket extends WithDebug {
|
|
|
10138
10138
|
class Ticket extends WithDebug {
|
|
10139
10139
|
id;
|
|
10140
10140
|
attempt;
|
|
10141
|
-
static Codec =
|
|
10142
|
-
id:
|
|
10141
|
+
static Codec = Class(Ticket, {
|
|
10142
|
+
id: bytes(hash_HASH_SIZE),
|
|
10143
10143
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
10144
|
-
attempt:
|
|
10144
|
+
attempt: u8.asOpaque(),
|
|
10145
10145
|
});
|
|
10146
10146
|
static create({ id, attempt }) {
|
|
10147
10147
|
return new Ticket(id, attempt);
|
|
@@ -10193,9 +10193,9 @@ const ticketsExtrinsicCodec = codecWithContext((context) => {
|
|
|
10193
10193
|
class ValidatorKeys extends WithDebug {
|
|
10194
10194
|
bandersnatch;
|
|
10195
10195
|
ed25519;
|
|
10196
|
-
static Codec =
|
|
10197
|
-
bandersnatch:
|
|
10198
|
-
ed25519:
|
|
10196
|
+
static Codec = Class(ValidatorKeys, {
|
|
10197
|
+
bandersnatch: bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
10198
|
+
ed25519: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
10199
10199
|
});
|
|
10200
10200
|
static create({ bandersnatch, ed25519 }) {
|
|
10201
10201
|
return new ValidatorKeys(bandersnatch, ed25519);
|
|
@@ -10212,7 +10212,7 @@ class ValidatorKeys extends WithDebug {
|
|
|
10212
10212
|
}
|
|
10213
10213
|
class TicketsMarker extends WithDebug {
|
|
10214
10214
|
tickets;
|
|
10215
|
-
static Codec =
|
|
10215
|
+
static Codec = Class(TicketsMarker, {
|
|
10216
10216
|
tickets: codecPerEpochBlock(Ticket.Codec),
|
|
10217
10217
|
});
|
|
10218
10218
|
static create({ tickets }) {
|
|
@@ -10234,9 +10234,9 @@ class EpochMarker extends WithDebug {
|
|
|
10234
10234
|
entropy;
|
|
10235
10235
|
ticketsEntropy;
|
|
10236
10236
|
validators;
|
|
10237
|
-
static Codec =
|
|
10238
|
-
entropy:
|
|
10239
|
-
ticketsEntropy:
|
|
10237
|
+
static Codec = Class(EpochMarker, {
|
|
10238
|
+
entropy: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10239
|
+
ticketsEntropy: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10240
10240
|
validators: codecPerValidator(ValidatorKeys.Codec),
|
|
10241
10241
|
});
|
|
10242
10242
|
static create({ entropy, ticketsEntropy, validators }) {
|
|
@@ -10271,16 +10271,16 @@ const encodeUnsealedHeader = (view) => {
|
|
|
10271
10271
|
* Codec descriptor with pre 0.7.0 encoding order
|
|
10272
10272
|
*/
|
|
10273
10273
|
const legacyDescriptor = {
|
|
10274
|
-
parentHeaderHash:
|
|
10275
|
-
priorStateRoot:
|
|
10276
|
-
extrinsicHash:
|
|
10277
|
-
timeSlotIndex:
|
|
10278
|
-
epochMarker:
|
|
10279
|
-
ticketsMarker:
|
|
10280
|
-
offendersMarker:
|
|
10281
|
-
bandersnatchBlockAuthorIndex:
|
|
10282
|
-
entropySource:
|
|
10283
|
-
seal:
|
|
10274
|
+
parentHeaderHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10275
|
+
priorStateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10276
|
+
extrinsicHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10277
|
+
timeSlotIndex: u32.asOpaque(),
|
|
10278
|
+
epochMarker: optional(EpochMarker.Codec),
|
|
10279
|
+
ticketsMarker: optional(TicketsMarker.Codec),
|
|
10280
|
+
offendersMarker: sequenceVarLen(bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
10281
|
+
bandersnatchBlockAuthorIndex: u16.asOpaque(),
|
|
10282
|
+
entropySource: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10283
|
+
seal: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10284
10284
|
};
|
|
10285
10285
|
/**
|
|
10286
10286
|
* The header of the JAM block.
|
|
@@ -10288,19 +10288,19 @@ const legacyDescriptor = {
|
|
|
10288
10288
|
* https://graypaper.fluffylabs.dev/#/579bd12/0c66000c7200
|
|
10289
10289
|
*/
|
|
10290
10290
|
class header_Header extends WithDebug {
|
|
10291
|
-
static Codec =
|
|
10291
|
+
static Codec = Class(header_Header, Compatibility.isLessThan(GpVersion.V0_7_0)
|
|
10292
10292
|
? legacyDescriptor
|
|
10293
10293
|
: {
|
|
10294
|
-
parentHeaderHash:
|
|
10295
|
-
priorStateRoot:
|
|
10296
|
-
extrinsicHash:
|
|
10297
|
-
timeSlotIndex:
|
|
10298
|
-
epochMarker:
|
|
10299
|
-
ticketsMarker:
|
|
10300
|
-
bandersnatchBlockAuthorIndex:
|
|
10301
|
-
entropySource:
|
|
10302
|
-
offendersMarker:
|
|
10303
|
-
seal:
|
|
10294
|
+
parentHeaderHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10295
|
+
priorStateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10296
|
+
extrinsicHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10297
|
+
timeSlotIndex: u32.asOpaque(),
|
|
10298
|
+
epochMarker: optional(EpochMarker.Codec),
|
|
10299
|
+
ticketsMarker: optional(TicketsMarker.Codec),
|
|
10300
|
+
bandersnatchBlockAuthorIndex: u16.asOpaque(),
|
|
10301
|
+
entropySource: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10302
|
+
offendersMarker: sequenceVarLen(bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
10303
|
+
seal: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10304
10304
|
});
|
|
10305
10305
|
static create(h) {
|
|
10306
10306
|
return Object.assign(header_Header.empty(), h);
|
|
@@ -10355,8 +10355,8 @@ class header_Header extends WithDebug {
|
|
|
10355
10355
|
* `DescriptorRecord` or `CodecRecord` for some reason.
|
|
10356
10356
|
*/
|
|
10357
10357
|
class HeaderViewWithHash extends WithHash {
|
|
10358
|
-
static Codec =
|
|
10359
|
-
hash:
|
|
10358
|
+
static Codec = Class(HeaderViewWithHash, {
|
|
10359
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10360
10360
|
data: header_Header.Codec.View,
|
|
10361
10361
|
});
|
|
10362
10362
|
static create({ hash, data }) {
|
|
@@ -10377,9 +10377,9 @@ const headerViewWithHashCodec = HeaderViewWithHash.Codec;
|
|
|
10377
10377
|
class Preimage extends WithDebug {
|
|
10378
10378
|
requester;
|
|
10379
10379
|
blob;
|
|
10380
|
-
static Codec =
|
|
10381
|
-
requester:
|
|
10382
|
-
blob:
|
|
10380
|
+
static Codec = Class(Preimage, {
|
|
10381
|
+
requester: u32.asOpaque(),
|
|
10382
|
+
blob: blob,
|
|
10383
10383
|
});
|
|
10384
10384
|
static create({ requester, blob }) {
|
|
10385
10385
|
return new Preimage(requester, blob);
|
|
@@ -10394,7 +10394,7 @@ class Preimage extends WithDebug {
|
|
|
10394
10394
|
this.blob = blob;
|
|
10395
10395
|
}
|
|
10396
10396
|
}
|
|
10397
|
-
const preimagesExtrinsicCodec =
|
|
10397
|
+
const preimagesExtrinsicCodec = sequenceVarLen(Preimage.Codec);
|
|
10398
10398
|
|
|
10399
10399
|
;// CONCATENATED MODULE: ./packages/jam/block/block.ts
|
|
10400
10400
|
|
|
@@ -10420,7 +10420,7 @@ class Extrinsic extends WithDebug {
|
|
|
10420
10420
|
guarantees;
|
|
10421
10421
|
assurances;
|
|
10422
10422
|
disputes;
|
|
10423
|
-
static Codec =
|
|
10423
|
+
static Codec = Class(Extrinsic, {
|
|
10424
10424
|
tickets: ticketsExtrinsicCodec,
|
|
10425
10425
|
preimages: preimagesExtrinsicCodec,
|
|
10426
10426
|
guarantees: guaranteesExtrinsicCodec,
|
|
@@ -10473,7 +10473,7 @@ class Extrinsic extends WithDebug {
|
|
|
10473
10473
|
class Block extends WithDebug {
|
|
10474
10474
|
header;
|
|
10475
10475
|
extrinsic;
|
|
10476
|
-
static Codec =
|
|
10476
|
+
static Codec = Class(Block, {
|
|
10477
10477
|
header: header_Header.Codec,
|
|
10478
10478
|
extrinsic: Extrinsic.Codec,
|
|
10479
10479
|
});
|
|
@@ -11457,10 +11457,10 @@ class Version extends WithDebug {
|
|
|
11457
11457
|
major;
|
|
11458
11458
|
minor;
|
|
11459
11459
|
patch;
|
|
11460
|
-
static Codec =
|
|
11461
|
-
major:
|
|
11462
|
-
minor:
|
|
11463
|
-
patch:
|
|
11460
|
+
static Codec = Class(Version, {
|
|
11461
|
+
major: u8,
|
|
11462
|
+
minor: u8,
|
|
11463
|
+
patch: u8,
|
|
11464
11464
|
});
|
|
11465
11465
|
static tryFromString(str) {
|
|
11466
11466
|
const parse = (v) => tryAsU8(Number(v));
|
|
@@ -11512,12 +11512,12 @@ class PeerInfo extends WithDebug {
|
|
|
11512
11512
|
jamVersion;
|
|
11513
11513
|
appVersion;
|
|
11514
11514
|
name;
|
|
11515
|
-
static Codec =
|
|
11516
|
-
fuzzVersion:
|
|
11517
|
-
features:
|
|
11515
|
+
static Codec = Class(PeerInfo, {
|
|
11516
|
+
fuzzVersion: u8,
|
|
11517
|
+
features: u32,
|
|
11518
11518
|
jamVersion: Version.Codec,
|
|
11519
11519
|
appVersion: Version.Codec,
|
|
11520
|
-
name:
|
|
11520
|
+
name: string,
|
|
11521
11521
|
});
|
|
11522
11522
|
static create({ fuzzVersion, features, appVersion, jamVersion, name }) {
|
|
11523
11523
|
return new PeerInfo(fuzzVersion, features, jamVersion, appVersion, name);
|
|
@@ -11540,9 +11540,9 @@ class PeerInfo extends WithDebug {
|
|
|
11540
11540
|
class AncestryItem extends WithDebug {
|
|
11541
11541
|
slot;
|
|
11542
11542
|
headerHash;
|
|
11543
|
-
static Codec =
|
|
11544
|
-
slot:
|
|
11545
|
-
headerHash:
|
|
11543
|
+
static Codec = Class(AncestryItem, {
|
|
11544
|
+
slot: u32.asOpaque(),
|
|
11545
|
+
headerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
11546
11546
|
});
|
|
11547
11547
|
static create({ slot, headerHash }) {
|
|
11548
11548
|
return new AncestryItem(slot, headerHash);
|
|
@@ -11562,9 +11562,9 @@ class AncestryItem extends WithDebug {
|
|
|
11562
11562
|
class KeyValue extends WithDebug {
|
|
11563
11563
|
key;
|
|
11564
11564
|
value;
|
|
11565
|
-
static Codec =
|
|
11566
|
-
key:
|
|
11567
|
-
value:
|
|
11565
|
+
static Codec = Class(KeyValue, {
|
|
11566
|
+
key: bytes(TRUNCATED_HASH_SIZE),
|
|
11567
|
+
value: blob,
|
|
11568
11568
|
});
|
|
11569
11569
|
static create({ key, value }) {
|
|
11570
11570
|
return new KeyValue(key, value);
|
|
@@ -11576,12 +11576,12 @@ class KeyValue extends WithDebug {
|
|
|
11576
11576
|
}
|
|
11577
11577
|
}
|
|
11578
11578
|
/** State ::= SEQUENCE OF KeyValue */
|
|
11579
|
-
const stateCodec =
|
|
11579
|
+
const stateCodec = sequenceVarLen(KeyValue.Codec);
|
|
11580
11580
|
/**
|
|
11581
11581
|
* Ancestry ::= SEQUENCE (SIZE(0..24)) OF AncestryItem
|
|
11582
11582
|
* Empty when `feature-ancestry` is not supported by both parties
|
|
11583
11583
|
*/
|
|
11584
|
-
const ancestryCodec =
|
|
11584
|
+
const ancestryCodec = sequenceVarLen(AncestryItem.Codec, {
|
|
11585
11585
|
minLength: 0,
|
|
11586
11586
|
maxLength: 24,
|
|
11587
11587
|
});
|
|
@@ -11596,7 +11596,7 @@ class Initialize extends WithDebug {
|
|
|
11596
11596
|
header;
|
|
11597
11597
|
keyvals;
|
|
11598
11598
|
ancestry;
|
|
11599
|
-
static Codec =
|
|
11599
|
+
static Codec = Class(Initialize, {
|
|
11600
11600
|
header: header_Header.Codec,
|
|
11601
11601
|
keyvals: stateCodec,
|
|
11602
11602
|
ancestry: ancestryCodec,
|
|
@@ -11612,14 +11612,14 @@ class Initialize extends WithDebug {
|
|
|
11612
11612
|
}
|
|
11613
11613
|
}
|
|
11614
11614
|
/** GetState ::= HeaderHash */
|
|
11615
|
-
const getStateCodec =
|
|
11615
|
+
const getStateCodec = bytes(hash_HASH_SIZE).asOpaque();
|
|
11616
11616
|
/** StateRoot ::= StateRootHash */
|
|
11617
|
-
const stateRootCodec =
|
|
11617
|
+
const stateRootCodec = bytes(hash_HASH_SIZE).asOpaque();
|
|
11618
11618
|
/** Error ::= UTF8String */
|
|
11619
11619
|
class ErrorMessage extends WithDebug {
|
|
11620
11620
|
message;
|
|
11621
|
-
static Codec =
|
|
11622
|
-
message:
|
|
11621
|
+
static Codec = Class(ErrorMessage, {
|
|
11622
|
+
message: string,
|
|
11623
11623
|
});
|
|
11624
11624
|
static create({ message }) {
|
|
11625
11625
|
return new ErrorMessage(message);
|
|
@@ -11651,7 +11651,7 @@ var types_MessageType;
|
|
|
11651
11651
|
* error [255] Error
|
|
11652
11652
|
* }
|
|
11653
11653
|
*/
|
|
11654
|
-
const types_messageCodec =
|
|
11654
|
+
const types_messageCodec = custom({
|
|
11655
11655
|
name: "Message",
|
|
11656
11656
|
sizeHint: { bytes: 1, isExact: false },
|
|
11657
11657
|
}, (e, msg) => {
|
|
@@ -12015,9 +12015,9 @@ function getRegisters(argsLength) {
|
|
|
12015
12015
|
class AccumulationOutput {
|
|
12016
12016
|
serviceId;
|
|
12017
12017
|
output;
|
|
12018
|
-
static Codec =
|
|
12019
|
-
serviceId:
|
|
12020
|
-
output:
|
|
12018
|
+
static Codec = Class(AccumulationOutput, {
|
|
12019
|
+
serviceId: u32.asOpaque(),
|
|
12020
|
+
output: bytes(hash_HASH_SIZE),
|
|
12021
12021
|
});
|
|
12022
12022
|
static create(a) {
|
|
12023
12023
|
return new AccumulationOutput(a.serviceId, a.output);
|
|
@@ -12110,9 +12110,9 @@ const MAX_REPORT_DEPENDENCIES = 8;
|
|
|
12110
12110
|
class NotYetAccumulatedReport extends WithDebug {
|
|
12111
12111
|
report;
|
|
12112
12112
|
dependencies;
|
|
12113
|
-
static Codec =
|
|
12113
|
+
static Codec = Class(NotYetAccumulatedReport, {
|
|
12114
12114
|
report: WorkReport.Codec,
|
|
12115
|
-
dependencies: codecKnownSizeArray(
|
|
12115
|
+
dependencies: codecKnownSizeArray(bytes(hash_HASH_SIZE).asOpaque(), {
|
|
12116
12116
|
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
12117
12117
|
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
12118
12118
|
minLength: 0,
|
|
@@ -12139,7 +12139,7 @@ class NotYetAccumulatedReport extends WithDebug {
|
|
|
12139
12139
|
this.dependencies = dependencies;
|
|
12140
12140
|
}
|
|
12141
12141
|
}
|
|
12142
|
-
const accumulationQueueCodec = codecPerEpochBlock(readonlyArray(
|
|
12142
|
+
const accumulationQueueCodec = codecPerEpochBlock(readonlyArray(sequenceVarLen(NotYetAccumulatedReport.Codec)));
|
|
12143
12143
|
|
|
12144
12144
|
;// CONCATENATED MODULE: ./packages/jam/state/common.ts
|
|
12145
12145
|
|
|
@@ -12172,9 +12172,9 @@ const codecPerCore = (val) => codecWithContext((context) => {
|
|
|
12172
12172
|
class AvailabilityAssignment extends WithDebug {
|
|
12173
12173
|
workReport;
|
|
12174
12174
|
timeout;
|
|
12175
|
-
static Codec =
|
|
12175
|
+
static Codec = Class(AvailabilityAssignment, {
|
|
12176
12176
|
workReport: WorkReport.Codec,
|
|
12177
|
-
timeout:
|
|
12177
|
+
timeout: u32.asOpaque(),
|
|
12178
12178
|
});
|
|
12179
12179
|
static create({ workReport, timeout }) {
|
|
12180
12180
|
return new AvailabilityAssignment(workReport, timeout);
|
|
@@ -12189,7 +12189,7 @@ class AvailabilityAssignment extends WithDebug {
|
|
|
12189
12189
|
this.timeout = timeout;
|
|
12190
12190
|
}
|
|
12191
12191
|
}
|
|
12192
|
-
const availabilityAssignmentsCodec = codecPerCore(
|
|
12192
|
+
const availabilityAssignmentsCodec = codecPerCore(optional(AvailabilityAssignment.Codec));
|
|
12193
12193
|
|
|
12194
12194
|
;// CONCATENATED MODULE: ./packages/jam/state/auth.ts
|
|
12195
12195
|
|
|
@@ -12201,18 +12201,18 @@ const availabilityAssignmentsCodec = codecPerCore(descriptors_codec.optional(Ava
|
|
|
12201
12201
|
const MAX_AUTH_POOL_SIZE = O;
|
|
12202
12202
|
/** `Q`: Size of the authorization queue. */
|
|
12203
12203
|
const AUTHORIZATION_QUEUE_SIZE = Q;
|
|
12204
|
-
const authPoolsCodec = codecPerCore(codecKnownSizeArray(
|
|
12204
|
+
const authPoolsCodec = codecPerCore(codecKnownSizeArray(bytes(hash_HASH_SIZE).asOpaque(), {
|
|
12205
12205
|
minLength: 0,
|
|
12206
12206
|
maxLength: MAX_AUTH_POOL_SIZE,
|
|
12207
12207
|
typicalLength: MAX_AUTH_POOL_SIZE,
|
|
12208
12208
|
}));
|
|
12209
|
-
const authQueuesCodec = codecPerCore(codecFixedSizeArray(
|
|
12209
|
+
const authQueuesCodec = codecPerCore(codecFixedSizeArray(bytes(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE));
|
|
12210
12210
|
|
|
12211
12211
|
;// CONCATENATED MODULE: ./packages/jam/state/disputes.ts
|
|
12212
12212
|
|
|
12213
12213
|
|
|
12214
12214
|
|
|
12215
|
-
const sortedSetCodec = () => readonlyArray(
|
|
12215
|
+
const sortedSetCodec = () => readonlyArray(sequenceVarLen(bytes(hash_HASH_SIZE))).convert((input) => input.array, (output) => {
|
|
12216
12216
|
const typed = output.map((x) => x.asOpaque());
|
|
12217
12217
|
return SortedSet.fromSortedArray(hashComparator, typed);
|
|
12218
12218
|
});
|
|
@@ -12227,7 +12227,7 @@ class DisputesRecords {
|
|
|
12227
12227
|
badSet;
|
|
12228
12228
|
wonkySet;
|
|
12229
12229
|
punishSet;
|
|
12230
|
-
static Codec =
|
|
12230
|
+
static Codec = Class(DisputesRecords, {
|
|
12231
12231
|
goodSet: workReportsSortedSetCodec,
|
|
12232
12232
|
badSet: workReportsSortedSetCodec,
|
|
12233
12233
|
wonkySet: workReportsSortedSetCodec,
|
|
@@ -12300,10 +12300,10 @@ class BlockState extends WithDebug {
|
|
|
12300
12300
|
accumulationResult;
|
|
12301
12301
|
postStateRoot;
|
|
12302
12302
|
reported;
|
|
12303
|
-
static Codec =
|
|
12304
|
-
headerHash:
|
|
12305
|
-
accumulationResult:
|
|
12306
|
-
postStateRoot:
|
|
12303
|
+
static Codec = Class(BlockState, {
|
|
12304
|
+
headerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
12305
|
+
accumulationResult: bytes(hash_HASH_SIZE),
|
|
12306
|
+
postStateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
12307
12307
|
reported: codecHashDictionary(WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
12308
12308
|
});
|
|
12309
12309
|
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
@@ -12333,14 +12333,14 @@ class BlockState extends WithDebug {
|
|
|
12333
12333
|
class RecentBlocks extends WithDebug {
|
|
12334
12334
|
blocks;
|
|
12335
12335
|
accumulationLog;
|
|
12336
|
-
static Codec =
|
|
12336
|
+
static Codec = Class(RecentBlocks, {
|
|
12337
12337
|
blocks: codecKnownSizeArray(BlockState.Codec, {
|
|
12338
12338
|
minLength: 0,
|
|
12339
12339
|
maxLength: MAX_RECENT_HISTORY,
|
|
12340
12340
|
typicalLength: MAX_RECENT_HISTORY,
|
|
12341
12341
|
}),
|
|
12342
|
-
accumulationLog:
|
|
12343
|
-
peaks: readonlyArray(
|
|
12342
|
+
accumulationLog: object({
|
|
12343
|
+
peaks: readonlyArray(sequenceVarLen(optional(bytes(hash_HASH_SIZE)))),
|
|
12344
12344
|
}),
|
|
12345
12345
|
});
|
|
12346
12346
|
static empty() {
|
|
@@ -12373,7 +12373,7 @@ class RecentBlocks extends WithDebug {
|
|
|
12373
12373
|
|
|
12374
12374
|
|
|
12375
12375
|
|
|
12376
|
-
const recentlyAccumulatedCodec = codecPerEpochBlock(
|
|
12376
|
+
const recentlyAccumulatedCodec = codecPerEpochBlock(sequenceVarLen(bytes(hash_HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x)));
|
|
12377
12377
|
|
|
12378
12378
|
;// CONCATENATED MODULE: ./packages/jam/state/validator-data.ts
|
|
12379
12379
|
|
|
@@ -12396,11 +12396,11 @@ class ValidatorData extends WithDebug {
|
|
|
12396
12396
|
ed25519;
|
|
12397
12397
|
bls;
|
|
12398
12398
|
metadata;
|
|
12399
|
-
static Codec =
|
|
12400
|
-
bandersnatch:
|
|
12401
|
-
ed25519:
|
|
12402
|
-
bls:
|
|
12403
|
-
metadata:
|
|
12399
|
+
static Codec = Class(ValidatorData, {
|
|
12400
|
+
bandersnatch: bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
12401
|
+
ed25519: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
12402
|
+
bls: bytes(BLS_KEY_BYTES).asOpaque(),
|
|
12403
|
+
metadata: bytes(VALIDATOR_META_BYTES),
|
|
12404
12404
|
});
|
|
12405
12405
|
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
12406
12406
|
return new ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
@@ -12440,13 +12440,13 @@ var SafroleSealingKeysKind;
|
|
|
12440
12440
|
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
12441
12441
|
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
12442
12442
|
})(SafroleSealingKeysKind || (SafroleSealingKeysKind = {}));
|
|
12443
|
-
const codecBandersnatchKey =
|
|
12443
|
+
const codecBandersnatchKey = bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
12444
12444
|
class SafroleSealingKeysData extends WithDebug {
|
|
12445
12445
|
kind;
|
|
12446
12446
|
keys;
|
|
12447
12447
|
tickets;
|
|
12448
12448
|
static Codec = codecWithContext((context) => {
|
|
12449
|
-
return
|
|
12449
|
+
return custom({
|
|
12450
12450
|
name: "SafroleSealingKeys",
|
|
12451
12451
|
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
12452
12452
|
}, (e, x) => {
|
|
@@ -12500,11 +12500,11 @@ class safrole_data_SafroleData {
|
|
|
12500
12500
|
epochRoot;
|
|
12501
12501
|
sealingKeySeries;
|
|
12502
12502
|
ticketsAccumulator;
|
|
12503
|
-
static Codec =
|
|
12503
|
+
static Codec = Class(safrole_data_SafroleData, {
|
|
12504
12504
|
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
12505
|
-
epochRoot:
|
|
12505
|
+
epochRoot: bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
12506
12506
|
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
12507
|
-
ticketsAccumulator: readonlyArray(
|
|
12507
|
+
ticketsAccumulator: readonlyArray(sequenceVarLen(Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
12508
12508
|
});
|
|
12509
12509
|
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
12510
12510
|
return new safrole_data_SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
@@ -12589,17 +12589,17 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
12589
12589
|
created;
|
|
12590
12590
|
lastAccumulation;
|
|
12591
12591
|
parentService;
|
|
12592
|
-
static Codec =
|
|
12593
|
-
codeHash:
|
|
12594
|
-
balance:
|
|
12595
|
-
accumulateMinGas:
|
|
12596
|
-
onTransferMinGas:
|
|
12597
|
-
storageUtilisationBytes:
|
|
12598
|
-
gratisStorage:
|
|
12599
|
-
storageUtilisationCount:
|
|
12600
|
-
created:
|
|
12601
|
-
lastAccumulation:
|
|
12602
|
-
parentService:
|
|
12592
|
+
static Codec = Class(ServiceAccountInfo, {
|
|
12593
|
+
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
12594
|
+
balance: u64,
|
|
12595
|
+
accumulateMinGas: u64.convert((x) => x, tryAsServiceGas),
|
|
12596
|
+
onTransferMinGas: u64.convert((x) => x, tryAsServiceGas),
|
|
12597
|
+
storageUtilisationBytes: u64,
|
|
12598
|
+
gratisStorage: u64,
|
|
12599
|
+
storageUtilisationCount: u32,
|
|
12600
|
+
created: u32.convert((x) => x, common_tryAsTimeSlot),
|
|
12601
|
+
lastAccumulation: u32.convert((x) => x, common_tryAsTimeSlot),
|
|
12602
|
+
parentService: u32.convert((x) => x, tryAsServiceId),
|
|
12603
12603
|
});
|
|
12604
12604
|
static create(a) {
|
|
12605
12605
|
return new ServiceAccountInfo(a.codeHash, a.balance, a.accumulateMinGas, a.onTransferMinGas, a.storageUtilisationBytes, a.gratisStorage, a.storageUtilisationCount, a.created, a.lastAccumulation, a.parentService);
|
|
@@ -12655,9 +12655,9 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
12655
12655
|
class PreimageItem extends WithDebug {
|
|
12656
12656
|
hash;
|
|
12657
12657
|
blob;
|
|
12658
|
-
static Codec =
|
|
12659
|
-
hash:
|
|
12660
|
-
blob:
|
|
12658
|
+
static Codec = Class(PreimageItem, {
|
|
12659
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
12660
|
+
blob: blob,
|
|
12661
12661
|
});
|
|
12662
12662
|
static create({ hash, blob }) {
|
|
12663
12663
|
return new PreimageItem(hash, blob);
|
|
@@ -12671,9 +12671,9 @@ class PreimageItem extends WithDebug {
|
|
|
12671
12671
|
class StorageItem extends WithDebug {
|
|
12672
12672
|
key;
|
|
12673
12673
|
value;
|
|
12674
|
-
static Codec =
|
|
12675
|
-
key:
|
|
12676
|
-
value:
|
|
12674
|
+
static Codec = Class(StorageItem, {
|
|
12675
|
+
key: blob.convert((i) => i, (o) => opaque_asOpaqueType(o)),
|
|
12676
|
+
value: blob,
|
|
12677
12677
|
});
|
|
12678
12678
|
static create({ key, value }) {
|
|
12679
12679
|
return new StorageItem(key, value);
|
|
@@ -12723,8 +12723,8 @@ class LookupHistoryItem {
|
|
|
12723
12723
|
|
|
12724
12724
|
|
|
12725
12725
|
const codecServiceId = Compatibility.isSuite(TestSuite.W3F_DAVXY) || Compatibility.isSuite(TestSuite.JAMDUNA, GpVersion.V0_6_7)
|
|
12726
|
-
?
|
|
12727
|
-
:
|
|
12726
|
+
? u32.asOpaque()
|
|
12727
|
+
: varU32.convert((s) => numbers_tryAsU32(s), (i) => tryAsServiceId(i));
|
|
12728
12728
|
/**
|
|
12729
12729
|
* Activity Record of a single validator.
|
|
12730
12730
|
*
|
|
@@ -12737,13 +12737,13 @@ class ValidatorStatistics {
|
|
|
12737
12737
|
preImagesSize;
|
|
12738
12738
|
guarantees;
|
|
12739
12739
|
assurances;
|
|
12740
|
-
static Codec =
|
|
12741
|
-
blocks:
|
|
12742
|
-
tickets:
|
|
12743
|
-
preImages:
|
|
12744
|
-
preImagesSize:
|
|
12745
|
-
guarantees:
|
|
12746
|
-
assurances:
|
|
12740
|
+
static Codec = Class(ValidatorStatistics, {
|
|
12741
|
+
blocks: u32,
|
|
12742
|
+
tickets: u32,
|
|
12743
|
+
preImages: u32,
|
|
12744
|
+
preImagesSize: u32,
|
|
12745
|
+
guarantees: u32,
|
|
12746
|
+
assurances: u32,
|
|
12747
12747
|
});
|
|
12748
12748
|
static create({ blocks, tickets, preImages, preImagesSize, guarantees, assurances, }) {
|
|
12749
12749
|
return new ValidatorStatistics(blocks, tickets, preImages, preImagesSize, guarantees, assurances);
|
|
@@ -12773,9 +12773,9 @@ class ValidatorStatistics {
|
|
|
12773
12773
|
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
12774
12774
|
}
|
|
12775
12775
|
}
|
|
12776
|
-
const codecVarU16 =
|
|
12776
|
+
const codecVarU16 = varU32.convert((i) => numbers_tryAsU32(i), (o) => numbers_tryAsU16(o));
|
|
12777
12777
|
/** Encode/decode unsigned gas. */
|
|
12778
|
-
const codecVarGas =
|
|
12778
|
+
const codecVarGas = varU64.convert((g) => numbers_tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
12779
12779
|
/**
|
|
12780
12780
|
* Single core statistics.
|
|
12781
12781
|
* Updated per block, based on incoming work reports (`w`).
|
|
@@ -12793,24 +12793,24 @@ class CoreStatistics {
|
|
|
12793
12793
|
bundleSize;
|
|
12794
12794
|
gasUsed;
|
|
12795
12795
|
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
12796
|
-
?
|
|
12797
|
-
dataAvailabilityLoad:
|
|
12796
|
+
? Class(CoreStatistics, {
|
|
12797
|
+
dataAvailabilityLoad: varU32,
|
|
12798
12798
|
popularity: codecVarU16,
|
|
12799
12799
|
imports: codecVarU16,
|
|
12800
12800
|
extrinsicCount: codecVarU16,
|
|
12801
|
-
extrinsicSize:
|
|
12801
|
+
extrinsicSize: varU32,
|
|
12802
12802
|
exports: codecVarU16,
|
|
12803
|
-
bundleSize:
|
|
12803
|
+
bundleSize: varU32,
|
|
12804
12804
|
gasUsed: codecVarGas,
|
|
12805
12805
|
})
|
|
12806
|
-
:
|
|
12807
|
-
dataAvailabilityLoad:
|
|
12806
|
+
: Class(CoreStatistics, {
|
|
12807
|
+
dataAvailabilityLoad: varU32,
|
|
12808
12808
|
popularity: codecVarU16,
|
|
12809
12809
|
imports: codecVarU16,
|
|
12810
12810
|
exports: codecVarU16,
|
|
12811
|
-
extrinsicSize:
|
|
12811
|
+
extrinsicSize: varU32,
|
|
12812
12812
|
extrinsicCount: codecVarU16,
|
|
12813
|
-
bundleSize:
|
|
12813
|
+
bundleSize: varU32,
|
|
12814
12814
|
gasUsed: codecVarGas,
|
|
12815
12815
|
});
|
|
12816
12816
|
static create(v) {
|
|
@@ -12869,45 +12869,45 @@ class ServiceStatistics {
|
|
|
12869
12869
|
onTransfersCount;
|
|
12870
12870
|
onTransfersGasUsed;
|
|
12871
12871
|
static Codec = Compatibility.selectIfGreaterOrEqual({
|
|
12872
|
-
fallback:
|
|
12872
|
+
fallback: Class(ServiceStatistics, {
|
|
12873
12873
|
providedCount: codecVarU16,
|
|
12874
|
-
providedSize:
|
|
12875
|
-
refinementCount:
|
|
12874
|
+
providedSize: varU32,
|
|
12875
|
+
refinementCount: varU32,
|
|
12876
12876
|
refinementGasUsed: codecVarGas,
|
|
12877
12877
|
imports: codecVarU16,
|
|
12878
12878
|
exports: codecVarU16,
|
|
12879
|
-
extrinsicSize:
|
|
12879
|
+
extrinsicSize: varU32,
|
|
12880
12880
|
extrinsicCount: codecVarU16,
|
|
12881
|
-
accumulateCount:
|
|
12881
|
+
accumulateCount: varU32,
|
|
12882
12882
|
accumulateGasUsed: codecVarGas,
|
|
12883
|
-
onTransfersCount:
|
|
12883
|
+
onTransfersCount: varU32,
|
|
12884
12884
|
onTransfersGasUsed: codecVarGas,
|
|
12885
12885
|
}),
|
|
12886
12886
|
versions: {
|
|
12887
|
-
[GpVersion.V0_7_0]:
|
|
12887
|
+
[GpVersion.V0_7_0]: Class(ServiceStatistics, {
|
|
12888
12888
|
providedCount: codecVarU16,
|
|
12889
|
-
providedSize:
|
|
12890
|
-
refinementCount:
|
|
12889
|
+
providedSize: varU32,
|
|
12890
|
+
refinementCount: varU32,
|
|
12891
12891
|
refinementGasUsed: codecVarGas,
|
|
12892
12892
|
imports: codecVarU16,
|
|
12893
12893
|
extrinsicCount: codecVarU16,
|
|
12894
|
-
extrinsicSize:
|
|
12894
|
+
extrinsicSize: varU32,
|
|
12895
12895
|
exports: codecVarU16,
|
|
12896
|
-
accumulateCount:
|
|
12896
|
+
accumulateCount: varU32,
|
|
12897
12897
|
accumulateGasUsed: codecVarGas,
|
|
12898
|
-
onTransfersCount:
|
|
12898
|
+
onTransfersCount: varU32,
|
|
12899
12899
|
onTransfersGasUsed: codecVarGas,
|
|
12900
12900
|
}),
|
|
12901
|
-
[GpVersion.V0_7_1]:
|
|
12901
|
+
[GpVersion.V0_7_1]: Class(ServiceStatistics, {
|
|
12902
12902
|
providedCount: codecVarU16,
|
|
12903
|
-
providedSize:
|
|
12904
|
-
refinementCount:
|
|
12903
|
+
providedSize: varU32,
|
|
12904
|
+
refinementCount: varU32,
|
|
12905
12905
|
refinementGasUsed: codecVarGas,
|
|
12906
12906
|
imports: codecVarU16,
|
|
12907
12907
|
extrinsicCount: codecVarU16,
|
|
12908
|
-
extrinsicSize:
|
|
12908
|
+
extrinsicSize: varU32,
|
|
12909
12909
|
exports: codecVarU16,
|
|
12910
|
-
accumulateCount:
|
|
12910
|
+
accumulateCount: varU32,
|
|
12911
12911
|
accumulateGasUsed: codecVarGas,
|
|
12912
12912
|
onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
|
|
12913
12913
|
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
@@ -12968,11 +12968,11 @@ class StatisticsData {
|
|
|
12968
12968
|
previous;
|
|
12969
12969
|
cores;
|
|
12970
12970
|
services;
|
|
12971
|
-
static Codec =
|
|
12971
|
+
static Codec = Class(StatisticsData, {
|
|
12972
12972
|
current: codecPerValidator(ValidatorStatistics.Codec),
|
|
12973
12973
|
previous: codecPerValidator(ValidatorStatistics.Codec),
|
|
12974
12974
|
cores: codecPerCore(CoreStatistics.Codec),
|
|
12975
|
-
services:
|
|
12975
|
+
services: dictionary(codecServiceId, ServiceStatistics.Codec, {
|
|
12976
12976
|
sortKeys: (a, b) => a - b,
|
|
12977
12977
|
}),
|
|
12978
12978
|
});
|
|
@@ -13071,14 +13071,14 @@ class PrivilegedServices {
|
|
|
13071
13071
|
assigners;
|
|
13072
13072
|
autoAccumulateServices;
|
|
13073
13073
|
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
13074
|
-
static Codec =
|
|
13075
|
-
manager:
|
|
13076
|
-
assigners: codecPerCore(
|
|
13077
|
-
delegator:
|
|
13074
|
+
static Codec = Class(PrivilegedServices, {
|
|
13075
|
+
manager: u32.asOpaque(),
|
|
13076
|
+
assigners: codecPerCore(u32.asOpaque()),
|
|
13077
|
+
delegator: u32.asOpaque(),
|
|
13078
13078
|
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
13079
|
-
?
|
|
13079
|
+
? u32.asOpaque()
|
|
13080
13080
|
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
13081
|
-
autoAccumulateServices:
|
|
13081
|
+
autoAccumulateServices: dictionary(u32.asOpaque(), u64.asOpaque(), {
|
|
13082
13082
|
sortKeys: (a, b) => a - b,
|
|
13083
13083
|
}),
|
|
13084
13084
|
});
|
|
@@ -13751,15 +13751,15 @@ class InMemoryState extends WithDebug {
|
|
|
13751
13751
|
});
|
|
13752
13752
|
}
|
|
13753
13753
|
}
|
|
13754
|
-
const serviceEntriesCodec =
|
|
13755
|
-
storageKeys:
|
|
13756
|
-
preimages:
|
|
13757
|
-
lookupHistory:
|
|
13758
|
-
hash:
|
|
13759
|
-
length:
|
|
13754
|
+
const serviceEntriesCodec = object({
|
|
13755
|
+
storageKeys: sequenceVarLen(blob.convert((i) => i, (o) => opaque_asOpaqueType(o))),
|
|
13756
|
+
preimages: sequenceVarLen(bytes(hash_HASH_SIZE).asOpaque()),
|
|
13757
|
+
lookupHistory: sequenceVarLen(object({
|
|
13758
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
13759
|
+
length: u32,
|
|
13760
13760
|
})),
|
|
13761
13761
|
});
|
|
13762
|
-
const serviceDataCodec =
|
|
13762
|
+
const serviceDataCodec = dictionary(u32.asOpaque(), serviceEntriesCodec, {
|
|
13763
13763
|
sortKeys: (a, b) => a - b,
|
|
13764
13764
|
});
|
|
13765
13765
|
|
|
@@ -14498,7 +14498,7 @@ var serialize_serialize;
|
|
|
14498
14498
|
/** C(6): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bf3013bf301?v=0.6.7 */
|
|
14499
14499
|
serialize.entropy = {
|
|
14500
14500
|
key: stateKeys.index(StateKeyIdx.Eta),
|
|
14501
|
-
Codec: codecFixedSizeArray(
|
|
14501
|
+
Codec: codecFixedSizeArray(bytes(hash_HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
14502
14502
|
extract: (s) => s.entropy,
|
|
14503
14503
|
};
|
|
14504
14504
|
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
@@ -14528,7 +14528,7 @@ var serialize_serialize;
|
|
|
14528
14528
|
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
14529
14529
|
serialize.timeslot = {
|
|
14530
14530
|
key: stateKeys.index(StateKeyIdx.Tau),
|
|
14531
|
-
Codec:
|
|
14531
|
+
Codec: u32.asOpaque(),
|
|
14532
14532
|
extract: (s) => s.timeslot,
|
|
14533
14533
|
};
|
|
14534
14534
|
/** C(12): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b4c023b4c02?v=0.6.7 */
|
|
@@ -14558,7 +14558,7 @@ var serialize_serialize;
|
|
|
14558
14558
|
/** C(16): https://graypaper.fluffylabs.dev/#/38c4e62/3b46033b4603?v=0.7.0 */
|
|
14559
14559
|
serialize.accumulationOutputLog = {
|
|
14560
14560
|
key: stateKeys.index(StateKeyIdx.Theta),
|
|
14561
|
-
Codec:
|
|
14561
|
+
Codec: sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
|
|
14562
14562
|
extract: (s) => s.accumulationOutputLog,
|
|
14563
14563
|
};
|
|
14564
14564
|
/** C(255, s): https://graypaper.fluffylabs.dev/#/85129da/383103383103?v=0.6.3 */
|
|
@@ -14581,7 +14581,7 @@ var serialize_serialize;
|
|
|
14581
14581
|
/** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
|
|
14582
14582
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
14583
14583
|
key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
|
|
14584
|
-
Codec: readonlyArray(
|
|
14584
|
+
Codec: readonlyArray(sequenceVarLen(u32)),
|
|
14585
14585
|
});
|
|
14586
14586
|
})(serialize_serialize || (serialize_serialize = {}));
|
|
14587
14587
|
/**
|
|
@@ -15718,7 +15718,7 @@ function getSafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsA
|
|
|
15718
15718
|
|
|
15719
15719
|
const TYPICAL_STATE_ITEMS = 50;
|
|
15720
15720
|
const TYPICAL_STATE_ITEM_LEN = 50;
|
|
15721
|
-
const stateEntriesSequenceCodec =
|
|
15721
|
+
const stateEntriesSequenceCodec = sequenceVarLen(pair(bytes(TRUNCATED_HASH_SIZE), blob));
|
|
15722
15722
|
/**
|
|
15723
15723
|
* Full, in-memory state represented as serialized entries dictionary.
|
|
15724
15724
|
*
|
|
@@ -15726,7 +15726,7 @@ const stateEntriesSequenceCodec = descriptors_codec.sequenceVarLen(descriptors_c
|
|
|
15726
15726
|
*/
|
|
15727
15727
|
class state_entries_StateEntries {
|
|
15728
15728
|
entries;
|
|
15729
|
-
static Codec =
|
|
15729
|
+
static Codec = custom({
|
|
15730
15730
|
name: "StateEntries",
|
|
15731
15731
|
sizeHint: {
|
|
15732
15732
|
isExact: false,
|
|
@@ -15949,17 +15949,17 @@ const codecMap = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH
|
|
|
15949
15949
|
s.sequenceFixLen(value, len);
|
|
15950
15950
|
});
|
|
15951
15951
|
};
|
|
15952
|
-
const lookupHistoryItemCodec =
|
|
15953
|
-
hash:
|
|
15954
|
-
length:
|
|
15955
|
-
slots: readonlyArray(
|
|
15952
|
+
const lookupHistoryItemCodec = object({
|
|
15953
|
+
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
15954
|
+
length: u32,
|
|
15955
|
+
slots: readonlyArray(sequenceVarLen(u32.asOpaque()))
|
|
15956
|
+
.convert(seeThrough, service_tryAsLookupHistorySlots),
|
|
15956
15957
|
}, "LookupHistoryItem", ({ hash, length, slots }) => new LookupHistoryItem(hash, length, slots));
|
|
15957
|
-
const lookupHistoryEntryCodec =
|
|
15958
|
-
key:
|
|
15959
|
-
data:
|
|
15958
|
+
const lookupHistoryEntryCodec = object({
|
|
15959
|
+
key: bytes(hash_HASH_SIZE).asOpaque(),
|
|
15960
|
+
data: sequenceVarLen(lookupHistoryItemCodec),
|
|
15960
15961
|
});
|
|
15961
|
-
const lookupHistoryCodec =
|
|
15962
|
-
.sequenceVarLen(lookupHistoryEntryCodec)
|
|
15962
|
+
const lookupHistoryCodec = sequenceVarLen(lookupHistoryEntryCodec)
|
|
15963
15963
|
.convert((dict) => {
|
|
15964
15964
|
const entries = [];
|
|
15965
15965
|
for (const [key, data] of dict) {
|
|
@@ -15979,9 +15979,9 @@ const lookupHistoryCodec = descriptors_codec
|
|
|
15979
15979
|
return dict;
|
|
15980
15980
|
});
|
|
15981
15981
|
class ServiceWithCodec extends InMemoryService {
|
|
15982
|
-
static Codec =
|
|
15983
|
-
serviceId:
|
|
15984
|
-
data:
|
|
15982
|
+
static Codec = Class(ServiceWithCodec, {
|
|
15983
|
+
serviceId: u32.asOpaque(),
|
|
15984
|
+
data: object({
|
|
15985
15985
|
info: ServiceAccountInfo.Codec,
|
|
15986
15986
|
preimages: codecHashDictionary(PreimageItem.Codec, (x) => x.hash),
|
|
15987
15987
|
lookupHistory: lookupHistoryCodec,
|
|
@@ -15995,7 +15995,7 @@ class ServiceWithCodec extends InMemoryService {
|
|
|
15995
15995
|
return new ServiceWithCodec(serviceId, data);
|
|
15996
15996
|
}
|
|
15997
15997
|
}
|
|
15998
|
-
const inMemoryStateCodec = (spec) =>
|
|
15998
|
+
const inMemoryStateCodec = (spec) => Class(class State extends InMemoryState {
|
|
15999
15999
|
static create(data) {
|
|
16000
16000
|
return InMemoryState.new(spec, data);
|
|
16001
16001
|
}
|
|
@@ -16009,11 +16009,12 @@ const inMemoryStateCodec = (spec) => descriptors_codec.Class(class State extends
|
|
|
16009
16009
|
// gamma_k
|
|
16010
16010
|
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
16011
16011
|
// gamma_z
|
|
16012
|
-
epochRoot:
|
|
16012
|
+
epochRoot: bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
16013
16013
|
// gamma_s
|
|
16014
16014
|
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
16015
16015
|
// gamma_a
|
|
16016
|
-
ticketsAccumulator: readonlyArray(
|
|
16016
|
+
ticketsAccumulator: readonlyArray(sequenceVarLen(Ticket.Codec))
|
|
16017
|
+
.convert((x) => x, sized_array_asKnownSize),
|
|
16017
16018
|
// psi
|
|
16018
16019
|
disputesRecords: serialize_serialize.disputesRecords.Codec,
|
|
16019
16020
|
// eta
|
|
@@ -16039,7 +16040,7 @@ const inMemoryStateCodec = (spec) => descriptors_codec.Class(class State extends
|
|
|
16039
16040
|
// theta
|
|
16040
16041
|
accumulationOutputLog: serialize_serialize.accumulationOutputLog.Codec,
|
|
16041
16042
|
// delta
|
|
16042
|
-
services:
|
|
16043
|
+
services: dictionary(u32.asOpaque(), ServiceWithCodec.Codec, {
|
|
16043
16044
|
sortKeys: (a, b) => a - b,
|
|
16044
16045
|
}),
|
|
16045
16046
|
});
|
|
@@ -16064,11 +16065,11 @@ class TestState {
|
|
|
16064
16065
|
state_root: fromJson.bytes32(),
|
|
16065
16066
|
keyvals: json.array(StateKeyVal.fromJson),
|
|
16066
16067
|
};
|
|
16067
|
-
static Codec =
|
|
16068
|
-
state_root:
|
|
16069
|
-
keyvals:
|
|
16070
|
-
key:
|
|
16071
|
-
value:
|
|
16068
|
+
static Codec = object({
|
|
16069
|
+
state_root: bytes(hash_HASH_SIZE).asOpaque(),
|
|
16070
|
+
keyvals: sequenceVarLen(object({
|
|
16071
|
+
key: bytes(TRUNCATED_HASH_SIZE),
|
|
16072
|
+
value: blob,
|
|
16072
16073
|
})),
|
|
16073
16074
|
});
|
|
16074
16075
|
state_root;
|
|
@@ -16079,7 +16080,7 @@ class StateTransitionGenesis {
|
|
|
16079
16080
|
header: headerFromJson,
|
|
16080
16081
|
state: TestState.fromJson,
|
|
16081
16082
|
};
|
|
16082
|
-
static Codec =
|
|
16083
|
+
static Codec = object({
|
|
16083
16084
|
header: header_Header.Codec,
|
|
16084
16085
|
state: TestState.Codec,
|
|
16085
16086
|
});
|
|
@@ -16092,7 +16093,7 @@ class StateTransition {
|
|
|
16092
16093
|
post_state: TestState.fromJson,
|
|
16093
16094
|
block: blockFromJson(chain_spec_tinyChainSpec),
|
|
16094
16095
|
};
|
|
16095
|
-
static Codec =
|
|
16096
|
+
static Codec = object({
|
|
16096
16097
|
pre_state: TestState.Codec,
|
|
16097
16098
|
block: Block.Codec,
|
|
16098
16099
|
post_state: TestState.Codec,
|
|
@@ -20150,7 +20151,7 @@ const SUPPORTED_TYPES = [
|
|
|
20150
20151
|
if (option === "as-hash") {
|
|
20151
20152
|
return looseType({
|
|
20152
20153
|
value: blake2b.hashBytes(encoder_Encoder.encodeObject(header_Header.Codec, header, spec)),
|
|
20153
|
-
encode:
|
|
20154
|
+
encode: bytes(hash_HASH_SIZE),
|
|
20154
20155
|
});
|
|
20155
20156
|
}
|
|
20156
20157
|
throw new Error(`Invalid processing option: ${option}`);
|
|
@@ -20204,7 +20205,7 @@ const SUPPORTED_TYPES = [
|
|
|
20204
20205
|
if (option === "as-root-hash") {
|
|
20205
20206
|
return looseType({
|
|
20206
20207
|
value: state_entries_StateEntries.serializeInMemory(spec, blake2b, state).getRootHash(blake2b),
|
|
20207
|
-
encode:
|
|
20208
|
+
encode: bytes(hash_HASH_SIZE),
|
|
20208
20209
|
});
|
|
20209
20210
|
}
|
|
20210
20211
|
throw new Error(`Invalid processing option: ${option}`);
|