@typeberry/convert 0.5.1 → 0.5.2-03e1aed
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 +1 -1
- package/index.js +424 -326
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3871,6 +3871,17 @@ module.exports = __nccwpck_require__.p + "ccf8ada94096a8f232f5.js?reed_solomon_w
|
|
|
3871
3871
|
/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
3872
3872
|
/******/ })();
|
|
3873
3873
|
/******/
|
|
3874
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
3875
|
+
/******/ (() => {
|
|
3876
|
+
/******/ // define __esModule on exports
|
|
3877
|
+
/******/ __nccwpck_require__.r = (exports) => {
|
|
3878
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
3879
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3880
|
+
/******/ }
|
|
3881
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
3882
|
+
/******/ };
|
|
3883
|
+
/******/ })();
|
|
3884
|
+
/******/
|
|
3874
3885
|
/******/ /* webpack/runtime/publicPath */
|
|
3875
3886
|
/******/ (() => {
|
|
3876
3887
|
/******/ var scriptUrl;
|
|
@@ -3913,6 +3924,44 @@ module.exports = __nccwpck_require__.p + "ccf8ada94096a8f232f5.js?reed_solomon_w
|
|
|
3913
3924
|
/************************************************************************/
|
|
3914
3925
|
var __webpack_exports__ = {};
|
|
3915
3926
|
|
|
3927
|
+
// NAMESPACE OBJECT: ./packages/core/codec/descriptors.ts
|
|
3928
|
+
var descriptors_namespaceObject = {};
|
|
3929
|
+
__nccwpck_require__.r(descriptors_namespaceObject);
|
|
3930
|
+
__nccwpck_require__.d(descriptors_namespaceObject, {
|
|
3931
|
+
Class: () => (Class),
|
|
3932
|
+
TYPICAL_DICTIONARY_LENGTH: () => (TYPICAL_DICTIONARY_LENGTH),
|
|
3933
|
+
bitVecFixLen: () => (bitVecFixLen),
|
|
3934
|
+
bitVecVarLen: () => (bitVecVarLen),
|
|
3935
|
+
blob: () => (blob),
|
|
3936
|
+
bool: () => (bool),
|
|
3937
|
+
bytes: () => (bytes),
|
|
3938
|
+
custom: () => (custom),
|
|
3939
|
+
dictionary: () => (dictionary),
|
|
3940
|
+
forEachDescriptor: () => (forEachDescriptor),
|
|
3941
|
+
i16: () => (i16),
|
|
3942
|
+
i24: () => (i24),
|
|
3943
|
+
i32: () => (i32),
|
|
3944
|
+
i64: () => (i64),
|
|
3945
|
+
i8: () => (i8),
|
|
3946
|
+
nothing: () => (nothing),
|
|
3947
|
+
object: () => (object),
|
|
3948
|
+
optional: () => (optional),
|
|
3949
|
+
pair: () => (pair),
|
|
3950
|
+
readonlyArray: () => (readonlyArray),
|
|
3951
|
+
select: () => (descriptors_select),
|
|
3952
|
+
sequenceFixLen: () => (sequenceFixLen),
|
|
3953
|
+
sequenceVarLen: () => (sequenceVarLen),
|
|
3954
|
+
string: () => (string),
|
|
3955
|
+
u16: () => (u16),
|
|
3956
|
+
u24: () => (u24),
|
|
3957
|
+
u32: () => (u32),
|
|
3958
|
+
u64: () => (u64),
|
|
3959
|
+
u8: () => (u8),
|
|
3960
|
+
union: () => (union),
|
|
3961
|
+
varU32: () => (varU32),
|
|
3962
|
+
varU64: () => (varU64)
|
|
3963
|
+
});
|
|
3964
|
+
|
|
3916
3965
|
;// CONCATENATED MODULE: ./packages/core/logger/options.ts
|
|
3917
3966
|
var Level;
|
|
3918
3967
|
(function (Level) {
|
|
@@ -4846,7 +4895,7 @@ function isResult(x) {
|
|
|
4846
4895
|
var minimist = __nccwpck_require__(595);
|
|
4847
4896
|
var minimist_default = /*#__PURE__*/__nccwpck_require__.n(minimist);
|
|
4848
4897
|
;// CONCATENATED MODULE: ./bin/convert/package.json
|
|
4849
|
-
const package_namespaceObject = {"rE":"0.5.
|
|
4898
|
+
const package_namespaceObject = {"rE":"0.5.2"};
|
|
4850
4899
|
;// CONCATENATED MODULE: ./packages/core/bytes/bitvec.ts
|
|
4851
4900
|
|
|
4852
4901
|
/**
|
|
@@ -6627,6 +6676,48 @@ const pair = (a, b) => {
|
|
|
6627
6676
|
};
|
|
6628
6677
|
/** Custom encoding / decoding logic. */
|
|
6629
6678
|
const custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
6679
|
+
/** Tagged union type encoding. */
|
|
6680
|
+
const union = (name, variants) => {
|
|
6681
|
+
const keys = Object.keys(variants).map(Number);
|
|
6682
|
+
const variantMap = Object.fromEntries(keys.map((key, idx) => [key, idx]));
|
|
6683
|
+
const indexToKey = Object.fromEntries(keys.map((key, idx) => [idx, key]));
|
|
6684
|
+
// Calculate size hint as the minimum variant size + index size
|
|
6685
|
+
const minVariantSize = Math.max(...keys.map((key) => variants[key].sizeHint.bytes));
|
|
6686
|
+
const sizeHint = {
|
|
6687
|
+
bytes: 1 + minVariantSize, // varU32 index + smallest variant
|
|
6688
|
+
isExact: false,
|
|
6689
|
+
};
|
|
6690
|
+
const encode = (e, x) => {
|
|
6691
|
+
const idx = variantMap[x.kind];
|
|
6692
|
+
if (idx === undefined) {
|
|
6693
|
+
throw new Error(`Unknown variant type: ${x.kind} for ${name}`);
|
|
6694
|
+
}
|
|
6695
|
+
e.varU32(numbers_tryAsU32(idx));
|
|
6696
|
+
const codec = variants[x.kind];
|
|
6697
|
+
// I'm sorry but I can't figure out a better typing here :)
|
|
6698
|
+
codec.encode(e, x);
|
|
6699
|
+
};
|
|
6700
|
+
const decode = (d) => {
|
|
6701
|
+
const idx = d.varU32();
|
|
6702
|
+
const kind = indexToKey[idx];
|
|
6703
|
+
if (kind === undefined) {
|
|
6704
|
+
throw new Error(`Unknown variant index: ${idx} for ${name}`);
|
|
6705
|
+
}
|
|
6706
|
+
const codec = variants[kind];
|
|
6707
|
+
const value = codec.decode(d);
|
|
6708
|
+
return { kind, ...value };
|
|
6709
|
+
};
|
|
6710
|
+
const skip = (s) => {
|
|
6711
|
+
const idx = s.decoder.varU32();
|
|
6712
|
+
const kind = indexToKey[idx];
|
|
6713
|
+
if (kind === undefined) {
|
|
6714
|
+
throw new Error(`Unknown variant index: ${idx} for ${name}`);
|
|
6715
|
+
}
|
|
6716
|
+
const codec = variants[kind];
|
|
6717
|
+
codec.skip(s);
|
|
6718
|
+
};
|
|
6719
|
+
return Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
6720
|
+
};
|
|
6630
6721
|
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
6631
6722
|
const descriptors_select = ({ name, sizeHint, }, chooser) => {
|
|
6632
6723
|
const Self = chooser(null);
|
|
@@ -6778,6 +6869,11 @@ function sequenceViewFixLen(type, { fixedLength }) {
|
|
|
6778
6869
|
|
|
6779
6870
|
|
|
6780
6871
|
|
|
6872
|
+
// additional re-export of descriptors namespace under `codec`
|
|
6873
|
+
// note we export descriptors in top level as well,
|
|
6874
|
+
// because writing `codec.codec.u32` when using the library looks weird
|
|
6875
|
+
|
|
6876
|
+
const codec_codec = descriptors_namespaceObject;
|
|
6781
6877
|
|
|
6782
6878
|
;// CONCATENATED MODULE: ./node_modules/@typeberry/native/chunk-CPmnHcRE.js
|
|
6783
6879
|
//#region rolldown:runtime
|
|
@@ -9117,7 +9213,7 @@ function codecWithContext(chooser) {
|
|
|
9117
9213
|
const defaultContext = chain_spec_fullChainSpec;
|
|
9118
9214
|
const { name, sizeHint } = chooser(defaultContext);
|
|
9119
9215
|
const cache = new Map();
|
|
9120
|
-
return
|
|
9216
|
+
return codec_codec.select({
|
|
9121
9217
|
name,
|
|
9122
9218
|
sizeHint: { bytes: sizeHint.bytes, isExact: false },
|
|
9123
9219
|
}, (context) => {
|
|
@@ -9144,9 +9240,9 @@ function codecWithContext(chooser) {
|
|
|
9144
9240
|
/** Codec for a known-size array with length validation. */
|
|
9145
9241
|
const codecKnownSizeArray = (val, options, _id) => {
|
|
9146
9242
|
if ("fixedLength" in options) {
|
|
9147
|
-
return readonlyArray(sequenceFixLen(val, options.fixedLength)).convert(seeThrough, sized_array_asKnownSize);
|
|
9243
|
+
return codec_codec.readonlyArray(codec_codec.sequenceFixLen(val, options.fixedLength)).convert(seeThrough, sized_array_asKnownSize);
|
|
9148
9244
|
}
|
|
9149
|
-
return readonlyArray(sequenceVarLen(val, options)).convert(seeThrough, sized_array_asKnownSize);
|
|
9245
|
+
return codec_codec.readonlyArray(codec_codec.sequenceVarLen(val, options)).convert(seeThrough, sized_array_asKnownSize);
|
|
9150
9246
|
};
|
|
9151
9247
|
/** Codec for a fixed-size array with length validation. */
|
|
9152
9248
|
const codecFixedSizeArray = (val, len) => {
|
|
@@ -9155,7 +9251,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
9155
9251
|
throw new Error(`[${val.name}] Invalid size of fixed-size array. Got ${actual}, expected: ${len}`);
|
|
9156
9252
|
}
|
|
9157
9253
|
};
|
|
9158
|
-
return sequenceFixLen(val, len).convert((i) => {
|
|
9254
|
+
return codec_codec.sequenceFixLen(val, len).convert((i) => {
|
|
9159
9255
|
checkLength(i.length);
|
|
9160
9256
|
return i;
|
|
9161
9257
|
}, (o) => {
|
|
@@ -9164,7 +9260,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
9164
9260
|
});
|
|
9165
9261
|
};
|
|
9166
9262
|
/** Codec for a hash-dictionary. */
|
|
9167
|
-
const codecHashDictionary = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
|
|
9263
|
+
const codecHashDictionary = (value, extractKey, { typicalLength = codec_codec.TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
|
|
9168
9264
|
return Descriptor.new(`HashDictionary<${value.name}>[?]`, {
|
|
9169
9265
|
bytes: typicalLength * value.sizeHint.bytes,
|
|
9170
9266
|
isExact: false,
|
|
@@ -9216,13 +9312,13 @@ class AvailabilityAssurance extends WithDebug {
|
|
|
9216
9312
|
bitfield;
|
|
9217
9313
|
validatorIndex;
|
|
9218
9314
|
signature;
|
|
9219
|
-
static Codec = Class(AvailabilityAssurance, {
|
|
9220
|
-
anchor: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9315
|
+
static Codec = codec_codec.Class(AvailabilityAssurance, {
|
|
9316
|
+
anchor: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9221
9317
|
bitfield: codecWithContext((context) => {
|
|
9222
|
-
return bitVecFixLen(context.coresCount);
|
|
9318
|
+
return codec_codec.bitVecFixLen(context.coresCount);
|
|
9223
9319
|
}),
|
|
9224
|
-
validatorIndex: u16.asOpaque(),
|
|
9225
|
-
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9320
|
+
validatorIndex: codec_codec.u16.asOpaque(),
|
|
9321
|
+
signature: codec_codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9226
9322
|
});
|
|
9227
9323
|
static create({ anchor, bitfield, validatorIndex, signature }) {
|
|
9228
9324
|
return new AvailabilityAssurance(anchor, bitfield, validatorIndex, signature);
|
|
@@ -9314,11 +9410,11 @@ class Fault extends WithDebug {
|
|
|
9314
9410
|
wasConsideredValid;
|
|
9315
9411
|
key;
|
|
9316
9412
|
signature;
|
|
9317
|
-
static Codec = Class(Fault, {
|
|
9318
|
-
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9319
|
-
wasConsideredValid: bool,
|
|
9320
|
-
key: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
9321
|
-
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9413
|
+
static Codec = codec_codec.Class(Fault, {
|
|
9414
|
+
workReportHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9415
|
+
wasConsideredValid: codec_codec.bool,
|
|
9416
|
+
key: codec_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
9417
|
+
signature: codec_codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9322
9418
|
});
|
|
9323
9419
|
static create({ workReportHash, wasConsideredValid, key, signature }) {
|
|
9324
9420
|
return new Fault(workReportHash, wasConsideredValid, key, signature);
|
|
@@ -9346,10 +9442,10 @@ class Culprit extends WithDebug {
|
|
|
9346
9442
|
workReportHash;
|
|
9347
9443
|
key;
|
|
9348
9444
|
signature;
|
|
9349
|
-
static Codec = Class(Culprit, {
|
|
9350
|
-
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9351
|
-
key: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
9352
|
-
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9445
|
+
static Codec = codec_codec.Class(Culprit, {
|
|
9446
|
+
workReportHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9447
|
+
key: codec_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
9448
|
+
signature: codec_codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9353
9449
|
});
|
|
9354
9450
|
static create({ workReportHash, key, signature }) {
|
|
9355
9451
|
return new Culprit(workReportHash, key, signature);
|
|
@@ -9374,10 +9470,10 @@ class Judgement extends WithDebug {
|
|
|
9374
9470
|
isWorkReportValid;
|
|
9375
9471
|
index;
|
|
9376
9472
|
signature;
|
|
9377
|
-
static Codec = Class(Judgement, {
|
|
9378
|
-
isWorkReportValid: bool,
|
|
9379
|
-
index: u16.asOpaque(),
|
|
9380
|
-
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9473
|
+
static Codec = codec_codec.Class(Judgement, {
|
|
9474
|
+
isWorkReportValid: codec_codec.bool,
|
|
9475
|
+
index: codec_codec.u16.asOpaque(),
|
|
9476
|
+
signature: codec_codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
9381
9477
|
});
|
|
9382
9478
|
static create({ isWorkReportValid, index, signature }) {
|
|
9383
9479
|
return new Judgement(isWorkReportValid, index, signature);
|
|
@@ -9406,11 +9502,12 @@ class Verdict extends WithDebug {
|
|
|
9406
9502
|
workReportHash;
|
|
9407
9503
|
votesEpoch;
|
|
9408
9504
|
votes;
|
|
9409
|
-
static Codec = Class(Verdict, {
|
|
9410
|
-
workReportHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9411
|
-
votesEpoch: u32.asOpaque(),
|
|
9505
|
+
static Codec = codec_codec.Class(Verdict, {
|
|
9506
|
+
workReportHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9507
|
+
votesEpoch: codec_codec.u32.asOpaque(),
|
|
9412
9508
|
votes: codecWithContext((context) => {
|
|
9413
|
-
return
|
|
9509
|
+
return codec_codec
|
|
9510
|
+
.readonlyArray(codec_codec.sequenceFixLen(Judgement.Codec, context.validatorsSuperMajority))
|
|
9414
9511
|
.convert(seeThrough, sized_array_asKnownSize);
|
|
9415
9512
|
}),
|
|
9416
9513
|
});
|
|
@@ -9452,10 +9549,10 @@ class DisputesExtrinsic extends WithDebug {
|
|
|
9452
9549
|
verdicts;
|
|
9453
9550
|
culprits;
|
|
9454
9551
|
faults;
|
|
9455
|
-
static Codec = Class(DisputesExtrinsic, {
|
|
9456
|
-
verdicts: sequenceVarLen(Verdict.Codec),
|
|
9457
|
-
culprits: sequenceVarLen(Culprit.Codec),
|
|
9458
|
-
faults: sequenceVarLen(Fault.Codec),
|
|
9552
|
+
static Codec = codec_codec.Class(DisputesExtrinsic, {
|
|
9553
|
+
verdicts: codec_codec.sequenceVarLen(Verdict.Codec),
|
|
9554
|
+
culprits: codec_codec.sequenceVarLen(Culprit.Codec),
|
|
9555
|
+
faults: codec_codec.sequenceVarLen(Fault.Codec),
|
|
9459
9556
|
});
|
|
9460
9557
|
static create({ verdicts, culprits, faults }) {
|
|
9461
9558
|
return new DisputesExtrinsic(verdicts, culprits, faults);
|
|
@@ -9501,9 +9598,9 @@ class DisputesExtrinsic extends WithDebug {
|
|
|
9501
9598
|
class WorkPackageInfo extends WithDebug {
|
|
9502
9599
|
workPackageHash;
|
|
9503
9600
|
segmentTreeRoot;
|
|
9504
|
-
static Codec = Class(WorkPackageInfo, {
|
|
9505
|
-
workPackageHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9506
|
-
segmentTreeRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9601
|
+
static Codec = codec_codec.Class(WorkPackageInfo, {
|
|
9602
|
+
workPackageHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9603
|
+
segmentTreeRoot: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9507
9604
|
});
|
|
9508
9605
|
constructor(
|
|
9509
9606
|
/** Hash of the described work package. */
|
|
@@ -9531,13 +9628,13 @@ class RefineContext extends WithDebug {
|
|
|
9531
9628
|
lookupAnchor;
|
|
9532
9629
|
lookupAnchorSlot;
|
|
9533
9630
|
prerequisites;
|
|
9534
|
-
static Codec = Class(RefineContext, {
|
|
9535
|
-
anchor: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9536
|
-
stateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9537
|
-
beefyRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9538
|
-
lookupAnchor: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9539
|
-
lookupAnchorSlot: u32.asOpaque(),
|
|
9540
|
-
prerequisites: sequenceVarLen(bytes(hash_HASH_SIZE).asOpaque()),
|
|
9631
|
+
static Codec = codec_codec.Class(RefineContext, {
|
|
9632
|
+
anchor: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9633
|
+
stateRoot: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9634
|
+
beefyRoot: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9635
|
+
lookupAnchor: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9636
|
+
lookupAnchorSlot: codec_codec.u32.asOpaque(),
|
|
9637
|
+
prerequisites: codec_codec.sequenceVarLen(codec_codec.bytes(hash_HASH_SIZE).asOpaque()),
|
|
9541
9638
|
});
|
|
9542
9639
|
static create({ anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites, }) {
|
|
9543
9640
|
return new RefineContext(anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites);
|
|
@@ -9594,9 +9691,9 @@ const tryAsSegmentIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
|
9594
9691
|
class ImportSpec extends WithDebug {
|
|
9595
9692
|
treeRoot;
|
|
9596
9693
|
index;
|
|
9597
|
-
static Codec = Class(ImportSpec, {
|
|
9598
|
-
treeRoot: bytes(hash_HASH_SIZE),
|
|
9599
|
-
index: u16.asOpaque(),
|
|
9694
|
+
static Codec = codec_codec.Class(ImportSpec, {
|
|
9695
|
+
treeRoot: codec_codec.bytes(hash_HASH_SIZE),
|
|
9696
|
+
index: codec_codec.u16.asOpaque(),
|
|
9600
9697
|
});
|
|
9601
9698
|
static create({ treeRoot, index }) {
|
|
9602
9699
|
return new ImportSpec(treeRoot, index);
|
|
@@ -9618,9 +9715,9 @@ class ImportSpec extends WithDebug {
|
|
|
9618
9715
|
class WorkItemExtrinsicSpec extends WithDebug {
|
|
9619
9716
|
hash;
|
|
9620
9717
|
len;
|
|
9621
|
-
static Codec = Class(WorkItemExtrinsicSpec, {
|
|
9622
|
-
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9623
|
-
len: u32,
|
|
9718
|
+
static Codec = codec_codec.Class(WorkItemExtrinsicSpec, {
|
|
9719
|
+
hash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9720
|
+
len: codec_codec.u32,
|
|
9624
9721
|
});
|
|
9625
9722
|
static create({ hash, len }) {
|
|
9626
9723
|
return new WorkItemExtrinsicSpec(hash, len);
|
|
@@ -9680,19 +9777,19 @@ class work_item_WorkItem extends WithDebug {
|
|
|
9680
9777
|
importSegments;
|
|
9681
9778
|
extrinsic;
|
|
9682
9779
|
exportCount;
|
|
9683
|
-
static Codec = Class(work_item_WorkItem, {
|
|
9684
|
-
service: u32.asOpaque(),
|
|
9685
|
-
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9686
|
-
refineGasLimit: u64.asOpaque(),
|
|
9687
|
-
accumulateGasLimit: u64.asOpaque(),
|
|
9688
|
-
exportCount: u16,
|
|
9689
|
-
payload: blob,
|
|
9780
|
+
static Codec = codec_codec.Class(work_item_WorkItem, {
|
|
9781
|
+
service: codec_codec.u32.asOpaque(),
|
|
9782
|
+
codeHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9783
|
+
refineGasLimit: codec_codec.u64.asOpaque(),
|
|
9784
|
+
accumulateGasLimit: codec_codec.u64.asOpaque(),
|
|
9785
|
+
exportCount: codec_codec.u16,
|
|
9786
|
+
payload: codec_codec.blob,
|
|
9690
9787
|
importSegments: codecKnownSizeArray(ImportSpec.Codec, {
|
|
9691
9788
|
minLength: 0,
|
|
9692
9789
|
maxLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9693
9790
|
typicalLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9694
9791
|
}),
|
|
9695
|
-
extrinsic: sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
9792
|
+
extrinsic: codec_codec.sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
9696
9793
|
});
|
|
9697
9794
|
static create({ service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount, }) {
|
|
9698
9795
|
return new work_item_WorkItem(service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount);
|
|
@@ -9765,13 +9862,13 @@ class work_package_WorkPackage extends WithDebug {
|
|
|
9765
9862
|
parametrization;
|
|
9766
9863
|
context;
|
|
9767
9864
|
items;
|
|
9768
|
-
static Codec = Class(work_package_WorkPackage, {
|
|
9769
|
-
authCodeHost: u32.asOpaque(),
|
|
9770
|
-
authCodeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9865
|
+
static Codec = codec_codec.Class(work_package_WorkPackage, {
|
|
9866
|
+
authCodeHost: codec_codec.u32.asOpaque(),
|
|
9867
|
+
authCodeHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9771
9868
|
context: RefineContext.Codec,
|
|
9772
|
-
authorization: blob,
|
|
9773
|
-
parametrization: blob,
|
|
9774
|
-
items: sequenceVarLen(work_item_WorkItem.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
9869
|
+
authorization: codec_codec.blob,
|
|
9870
|
+
parametrization: codec_codec.blob,
|
|
9871
|
+
items: codec_codec.sequenceVarLen(work_item_WorkItem.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
9775
9872
|
});
|
|
9776
9873
|
static create({ authorization, authCodeHost, authCodeHash, parametrization, context, items, }) {
|
|
9777
9874
|
return new work_package_WorkPackage(authorization, authCodeHost, authCodeHash, parametrization, context, items);
|
|
@@ -9831,30 +9928,22 @@ var WorkExecResultKind;
|
|
|
9831
9928
|
class WorkExecResult extends WithDebug {
|
|
9832
9929
|
kind;
|
|
9833
9930
|
okBlob;
|
|
9834
|
-
static Codec =
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
}
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
return
|
|
9847
|
-
}
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
}
|
|
9851
|
-
return new WorkExecResult(kind);
|
|
9852
|
-
}, (s) => {
|
|
9853
|
-
const kind = s.decoder.varU32();
|
|
9854
|
-
if (kind === WorkExecResultKind.ok) {
|
|
9855
|
-
s.bytesBlob();
|
|
9856
|
-
}
|
|
9857
|
-
});
|
|
9931
|
+
static Codec = codec_codec
|
|
9932
|
+
.union("WorkExecResult", {
|
|
9933
|
+
[WorkExecResultKind.ok]: codec_codec.object({ okBlob: codec_codec.blob }),
|
|
9934
|
+
[WorkExecResultKind.outOfGas]: codec_codec.object({}),
|
|
9935
|
+
[WorkExecResultKind.panic]: codec_codec.object({}),
|
|
9936
|
+
[WorkExecResultKind.incorrectNumberOfExports]: codec_codec.object({}),
|
|
9937
|
+
[WorkExecResultKind.digestTooBig]: codec_codec.object({}),
|
|
9938
|
+
[WorkExecResultKind.badCode]: codec_codec.object({}),
|
|
9939
|
+
[WorkExecResultKind.codeOversize]: codec_codec.object({}),
|
|
9940
|
+
})
|
|
9941
|
+
.convert((x) => {
|
|
9942
|
+
if (x.kind === WorkExecResultKind.ok) {
|
|
9943
|
+
return { kind: WorkExecResultKind.ok, okBlob: x.okBlob ?? bytes_BytesBlob.empty() };
|
|
9944
|
+
}
|
|
9945
|
+
return { kind: x.kind };
|
|
9946
|
+
}, (x) => new WorkExecResult(x.kind, x.kind === WorkExecResultKind.ok ? x.okBlob : null));
|
|
9858
9947
|
constructor(
|
|
9859
9948
|
/** The execution result tag. */
|
|
9860
9949
|
kind,
|
|
@@ -9878,12 +9967,12 @@ class WorkRefineLoad extends WithDebug {
|
|
|
9878
9967
|
extrinsicCount;
|
|
9879
9968
|
extrinsicSize;
|
|
9880
9969
|
exportedSegments;
|
|
9881
|
-
static Codec = Class(WorkRefineLoad, {
|
|
9882
|
-
gasUsed: varU64.asOpaque(),
|
|
9883
|
-
importedSegments: varU32,
|
|
9884
|
-
extrinsicCount: varU32,
|
|
9885
|
-
extrinsicSize: varU32,
|
|
9886
|
-
exportedSegments: varU32,
|
|
9970
|
+
static Codec = codec_codec.Class(WorkRefineLoad, {
|
|
9971
|
+
gasUsed: codec_codec.varU64.asOpaque(),
|
|
9972
|
+
importedSegments: codec_codec.varU32,
|
|
9973
|
+
extrinsicCount: codec_codec.varU32,
|
|
9974
|
+
extrinsicSize: codec_codec.varU32,
|
|
9975
|
+
exportedSegments: codec_codec.varU32,
|
|
9887
9976
|
});
|
|
9888
9977
|
static create({ gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments, }) {
|
|
9889
9978
|
return new WorkRefineLoad(gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments);
|
|
@@ -9919,11 +10008,11 @@ class WorkResult {
|
|
|
9919
10008
|
gas;
|
|
9920
10009
|
result;
|
|
9921
10010
|
load;
|
|
9922
|
-
static Codec = Class(WorkResult, {
|
|
9923
|
-
serviceId: u32.asOpaque(),
|
|
9924
|
-
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9925
|
-
payloadHash: bytes(hash_HASH_SIZE),
|
|
9926
|
-
gas: u64.asOpaque(),
|
|
10011
|
+
static Codec = codec_codec.Class(WorkResult, {
|
|
10012
|
+
serviceId: codec_codec.u32.asOpaque(),
|
|
10013
|
+
codeHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10014
|
+
payloadHash: codec_codec.bytes(hash_HASH_SIZE),
|
|
10015
|
+
gas: codec_codec.u64.asOpaque(),
|
|
9927
10016
|
result: WorkExecResult.Codec,
|
|
9928
10017
|
load: WorkRefineLoad.Codec,
|
|
9929
10018
|
});
|
|
@@ -9990,12 +10079,12 @@ class WorkPackageSpec extends WithDebug {
|
|
|
9990
10079
|
erasureRoot;
|
|
9991
10080
|
exportsRoot;
|
|
9992
10081
|
exportsCount;
|
|
9993
|
-
static Codec = Class(WorkPackageSpec, {
|
|
9994
|
-
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9995
|
-
length: u32,
|
|
9996
|
-
erasureRoot: bytes(hash_HASH_SIZE),
|
|
9997
|
-
exportsRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9998
|
-
exportsCount: u16,
|
|
10082
|
+
static Codec = codec_codec.Class(WorkPackageSpec, {
|
|
10083
|
+
hash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10084
|
+
length: codec_codec.u32,
|
|
10085
|
+
erasureRoot: codec_codec.bytes(hash_HASH_SIZE),
|
|
10086
|
+
exportsRoot: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10087
|
+
exportsCount: codec_codec.u16,
|
|
9999
10088
|
});
|
|
10000
10089
|
static create({ hash, length, erasureRoot, exportsRoot, exportsCount }) {
|
|
10001
10090
|
return new WorkPackageSpec(hash, length, erasureRoot, exportsRoot, exportsCount);
|
|
@@ -10033,20 +10122,20 @@ class WorkReport extends WithDebug {
|
|
|
10033
10122
|
segmentRootLookup;
|
|
10034
10123
|
results;
|
|
10035
10124
|
authorizationGasUsed;
|
|
10036
|
-
static Codec = Class(WorkReport, {
|
|
10125
|
+
static Codec = codec_codec.Class(WorkReport, {
|
|
10037
10126
|
workPackageSpec: WorkPackageSpec.Codec,
|
|
10038
10127
|
context: RefineContext.Codec,
|
|
10039
|
-
coreIndex: varU32.convert((o) => numbers_tryAsU32(o), (i) => {
|
|
10128
|
+
coreIndex: codec_codec.varU32.convert((o) => numbers_tryAsU32(o), (i) => {
|
|
10040
10129
|
if (!isU16(i)) {
|
|
10041
10130
|
throw new Error(`Core index exceeds U16: ${i}`);
|
|
10042
10131
|
}
|
|
10043
10132
|
return tryAsCoreIndex(i);
|
|
10044
10133
|
}),
|
|
10045
|
-
authorizerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10046
|
-
authorizationGasUsed: varU64.asOpaque(),
|
|
10047
|
-
authorizationOutput: blob,
|
|
10048
|
-
segmentRootLookup: readonlyArray(sequenceVarLen(WorkPackageInfo.Codec)),
|
|
10049
|
-
results: sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
10134
|
+
authorizerHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10135
|
+
authorizationGasUsed: codec_codec.varU64.asOpaque(),
|
|
10136
|
+
authorizationOutput: codec_codec.blob,
|
|
10137
|
+
segmentRootLookup: codec_codec.readonlyArray(codec_codec.sequenceVarLen(WorkPackageInfo.Codec)),
|
|
10138
|
+
results: codec_codec.sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
10050
10139
|
});
|
|
10051
10140
|
static create({ workPackageSpec, context, coreIndex, authorizerHash, authorizationOutput, segmentRootLookup, results, authorizationGasUsed, }) {
|
|
10052
10141
|
return new WorkReport(workPackageSpec, context, coreIndex, authorizerHash, authorizationOutput, segmentRootLookup, results, authorizationGasUsed);
|
|
@@ -10094,9 +10183,9 @@ const REQUIRED_CREDENTIALS_RANGE = [2, 3];
|
|
|
10094
10183
|
class Credential extends WithDebug {
|
|
10095
10184
|
validatorIndex;
|
|
10096
10185
|
signature;
|
|
10097
|
-
static Codec = Class(Credential, {
|
|
10098
|
-
validatorIndex: u16.asOpaque(),
|
|
10099
|
-
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
10186
|
+
static Codec = codec_codec.Class(Credential, {
|
|
10187
|
+
validatorIndex: codec_codec.u16.asOpaque(),
|
|
10188
|
+
signature: codec_codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
10100
10189
|
});
|
|
10101
10190
|
static create({ validatorIndex, signature }) {
|
|
10102
10191
|
return new Credential(validatorIndex, signature);
|
|
@@ -10120,9 +10209,9 @@ class ReportGuarantee extends WithDebug {
|
|
|
10120
10209
|
report;
|
|
10121
10210
|
slot;
|
|
10122
10211
|
credentials;
|
|
10123
|
-
static Codec = Class(ReportGuarantee, {
|
|
10212
|
+
static Codec = codec_codec.Class(ReportGuarantee, {
|
|
10124
10213
|
report: WorkReport.Codec,
|
|
10125
|
-
slot: u32.asOpaque(),
|
|
10214
|
+
slot: codec_codec.u32.asOpaque(),
|
|
10126
10215
|
credentials: codecKnownSizeArray(Credential.Codec, {
|
|
10127
10216
|
minLength: REQUIRED_CREDENTIALS_RANGE[0],
|
|
10128
10217
|
maxLength: REQUIRED_CREDENTIALS_RANGE[1],
|
|
@@ -10172,10 +10261,10 @@ function tryAsTicketAttempt(x) {
|
|
|
10172
10261
|
class SignedTicket extends WithDebug {
|
|
10173
10262
|
attempt;
|
|
10174
10263
|
signature;
|
|
10175
|
-
static Codec = Class(SignedTicket, {
|
|
10264
|
+
static Codec = codec_codec.Class(SignedTicket, {
|
|
10176
10265
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
10177
|
-
attempt: u8.asOpaque(),
|
|
10178
|
-
signature: bytes(BANDERSNATCH_PROOF_BYTES).asOpaque(),
|
|
10266
|
+
attempt: codec_codec.u8.asOpaque(),
|
|
10267
|
+
signature: codec_codec.bytes(BANDERSNATCH_PROOF_BYTES).asOpaque(),
|
|
10179
10268
|
});
|
|
10180
10269
|
static create({ attempt, signature }) {
|
|
10181
10270
|
return new SignedTicket(attempt, signature);
|
|
@@ -10194,10 +10283,10 @@ class SignedTicket extends WithDebug {
|
|
|
10194
10283
|
class Ticket extends WithDebug {
|
|
10195
10284
|
id;
|
|
10196
10285
|
attempt;
|
|
10197
|
-
static Codec = Class(Ticket, {
|
|
10198
|
-
id: bytes(hash_HASH_SIZE),
|
|
10286
|
+
static Codec = codec_codec.Class(Ticket, {
|
|
10287
|
+
id: codec_codec.bytes(hash_HASH_SIZE),
|
|
10199
10288
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
10200
|
-
attempt: u8.asOpaque(),
|
|
10289
|
+
attempt: codec_codec.u8.asOpaque(),
|
|
10201
10290
|
});
|
|
10202
10291
|
static create({ id, attempt }) {
|
|
10203
10292
|
return new Ticket(id, attempt);
|
|
@@ -10249,9 +10338,9 @@ const ticketsExtrinsicCodec = codecWithContext((context) => {
|
|
|
10249
10338
|
class ValidatorKeys extends WithDebug {
|
|
10250
10339
|
bandersnatch;
|
|
10251
10340
|
ed25519;
|
|
10252
|
-
static Codec = Class(ValidatorKeys, {
|
|
10253
|
-
bandersnatch: bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
10254
|
-
ed25519: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
10341
|
+
static Codec = codec_codec.Class(ValidatorKeys, {
|
|
10342
|
+
bandersnatch: codec_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
10343
|
+
ed25519: codec_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
10255
10344
|
});
|
|
10256
10345
|
static create({ bandersnatch, ed25519 }) {
|
|
10257
10346
|
return new ValidatorKeys(bandersnatch, ed25519);
|
|
@@ -10268,7 +10357,7 @@ class ValidatorKeys extends WithDebug {
|
|
|
10268
10357
|
}
|
|
10269
10358
|
class TicketsMarker extends WithDebug {
|
|
10270
10359
|
tickets;
|
|
10271
|
-
static Codec = Class(TicketsMarker, {
|
|
10360
|
+
static Codec = codec_codec.Class(TicketsMarker, {
|
|
10272
10361
|
tickets: codecPerEpochBlock(Ticket.Codec),
|
|
10273
10362
|
});
|
|
10274
10363
|
static create({ tickets }) {
|
|
@@ -10290,9 +10379,9 @@ class EpochMarker extends WithDebug {
|
|
|
10290
10379
|
entropy;
|
|
10291
10380
|
ticketsEntropy;
|
|
10292
10381
|
validators;
|
|
10293
|
-
static Codec = Class(EpochMarker, {
|
|
10294
|
-
entropy: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10295
|
-
ticketsEntropy: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10382
|
+
static Codec = codec_codec.Class(EpochMarker, {
|
|
10383
|
+
entropy: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10384
|
+
ticketsEntropy: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10296
10385
|
validators: codecPerValidator(ValidatorKeys.Codec),
|
|
10297
10386
|
});
|
|
10298
10387
|
static create({ entropy, ticketsEntropy, validators }) {
|
|
@@ -10329,17 +10418,17 @@ const encodeUnsealedHeader = (view) => {
|
|
|
10329
10418
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/0c66000c7200?v=0.7.2
|
|
10330
10419
|
*/
|
|
10331
10420
|
class header_Header extends WithDebug {
|
|
10332
|
-
static Codec = Class(header_Header, {
|
|
10333
|
-
parentHeaderHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10334
|
-
priorStateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10335
|
-
extrinsicHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10336
|
-
timeSlotIndex: u32.asOpaque(),
|
|
10337
|
-
epochMarker: optional(EpochMarker.Codec),
|
|
10338
|
-
ticketsMarker: optional(TicketsMarker.Codec),
|
|
10339
|
-
bandersnatchBlockAuthorIndex: u16.asOpaque(),
|
|
10340
|
-
entropySource: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10341
|
-
offendersMarker: sequenceVarLen(bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
10342
|
-
seal: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10421
|
+
static Codec = codec_codec.Class(header_Header, {
|
|
10422
|
+
parentHeaderHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10423
|
+
priorStateRoot: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10424
|
+
extrinsicHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10425
|
+
timeSlotIndex: codec_codec.u32.asOpaque(),
|
|
10426
|
+
epochMarker: codec_codec.optional(EpochMarker.Codec),
|
|
10427
|
+
ticketsMarker: codec_codec.optional(TicketsMarker.Codec),
|
|
10428
|
+
bandersnatchBlockAuthorIndex: codec_codec.u16.asOpaque(),
|
|
10429
|
+
entropySource: codec_codec.bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10430
|
+
offendersMarker: codec_codec.sequenceVarLen(codec_codec.bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
10431
|
+
seal: codec_codec.bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10343
10432
|
});
|
|
10344
10433
|
static create(h) {
|
|
10345
10434
|
return Object.assign(header_Header.empty(), h);
|
|
@@ -10394,8 +10483,8 @@ class header_Header extends WithDebug {
|
|
|
10394
10483
|
* `DescriptorRecord` or `CodecRecord` for some reason.
|
|
10395
10484
|
*/
|
|
10396
10485
|
class HeaderViewWithHash extends WithHash {
|
|
10397
|
-
static Codec = Class(HeaderViewWithHash, {
|
|
10398
|
-
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10486
|
+
static Codec = codec_codec.Class(HeaderViewWithHash, {
|
|
10487
|
+
hash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
10399
10488
|
data: header_Header.Codec.View,
|
|
10400
10489
|
});
|
|
10401
10490
|
static create({ hash, data }) {
|
|
@@ -10416,9 +10505,9 @@ const headerViewWithHashCodec = HeaderViewWithHash.Codec;
|
|
|
10416
10505
|
class Preimage extends WithDebug {
|
|
10417
10506
|
requester;
|
|
10418
10507
|
blob;
|
|
10419
|
-
static Codec = Class(Preimage, {
|
|
10420
|
-
requester: u32.asOpaque(),
|
|
10421
|
-
blob: blob,
|
|
10508
|
+
static Codec = codec_codec.Class(Preimage, {
|
|
10509
|
+
requester: codec_codec.u32.asOpaque(),
|
|
10510
|
+
blob: codec_codec.blob,
|
|
10422
10511
|
});
|
|
10423
10512
|
static create({ requester, blob }) {
|
|
10424
10513
|
return new Preimage(requester, blob);
|
|
@@ -10433,7 +10522,7 @@ class Preimage extends WithDebug {
|
|
|
10433
10522
|
this.blob = blob;
|
|
10434
10523
|
}
|
|
10435
10524
|
}
|
|
10436
|
-
const preimagesExtrinsicCodec = sequenceVarLen(Preimage.Codec);
|
|
10525
|
+
const preimagesExtrinsicCodec = codec_codec.sequenceVarLen(Preimage.Codec);
|
|
10437
10526
|
|
|
10438
10527
|
;// CONCATENATED MODULE: ./packages/jam/block/block.ts
|
|
10439
10528
|
|
|
@@ -10459,7 +10548,7 @@ class Extrinsic extends WithDebug {
|
|
|
10459
10548
|
guarantees;
|
|
10460
10549
|
assurances;
|
|
10461
10550
|
disputes;
|
|
10462
|
-
static Codec = Class(Extrinsic, {
|
|
10551
|
+
static Codec = codec_codec.Class(Extrinsic, {
|
|
10463
10552
|
tickets: ticketsExtrinsicCodec,
|
|
10464
10553
|
preimages: preimagesExtrinsicCodec,
|
|
10465
10554
|
guarantees: guaranteesExtrinsicCodec,
|
|
@@ -10512,7 +10601,7 @@ class Extrinsic extends WithDebug {
|
|
|
10512
10601
|
class Block extends WithDebug {
|
|
10513
10602
|
header;
|
|
10514
10603
|
extrinsic;
|
|
10515
|
-
static Codec = Class(Block, {
|
|
10604
|
+
static Codec = codec_codec.Class(Block, {
|
|
10516
10605
|
header: header_Header.Codec,
|
|
10517
10606
|
extrinsic: Extrinsic.Codec,
|
|
10518
10607
|
});
|
|
@@ -11493,10 +11582,10 @@ class Version extends WithDebug {
|
|
|
11493
11582
|
major;
|
|
11494
11583
|
minor;
|
|
11495
11584
|
patch;
|
|
11496
|
-
static Codec = Class(Version, {
|
|
11497
|
-
major: u8,
|
|
11498
|
-
minor: u8,
|
|
11499
|
-
patch: u8,
|
|
11585
|
+
static Codec = codec_codec.Class(Version, {
|
|
11586
|
+
major: codec_codec.u8,
|
|
11587
|
+
minor: codec_codec.u8,
|
|
11588
|
+
patch: codec_codec.u8,
|
|
11500
11589
|
});
|
|
11501
11590
|
static tryFromString(str) {
|
|
11502
11591
|
const parse = (v) => tryAsU8(Number(v));
|
|
@@ -11548,12 +11637,12 @@ class PeerInfo extends WithDebug {
|
|
|
11548
11637
|
jamVersion;
|
|
11549
11638
|
appVersion;
|
|
11550
11639
|
name;
|
|
11551
|
-
static Codec = Class(PeerInfo, {
|
|
11552
|
-
fuzzVersion: u8,
|
|
11553
|
-
features: u32,
|
|
11640
|
+
static Codec = codec_codec.Class(PeerInfo, {
|
|
11641
|
+
fuzzVersion: codec_codec.u8,
|
|
11642
|
+
features: codec_codec.u32,
|
|
11554
11643
|
jamVersion: Version.Codec,
|
|
11555
11644
|
appVersion: Version.Codec,
|
|
11556
|
-
name: string,
|
|
11645
|
+
name: codec_codec.string,
|
|
11557
11646
|
});
|
|
11558
11647
|
static create({ fuzzVersion, features, appVersion, jamVersion, name }) {
|
|
11559
11648
|
return new PeerInfo(fuzzVersion, features, jamVersion, appVersion, name);
|
|
@@ -11576,9 +11665,9 @@ class PeerInfo extends WithDebug {
|
|
|
11576
11665
|
class AncestryItem extends WithDebug {
|
|
11577
11666
|
slot;
|
|
11578
11667
|
headerHash;
|
|
11579
|
-
static Codec = Class(AncestryItem, {
|
|
11580
|
-
slot: u32.asOpaque(),
|
|
11581
|
-
headerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
11668
|
+
static Codec = codec_codec.Class(AncestryItem, {
|
|
11669
|
+
slot: codec_codec.u32.asOpaque(),
|
|
11670
|
+
headerHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
11582
11671
|
});
|
|
11583
11672
|
static create({ slot, headerHash }) {
|
|
11584
11673
|
return new AncestryItem(slot, headerHash);
|
|
@@ -11598,9 +11687,9 @@ class AncestryItem extends WithDebug {
|
|
|
11598
11687
|
class KeyValue extends WithDebug {
|
|
11599
11688
|
key;
|
|
11600
11689
|
value;
|
|
11601
|
-
static Codec = Class(KeyValue, {
|
|
11602
|
-
key: bytes(TRUNCATED_HASH_SIZE),
|
|
11603
|
-
value: blob,
|
|
11690
|
+
static Codec = codec_codec.Class(KeyValue, {
|
|
11691
|
+
key: codec_codec.bytes(TRUNCATED_HASH_SIZE),
|
|
11692
|
+
value: codec_codec.blob,
|
|
11604
11693
|
});
|
|
11605
11694
|
static create({ key, value }) {
|
|
11606
11695
|
return new KeyValue(key, value);
|
|
@@ -11612,12 +11701,12 @@ class KeyValue extends WithDebug {
|
|
|
11612
11701
|
}
|
|
11613
11702
|
}
|
|
11614
11703
|
/** State ::= SEQUENCE OF KeyValue */
|
|
11615
|
-
const stateCodec = sequenceVarLen(KeyValue.Codec);
|
|
11704
|
+
const stateCodec = codec_codec.sequenceVarLen(KeyValue.Codec);
|
|
11616
11705
|
/**
|
|
11617
11706
|
* Ancestry ::= SEQUENCE (SIZE(0..24)) OF AncestryItem
|
|
11618
11707
|
* Empty when `feature-ancestry` is not supported by both parties
|
|
11619
11708
|
*/
|
|
11620
|
-
const ancestryCodec = sequenceVarLen(AncestryItem.Codec, {
|
|
11709
|
+
const ancestryCodec = codec_codec.sequenceVarLen(AncestryItem.Codec, {
|
|
11621
11710
|
minLength: 0,
|
|
11622
11711
|
maxLength: 24,
|
|
11623
11712
|
});
|
|
@@ -11632,7 +11721,7 @@ class Initialize extends WithDebug {
|
|
|
11632
11721
|
header;
|
|
11633
11722
|
keyvals;
|
|
11634
11723
|
ancestry;
|
|
11635
|
-
static Codec = Class(Initialize, {
|
|
11724
|
+
static Codec = codec_codec.Class(Initialize, {
|
|
11636
11725
|
header: header_Header.Codec,
|
|
11637
11726
|
keyvals: stateCodec,
|
|
11638
11727
|
ancestry: ancestryCodec,
|
|
@@ -11648,14 +11737,14 @@ class Initialize extends WithDebug {
|
|
|
11648
11737
|
}
|
|
11649
11738
|
}
|
|
11650
11739
|
/** GetState ::= HeaderHash */
|
|
11651
|
-
const getStateCodec = bytes(hash_HASH_SIZE).asOpaque();
|
|
11740
|
+
const getStateCodec = codec_codec.bytes(hash_HASH_SIZE).asOpaque();
|
|
11652
11741
|
/** StateRoot ::= StateRootHash */
|
|
11653
|
-
const stateRootCodec = bytes(hash_HASH_SIZE).asOpaque();
|
|
11742
|
+
const stateRootCodec = codec_codec.bytes(hash_HASH_SIZE).asOpaque();
|
|
11654
11743
|
/** Error ::= UTF8String */
|
|
11655
11744
|
class ErrorMessage extends WithDebug {
|
|
11656
11745
|
message;
|
|
11657
|
-
static Codec = Class(ErrorMessage, {
|
|
11658
|
-
message: string,
|
|
11746
|
+
static Codec = codec_codec.Class(ErrorMessage, {
|
|
11747
|
+
message: codec_codec.string,
|
|
11659
11748
|
});
|
|
11660
11749
|
static create({ message }) {
|
|
11661
11750
|
return new ErrorMessage(message);
|
|
@@ -11687,7 +11776,7 @@ var types_MessageType;
|
|
|
11687
11776
|
* error [255] Error
|
|
11688
11777
|
* }
|
|
11689
11778
|
*/
|
|
11690
|
-
const types_messageCodec = custom({
|
|
11779
|
+
const types_messageCodec = codec_codec.custom({
|
|
11691
11780
|
name: "Message",
|
|
11692
11781
|
sizeHint: { bytes: 1, isExact: false },
|
|
11693
11782
|
}, (e, msg) => {
|
|
@@ -12053,9 +12142,9 @@ function getRegisters(argsLength) {
|
|
|
12053
12142
|
class AccumulationOutput {
|
|
12054
12143
|
serviceId;
|
|
12055
12144
|
output;
|
|
12056
|
-
static Codec = Class(AccumulationOutput, {
|
|
12057
|
-
serviceId: u32.asOpaque(),
|
|
12058
|
-
output: bytes(hash_HASH_SIZE),
|
|
12145
|
+
static Codec = codec_codec.Class(AccumulationOutput, {
|
|
12146
|
+
serviceId: codec_codec.u32.asOpaque(),
|
|
12147
|
+
output: codec_codec.bytes(hash_HASH_SIZE),
|
|
12059
12148
|
});
|
|
12060
12149
|
static create(a) {
|
|
12061
12150
|
return new AccumulationOutput(a.serviceId, a.output);
|
|
@@ -12146,9 +12235,9 @@ const MAX_REPORT_DEPENDENCIES = 8;
|
|
|
12146
12235
|
class NotYetAccumulatedReport extends WithDebug {
|
|
12147
12236
|
report;
|
|
12148
12237
|
dependencies;
|
|
12149
|
-
static Codec = Class(NotYetAccumulatedReport, {
|
|
12238
|
+
static Codec = codec_codec.Class(NotYetAccumulatedReport, {
|
|
12150
12239
|
report: WorkReport.Codec,
|
|
12151
|
-
dependencies: codecKnownSizeArray(bytes(hash_HASH_SIZE).asOpaque(), {
|
|
12240
|
+
dependencies: codecKnownSizeArray(codec_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
12152
12241
|
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
12153
12242
|
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
12154
12243
|
minLength: 0,
|
|
@@ -12175,7 +12264,7 @@ class NotYetAccumulatedReport extends WithDebug {
|
|
|
12175
12264
|
this.dependencies = dependencies;
|
|
12176
12265
|
}
|
|
12177
12266
|
}
|
|
12178
|
-
const accumulationQueueCodec = codecPerEpochBlock(readonlyArray(sequenceVarLen(NotYetAccumulatedReport.Codec)));
|
|
12267
|
+
const accumulationQueueCodec = codecPerEpochBlock(codec_codec.readonlyArray(codec_codec.sequenceVarLen(NotYetAccumulatedReport.Codec)));
|
|
12179
12268
|
|
|
12180
12269
|
;// CONCATENATED MODULE: ./packages/jam/state/common.ts
|
|
12181
12270
|
|
|
@@ -12208,9 +12297,9 @@ const codecPerCore = (val) => codecWithContext((context) => {
|
|
|
12208
12297
|
class AvailabilityAssignment extends WithDebug {
|
|
12209
12298
|
workReport;
|
|
12210
12299
|
timeout;
|
|
12211
|
-
static Codec = Class(AvailabilityAssignment, {
|
|
12300
|
+
static Codec = codec_codec.Class(AvailabilityAssignment, {
|
|
12212
12301
|
workReport: WorkReport.Codec,
|
|
12213
|
-
timeout: u32.asOpaque(),
|
|
12302
|
+
timeout: codec_codec.u32.asOpaque(),
|
|
12214
12303
|
});
|
|
12215
12304
|
static create({ workReport, timeout }) {
|
|
12216
12305
|
return new AvailabilityAssignment(workReport, timeout);
|
|
@@ -12225,7 +12314,7 @@ class AvailabilityAssignment extends WithDebug {
|
|
|
12225
12314
|
this.timeout = timeout;
|
|
12226
12315
|
}
|
|
12227
12316
|
}
|
|
12228
|
-
const availabilityAssignmentsCodec = codecPerCore(optional(AvailabilityAssignment.Codec));
|
|
12317
|
+
const availabilityAssignmentsCodec = codecPerCore(codec_codec.optional(AvailabilityAssignment.Codec));
|
|
12229
12318
|
|
|
12230
12319
|
;// CONCATENATED MODULE: ./packages/jam/state/auth.ts
|
|
12231
12320
|
|
|
@@ -12237,18 +12326,18 @@ const availabilityAssignmentsCodec = codecPerCore(optional(AvailabilityAssignmen
|
|
|
12237
12326
|
const MAX_AUTH_POOL_SIZE = O;
|
|
12238
12327
|
/** `Q`: Size of the authorization queue. */
|
|
12239
12328
|
const AUTHORIZATION_QUEUE_SIZE = Q;
|
|
12240
|
-
const authPoolsCodec = codecPerCore(codecKnownSizeArray(bytes(hash_HASH_SIZE).asOpaque(), {
|
|
12329
|
+
const authPoolsCodec = codecPerCore(codecKnownSizeArray(codec_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
12241
12330
|
minLength: 0,
|
|
12242
12331
|
maxLength: MAX_AUTH_POOL_SIZE,
|
|
12243
12332
|
typicalLength: MAX_AUTH_POOL_SIZE,
|
|
12244
12333
|
}));
|
|
12245
|
-
const authQueuesCodec = codecPerCore(codecFixedSizeArray(bytes(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE));
|
|
12334
|
+
const authQueuesCodec = codecPerCore(codecFixedSizeArray(codec_codec.bytes(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE));
|
|
12246
12335
|
|
|
12247
12336
|
;// CONCATENATED MODULE: ./packages/jam/state/disputes.ts
|
|
12248
12337
|
|
|
12249
12338
|
|
|
12250
12339
|
|
|
12251
|
-
const sortedSetCodec = () => readonlyArray(sequenceVarLen(bytes(hash_HASH_SIZE))).convert((input) => input.array, (output) => {
|
|
12340
|
+
const sortedSetCodec = () => codec_codec.readonlyArray(codec_codec.sequenceVarLen(codec_codec.bytes(hash_HASH_SIZE))).convert((input) => input.array, (output) => {
|
|
12252
12341
|
const typed = output.map((x) => x.asOpaque());
|
|
12253
12342
|
return SortedSet.fromSortedArray(hashComparator, typed);
|
|
12254
12343
|
});
|
|
@@ -12263,7 +12352,7 @@ class DisputesRecords {
|
|
|
12263
12352
|
badSet;
|
|
12264
12353
|
wonkySet;
|
|
12265
12354
|
punishSet;
|
|
12266
|
-
static Codec = Class(DisputesRecords, {
|
|
12355
|
+
static Codec = codec_codec.Class(DisputesRecords, {
|
|
12267
12356
|
goodSet: workReportsSortedSetCodec,
|
|
12268
12357
|
badSet: workReportsSortedSetCodec,
|
|
12269
12358
|
wonkySet: workReportsSortedSetCodec,
|
|
@@ -12336,10 +12425,10 @@ class BlockState extends WithDebug {
|
|
|
12336
12425
|
accumulationResult;
|
|
12337
12426
|
postStateRoot;
|
|
12338
12427
|
reported;
|
|
12339
|
-
static Codec = Class(BlockState, {
|
|
12340
|
-
headerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
12341
|
-
accumulationResult: bytes(hash_HASH_SIZE),
|
|
12342
|
-
postStateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
12428
|
+
static Codec = codec_codec.Class(BlockState, {
|
|
12429
|
+
headerHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
12430
|
+
accumulationResult: codec_codec.bytes(hash_HASH_SIZE),
|
|
12431
|
+
postStateRoot: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
12343
12432
|
reported: codecHashDictionary(WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
12344
12433
|
});
|
|
12345
12434
|
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
@@ -12369,14 +12458,14 @@ class BlockState extends WithDebug {
|
|
|
12369
12458
|
class RecentBlocks extends WithDebug {
|
|
12370
12459
|
blocks;
|
|
12371
12460
|
accumulationLog;
|
|
12372
|
-
static Codec = Class(RecentBlocks, {
|
|
12461
|
+
static Codec = codec_codec.Class(RecentBlocks, {
|
|
12373
12462
|
blocks: codecKnownSizeArray(BlockState.Codec, {
|
|
12374
12463
|
minLength: 0,
|
|
12375
12464
|
maxLength: MAX_RECENT_HISTORY,
|
|
12376
12465
|
typicalLength: MAX_RECENT_HISTORY,
|
|
12377
12466
|
}),
|
|
12378
|
-
accumulationLog: object({
|
|
12379
|
-
peaks: readonlyArray(sequenceVarLen(optional(bytes(hash_HASH_SIZE)))),
|
|
12467
|
+
accumulationLog: codec_codec.object({
|
|
12468
|
+
peaks: codec_codec.readonlyArray(codec_codec.sequenceVarLen(codec_codec.optional(codec_codec.bytes(hash_HASH_SIZE)))),
|
|
12380
12469
|
}),
|
|
12381
12470
|
});
|
|
12382
12471
|
static empty() {
|
|
@@ -12409,7 +12498,7 @@ class RecentBlocks extends WithDebug {
|
|
|
12409
12498
|
|
|
12410
12499
|
|
|
12411
12500
|
|
|
12412
|
-
const recentlyAccumulatedCodec = codecPerEpochBlock(sequenceVarLen(bytes(hash_HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x)));
|
|
12501
|
+
const recentlyAccumulatedCodec = codecPerEpochBlock(codec_codec.sequenceVarLen(codec_codec.bytes(hash_HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x)));
|
|
12413
12502
|
|
|
12414
12503
|
;// CONCATENATED MODULE: ./packages/jam/state/validator-data.ts
|
|
12415
12504
|
|
|
@@ -12432,11 +12521,11 @@ class ValidatorData extends WithDebug {
|
|
|
12432
12521
|
ed25519;
|
|
12433
12522
|
bls;
|
|
12434
12523
|
metadata;
|
|
12435
|
-
static Codec = Class(ValidatorData, {
|
|
12436
|
-
bandersnatch: bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
12437
|
-
ed25519: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
12438
|
-
bls: bytes(BLS_KEY_BYTES).asOpaque(),
|
|
12439
|
-
metadata: bytes(VALIDATOR_META_BYTES),
|
|
12524
|
+
static Codec = codec_codec.Class(ValidatorData, {
|
|
12525
|
+
bandersnatch: codec_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
12526
|
+
ed25519: codec_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
12527
|
+
bls: codec_codec.bytes(BLS_KEY_BYTES).asOpaque(),
|
|
12528
|
+
metadata: codec_codec.bytes(VALIDATOR_META_BYTES),
|
|
12440
12529
|
});
|
|
12441
12530
|
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
12442
12531
|
return new ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
@@ -12469,53 +12558,31 @@ const validatorsDataCodec = codecPerValidator(ValidatorData.Codec);
|
|
|
12469
12558
|
|
|
12470
12559
|
|
|
12471
12560
|
|
|
12472
|
-
|
|
12473
|
-
|
|
12474
12561
|
var SafroleSealingKeysKind;
|
|
12475
12562
|
(function (SafroleSealingKeysKind) {
|
|
12476
12563
|
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
12477
12564
|
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
12478
12565
|
})(SafroleSealingKeysKind || (SafroleSealingKeysKind = {}));
|
|
12479
|
-
const codecBandersnatchKey = bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
12566
|
+
const codecBandersnatchKey = codec_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
12480
12567
|
class SafroleSealingKeysData extends WithDebug {
|
|
12481
12568
|
kind;
|
|
12482
12569
|
keys;
|
|
12483
12570
|
tickets;
|
|
12484
12571
|
static Codec = codecWithContext((context) => {
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12572
|
+
const keysCodec = codec_codec
|
|
12573
|
+
.sequenceFixLen(codecBandersnatchKey, context.epochLength)
|
|
12574
|
+
.convert((keys) => Array.from(keys), (keys) => tryAsPerEpochBlock(keys, context));
|
|
12575
|
+
const ticketsCodec = codec_codec.sequenceFixLen(Ticket.Codec, context.epochLength).convert((tickets) => Array.from(tickets), (tickets) => tryAsPerEpochBlock(tickets, context));
|
|
12576
|
+
return codec_codec
|
|
12577
|
+
.union("SafroleSealingKeys", {
|
|
12578
|
+
[SafroleSealingKeysKind.Keys]: codec_codec.object({ keys: keysCodec }),
|
|
12579
|
+
[SafroleSealingKeysKind.Tickets]: codec_codec.object({ tickets: ticketsCodec }),
|
|
12580
|
+
})
|
|
12581
|
+
.convert((x) => x, (x) => {
|
|
12490
12582
|
if (x.kind === SafroleSealingKeysKind.Keys) {
|
|
12491
|
-
|
|
12492
|
-
}
|
|
12493
|
-
else {
|
|
12494
|
-
e.sequenceFixLen(Ticket.Codec, x.tickets);
|
|
12583
|
+
return SafroleSealingKeysData.keys(x.keys);
|
|
12495
12584
|
}
|
|
12496
|
-
|
|
12497
|
-
const epochLength = context.epochLength;
|
|
12498
|
-
const kind = d.varU32();
|
|
12499
|
-
if (kind === SafroleSealingKeysKind.Keys) {
|
|
12500
|
-
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
12501
|
-
return SafroleSealingKeysData.keys(tryAsPerEpochBlock(keys, context));
|
|
12502
|
-
}
|
|
12503
|
-
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
12504
|
-
const tickets = d.sequenceFixLen(Ticket.Codec, epochLength);
|
|
12505
|
-
return SafroleSealingKeysData.tickets(tryAsPerEpochBlock(tickets, context));
|
|
12506
|
-
}
|
|
12507
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
12508
|
-
}, (s) => {
|
|
12509
|
-
const kind = s.decoder.varU32();
|
|
12510
|
-
if (kind === SafroleSealingKeysKind.Keys) {
|
|
12511
|
-
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
12512
|
-
return;
|
|
12513
|
-
}
|
|
12514
|
-
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
12515
|
-
s.sequenceFixLen(Ticket.Codec, context.epochLength);
|
|
12516
|
-
return;
|
|
12517
|
-
}
|
|
12518
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
12585
|
+
return SafroleSealingKeysData.tickets(x.tickets);
|
|
12519
12586
|
});
|
|
12520
12587
|
});
|
|
12521
12588
|
static keys(keys) {
|
|
@@ -12536,11 +12603,11 @@ class safrole_data_SafroleData {
|
|
|
12536
12603
|
epochRoot;
|
|
12537
12604
|
sealingKeySeries;
|
|
12538
12605
|
ticketsAccumulator;
|
|
12539
|
-
static Codec = Class(safrole_data_SafroleData, {
|
|
12606
|
+
static Codec = codec_codec.Class(safrole_data_SafroleData, {
|
|
12540
12607
|
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
12541
|
-
epochRoot: bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
12608
|
+
epochRoot: codec_codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
12542
12609
|
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
12543
|
-
ticketsAccumulator: readonlyArray(sequenceVarLen(Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
12610
|
+
ticketsAccumulator: codec_codec.readonlyArray(codec_codec.sequenceVarLen(Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
12544
12611
|
});
|
|
12545
12612
|
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
12546
12613
|
return new safrole_data_SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
@@ -12625,17 +12692,17 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
12625
12692
|
created;
|
|
12626
12693
|
lastAccumulation;
|
|
12627
12694
|
parentService;
|
|
12628
|
-
static Codec = Class(ServiceAccountInfo, {
|
|
12629
|
-
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
12630
|
-
balance: u64,
|
|
12631
|
-
accumulateMinGas: u64.convert((x) => x, tryAsServiceGas),
|
|
12632
|
-
onTransferMinGas: u64.convert((x) => x, tryAsServiceGas),
|
|
12633
|
-
storageUtilisationBytes: u64,
|
|
12634
|
-
gratisStorage: u64,
|
|
12635
|
-
storageUtilisationCount: u32,
|
|
12636
|
-
created: u32.convert((x) => x, common_tryAsTimeSlot),
|
|
12637
|
-
lastAccumulation: u32.convert((x) => x, common_tryAsTimeSlot),
|
|
12638
|
-
parentService: u32.convert((x) => x, tryAsServiceId),
|
|
12695
|
+
static Codec = codec_codec.Class(ServiceAccountInfo, {
|
|
12696
|
+
codeHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
12697
|
+
balance: codec_codec.u64,
|
|
12698
|
+
accumulateMinGas: codec_codec.u64.convert((x) => x, tryAsServiceGas),
|
|
12699
|
+
onTransferMinGas: codec_codec.u64.convert((x) => x, tryAsServiceGas),
|
|
12700
|
+
storageUtilisationBytes: codec_codec.u64,
|
|
12701
|
+
gratisStorage: codec_codec.u64,
|
|
12702
|
+
storageUtilisationCount: codec_codec.u32,
|
|
12703
|
+
created: codec_codec.u32.convert((x) => x, common_tryAsTimeSlot),
|
|
12704
|
+
lastAccumulation: codec_codec.u32.convert((x) => x, common_tryAsTimeSlot),
|
|
12705
|
+
parentService: codec_codec.u32.convert((x) => x, tryAsServiceId),
|
|
12639
12706
|
});
|
|
12640
12707
|
static create(a) {
|
|
12641
12708
|
return new ServiceAccountInfo(a.codeHash, a.balance, a.accumulateMinGas, a.onTransferMinGas, a.storageUtilisationBytes, a.gratisStorage, a.storageUtilisationCount, a.created, a.lastAccumulation, a.parentService);
|
|
@@ -12691,9 +12758,9 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
12691
12758
|
class PreimageItem extends WithDebug {
|
|
12692
12759
|
hash;
|
|
12693
12760
|
blob;
|
|
12694
|
-
static Codec = Class(PreimageItem, {
|
|
12695
|
-
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
12696
|
-
blob: blob,
|
|
12761
|
+
static Codec = codec_codec.Class(PreimageItem, {
|
|
12762
|
+
hash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
12763
|
+
blob: codec_codec.blob,
|
|
12697
12764
|
});
|
|
12698
12765
|
static create({ hash, blob }) {
|
|
12699
12766
|
return new PreimageItem(hash, blob);
|
|
@@ -12707,9 +12774,9 @@ class PreimageItem extends WithDebug {
|
|
|
12707
12774
|
class StorageItem extends WithDebug {
|
|
12708
12775
|
key;
|
|
12709
12776
|
value;
|
|
12710
|
-
static Codec = Class(StorageItem, {
|
|
12711
|
-
key: blob.convert((i) => i, (o) => opaque_asOpaqueType(o)),
|
|
12712
|
-
value: blob,
|
|
12777
|
+
static Codec = codec_codec.Class(StorageItem, {
|
|
12778
|
+
key: codec_codec.blob.convert((i) => i, (o) => opaque_asOpaqueType(o)),
|
|
12779
|
+
value: codec_codec.blob,
|
|
12713
12780
|
});
|
|
12714
12781
|
static create({ key, value }) {
|
|
12715
12782
|
return new StorageItem(key, value);
|
|
@@ -12770,13 +12837,13 @@ class ValidatorStatistics {
|
|
|
12770
12837
|
preImagesSize;
|
|
12771
12838
|
guarantees;
|
|
12772
12839
|
assurances;
|
|
12773
|
-
static Codec = Class(ValidatorStatistics, {
|
|
12774
|
-
blocks: u32,
|
|
12775
|
-
tickets: u32,
|
|
12776
|
-
preImages: u32,
|
|
12777
|
-
preImagesSize: u32,
|
|
12778
|
-
guarantees: u32,
|
|
12779
|
-
assurances: u32,
|
|
12840
|
+
static Codec = codec_codec.Class(ValidatorStatistics, {
|
|
12841
|
+
blocks: codec_codec.u32,
|
|
12842
|
+
tickets: codec_codec.u32,
|
|
12843
|
+
preImages: codec_codec.u32,
|
|
12844
|
+
preImagesSize: codec_codec.u32,
|
|
12845
|
+
guarantees: codec_codec.u32,
|
|
12846
|
+
assurances: codec_codec.u32,
|
|
12780
12847
|
});
|
|
12781
12848
|
static create({ blocks, tickets, preImages, preImagesSize, guarantees, assurances, }) {
|
|
12782
12849
|
return new ValidatorStatistics(blocks, tickets, preImages, preImagesSize, guarantees, assurances);
|
|
@@ -12806,9 +12873,9 @@ class ValidatorStatistics {
|
|
|
12806
12873
|
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
12807
12874
|
}
|
|
12808
12875
|
}
|
|
12809
|
-
const codecVarU16 = varU32.convert((i) => numbers_tryAsU32(i), (o) => numbers_tryAsU16(o));
|
|
12876
|
+
const codecVarU16 = codec_codec.varU32.convert((i) => numbers_tryAsU32(i), (o) => numbers_tryAsU16(o));
|
|
12810
12877
|
/** Encode/decode unsigned gas. */
|
|
12811
|
-
const codecVarGas = varU64.convert((g) => numbers_tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
12878
|
+
const codecVarGas = codec_codec.varU64.convert((g) => numbers_tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
12812
12879
|
/**
|
|
12813
12880
|
* Single core statistics.
|
|
12814
12881
|
* Updated per block, based on incoming work reports (`w`).
|
|
@@ -12825,14 +12892,14 @@ class CoreStatistics {
|
|
|
12825
12892
|
extrinsicCount;
|
|
12826
12893
|
bundleSize;
|
|
12827
12894
|
gasUsed;
|
|
12828
|
-
static Codec = Class(CoreStatistics, {
|
|
12829
|
-
dataAvailabilityLoad: varU32,
|
|
12895
|
+
static Codec = codec_codec.Class(CoreStatistics, {
|
|
12896
|
+
dataAvailabilityLoad: codec_codec.varU32,
|
|
12830
12897
|
popularity: codecVarU16,
|
|
12831
12898
|
imports: codecVarU16,
|
|
12832
12899
|
extrinsicCount: codecVarU16,
|
|
12833
|
-
extrinsicSize: varU32,
|
|
12900
|
+
extrinsicSize: codec_codec.varU32,
|
|
12834
12901
|
exports: codecVarU16,
|
|
12835
|
-
bundleSize: varU32,
|
|
12902
|
+
bundleSize: codec_codec.varU32,
|
|
12836
12903
|
gasUsed: codecVarGas,
|
|
12837
12904
|
});
|
|
12838
12905
|
static create(v) {
|
|
@@ -12891,31 +12958,31 @@ class ServiceStatistics {
|
|
|
12891
12958
|
onTransfersCount;
|
|
12892
12959
|
onTransfersGasUsed;
|
|
12893
12960
|
static Codec = Compatibility.selectIfGreaterOrEqual({
|
|
12894
|
-
fallback: Class(ServiceStatistics, {
|
|
12961
|
+
fallback: codec_codec.Class(ServiceStatistics, {
|
|
12895
12962
|
providedCount: codecVarU16,
|
|
12896
|
-
providedSize: varU32,
|
|
12897
|
-
refinementCount: varU32,
|
|
12963
|
+
providedSize: codec_codec.varU32,
|
|
12964
|
+
refinementCount: codec_codec.varU32,
|
|
12898
12965
|
refinementGasUsed: codecVarGas,
|
|
12899
12966
|
imports: codecVarU16,
|
|
12900
12967
|
extrinsicCount: codecVarU16,
|
|
12901
|
-
extrinsicSize: varU32,
|
|
12968
|
+
extrinsicSize: codec_codec.varU32,
|
|
12902
12969
|
exports: codecVarU16,
|
|
12903
|
-
accumulateCount: varU32,
|
|
12970
|
+
accumulateCount: codec_codec.varU32,
|
|
12904
12971
|
accumulateGasUsed: codecVarGas,
|
|
12905
|
-
onTransfersCount: varU32,
|
|
12972
|
+
onTransfersCount: codec_codec.varU32,
|
|
12906
12973
|
onTransfersGasUsed: codecVarGas,
|
|
12907
12974
|
}),
|
|
12908
12975
|
versions: {
|
|
12909
|
-
[GpVersion.V0_7_1]: Class(ServiceStatistics, {
|
|
12976
|
+
[GpVersion.V0_7_1]: codec_codec.Class(ServiceStatistics, {
|
|
12910
12977
|
providedCount: codecVarU16,
|
|
12911
|
-
providedSize: varU32,
|
|
12912
|
-
refinementCount: varU32,
|
|
12978
|
+
providedSize: codec_codec.varU32,
|
|
12979
|
+
refinementCount: codec_codec.varU32,
|
|
12913
12980
|
refinementGasUsed: codecVarGas,
|
|
12914
12981
|
imports: codecVarU16,
|
|
12915
12982
|
extrinsicCount: codecVarU16,
|
|
12916
|
-
extrinsicSize: varU32,
|
|
12983
|
+
extrinsicSize: codec_codec.varU32,
|
|
12917
12984
|
exports: codecVarU16,
|
|
12918
|
-
accumulateCount: varU32,
|
|
12985
|
+
accumulateCount: codec_codec.varU32,
|
|
12919
12986
|
accumulateGasUsed: codecVarGas,
|
|
12920
12987
|
onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
|
|
12921
12988
|
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
@@ -12976,11 +13043,11 @@ class StatisticsData {
|
|
|
12976
13043
|
previous;
|
|
12977
13044
|
cores;
|
|
12978
13045
|
services;
|
|
12979
|
-
static Codec = Class(StatisticsData, {
|
|
13046
|
+
static Codec = codec_codec.Class(StatisticsData, {
|
|
12980
13047
|
current: codecPerValidator(ValidatorStatistics.Codec),
|
|
12981
13048
|
previous: codecPerValidator(ValidatorStatistics.Codec),
|
|
12982
13049
|
cores: codecPerCore(CoreStatistics.Codec),
|
|
12983
|
-
services: dictionary(u32.asOpaque(), ServiceStatistics.Codec, {
|
|
13050
|
+
services: codec_codec.dictionary(codec_codec.u32.asOpaque(), ServiceStatistics.Codec, {
|
|
12984
13051
|
sortKeys: (a, b) => a - b,
|
|
12985
13052
|
}),
|
|
12986
13053
|
});
|
|
@@ -13079,14 +13146,14 @@ class PrivilegedServices {
|
|
|
13079
13146
|
assigners;
|
|
13080
13147
|
autoAccumulateServices;
|
|
13081
13148
|
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
13082
|
-
static Codec = Class(PrivilegedServices, {
|
|
13083
|
-
manager: u32.asOpaque(),
|
|
13084
|
-
assigners: codecPerCore(u32.asOpaque()),
|
|
13085
|
-
delegator: u32.asOpaque(),
|
|
13149
|
+
static Codec = codec_codec.Class(PrivilegedServices, {
|
|
13150
|
+
manager: codec_codec.u32.asOpaque(),
|
|
13151
|
+
assigners: codecPerCore(codec_codec.u32.asOpaque()),
|
|
13152
|
+
delegator: codec_codec.u32.asOpaque(),
|
|
13086
13153
|
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
13087
|
-
? u32.asOpaque()
|
|
13154
|
+
? codec_codec.u32.asOpaque()
|
|
13088
13155
|
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
13089
|
-
autoAccumulateServices: dictionary(u32.asOpaque(), u64.asOpaque(), {
|
|
13156
|
+
autoAccumulateServices: codec_codec.dictionary(codec_codec.u32.asOpaque(), codec_codec.u64.asOpaque(), {
|
|
13090
13157
|
sortKeys: (a, b) => a - b,
|
|
13091
13158
|
}),
|
|
13092
13159
|
});
|
|
@@ -13759,15 +13826,15 @@ class InMemoryState extends WithDebug {
|
|
|
13759
13826
|
});
|
|
13760
13827
|
}
|
|
13761
13828
|
}
|
|
13762
|
-
const serviceEntriesCodec = object({
|
|
13763
|
-
storageKeys: sequenceVarLen(blob.convert((i) => i, (o) => opaque_asOpaqueType(o))),
|
|
13764
|
-
preimages: sequenceVarLen(bytes(hash_HASH_SIZE).asOpaque()),
|
|
13765
|
-
lookupHistory: sequenceVarLen(object({
|
|
13766
|
-
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
13767
|
-
length: u32,
|
|
13829
|
+
const serviceEntriesCodec = codec_codec.object({
|
|
13830
|
+
storageKeys: codec_codec.sequenceVarLen(codec_codec.blob.convert((i) => i, (o) => opaque_asOpaqueType(o))),
|
|
13831
|
+
preimages: codec_codec.sequenceVarLen(codec_codec.bytes(hash_HASH_SIZE).asOpaque()),
|
|
13832
|
+
lookupHistory: codec_codec.sequenceVarLen(codec_codec.object({
|
|
13833
|
+
hash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
13834
|
+
length: codec_codec.u32,
|
|
13768
13835
|
})),
|
|
13769
13836
|
});
|
|
13770
|
-
const serviceDataCodec = dictionary(u32.asOpaque(), serviceEntriesCodec, {
|
|
13837
|
+
const serviceDataCodec = codec_codec.dictionary(codec_codec.u32.asOpaque(), serviceEntriesCodec, {
|
|
13771
13838
|
sortKeys: (a, b) => a - b,
|
|
13772
13839
|
});
|
|
13773
13840
|
|
|
@@ -14485,7 +14552,7 @@ var serialize_serialize;
|
|
|
14485
14552
|
/** C(6): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bf3013bf301?v=0.6.7 */
|
|
14486
14553
|
serialize.entropy = {
|
|
14487
14554
|
key: stateKeys.index(StateKeyIdx.Eta),
|
|
14488
|
-
Codec: codecFixedSizeArray(bytes(hash_HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
14555
|
+
Codec: codecFixedSizeArray(codec_codec.bytes(hash_HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
14489
14556
|
extract: (s) => s.entropy,
|
|
14490
14557
|
};
|
|
14491
14558
|
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
@@ -14515,7 +14582,7 @@ var serialize_serialize;
|
|
|
14515
14582
|
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
14516
14583
|
serialize.timeslot = {
|
|
14517
14584
|
key: stateKeys.index(StateKeyIdx.Tau),
|
|
14518
|
-
Codec: u32.asOpaque(),
|
|
14585
|
+
Codec: codec_codec.u32.asOpaque(),
|
|
14519
14586
|
extract: (s) => s.timeslot,
|
|
14520
14587
|
};
|
|
14521
14588
|
/** C(12): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b4c023b4c02?v=0.6.7 */
|
|
@@ -14545,7 +14612,7 @@ var serialize_serialize;
|
|
|
14545
14612
|
/** C(16): https://graypaper.fluffylabs.dev/#/38c4e62/3b46033b4603?v=0.7.0 */
|
|
14546
14613
|
serialize.accumulationOutputLog = {
|
|
14547
14614
|
key: stateKeys.index(StateKeyIdx.Theta),
|
|
14548
|
-
Codec: sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
|
|
14615
|
+
Codec: codec_codec.sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
|
|
14549
14616
|
extract: (s) => s.accumulationOutputLog,
|
|
14550
14617
|
};
|
|
14551
14618
|
/** C(255, s): https://graypaper.fluffylabs.dev/#/85129da/383103383103?v=0.6.3 */
|
|
@@ -14568,7 +14635,7 @@ var serialize_serialize;
|
|
|
14568
14635
|
/** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
|
|
14569
14636
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
14570
14637
|
key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
|
|
14571
|
-
Codec: readonlyArray(sequenceVarLen(u32)),
|
|
14638
|
+
Codec: codec_codec.readonlyArray(codec_codec.sequenceVarLen(codec_codec.u32)),
|
|
14572
14639
|
});
|
|
14573
14640
|
})(serialize_serialize || (serialize_serialize = {}));
|
|
14574
14641
|
/**
|
|
@@ -15695,7 +15762,7 @@ function getSafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsA
|
|
|
15695
15762
|
|
|
15696
15763
|
const TYPICAL_STATE_ITEMS = 50;
|
|
15697
15764
|
const TYPICAL_STATE_ITEM_LEN = 50;
|
|
15698
|
-
const stateEntriesSequenceCodec = sequenceVarLen(pair(bytes(TRUNCATED_HASH_SIZE), blob));
|
|
15765
|
+
const stateEntriesSequenceCodec = codec_codec.sequenceVarLen(codec_codec.pair(codec_codec.bytes(TRUNCATED_HASH_SIZE), codec_codec.blob));
|
|
15699
15766
|
/**
|
|
15700
15767
|
* Full, in-memory state represented as serialized entries dictionary.
|
|
15701
15768
|
*
|
|
@@ -15703,7 +15770,7 @@ const stateEntriesSequenceCodec = sequenceVarLen(pair(bytes(TRUNCATED_HASH_SIZE)
|
|
|
15703
15770
|
*/
|
|
15704
15771
|
class state_entries_StateEntries {
|
|
15705
15772
|
dictionary;
|
|
15706
|
-
static Codec = custom({
|
|
15773
|
+
static Codec = codec_codec.custom({
|
|
15707
15774
|
name: "StateEntries",
|
|
15708
15775
|
sizeHint: {
|
|
15709
15776
|
isExact: false,
|
|
@@ -15895,7 +15962,7 @@ function loadState(spec, blake2b, entries) {
|
|
|
15895
15962
|
|
|
15896
15963
|
|
|
15897
15964
|
/** Codec for a map with string keys. */
|
|
15898
|
-
const codecMap = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => {
|
|
15965
|
+
const codecMap = (value, extractKey, { typicalLength = codec_codec.TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => {
|
|
15899
15966
|
const keyA = extractKey(a);
|
|
15900
15967
|
const keyB = extractKey(b);
|
|
15901
15968
|
if (keyA < keyB) {
|
|
@@ -15938,17 +16005,19 @@ const codecMap = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH
|
|
|
15938
16005
|
s.sequenceFixLen(value, len);
|
|
15939
16006
|
});
|
|
15940
16007
|
};
|
|
15941
|
-
const lookupHistoryItemCodec = object({
|
|
15942
|
-
hash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
15943
|
-
length: u32,
|
|
15944
|
-
slots:
|
|
16008
|
+
const lookupHistoryItemCodec = codec_codec.object({
|
|
16009
|
+
hash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
16010
|
+
length: codec_codec.u32,
|
|
16011
|
+
slots: codec_codec
|
|
16012
|
+
.readonlyArray(codec_codec.sequenceVarLen(codec_codec.u32.asOpaque()))
|
|
15945
16013
|
.convert(seeThrough, service_tryAsLookupHistorySlots),
|
|
15946
16014
|
}, "LookupHistoryItem", ({ hash, length, slots }) => new LookupHistoryItem(hash, length, slots));
|
|
15947
|
-
const lookupHistoryEntryCodec = object({
|
|
15948
|
-
key: bytes(hash_HASH_SIZE).asOpaque(),
|
|
15949
|
-
data: sequenceVarLen(lookupHistoryItemCodec),
|
|
16015
|
+
const lookupHistoryEntryCodec = codec_codec.object({
|
|
16016
|
+
key: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
16017
|
+
data: codec_codec.sequenceVarLen(lookupHistoryItemCodec),
|
|
15950
16018
|
});
|
|
15951
|
-
const lookupHistoryCodec =
|
|
16019
|
+
const lookupHistoryCodec = codec_codec
|
|
16020
|
+
.sequenceVarLen(lookupHistoryEntryCodec)
|
|
15952
16021
|
.convert((dict) => {
|
|
15953
16022
|
const entries = [];
|
|
15954
16023
|
for (const [key, data] of dict) {
|
|
@@ -15968,9 +16037,9 @@ const lookupHistoryCodec = sequenceVarLen(lookupHistoryEntryCodec)
|
|
|
15968
16037
|
return dict;
|
|
15969
16038
|
});
|
|
15970
16039
|
class ServiceWithCodec extends InMemoryService {
|
|
15971
|
-
static Codec = Class(ServiceWithCodec, {
|
|
15972
|
-
serviceId: u32.asOpaque(),
|
|
15973
|
-
data: object({
|
|
16040
|
+
static Codec = codec_codec.Class(ServiceWithCodec, {
|
|
16041
|
+
serviceId: codec_codec.u32.asOpaque(),
|
|
16042
|
+
data: codec_codec.object({
|
|
15974
16043
|
info: ServiceAccountInfo.Codec,
|
|
15975
16044
|
preimages: codecHashDictionary(PreimageItem.Codec, (x) => x.hash),
|
|
15976
16045
|
lookupHistory: lookupHistoryCodec,
|
|
@@ -15984,7 +16053,7 @@ class ServiceWithCodec extends InMemoryService {
|
|
|
15984
16053
|
return new ServiceWithCodec(serviceId, data);
|
|
15985
16054
|
}
|
|
15986
16055
|
}
|
|
15987
|
-
const inMemoryStateCodec = (spec) => Class(class State extends InMemoryState {
|
|
16056
|
+
const inMemoryStateCodec = (spec) => codec_codec.Class(class State extends InMemoryState {
|
|
15988
16057
|
static create(data) {
|
|
15989
16058
|
return InMemoryState.new(spec, data);
|
|
15990
16059
|
}
|
|
@@ -15998,11 +16067,12 @@ const inMemoryStateCodec = (spec) => Class(class State extends InMemoryState {
|
|
|
15998
16067
|
// gamma_k
|
|
15999
16068
|
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
16000
16069
|
// gamma_z
|
|
16001
|
-
epochRoot: bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
16070
|
+
epochRoot: codec_codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
16002
16071
|
// gamma_s
|
|
16003
16072
|
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
16004
16073
|
// gamma_a
|
|
16005
|
-
ticketsAccumulator:
|
|
16074
|
+
ticketsAccumulator: codec_codec
|
|
16075
|
+
.readonlyArray(codec_codec.sequenceVarLen(Ticket.Codec))
|
|
16006
16076
|
.convert((x) => x, sized_array_asKnownSize),
|
|
16007
16077
|
// psi
|
|
16008
16078
|
disputesRecords: serialize_serialize.disputesRecords.Codec,
|
|
@@ -16029,7 +16099,7 @@ const inMemoryStateCodec = (spec) => Class(class State extends InMemoryState {
|
|
|
16029
16099
|
// theta
|
|
16030
16100
|
accumulationOutputLog: serialize_serialize.accumulationOutputLog.Codec,
|
|
16031
16101
|
// delta
|
|
16032
|
-
services: dictionary(u32.asOpaque(), ServiceWithCodec.Codec, {
|
|
16102
|
+
services: codec_codec.dictionary(codec_codec.u32.asOpaque(), ServiceWithCodec.Codec, {
|
|
16033
16103
|
sortKeys: (a, b) => a - b,
|
|
16034
16104
|
}),
|
|
16035
16105
|
});
|
|
@@ -16054,11 +16124,11 @@ class TestState {
|
|
|
16054
16124
|
state_root: fromJson.bytes32(),
|
|
16055
16125
|
keyvals: json.array(StateKeyVal.fromJson),
|
|
16056
16126
|
};
|
|
16057
|
-
static Codec = object({
|
|
16058
|
-
state_root: bytes(hash_HASH_SIZE).asOpaque(),
|
|
16059
|
-
keyvals: sequenceVarLen(object({
|
|
16060
|
-
key: bytes(TRUNCATED_HASH_SIZE),
|
|
16061
|
-
value: blob,
|
|
16127
|
+
static Codec = codec_codec.object({
|
|
16128
|
+
state_root: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
16129
|
+
keyvals: codec_codec.sequenceVarLen(codec_codec.object({
|
|
16130
|
+
key: codec_codec.bytes(TRUNCATED_HASH_SIZE),
|
|
16131
|
+
value: codec_codec.blob,
|
|
16062
16132
|
})),
|
|
16063
16133
|
});
|
|
16064
16134
|
state_root;
|
|
@@ -16069,7 +16139,7 @@ class StateTransitionGenesis {
|
|
|
16069
16139
|
header: headerFromJson,
|
|
16070
16140
|
state: TestState.fromJson,
|
|
16071
16141
|
};
|
|
16072
|
-
static Codec = object({
|
|
16142
|
+
static Codec = codec_codec.object({
|
|
16073
16143
|
header: header_Header.Codec,
|
|
16074
16144
|
state: TestState.Codec,
|
|
16075
16145
|
});
|
|
@@ -16082,7 +16152,7 @@ class StateTransition {
|
|
|
16082
16152
|
post_state: TestState.fromJson,
|
|
16083
16153
|
block: blockFromJson(chain_spec_tinyChainSpec),
|
|
16084
16154
|
};
|
|
16085
|
-
static Codec = object({
|
|
16155
|
+
static Codec = codec_codec.object({
|
|
16086
16156
|
pre_state: TestState.Codec,
|
|
16087
16157
|
block: Block.Codec,
|
|
16088
16158
|
post_state: TestState.Codec,
|
|
@@ -19732,11 +19802,8 @@ class interpreter_Interpreter {
|
|
|
19732
19802
|
this.memory.reset();
|
|
19733
19803
|
}
|
|
19734
19804
|
}
|
|
19735
|
-
|
|
19736
|
-
|
|
19737
|
-
// biome-ignore lint/suspicious/noConsole: We do want to print that.
|
|
19738
|
-
console.table(p);
|
|
19739
|
-
return p;
|
|
19805
|
+
dumpProgram() {
|
|
19806
|
+
return assemblify(this.code, this.mask);
|
|
19740
19807
|
}
|
|
19741
19808
|
runProgram() {
|
|
19742
19809
|
while (this.nextStep() === Status.OK) { }
|
|
@@ -20159,7 +20226,7 @@ const SUPPORTED_TYPES = [
|
|
|
20159
20226
|
if (option === "as-hash") {
|
|
20160
20227
|
return looseType({
|
|
20161
20228
|
value: blake2b.hashBytes(encoder_Encoder.encodeObject(header_Header.Codec, header, spec)),
|
|
20162
|
-
encode: bytes(hash_HASH_SIZE),
|
|
20229
|
+
encode: codec_codec.bytes(hash_HASH_SIZE),
|
|
20163
20230
|
});
|
|
20164
20231
|
}
|
|
20165
20232
|
throw new Error(`Invalid processing option: ${option}`);
|
|
@@ -20213,7 +20280,7 @@ const SUPPORTED_TYPES = [
|
|
|
20213
20280
|
if (option === "as-root-hash") {
|
|
20214
20281
|
return looseType({
|
|
20215
20282
|
value: state_entries_StateEntries.serializeInMemory(spec, blake2b, state).getRootHash(blake2b),
|
|
20216
|
-
encode: bytes(hash_HASH_SIZE),
|
|
20283
|
+
encode: codec_codec.bytes(hash_HASH_SIZE),
|
|
20217
20284
|
});
|
|
20218
20285
|
}
|
|
20219
20286
|
throw new Error(`Invalid processing option: ${option}`);
|
|
@@ -20268,7 +20335,14 @@ const SUPPORTED_TYPES = [
|
|
|
20268
20335
|
decode: StateTransition.Codec,
|
|
20269
20336
|
json: () => StateTransition.fromJson,
|
|
20270
20337
|
process: {
|
|
20271
|
-
options: [
|
|
20338
|
+
options: [
|
|
20339
|
+
"as-pre-state",
|
|
20340
|
+
"as-post-state",
|
|
20341
|
+
"as-fuzz-message",
|
|
20342
|
+
"as-block-fuzz-message",
|
|
20343
|
+
"as-state-fuzz-message",
|
|
20344
|
+
"as-block",
|
|
20345
|
+
],
|
|
20272
20346
|
run(spec, data, option, blake2b) {
|
|
20273
20347
|
const test = data;
|
|
20274
20348
|
if (option === "as-pre-state") {
|
|
@@ -20288,6 +20362,10 @@ const SUPPORTED_TYPES = [
|
|
|
20288
20362
|
});
|
|
20289
20363
|
}
|
|
20290
20364
|
if (option === "as-fuzz-message") {
|
|
20365
|
+
// biome-ignore lint/suspicious/noConsole: deprecation warning
|
|
20366
|
+
console.warn("⚠️ Warning: 'as-fuzz-message' is deprecated and will be removed in version 0.6.0. Use 'as-block-fuzz-message' instead.");
|
|
20367
|
+
}
|
|
20368
|
+
if (option === "as-block-fuzz-message" || option === "as-fuzz-message") {
|
|
20291
20369
|
const encoded = encoder_Encoder.encodeObject(Block.Codec, test.block, spec);
|
|
20292
20370
|
const blockView = decoder_Decoder.decodeObject(Block.Codec.View, encoded, spec);
|
|
20293
20371
|
const msg = {
|
|
@@ -20299,6 +20377,26 @@ const SUPPORTED_TYPES = [
|
|
|
20299
20377
|
encode: types_messageCodec,
|
|
20300
20378
|
});
|
|
20301
20379
|
}
|
|
20380
|
+
if (option === "as-state-fuzz-message") {
|
|
20381
|
+
const init = Initialize.create({
|
|
20382
|
+
header: header_Header.empty(),
|
|
20383
|
+
keyvals: test.pre_state.keyvals,
|
|
20384
|
+
ancestry: [
|
|
20385
|
+
AncestryItem.create({
|
|
20386
|
+
headerHash: test.block.header.parentHeaderHash,
|
|
20387
|
+
slot: common_tryAsTimeSlot(Math.max(0, test.block.header.timeSlotIndex - 1)),
|
|
20388
|
+
}),
|
|
20389
|
+
],
|
|
20390
|
+
});
|
|
20391
|
+
const msg = {
|
|
20392
|
+
type: types_MessageType.Initialize,
|
|
20393
|
+
value: init,
|
|
20394
|
+
};
|
|
20395
|
+
return looseType({
|
|
20396
|
+
value: msg,
|
|
20397
|
+
encode: types_messageCodec,
|
|
20398
|
+
});
|
|
20399
|
+
}
|
|
20302
20400
|
throw new Error(`Invalid processing option: ${option}`);
|
|
20303
20401
|
},
|
|
20304
20402
|
},
|