@typeberry/lib 0.5.1-1dda9d6 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +429 -455
- package/index.d.ts +19 -268
- package/{index.mjs → index.js} +429 -455
- package/package.json +3 -5
package/index.cjs
CHANGED
|
@@ -2382,48 +2382,6 @@ const pair = (a, b) => {
|
|
|
2382
2382
|
};
|
|
2383
2383
|
/** Custom encoding / decoding logic. */
|
|
2384
2384
|
const custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
2385
|
-
/** Tagged union type encoding. */
|
|
2386
|
-
const union = (name, variants) => {
|
|
2387
|
-
const keys = Object.keys(variants).map(Number);
|
|
2388
|
-
const variantMap = Object.fromEntries(keys.map((key, idx) => [key, idx]));
|
|
2389
|
-
const indexToKey = Object.fromEntries(keys.map((key, idx) => [idx, key]));
|
|
2390
|
-
// Calculate size hint as the minimum variant size + index size
|
|
2391
|
-
const minVariantSize = Math.max(...keys.map((key) => variants[key].sizeHint.bytes));
|
|
2392
|
-
const sizeHint = {
|
|
2393
|
-
bytes: 1 + minVariantSize, // varU32 index + smallest variant
|
|
2394
|
-
isExact: false,
|
|
2395
|
-
};
|
|
2396
|
-
const encode = (e, x) => {
|
|
2397
|
-
const idx = variantMap[x.kind];
|
|
2398
|
-
if (idx === undefined) {
|
|
2399
|
-
throw new Error(`Unknown variant type: ${x.kind} for ${name}`);
|
|
2400
|
-
}
|
|
2401
|
-
e.varU32(tryAsU32(idx));
|
|
2402
|
-
const codec = variants[x.kind];
|
|
2403
|
-
// I'm sorry but I can't figure out a better typing here :)
|
|
2404
|
-
codec.encode(e, x);
|
|
2405
|
-
};
|
|
2406
|
-
const decode = (d) => {
|
|
2407
|
-
const idx = d.varU32();
|
|
2408
|
-
const kind = indexToKey[idx];
|
|
2409
|
-
if (kind === undefined) {
|
|
2410
|
-
throw new Error(`Unknown variant index: ${idx} for ${name}`);
|
|
2411
|
-
}
|
|
2412
|
-
const codec = variants[kind];
|
|
2413
|
-
const value = codec.decode(d);
|
|
2414
|
-
return { kind, ...value };
|
|
2415
|
-
};
|
|
2416
|
-
const skip = (s) => {
|
|
2417
|
-
const idx = s.decoder.varU32();
|
|
2418
|
-
const kind = indexToKey[idx];
|
|
2419
|
-
if (kind === undefined) {
|
|
2420
|
-
throw new Error(`Unknown variant index: ${idx} for ${name}`);
|
|
2421
|
-
}
|
|
2422
|
-
const codec = variants[kind];
|
|
2423
|
-
codec.skip(s);
|
|
2424
|
-
};
|
|
2425
|
-
return Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
2426
|
-
};
|
|
2427
2385
|
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
2428
2386
|
const select = ({ name, sizeHint, }, chooser) => {
|
|
2429
2387
|
const Self = chooser(null);
|
|
@@ -2599,59 +2557,24 @@ var descriptors = /*#__PURE__*/Object.freeze({
|
|
|
2599
2557
|
u32: u32,
|
|
2600
2558
|
u64: u64,
|
|
2601
2559
|
u8: u8,
|
|
2602
|
-
union: union,
|
|
2603
2560
|
varU32: varU32,
|
|
2604
2561
|
varU64: varU64
|
|
2605
2562
|
});
|
|
2606
2563
|
|
|
2607
|
-
const codec = descriptors;
|
|
2608
|
-
|
|
2609
2564
|
var index$x = /*#__PURE__*/Object.freeze({
|
|
2610
2565
|
__proto__: null,
|
|
2611
|
-
Class: Class,
|
|
2612
2566
|
Decoder: Decoder,
|
|
2613
2567
|
Descriptor: Descriptor,
|
|
2614
2568
|
Encoder: Encoder,
|
|
2615
2569
|
EndOfDataError: EndOfDataError,
|
|
2616
2570
|
ObjectView: ObjectView,
|
|
2617
2571
|
SequenceView: SequenceView,
|
|
2618
|
-
TYPICAL_DICTIONARY_LENGTH: TYPICAL_DICTIONARY_LENGTH,
|
|
2619
2572
|
ViewField: ViewField,
|
|
2620
2573
|
addSizeHints: addSizeHints,
|
|
2621
|
-
|
|
2622
|
-
bitVecVarLen: bitVecVarLen,
|
|
2623
|
-
blob: blob,
|
|
2624
|
-
bool: bool,
|
|
2625
|
-
bytes: bytes,
|
|
2626
|
-
codec: codec,
|
|
2627
|
-
custom: custom,
|
|
2574
|
+
codec: descriptors,
|
|
2628
2575
|
decodeVariableLengthExtraBytes: decodeVariableLengthExtraBytes,
|
|
2629
|
-
dictionary: dictionary,
|
|
2630
|
-
forEachDescriptor: forEachDescriptor,
|
|
2631
|
-
i16: i16,
|
|
2632
|
-
i24: i24,
|
|
2633
|
-
i32: i32,
|
|
2634
|
-
i64: i64,
|
|
2635
|
-
i8: i8,
|
|
2636
|
-
nothing: nothing,
|
|
2637
|
-
object: object,
|
|
2638
|
-
optional: optional,
|
|
2639
|
-
pair: pair,
|
|
2640
|
-
readonlyArray: readonlyArray,
|
|
2641
|
-
select: select,
|
|
2642
|
-
sequenceFixLen: sequenceFixLen,
|
|
2643
|
-
sequenceVarLen: sequenceVarLen,
|
|
2644
|
-
string: string,
|
|
2645
2576
|
tryAsExactBytes: tryAsExactBytes,
|
|
2646
|
-
|
|
2647
|
-
u24: u24,
|
|
2648
|
-
u32: u32,
|
|
2649
|
-
u64: u64,
|
|
2650
|
-
u8: u8,
|
|
2651
|
-
union: union,
|
|
2652
|
-
validateLength: validateLength,
|
|
2653
|
-
varU32: varU32,
|
|
2654
|
-
varU64: varU64
|
|
2577
|
+
validateLength: validateLength
|
|
2655
2578
|
});
|
|
2656
2579
|
|
|
2657
2580
|
//#region rolldown:runtime
|
|
@@ -5862,7 +5785,7 @@ function codecWithContext(chooser) {
|
|
|
5862
5785
|
const defaultContext = fullChainSpec;
|
|
5863
5786
|
const { name, sizeHint } = chooser(defaultContext);
|
|
5864
5787
|
const cache = new Map();
|
|
5865
|
-
return
|
|
5788
|
+
return select({
|
|
5866
5789
|
name,
|
|
5867
5790
|
sizeHint: { bytes: sizeHint.bytes, isExact: false },
|
|
5868
5791
|
}, (context) => {
|
|
@@ -5889,9 +5812,9 @@ function codecWithContext(chooser) {
|
|
|
5889
5812
|
/** Codec for a known-size array with length validation. */
|
|
5890
5813
|
const codecKnownSizeArray = (val, options, _id) => {
|
|
5891
5814
|
if ("fixedLength" in options) {
|
|
5892
|
-
return
|
|
5815
|
+
return readonlyArray(sequenceFixLen(val, options.fixedLength)).convert(seeThrough, asKnownSize);
|
|
5893
5816
|
}
|
|
5894
|
-
return
|
|
5817
|
+
return readonlyArray(sequenceVarLen(val, options)).convert(seeThrough, asKnownSize);
|
|
5895
5818
|
};
|
|
5896
5819
|
/** Codec for a fixed-size array with length validation. */
|
|
5897
5820
|
const codecFixedSizeArray = (val, len) => {
|
|
@@ -5900,7 +5823,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
5900
5823
|
throw new Error(`[${val.name}] Invalid size of fixed-size array. Got ${actual}, expected: ${len}`);
|
|
5901
5824
|
}
|
|
5902
5825
|
};
|
|
5903
|
-
return
|
|
5826
|
+
return sequenceFixLen(val, len).convert((i) => {
|
|
5904
5827
|
checkLength(i.length);
|
|
5905
5828
|
return i;
|
|
5906
5829
|
}, (o) => {
|
|
@@ -5909,7 +5832,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
5909
5832
|
});
|
|
5910
5833
|
};
|
|
5911
5834
|
/** Codec for a hash-dictionary. */
|
|
5912
|
-
const codecHashDictionary = (value, extractKey, { typicalLength =
|
|
5835
|
+
const codecHashDictionary = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
|
|
5913
5836
|
return Descriptor.new(`HashDictionary<${value.name}>[?]`, {
|
|
5914
5837
|
bytes: typicalLength * value.sizeHint.bytes,
|
|
5915
5838
|
isExact: false,
|
|
@@ -5963,13 +5886,13 @@ class AvailabilityAssurance extends WithDebug {
|
|
|
5963
5886
|
bitfield;
|
|
5964
5887
|
validatorIndex;
|
|
5965
5888
|
signature;
|
|
5966
|
-
static Codec =
|
|
5967
|
-
anchor:
|
|
5889
|
+
static Codec = Class(AvailabilityAssurance, {
|
|
5890
|
+
anchor: bytes(HASH_SIZE).asOpaque(),
|
|
5968
5891
|
bitfield: codecWithContext((context) => {
|
|
5969
|
-
return
|
|
5892
|
+
return bitVecFixLen(context.coresCount);
|
|
5970
5893
|
}),
|
|
5971
|
-
validatorIndex:
|
|
5972
|
-
signature:
|
|
5894
|
+
validatorIndex: u16.asOpaque(),
|
|
5895
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
5973
5896
|
});
|
|
5974
5897
|
static create({ anchor, bitfield, validatorIndex, signature }) {
|
|
5975
5898
|
return new AvailabilityAssurance(anchor, bitfield, validatorIndex, signature);
|
|
@@ -6054,11 +5977,11 @@ class Fault extends WithDebug {
|
|
|
6054
5977
|
wasConsideredValid;
|
|
6055
5978
|
key;
|
|
6056
5979
|
signature;
|
|
6057
|
-
static Codec =
|
|
6058
|
-
workReportHash:
|
|
6059
|
-
wasConsideredValid:
|
|
6060
|
-
key:
|
|
6061
|
-
signature:
|
|
5980
|
+
static Codec = Class(Fault, {
|
|
5981
|
+
workReportHash: bytes(HASH_SIZE).asOpaque(),
|
|
5982
|
+
wasConsideredValid: bool,
|
|
5983
|
+
key: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
5984
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
6062
5985
|
});
|
|
6063
5986
|
static create({ workReportHash, wasConsideredValid, key, signature }) {
|
|
6064
5987
|
return new Fault(workReportHash, wasConsideredValid, key, signature);
|
|
@@ -6086,10 +6009,10 @@ class Culprit extends WithDebug {
|
|
|
6086
6009
|
workReportHash;
|
|
6087
6010
|
key;
|
|
6088
6011
|
signature;
|
|
6089
|
-
static Codec =
|
|
6090
|
-
workReportHash:
|
|
6091
|
-
key:
|
|
6092
|
-
signature:
|
|
6012
|
+
static Codec = Class(Culprit, {
|
|
6013
|
+
workReportHash: bytes(HASH_SIZE).asOpaque(),
|
|
6014
|
+
key: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
6015
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
6093
6016
|
});
|
|
6094
6017
|
static create({ workReportHash, key, signature }) {
|
|
6095
6018
|
return new Culprit(workReportHash, key, signature);
|
|
@@ -6114,10 +6037,10 @@ class Judgement extends WithDebug {
|
|
|
6114
6037
|
isWorkReportValid;
|
|
6115
6038
|
index;
|
|
6116
6039
|
signature;
|
|
6117
|
-
static Codec =
|
|
6118
|
-
isWorkReportValid:
|
|
6119
|
-
index:
|
|
6120
|
-
signature:
|
|
6040
|
+
static Codec = Class(Judgement, {
|
|
6041
|
+
isWorkReportValid: bool,
|
|
6042
|
+
index: u16.asOpaque(),
|
|
6043
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
6121
6044
|
});
|
|
6122
6045
|
static create({ isWorkReportValid, index, signature }) {
|
|
6123
6046
|
return new Judgement(isWorkReportValid, index, signature);
|
|
@@ -6146,12 +6069,11 @@ class Verdict extends WithDebug {
|
|
|
6146
6069
|
workReportHash;
|
|
6147
6070
|
votesEpoch;
|
|
6148
6071
|
votes;
|
|
6149
|
-
static Codec =
|
|
6150
|
-
workReportHash:
|
|
6151
|
-
votesEpoch:
|
|
6072
|
+
static Codec = Class(Verdict, {
|
|
6073
|
+
workReportHash: bytes(HASH_SIZE).asOpaque(),
|
|
6074
|
+
votesEpoch: u32.asOpaque(),
|
|
6152
6075
|
votes: codecWithContext((context) => {
|
|
6153
|
-
return
|
|
6154
|
-
.readonlyArray(codec.sequenceFixLen(Judgement.Codec, context.validatorsSuperMajority))
|
|
6076
|
+
return readonlyArray(sequenceFixLen(Judgement.Codec, context.validatorsSuperMajority))
|
|
6155
6077
|
.convert(seeThrough, asKnownSize);
|
|
6156
6078
|
}),
|
|
6157
6079
|
});
|
|
@@ -6193,10 +6115,10 @@ class DisputesExtrinsic extends WithDebug {
|
|
|
6193
6115
|
verdicts;
|
|
6194
6116
|
culprits;
|
|
6195
6117
|
faults;
|
|
6196
|
-
static Codec =
|
|
6197
|
-
verdicts:
|
|
6198
|
-
culprits:
|
|
6199
|
-
faults:
|
|
6118
|
+
static Codec = Class(DisputesExtrinsic, {
|
|
6119
|
+
verdicts: sequenceVarLen(Verdict.Codec),
|
|
6120
|
+
culprits: sequenceVarLen(Culprit.Codec),
|
|
6121
|
+
faults: sequenceVarLen(Fault.Codec),
|
|
6200
6122
|
});
|
|
6201
6123
|
static create({ verdicts, culprits, faults }) {
|
|
6202
6124
|
return new DisputesExtrinsic(verdicts, culprits, faults);
|
|
@@ -6247,9 +6169,9 @@ var disputes = /*#__PURE__*/Object.freeze({
|
|
|
6247
6169
|
class WorkPackageInfo extends WithDebug {
|
|
6248
6170
|
workPackageHash;
|
|
6249
6171
|
segmentTreeRoot;
|
|
6250
|
-
static Codec =
|
|
6251
|
-
workPackageHash:
|
|
6252
|
-
segmentTreeRoot:
|
|
6172
|
+
static Codec = Class(WorkPackageInfo, {
|
|
6173
|
+
workPackageHash: bytes(HASH_SIZE).asOpaque(),
|
|
6174
|
+
segmentTreeRoot: bytes(HASH_SIZE).asOpaque(),
|
|
6253
6175
|
});
|
|
6254
6176
|
constructor(
|
|
6255
6177
|
/** Hash of the described work package. */
|
|
@@ -6277,13 +6199,13 @@ class RefineContext extends WithDebug {
|
|
|
6277
6199
|
lookupAnchor;
|
|
6278
6200
|
lookupAnchorSlot;
|
|
6279
6201
|
prerequisites;
|
|
6280
|
-
static Codec =
|
|
6281
|
-
anchor:
|
|
6282
|
-
stateRoot:
|
|
6283
|
-
beefyRoot:
|
|
6284
|
-
lookupAnchor:
|
|
6285
|
-
lookupAnchorSlot:
|
|
6286
|
-
prerequisites:
|
|
6202
|
+
static Codec = Class(RefineContext, {
|
|
6203
|
+
anchor: bytes(HASH_SIZE).asOpaque(),
|
|
6204
|
+
stateRoot: bytes(HASH_SIZE).asOpaque(),
|
|
6205
|
+
beefyRoot: bytes(HASH_SIZE).asOpaque(),
|
|
6206
|
+
lookupAnchor: bytes(HASH_SIZE).asOpaque(),
|
|
6207
|
+
lookupAnchorSlot: u32.asOpaque(),
|
|
6208
|
+
prerequisites: sequenceVarLen(bytes(HASH_SIZE).asOpaque()),
|
|
6287
6209
|
});
|
|
6288
6210
|
static create({ anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites, }) {
|
|
6289
6211
|
return new RefineContext(anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites);
|
|
@@ -6335,9 +6257,9 @@ const tryAsSegmentIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
|
6335
6257
|
class ImportSpec extends WithDebug {
|
|
6336
6258
|
treeRoot;
|
|
6337
6259
|
index;
|
|
6338
|
-
static Codec =
|
|
6339
|
-
treeRoot:
|
|
6340
|
-
index:
|
|
6260
|
+
static Codec = Class(ImportSpec, {
|
|
6261
|
+
treeRoot: bytes(HASH_SIZE),
|
|
6262
|
+
index: u16.asOpaque(),
|
|
6341
6263
|
});
|
|
6342
6264
|
static create({ treeRoot, index }) {
|
|
6343
6265
|
return new ImportSpec(treeRoot, index);
|
|
@@ -6359,9 +6281,9 @@ class ImportSpec extends WithDebug {
|
|
|
6359
6281
|
class WorkItemExtrinsicSpec extends WithDebug {
|
|
6360
6282
|
hash;
|
|
6361
6283
|
len;
|
|
6362
|
-
static Codec =
|
|
6363
|
-
hash:
|
|
6364
|
-
len:
|
|
6284
|
+
static Codec = Class(WorkItemExtrinsicSpec, {
|
|
6285
|
+
hash: bytes(HASH_SIZE).asOpaque(),
|
|
6286
|
+
len: u32,
|
|
6365
6287
|
});
|
|
6366
6288
|
static create({ hash, len }) {
|
|
6367
6289
|
return new WorkItemExtrinsicSpec(hash, len);
|
|
@@ -6391,7 +6313,7 @@ function workItemExtrinsicsCodec(workItems) {
|
|
|
6391
6313
|
if (sum.overflow) {
|
|
6392
6314
|
throw new Error("Unable to create a decoder, because the length of extrinsics overflows!");
|
|
6393
6315
|
}
|
|
6394
|
-
return
|
|
6316
|
+
return custom({
|
|
6395
6317
|
name: "WorkItemExtrinsics",
|
|
6396
6318
|
sizeHint: { bytes: sum.value, isExact: true },
|
|
6397
6319
|
}, (e, val) => {
|
|
@@ -6421,19 +6343,19 @@ class WorkItem extends WithDebug {
|
|
|
6421
6343
|
importSegments;
|
|
6422
6344
|
extrinsic;
|
|
6423
6345
|
exportCount;
|
|
6424
|
-
static Codec =
|
|
6425
|
-
service:
|
|
6426
|
-
codeHash:
|
|
6427
|
-
refineGasLimit:
|
|
6428
|
-
accumulateGasLimit:
|
|
6429
|
-
exportCount:
|
|
6430
|
-
payload:
|
|
6346
|
+
static Codec = Class(WorkItem, {
|
|
6347
|
+
service: u32.asOpaque(),
|
|
6348
|
+
codeHash: bytes(HASH_SIZE).asOpaque(),
|
|
6349
|
+
refineGasLimit: u64.asOpaque(),
|
|
6350
|
+
accumulateGasLimit: u64.asOpaque(),
|
|
6351
|
+
exportCount: u16,
|
|
6352
|
+
payload: blob,
|
|
6431
6353
|
importSegments: codecKnownSizeArray(ImportSpec.Codec, {
|
|
6432
6354
|
minLength: 0,
|
|
6433
6355
|
maxLength: MAX_NUMBER_OF_SEGMENTS,
|
|
6434
6356
|
typicalLength: MAX_NUMBER_OF_SEGMENTS,
|
|
6435
6357
|
}),
|
|
6436
|
-
extrinsic:
|
|
6358
|
+
extrinsic: sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
6437
6359
|
});
|
|
6438
6360
|
static create({ service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount, }) {
|
|
6439
6361
|
return new WorkItem(service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount);
|
|
@@ -6506,13 +6428,13 @@ class WorkPackage extends WithDebug {
|
|
|
6506
6428
|
parametrization;
|
|
6507
6429
|
context;
|
|
6508
6430
|
items;
|
|
6509
|
-
static Codec =
|
|
6510
|
-
authCodeHost:
|
|
6511
|
-
authCodeHash:
|
|
6431
|
+
static Codec = Class(WorkPackage, {
|
|
6432
|
+
authCodeHost: u32.asOpaque(),
|
|
6433
|
+
authCodeHash: bytes(HASH_SIZE).asOpaque(),
|
|
6512
6434
|
context: RefineContext.Codec,
|
|
6513
|
-
authorization:
|
|
6514
|
-
parametrization:
|
|
6515
|
-
items:
|
|
6435
|
+
authorization: blob,
|
|
6436
|
+
parametrization: blob,
|
|
6437
|
+
items: sequenceVarLen(WorkItem.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
6516
6438
|
});
|
|
6517
6439
|
static create({ authorization, authCodeHost, authCodeHash, parametrization, context, items, }) {
|
|
6518
6440
|
return new WorkPackage(authorization, authCodeHost, authCodeHash, parametrization, context, items);
|
|
@@ -6575,22 +6497,30 @@ var WorkExecResultKind;
|
|
|
6575
6497
|
class WorkExecResult extends WithDebug {
|
|
6576
6498
|
kind;
|
|
6577
6499
|
okBlob;
|
|
6578
|
-
static Codec =
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
.
|
|
6589
|
-
|
|
6590
|
-
return
|
|
6591
|
-
}
|
|
6592
|
-
|
|
6593
|
-
|
|
6500
|
+
static Codec = custom({
|
|
6501
|
+
name: "WorkExecResult",
|
|
6502
|
+
sizeHint: { bytes: 1, isExact: false },
|
|
6503
|
+
}, (e, x) => {
|
|
6504
|
+
e.varU32(tryAsU32(x.kind));
|
|
6505
|
+
if (x.kind === WorkExecResultKind.ok && x.okBlob !== null) {
|
|
6506
|
+
e.bytesBlob(x.okBlob);
|
|
6507
|
+
}
|
|
6508
|
+
}, (d) => {
|
|
6509
|
+
const kind = d.varU32();
|
|
6510
|
+
if (kind === WorkExecResultKind.ok) {
|
|
6511
|
+
const blob = d.bytesBlob();
|
|
6512
|
+
return new WorkExecResult(kind, blob);
|
|
6513
|
+
}
|
|
6514
|
+
if (kind > WorkExecResultKind.codeOversize) {
|
|
6515
|
+
throw new Error(`Invalid WorkExecResultKind: ${kind}`);
|
|
6516
|
+
}
|
|
6517
|
+
return new WorkExecResult(kind);
|
|
6518
|
+
}, (s) => {
|
|
6519
|
+
const kind = s.decoder.varU32();
|
|
6520
|
+
if (kind === WorkExecResultKind.ok) {
|
|
6521
|
+
s.bytesBlob();
|
|
6522
|
+
}
|
|
6523
|
+
});
|
|
6594
6524
|
constructor(
|
|
6595
6525
|
/** The execution result tag. */
|
|
6596
6526
|
kind,
|
|
@@ -6614,12 +6544,12 @@ class WorkRefineLoad extends WithDebug {
|
|
|
6614
6544
|
extrinsicCount;
|
|
6615
6545
|
extrinsicSize;
|
|
6616
6546
|
exportedSegments;
|
|
6617
|
-
static Codec =
|
|
6618
|
-
gasUsed:
|
|
6619
|
-
importedSegments:
|
|
6620
|
-
extrinsicCount:
|
|
6621
|
-
extrinsicSize:
|
|
6622
|
-
exportedSegments:
|
|
6547
|
+
static Codec = Class(WorkRefineLoad, {
|
|
6548
|
+
gasUsed: varU64.asOpaque(),
|
|
6549
|
+
importedSegments: varU32,
|
|
6550
|
+
extrinsicCount: varU32,
|
|
6551
|
+
extrinsicSize: varU32,
|
|
6552
|
+
exportedSegments: varU32,
|
|
6623
6553
|
});
|
|
6624
6554
|
static create({ gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments, }) {
|
|
6625
6555
|
return new WorkRefineLoad(gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments);
|
|
@@ -6655,11 +6585,11 @@ class WorkResult {
|
|
|
6655
6585
|
gas;
|
|
6656
6586
|
result;
|
|
6657
6587
|
load;
|
|
6658
|
-
static Codec =
|
|
6659
|
-
serviceId:
|
|
6660
|
-
codeHash:
|
|
6661
|
-
payloadHash:
|
|
6662
|
-
gas:
|
|
6588
|
+
static Codec = Class(WorkResult, {
|
|
6589
|
+
serviceId: u32.asOpaque(),
|
|
6590
|
+
codeHash: bytes(HASH_SIZE).asOpaque(),
|
|
6591
|
+
payloadHash: bytes(HASH_SIZE),
|
|
6592
|
+
gas: u64.asOpaque(),
|
|
6663
6593
|
result: WorkExecResult.Codec,
|
|
6664
6594
|
load: WorkRefineLoad.Codec,
|
|
6665
6595
|
});
|
|
@@ -6724,12 +6654,12 @@ class WorkPackageSpec extends WithDebug {
|
|
|
6724
6654
|
erasureRoot;
|
|
6725
6655
|
exportsRoot;
|
|
6726
6656
|
exportsCount;
|
|
6727
|
-
static Codec =
|
|
6728
|
-
hash:
|
|
6729
|
-
length:
|
|
6730
|
-
erasureRoot:
|
|
6731
|
-
exportsRoot:
|
|
6732
|
-
exportsCount:
|
|
6657
|
+
static Codec = Class(WorkPackageSpec, {
|
|
6658
|
+
hash: bytes(HASH_SIZE).asOpaque(),
|
|
6659
|
+
length: u32,
|
|
6660
|
+
erasureRoot: bytes(HASH_SIZE),
|
|
6661
|
+
exportsRoot: bytes(HASH_SIZE).asOpaque(),
|
|
6662
|
+
exportsCount: u16,
|
|
6733
6663
|
});
|
|
6734
6664
|
static create({ hash, length, erasureRoot, exportsRoot, exportsCount }) {
|
|
6735
6665
|
return new WorkPackageSpec(hash, length, erasureRoot, exportsRoot, exportsCount);
|
|
@@ -6767,20 +6697,20 @@ class WorkReport extends WithDebug {
|
|
|
6767
6697
|
segmentRootLookup;
|
|
6768
6698
|
results;
|
|
6769
6699
|
authorizationGasUsed;
|
|
6770
|
-
static Codec =
|
|
6700
|
+
static Codec = Class(WorkReport, {
|
|
6771
6701
|
workPackageSpec: WorkPackageSpec.Codec,
|
|
6772
6702
|
context: RefineContext.Codec,
|
|
6773
|
-
coreIndex:
|
|
6703
|
+
coreIndex: varU32.convert((o) => tryAsU32(o), (i) => {
|
|
6774
6704
|
if (!isU16(i)) {
|
|
6775
6705
|
throw new Error(`Core index exceeds U16: ${i}`);
|
|
6776
6706
|
}
|
|
6777
6707
|
return tryAsCoreIndex(i);
|
|
6778
6708
|
}),
|
|
6779
|
-
authorizerHash:
|
|
6780
|
-
authorizationGasUsed:
|
|
6781
|
-
authorizationOutput:
|
|
6782
|
-
segmentRootLookup:
|
|
6783
|
-
results:
|
|
6709
|
+
authorizerHash: bytes(HASH_SIZE).asOpaque(),
|
|
6710
|
+
authorizationGasUsed: varU64.asOpaque(),
|
|
6711
|
+
authorizationOutput: blob,
|
|
6712
|
+
segmentRootLookup: readonlyArray(sequenceVarLen(WorkPackageInfo.Codec)),
|
|
6713
|
+
results: sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
6784
6714
|
});
|
|
6785
6715
|
static create({ workPackageSpec, context, coreIndex, authorizerHash, authorizationOutput, segmentRootLookup, results, authorizationGasUsed, }) {
|
|
6786
6716
|
return new WorkReport(workPackageSpec, context, coreIndex, authorizerHash, authorizationOutput, segmentRootLookup, results, authorizationGasUsed);
|
|
@@ -6828,9 +6758,9 @@ const REQUIRED_CREDENTIALS_RANGE = [2, 3];
|
|
|
6828
6758
|
class Credential extends WithDebug {
|
|
6829
6759
|
validatorIndex;
|
|
6830
6760
|
signature;
|
|
6831
|
-
static Codec =
|
|
6832
|
-
validatorIndex:
|
|
6833
|
-
signature:
|
|
6761
|
+
static Codec = Class(Credential, {
|
|
6762
|
+
validatorIndex: u16.asOpaque(),
|
|
6763
|
+
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
6834
6764
|
});
|
|
6835
6765
|
static create({ validatorIndex, signature }) {
|
|
6836
6766
|
return new Credential(validatorIndex, signature);
|
|
@@ -6854,9 +6784,9 @@ class ReportGuarantee extends WithDebug {
|
|
|
6854
6784
|
report;
|
|
6855
6785
|
slot;
|
|
6856
6786
|
credentials;
|
|
6857
|
-
static Codec =
|
|
6787
|
+
static Codec = Class(ReportGuarantee, {
|
|
6858
6788
|
report: WorkReport.Codec,
|
|
6859
|
-
slot:
|
|
6789
|
+
slot: u32.asOpaque(),
|
|
6860
6790
|
credentials: codecKnownSizeArray(Credential.Codec, {
|
|
6861
6791
|
minLength: REQUIRED_CREDENTIALS_RANGE[0],
|
|
6862
6792
|
maxLength: REQUIRED_CREDENTIALS_RANGE[1],
|
|
@@ -6908,10 +6838,10 @@ function tryAsTicketAttempt(x) {
|
|
|
6908
6838
|
class SignedTicket extends WithDebug {
|
|
6909
6839
|
attempt;
|
|
6910
6840
|
signature;
|
|
6911
|
-
static Codec =
|
|
6841
|
+
static Codec = Class(SignedTicket, {
|
|
6912
6842
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
6913
|
-
attempt:
|
|
6914
|
-
signature:
|
|
6843
|
+
attempt: u8.asOpaque(),
|
|
6844
|
+
signature: bytes(BANDERSNATCH_PROOF_BYTES).asOpaque(),
|
|
6915
6845
|
});
|
|
6916
6846
|
static create({ attempt, signature }) {
|
|
6917
6847
|
return new SignedTicket(attempt, signature);
|
|
@@ -6930,10 +6860,10 @@ class SignedTicket extends WithDebug {
|
|
|
6930
6860
|
class Ticket extends WithDebug {
|
|
6931
6861
|
id;
|
|
6932
6862
|
attempt;
|
|
6933
|
-
static Codec =
|
|
6934
|
-
id:
|
|
6863
|
+
static Codec = Class(Ticket, {
|
|
6864
|
+
id: bytes(HASH_SIZE),
|
|
6935
6865
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
6936
|
-
attempt:
|
|
6866
|
+
attempt: u8.asOpaque(),
|
|
6937
6867
|
});
|
|
6938
6868
|
static create({ id, attempt }) {
|
|
6939
6869
|
return new Ticket(id, attempt);
|
|
@@ -6975,9 +6905,9 @@ var tickets = /*#__PURE__*/Object.freeze({
|
|
|
6975
6905
|
class ValidatorKeys extends WithDebug {
|
|
6976
6906
|
bandersnatch;
|
|
6977
6907
|
ed25519;
|
|
6978
|
-
static Codec =
|
|
6979
|
-
bandersnatch:
|
|
6980
|
-
ed25519:
|
|
6908
|
+
static Codec = Class(ValidatorKeys, {
|
|
6909
|
+
bandersnatch: bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
6910
|
+
ed25519: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
6981
6911
|
});
|
|
6982
6912
|
static create({ bandersnatch, ed25519 }) {
|
|
6983
6913
|
return new ValidatorKeys(bandersnatch, ed25519);
|
|
@@ -6994,7 +6924,7 @@ class ValidatorKeys extends WithDebug {
|
|
|
6994
6924
|
}
|
|
6995
6925
|
class TicketsMarker extends WithDebug {
|
|
6996
6926
|
tickets;
|
|
6997
|
-
static Codec =
|
|
6927
|
+
static Codec = Class(TicketsMarker, {
|
|
6998
6928
|
tickets: codecPerEpochBlock(Ticket.Codec),
|
|
6999
6929
|
});
|
|
7000
6930
|
static create({ tickets }) {
|
|
@@ -7016,9 +6946,9 @@ class EpochMarker extends WithDebug {
|
|
|
7016
6946
|
entropy;
|
|
7017
6947
|
ticketsEntropy;
|
|
7018
6948
|
validators;
|
|
7019
|
-
static Codec =
|
|
7020
|
-
entropy:
|
|
7021
|
-
ticketsEntropy:
|
|
6949
|
+
static Codec = Class(EpochMarker, {
|
|
6950
|
+
entropy: bytes(HASH_SIZE).asOpaque(),
|
|
6951
|
+
ticketsEntropy: bytes(HASH_SIZE).asOpaque(),
|
|
7022
6952
|
validators: codecPerValidator(ValidatorKeys.Codec),
|
|
7023
6953
|
});
|
|
7024
6954
|
static create({ entropy, ticketsEntropy, validators }) {
|
|
@@ -7055,17 +6985,17 @@ const encodeUnsealedHeader = (view) => {
|
|
|
7055
6985
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/0c66000c7200?v=0.7.2
|
|
7056
6986
|
*/
|
|
7057
6987
|
class Header extends WithDebug {
|
|
7058
|
-
static Codec =
|
|
7059
|
-
parentHeaderHash:
|
|
7060
|
-
priorStateRoot:
|
|
7061
|
-
extrinsicHash:
|
|
7062
|
-
timeSlotIndex:
|
|
7063
|
-
epochMarker:
|
|
7064
|
-
ticketsMarker:
|
|
7065
|
-
bandersnatchBlockAuthorIndex:
|
|
7066
|
-
entropySource:
|
|
7067
|
-
offendersMarker:
|
|
7068
|
-
seal:
|
|
6988
|
+
static Codec = Class(Header, {
|
|
6989
|
+
parentHeaderHash: bytes(HASH_SIZE).asOpaque(),
|
|
6990
|
+
priorStateRoot: bytes(HASH_SIZE).asOpaque(),
|
|
6991
|
+
extrinsicHash: bytes(HASH_SIZE).asOpaque(),
|
|
6992
|
+
timeSlotIndex: u32.asOpaque(),
|
|
6993
|
+
epochMarker: optional(EpochMarker.Codec),
|
|
6994
|
+
ticketsMarker: optional(TicketsMarker.Codec),
|
|
6995
|
+
bandersnatchBlockAuthorIndex: u16.asOpaque(),
|
|
6996
|
+
entropySource: bytes(BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
6997
|
+
offendersMarker: sequenceVarLen(bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
6998
|
+
seal: bytes(BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
7069
6999
|
});
|
|
7070
7000
|
static create(h) {
|
|
7071
7001
|
return Object.assign(Header.empty(), h);
|
|
@@ -7120,8 +7050,8 @@ class Header extends WithDebug {
|
|
|
7120
7050
|
* `DescriptorRecord` or `CodecRecord` for some reason.
|
|
7121
7051
|
*/
|
|
7122
7052
|
class HeaderViewWithHash extends WithHash {
|
|
7123
|
-
static Codec =
|
|
7124
|
-
hash:
|
|
7053
|
+
static Codec = Class(HeaderViewWithHash, {
|
|
7054
|
+
hash: bytes(HASH_SIZE).asOpaque(),
|
|
7125
7055
|
data: Header.Codec.View,
|
|
7126
7056
|
});
|
|
7127
7057
|
static create({ hash, data }) {
|
|
@@ -7139,9 +7069,9 @@ const headerViewWithHashCodec = HeaderViewWithHash.Codec;
|
|
|
7139
7069
|
class Preimage extends WithDebug {
|
|
7140
7070
|
requester;
|
|
7141
7071
|
blob;
|
|
7142
|
-
static Codec =
|
|
7143
|
-
requester:
|
|
7144
|
-
blob:
|
|
7072
|
+
static Codec = Class(Preimage, {
|
|
7073
|
+
requester: u32.asOpaque(),
|
|
7074
|
+
blob: blob,
|
|
7145
7075
|
});
|
|
7146
7076
|
static create({ requester, blob }) {
|
|
7147
7077
|
return new Preimage(requester, blob);
|
|
@@ -7156,7 +7086,7 @@ class Preimage extends WithDebug {
|
|
|
7156
7086
|
this.blob = blob;
|
|
7157
7087
|
}
|
|
7158
7088
|
}
|
|
7159
|
-
const preimagesExtrinsicCodec =
|
|
7089
|
+
const preimagesExtrinsicCodec = sequenceVarLen(Preimage.Codec);
|
|
7160
7090
|
|
|
7161
7091
|
var preimage = /*#__PURE__*/Object.freeze({
|
|
7162
7092
|
__proto__: null,
|
|
@@ -7177,7 +7107,7 @@ class Extrinsic extends WithDebug {
|
|
|
7177
7107
|
guarantees;
|
|
7178
7108
|
assurances;
|
|
7179
7109
|
disputes;
|
|
7180
|
-
static Codec =
|
|
7110
|
+
static Codec = Class(Extrinsic, {
|
|
7181
7111
|
tickets: ticketsExtrinsicCodec,
|
|
7182
7112
|
preimages: preimagesExtrinsicCodec,
|
|
7183
7113
|
guarantees: guaranteesExtrinsicCodec,
|
|
@@ -7230,7 +7160,7 @@ class Extrinsic extends WithDebug {
|
|
|
7230
7160
|
class Block extends WithDebug {
|
|
7231
7161
|
header;
|
|
7232
7162
|
extrinsic;
|
|
7233
|
-
static Codec =
|
|
7163
|
+
static Codec = Class(Block, {
|
|
7234
7164
|
header: Header.Codec,
|
|
7235
7165
|
extrinsic: Extrinsic.Codec,
|
|
7236
7166
|
});
|
|
@@ -8728,9 +8658,9 @@ function legacyServiceNested(serviceId, hash) {
|
|
|
8728
8658
|
class AccumulationOutput {
|
|
8729
8659
|
serviceId;
|
|
8730
8660
|
output;
|
|
8731
|
-
static Codec =
|
|
8732
|
-
serviceId:
|
|
8733
|
-
output:
|
|
8661
|
+
static Codec = Class(AccumulationOutput, {
|
|
8662
|
+
serviceId: u32.asOpaque(),
|
|
8663
|
+
output: bytes(HASH_SIZE),
|
|
8734
8664
|
});
|
|
8735
8665
|
static create(a) {
|
|
8736
8666
|
return new AccumulationOutput(a.serviceId, a.output);
|
|
@@ -8806,9 +8736,9 @@ const MAX_REPORT_DEPENDENCIES = 8;
|
|
|
8806
8736
|
class NotYetAccumulatedReport extends WithDebug {
|
|
8807
8737
|
report;
|
|
8808
8738
|
dependencies;
|
|
8809
|
-
static Codec =
|
|
8739
|
+
static Codec = Class(NotYetAccumulatedReport, {
|
|
8810
8740
|
report: WorkReport.Codec,
|
|
8811
|
-
dependencies: codecKnownSizeArray(
|
|
8741
|
+
dependencies: codecKnownSizeArray(bytes(HASH_SIZE).asOpaque(), {
|
|
8812
8742
|
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
8813
8743
|
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
8814
8744
|
minLength: 0,
|
|
@@ -8835,7 +8765,7 @@ class NotYetAccumulatedReport extends WithDebug {
|
|
|
8835
8765
|
this.dependencies = dependencies;
|
|
8836
8766
|
}
|
|
8837
8767
|
}
|
|
8838
|
-
const accumulationQueueCodec = codecPerEpochBlock(
|
|
8768
|
+
const accumulationQueueCodec = codecPerEpochBlock(readonlyArray(sequenceVarLen(NotYetAccumulatedReport.Codec)));
|
|
8839
8769
|
|
|
8840
8770
|
/** Check if given array has correct length before casting to the opaque type. */
|
|
8841
8771
|
function tryAsPerCore(array, spec) {
|
|
@@ -8860,9 +8790,9 @@ const codecPerCore = (val) => codecWithContext((context) => {
|
|
|
8860
8790
|
class AvailabilityAssignment extends WithDebug {
|
|
8861
8791
|
workReport;
|
|
8862
8792
|
timeout;
|
|
8863
|
-
static Codec =
|
|
8793
|
+
static Codec = Class(AvailabilityAssignment, {
|
|
8864
8794
|
workReport: WorkReport.Codec,
|
|
8865
|
-
timeout:
|
|
8795
|
+
timeout: u32.asOpaque(),
|
|
8866
8796
|
});
|
|
8867
8797
|
static create({ workReport, timeout }) {
|
|
8868
8798
|
return new AvailabilityAssignment(workReport, timeout);
|
|
@@ -8877,20 +8807,20 @@ class AvailabilityAssignment extends WithDebug {
|
|
|
8877
8807
|
this.timeout = timeout;
|
|
8878
8808
|
}
|
|
8879
8809
|
}
|
|
8880
|
-
const availabilityAssignmentsCodec = codecPerCore(
|
|
8810
|
+
const availabilityAssignmentsCodec = codecPerCore(optional(AvailabilityAssignment.Codec));
|
|
8881
8811
|
|
|
8882
8812
|
/** `O`: Maximal authorization pool size. */
|
|
8883
8813
|
const MAX_AUTH_POOL_SIZE = O;
|
|
8884
8814
|
/** `Q`: Size of the authorization queue. */
|
|
8885
8815
|
const AUTHORIZATION_QUEUE_SIZE = Q;
|
|
8886
|
-
const authPoolsCodec = codecPerCore(codecKnownSizeArray(
|
|
8816
|
+
const authPoolsCodec = codecPerCore(codecKnownSizeArray(bytes(HASH_SIZE).asOpaque(), {
|
|
8887
8817
|
minLength: 0,
|
|
8888
8818
|
maxLength: MAX_AUTH_POOL_SIZE,
|
|
8889
8819
|
typicalLength: MAX_AUTH_POOL_SIZE,
|
|
8890
8820
|
}));
|
|
8891
|
-
const authQueuesCodec = codecPerCore(codecFixedSizeArray(
|
|
8821
|
+
const authQueuesCodec = codecPerCore(codecFixedSizeArray(bytes(HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE));
|
|
8892
8822
|
|
|
8893
|
-
const sortedSetCodec = () =>
|
|
8823
|
+
const sortedSetCodec = () => readonlyArray(sequenceVarLen(bytes(HASH_SIZE))).convert((input) => input.array, (output) => {
|
|
8894
8824
|
const typed = output.map((x) => x.asOpaque());
|
|
8895
8825
|
return SortedSet.fromSortedArray(hashComparator, typed);
|
|
8896
8826
|
});
|
|
@@ -8905,7 +8835,7 @@ class DisputesRecords {
|
|
|
8905
8835
|
badSet;
|
|
8906
8836
|
wonkySet;
|
|
8907
8837
|
punishSet;
|
|
8908
|
-
static Codec =
|
|
8838
|
+
static Codec = Class(DisputesRecords, {
|
|
8909
8839
|
goodSet: workReportsSortedSetCodec,
|
|
8910
8840
|
badSet: workReportsSortedSetCodec,
|
|
8911
8841
|
wonkySet: workReportsSortedSetCodec,
|
|
@@ -8970,10 +8900,10 @@ class BlockState extends WithDebug {
|
|
|
8970
8900
|
accumulationResult;
|
|
8971
8901
|
postStateRoot;
|
|
8972
8902
|
reported;
|
|
8973
|
-
static Codec =
|
|
8974
|
-
headerHash:
|
|
8975
|
-
accumulationResult:
|
|
8976
|
-
postStateRoot:
|
|
8903
|
+
static Codec = Class(BlockState, {
|
|
8904
|
+
headerHash: bytes(HASH_SIZE).asOpaque(),
|
|
8905
|
+
accumulationResult: bytes(HASH_SIZE),
|
|
8906
|
+
postStateRoot: bytes(HASH_SIZE).asOpaque(),
|
|
8977
8907
|
reported: codecHashDictionary(WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
8978
8908
|
});
|
|
8979
8909
|
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
@@ -9003,14 +8933,14 @@ class BlockState extends WithDebug {
|
|
|
9003
8933
|
class RecentBlocks extends WithDebug {
|
|
9004
8934
|
blocks;
|
|
9005
8935
|
accumulationLog;
|
|
9006
|
-
static Codec =
|
|
8936
|
+
static Codec = Class(RecentBlocks, {
|
|
9007
8937
|
blocks: codecKnownSizeArray(BlockState.Codec, {
|
|
9008
8938
|
minLength: 0,
|
|
9009
8939
|
maxLength: MAX_RECENT_HISTORY,
|
|
9010
8940
|
typicalLength: MAX_RECENT_HISTORY,
|
|
9011
8941
|
}),
|
|
9012
|
-
accumulationLog:
|
|
9013
|
-
peaks:
|
|
8942
|
+
accumulationLog: object({
|
|
8943
|
+
peaks: readonlyArray(sequenceVarLen(optional(bytes(HASH_SIZE)))),
|
|
9014
8944
|
}),
|
|
9015
8945
|
});
|
|
9016
8946
|
static empty() {
|
|
@@ -9038,7 +8968,7 @@ class RecentBlocks extends WithDebug {
|
|
|
9038
8968
|
}
|
|
9039
8969
|
}
|
|
9040
8970
|
|
|
9041
|
-
const recentlyAccumulatedCodec = codecPerEpochBlock(
|
|
8971
|
+
const recentlyAccumulatedCodec = codecPerEpochBlock(sequenceVarLen(bytes(HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x)));
|
|
9042
8972
|
|
|
9043
8973
|
/**
|
|
9044
8974
|
* Fixed size of validator metadata.
|
|
@@ -9056,11 +8986,11 @@ class ValidatorData extends WithDebug {
|
|
|
9056
8986
|
ed25519;
|
|
9057
8987
|
bls;
|
|
9058
8988
|
metadata;
|
|
9059
|
-
static Codec =
|
|
9060
|
-
bandersnatch:
|
|
9061
|
-
ed25519:
|
|
9062
|
-
bls:
|
|
9063
|
-
metadata:
|
|
8989
|
+
static Codec = Class(ValidatorData, {
|
|
8990
|
+
bandersnatch: bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
8991
|
+
ed25519: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
8992
|
+
bls: bytes(BLS_KEY_BYTES).asOpaque(),
|
|
8993
|
+
metadata: bytes(VALIDATOR_META_BYTES),
|
|
9064
8994
|
});
|
|
9065
8995
|
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
9066
8996
|
return new ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
@@ -9088,26 +9018,46 @@ var SafroleSealingKeysKind;
|
|
|
9088
9018
|
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
9089
9019
|
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
9090
9020
|
})(SafroleSealingKeysKind || (SafroleSealingKeysKind = {}));
|
|
9091
|
-
const codecBandersnatchKey =
|
|
9021
|
+
const codecBandersnatchKey = bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
9092
9022
|
class SafroleSealingKeysData extends WithDebug {
|
|
9093
9023
|
kind;
|
|
9094
9024
|
keys;
|
|
9095
9025
|
tickets;
|
|
9096
9026
|
static Codec = codecWithContext((context) => {
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
.union("SafroleSealingKeys", {
|
|
9103
|
-
[SafroleSealingKeysKind.Keys]: codec.object({ keys: keysCodec }),
|
|
9104
|
-
[SafroleSealingKeysKind.Tickets]: codec.object({ tickets: ticketsCodec }),
|
|
9105
|
-
})
|
|
9106
|
-
.convert((x) => x, (x) => {
|
|
9027
|
+
return custom({
|
|
9028
|
+
name: "SafroleSealingKeys",
|
|
9029
|
+
sizeHint: { bytes: 1 + HASH_SIZE * context.epochLength, isExact: false },
|
|
9030
|
+
}, (e, x) => {
|
|
9031
|
+
e.varU32(tryAsU32(x.kind));
|
|
9107
9032
|
if (x.kind === SafroleSealingKeysKind.Keys) {
|
|
9108
|
-
|
|
9033
|
+
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
9109
9034
|
}
|
|
9110
|
-
|
|
9035
|
+
else {
|
|
9036
|
+
e.sequenceFixLen(Ticket.Codec, x.tickets);
|
|
9037
|
+
}
|
|
9038
|
+
}, (d) => {
|
|
9039
|
+
const epochLength = context.epochLength;
|
|
9040
|
+
const kind = d.varU32();
|
|
9041
|
+
if (kind === SafroleSealingKeysKind.Keys) {
|
|
9042
|
+
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
9043
|
+
return SafroleSealingKeysData.keys(tryAsPerEpochBlock(keys, context));
|
|
9044
|
+
}
|
|
9045
|
+
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
9046
|
+
const tickets = d.sequenceFixLen(Ticket.Codec, epochLength);
|
|
9047
|
+
return SafroleSealingKeysData.tickets(tryAsPerEpochBlock(tickets, context));
|
|
9048
|
+
}
|
|
9049
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
9050
|
+
}, (s) => {
|
|
9051
|
+
const kind = s.decoder.varU32();
|
|
9052
|
+
if (kind === SafroleSealingKeysKind.Keys) {
|
|
9053
|
+
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
9054
|
+
return;
|
|
9055
|
+
}
|
|
9056
|
+
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
9057
|
+
s.sequenceFixLen(Ticket.Codec, context.epochLength);
|
|
9058
|
+
return;
|
|
9059
|
+
}
|
|
9060
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
9111
9061
|
});
|
|
9112
9062
|
});
|
|
9113
9063
|
static keys(keys) {
|
|
@@ -9128,11 +9078,11 @@ class SafroleData {
|
|
|
9128
9078
|
epochRoot;
|
|
9129
9079
|
sealingKeySeries;
|
|
9130
9080
|
ticketsAccumulator;
|
|
9131
|
-
static Codec =
|
|
9081
|
+
static Codec = Class(SafroleData, {
|
|
9132
9082
|
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
9133
|
-
epochRoot:
|
|
9083
|
+
epochRoot: bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
9134
9084
|
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
9135
|
-
ticketsAccumulator:
|
|
9085
|
+
ticketsAccumulator: readonlyArray(sequenceVarLen(Ticket.Codec)).convert(seeThrough, asKnownSize),
|
|
9136
9086
|
});
|
|
9137
9087
|
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
9138
9088
|
return new SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
@@ -9210,17 +9160,17 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
9210
9160
|
created;
|
|
9211
9161
|
lastAccumulation;
|
|
9212
9162
|
parentService;
|
|
9213
|
-
static Codec =
|
|
9214
|
-
codeHash:
|
|
9215
|
-
balance:
|
|
9216
|
-
accumulateMinGas:
|
|
9217
|
-
onTransferMinGas:
|
|
9218
|
-
storageUtilisationBytes:
|
|
9219
|
-
gratisStorage:
|
|
9220
|
-
storageUtilisationCount:
|
|
9221
|
-
created:
|
|
9222
|
-
lastAccumulation:
|
|
9223
|
-
parentService:
|
|
9163
|
+
static Codec = Class(ServiceAccountInfo, {
|
|
9164
|
+
codeHash: bytes(HASH_SIZE).asOpaque(),
|
|
9165
|
+
balance: u64,
|
|
9166
|
+
accumulateMinGas: u64.convert((x) => x, tryAsServiceGas),
|
|
9167
|
+
onTransferMinGas: u64.convert((x) => x, tryAsServiceGas),
|
|
9168
|
+
storageUtilisationBytes: u64,
|
|
9169
|
+
gratisStorage: u64,
|
|
9170
|
+
storageUtilisationCount: u32,
|
|
9171
|
+
created: u32.convert((x) => x, tryAsTimeSlot),
|
|
9172
|
+
lastAccumulation: u32.convert((x) => x, tryAsTimeSlot),
|
|
9173
|
+
parentService: u32.convert((x) => x, tryAsServiceId),
|
|
9224
9174
|
});
|
|
9225
9175
|
static create(a) {
|
|
9226
9176
|
return new ServiceAccountInfo(a.codeHash, a.balance, a.accumulateMinGas, a.onTransferMinGas, a.storageUtilisationBytes, a.gratisStorage, a.storageUtilisationCount, a.created, a.lastAccumulation, a.parentService);
|
|
@@ -9276,9 +9226,9 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
9276
9226
|
class PreimageItem extends WithDebug {
|
|
9277
9227
|
hash;
|
|
9278
9228
|
blob;
|
|
9279
|
-
static Codec =
|
|
9280
|
-
hash:
|
|
9281
|
-
blob:
|
|
9229
|
+
static Codec = Class(PreimageItem, {
|
|
9230
|
+
hash: bytes(HASH_SIZE).asOpaque(),
|
|
9231
|
+
blob: blob,
|
|
9282
9232
|
});
|
|
9283
9233
|
static create({ hash, blob }) {
|
|
9284
9234
|
return new PreimageItem(hash, blob);
|
|
@@ -9292,9 +9242,9 @@ class PreimageItem extends WithDebug {
|
|
|
9292
9242
|
class StorageItem extends WithDebug {
|
|
9293
9243
|
key;
|
|
9294
9244
|
value;
|
|
9295
|
-
static Codec =
|
|
9296
|
-
key:
|
|
9297
|
-
value:
|
|
9245
|
+
static Codec = Class(StorageItem, {
|
|
9246
|
+
key: blob.convert((i) => i, (o) => asOpaqueType(o)),
|
|
9247
|
+
value: blob,
|
|
9298
9248
|
});
|
|
9299
9249
|
static create({ key, value }) {
|
|
9300
9250
|
return new StorageItem(key, value);
|
|
@@ -9348,13 +9298,13 @@ class ValidatorStatistics {
|
|
|
9348
9298
|
preImagesSize;
|
|
9349
9299
|
guarantees;
|
|
9350
9300
|
assurances;
|
|
9351
|
-
static Codec =
|
|
9352
|
-
blocks:
|
|
9353
|
-
tickets:
|
|
9354
|
-
preImages:
|
|
9355
|
-
preImagesSize:
|
|
9356
|
-
guarantees:
|
|
9357
|
-
assurances:
|
|
9301
|
+
static Codec = Class(ValidatorStatistics, {
|
|
9302
|
+
blocks: u32,
|
|
9303
|
+
tickets: u32,
|
|
9304
|
+
preImages: u32,
|
|
9305
|
+
preImagesSize: u32,
|
|
9306
|
+
guarantees: u32,
|
|
9307
|
+
assurances: u32,
|
|
9358
9308
|
});
|
|
9359
9309
|
static create({ blocks, tickets, preImages, preImagesSize, guarantees, assurances, }) {
|
|
9360
9310
|
return new ValidatorStatistics(blocks, tickets, preImages, preImagesSize, guarantees, assurances);
|
|
@@ -9384,9 +9334,9 @@ class ValidatorStatistics {
|
|
|
9384
9334
|
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
9385
9335
|
}
|
|
9386
9336
|
}
|
|
9387
|
-
const codecVarU16 =
|
|
9337
|
+
const codecVarU16 = varU32.convert((i) => tryAsU32(i), (o) => tryAsU16(o));
|
|
9388
9338
|
/** Encode/decode unsigned gas. */
|
|
9389
|
-
const codecVarGas =
|
|
9339
|
+
const codecVarGas = varU64.convert((g) => tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
9390
9340
|
/**
|
|
9391
9341
|
* Single core statistics.
|
|
9392
9342
|
* Updated per block, based on incoming work reports (`w`).
|
|
@@ -9403,14 +9353,14 @@ class CoreStatistics {
|
|
|
9403
9353
|
extrinsicCount;
|
|
9404
9354
|
bundleSize;
|
|
9405
9355
|
gasUsed;
|
|
9406
|
-
static Codec =
|
|
9407
|
-
dataAvailabilityLoad:
|
|
9356
|
+
static Codec = Class(CoreStatistics, {
|
|
9357
|
+
dataAvailabilityLoad: varU32,
|
|
9408
9358
|
popularity: codecVarU16,
|
|
9409
9359
|
imports: codecVarU16,
|
|
9410
9360
|
extrinsicCount: codecVarU16,
|
|
9411
|
-
extrinsicSize:
|
|
9361
|
+
extrinsicSize: varU32,
|
|
9412
9362
|
exports: codecVarU16,
|
|
9413
|
-
bundleSize:
|
|
9363
|
+
bundleSize: varU32,
|
|
9414
9364
|
gasUsed: codecVarGas,
|
|
9415
9365
|
});
|
|
9416
9366
|
static create(v) {
|
|
@@ -9469,31 +9419,31 @@ class ServiceStatistics {
|
|
|
9469
9419
|
onTransfersCount;
|
|
9470
9420
|
onTransfersGasUsed;
|
|
9471
9421
|
static Codec = Compatibility.selectIfGreaterOrEqual({
|
|
9472
|
-
fallback:
|
|
9422
|
+
fallback: Class(ServiceStatistics, {
|
|
9473
9423
|
providedCount: codecVarU16,
|
|
9474
|
-
providedSize:
|
|
9475
|
-
refinementCount:
|
|
9424
|
+
providedSize: varU32,
|
|
9425
|
+
refinementCount: varU32,
|
|
9476
9426
|
refinementGasUsed: codecVarGas,
|
|
9477
9427
|
imports: codecVarU16,
|
|
9478
9428
|
extrinsicCount: codecVarU16,
|
|
9479
|
-
extrinsicSize:
|
|
9429
|
+
extrinsicSize: varU32,
|
|
9480
9430
|
exports: codecVarU16,
|
|
9481
|
-
accumulateCount:
|
|
9431
|
+
accumulateCount: varU32,
|
|
9482
9432
|
accumulateGasUsed: codecVarGas,
|
|
9483
|
-
onTransfersCount:
|
|
9433
|
+
onTransfersCount: varU32,
|
|
9484
9434
|
onTransfersGasUsed: codecVarGas,
|
|
9485
9435
|
}),
|
|
9486
9436
|
versions: {
|
|
9487
|
-
[GpVersion.V0_7_1]:
|
|
9437
|
+
[GpVersion.V0_7_1]: Class(ServiceStatistics, {
|
|
9488
9438
|
providedCount: codecVarU16,
|
|
9489
|
-
providedSize:
|
|
9490
|
-
refinementCount:
|
|
9439
|
+
providedSize: varU32,
|
|
9440
|
+
refinementCount: varU32,
|
|
9491
9441
|
refinementGasUsed: codecVarGas,
|
|
9492
9442
|
imports: codecVarU16,
|
|
9493
9443
|
extrinsicCount: codecVarU16,
|
|
9494
|
-
extrinsicSize:
|
|
9444
|
+
extrinsicSize: varU32,
|
|
9495
9445
|
exports: codecVarU16,
|
|
9496
|
-
accumulateCount:
|
|
9446
|
+
accumulateCount: varU32,
|
|
9497
9447
|
accumulateGasUsed: codecVarGas,
|
|
9498
9448
|
onTransfersCount: ignoreValueWithDefault(tryAsU32(0)),
|
|
9499
9449
|
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
@@ -9554,11 +9504,11 @@ class StatisticsData {
|
|
|
9554
9504
|
previous;
|
|
9555
9505
|
cores;
|
|
9556
9506
|
services;
|
|
9557
|
-
static Codec =
|
|
9507
|
+
static Codec = Class(StatisticsData, {
|
|
9558
9508
|
current: codecPerValidator(ValidatorStatistics.Codec),
|
|
9559
9509
|
previous: codecPerValidator(ValidatorStatistics.Codec),
|
|
9560
9510
|
cores: codecPerCore(CoreStatistics.Codec),
|
|
9561
|
-
services:
|
|
9511
|
+
services: dictionary(u32.asOpaque(), ServiceStatistics.Codec, {
|
|
9562
9512
|
sortKeys: (a, b) => a - b,
|
|
9563
9513
|
}),
|
|
9564
9514
|
});
|
|
@@ -9640,14 +9590,14 @@ class PrivilegedServices {
|
|
|
9640
9590
|
assigners;
|
|
9641
9591
|
autoAccumulateServices;
|
|
9642
9592
|
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
9643
|
-
static Codec =
|
|
9644
|
-
manager:
|
|
9645
|
-
assigners: codecPerCore(
|
|
9646
|
-
delegator:
|
|
9593
|
+
static Codec = Class(PrivilegedServices, {
|
|
9594
|
+
manager: u32.asOpaque(),
|
|
9595
|
+
assigners: codecPerCore(u32.asOpaque()),
|
|
9596
|
+
delegator: u32.asOpaque(),
|
|
9647
9597
|
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
9648
|
-
?
|
|
9598
|
+
? u32.asOpaque()
|
|
9649
9599
|
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
9650
|
-
autoAccumulateServices:
|
|
9600
|
+
autoAccumulateServices: dictionary(u32.asOpaque(), u64.asOpaque(), {
|
|
9651
9601
|
sortKeys: (a, b) => a - b,
|
|
9652
9602
|
}),
|
|
9653
9603
|
});
|
|
@@ -10292,15 +10242,15 @@ class InMemoryState extends WithDebug {
|
|
|
10292
10242
|
});
|
|
10293
10243
|
}
|
|
10294
10244
|
}
|
|
10295
|
-
const serviceEntriesCodec =
|
|
10296
|
-
storageKeys:
|
|
10297
|
-
preimages:
|
|
10298
|
-
lookupHistory:
|
|
10299
|
-
hash:
|
|
10300
|
-
length:
|
|
10245
|
+
const serviceEntriesCodec = object({
|
|
10246
|
+
storageKeys: sequenceVarLen(blob.convert((i) => i, (o) => asOpaqueType(o))),
|
|
10247
|
+
preimages: sequenceVarLen(bytes(HASH_SIZE).asOpaque()),
|
|
10248
|
+
lookupHistory: sequenceVarLen(object({
|
|
10249
|
+
hash: bytes(HASH_SIZE).asOpaque(),
|
|
10250
|
+
length: u32,
|
|
10301
10251
|
})),
|
|
10302
10252
|
});
|
|
10303
|
-
const serviceDataCodec =
|
|
10253
|
+
const serviceDataCodec = dictionary(u32.asOpaque(), serviceEntriesCodec, {
|
|
10304
10254
|
sortKeys: (a, b) => a - b,
|
|
10305
10255
|
});
|
|
10306
10256
|
|
|
@@ -10403,7 +10353,7 @@ var serialize;
|
|
|
10403
10353
|
/** C(6): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bf3013bf301?v=0.6.7 */
|
|
10404
10354
|
serialize.entropy = {
|
|
10405
10355
|
key: stateKeys.index(StateKeyIdx.Eta),
|
|
10406
|
-
Codec: codecFixedSizeArray(
|
|
10356
|
+
Codec: codecFixedSizeArray(bytes(HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
10407
10357
|
extract: (s) => s.entropy,
|
|
10408
10358
|
};
|
|
10409
10359
|
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
@@ -10433,7 +10383,7 @@ var serialize;
|
|
|
10433
10383
|
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
10434
10384
|
serialize.timeslot = {
|
|
10435
10385
|
key: stateKeys.index(StateKeyIdx.Tau),
|
|
10436
|
-
Codec:
|
|
10386
|
+
Codec: u32.asOpaque(),
|
|
10437
10387
|
extract: (s) => s.timeslot,
|
|
10438
10388
|
};
|
|
10439
10389
|
/** C(12): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b4c023b4c02?v=0.6.7 */
|
|
@@ -10463,7 +10413,7 @@ var serialize;
|
|
|
10463
10413
|
/** C(16): https://graypaper.fluffylabs.dev/#/38c4e62/3b46033b4603?v=0.7.0 */
|
|
10464
10414
|
serialize.accumulationOutputLog = {
|
|
10465
10415
|
key: stateKeys.index(StateKeyIdx.Theta),
|
|
10466
|
-
Codec:
|
|
10416
|
+
Codec: sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
|
|
10467
10417
|
extract: (s) => s.accumulationOutputLog,
|
|
10468
10418
|
};
|
|
10469
10419
|
/** C(255, s): https://graypaper.fluffylabs.dev/#/85129da/383103383103?v=0.6.3 */
|
|
@@ -10486,7 +10436,7 @@ var serialize;
|
|
|
10486
10436
|
/** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
|
|
10487
10437
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
10488
10438
|
key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
|
|
10489
|
-
Codec:
|
|
10439
|
+
Codec: readonlyArray(sequenceVarLen(u32)),
|
|
10490
10440
|
});
|
|
10491
10441
|
})(serialize || (serialize = {}));
|
|
10492
10442
|
/**
|
|
@@ -11580,7 +11530,7 @@ function getSafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsA
|
|
|
11580
11530
|
|
|
11581
11531
|
const TYPICAL_STATE_ITEMS = 50;
|
|
11582
11532
|
const TYPICAL_STATE_ITEM_LEN = 50;
|
|
11583
|
-
const stateEntriesSequenceCodec =
|
|
11533
|
+
const stateEntriesSequenceCodec = sequenceVarLen(pair(bytes(TRUNCATED_HASH_SIZE), blob));
|
|
11584
11534
|
/**
|
|
11585
11535
|
* Full, in-memory state represented as serialized entries dictionary.
|
|
11586
11536
|
*
|
|
@@ -11588,7 +11538,7 @@ const stateEntriesSequenceCodec = codec.sequenceVarLen(codec.pair(codec.bytes(TR
|
|
|
11588
11538
|
*/
|
|
11589
11539
|
class StateEntries {
|
|
11590
11540
|
dictionary;
|
|
11591
|
-
static Codec =
|
|
11541
|
+
static Codec = custom({
|
|
11592
11542
|
name: "StateEntries",
|
|
11593
11543
|
sizeHint: {
|
|
11594
11544
|
isExact: false,
|
|
@@ -12408,10 +12358,10 @@ class Version extends WithDebug {
|
|
|
12408
12358
|
major;
|
|
12409
12359
|
minor;
|
|
12410
12360
|
patch;
|
|
12411
|
-
static Codec =
|
|
12412
|
-
major:
|
|
12413
|
-
minor:
|
|
12414
|
-
patch:
|
|
12361
|
+
static Codec = Class(Version, {
|
|
12362
|
+
major: u8,
|
|
12363
|
+
minor: u8,
|
|
12364
|
+
patch: u8,
|
|
12415
12365
|
});
|
|
12416
12366
|
static tryFromString(str) {
|
|
12417
12367
|
const parse = (v) => tryAsU8(Number(v));
|
|
@@ -12463,12 +12413,12 @@ class PeerInfo extends WithDebug {
|
|
|
12463
12413
|
jamVersion;
|
|
12464
12414
|
appVersion;
|
|
12465
12415
|
name;
|
|
12466
|
-
static Codec =
|
|
12467
|
-
fuzzVersion:
|
|
12468
|
-
features:
|
|
12416
|
+
static Codec = Class(PeerInfo, {
|
|
12417
|
+
fuzzVersion: u8,
|
|
12418
|
+
features: u32,
|
|
12469
12419
|
jamVersion: Version.Codec,
|
|
12470
12420
|
appVersion: Version.Codec,
|
|
12471
|
-
name:
|
|
12421
|
+
name: string,
|
|
12472
12422
|
});
|
|
12473
12423
|
static create({ fuzzVersion, features, appVersion, jamVersion, name }) {
|
|
12474
12424
|
return new PeerInfo(fuzzVersion, features, jamVersion, appVersion, name);
|
|
@@ -12491,9 +12441,9 @@ class PeerInfo extends WithDebug {
|
|
|
12491
12441
|
class AncestryItem extends WithDebug {
|
|
12492
12442
|
slot;
|
|
12493
12443
|
headerHash;
|
|
12494
|
-
static Codec =
|
|
12495
|
-
slot:
|
|
12496
|
-
headerHash:
|
|
12444
|
+
static Codec = Class(AncestryItem, {
|
|
12445
|
+
slot: u32.asOpaque(),
|
|
12446
|
+
headerHash: bytes(HASH_SIZE).asOpaque(),
|
|
12497
12447
|
});
|
|
12498
12448
|
static create({ slot, headerHash }) {
|
|
12499
12449
|
return new AncestryItem(slot, headerHash);
|
|
@@ -12513,9 +12463,9 @@ class AncestryItem extends WithDebug {
|
|
|
12513
12463
|
class KeyValue extends WithDebug {
|
|
12514
12464
|
key;
|
|
12515
12465
|
value;
|
|
12516
|
-
static Codec =
|
|
12517
|
-
key:
|
|
12518
|
-
value:
|
|
12466
|
+
static Codec = Class(KeyValue, {
|
|
12467
|
+
key: bytes(TRUNCATED_HASH_SIZE),
|
|
12468
|
+
value: blob,
|
|
12519
12469
|
});
|
|
12520
12470
|
static create({ key, value }) {
|
|
12521
12471
|
return new KeyValue(key, value);
|
|
@@ -12527,12 +12477,12 @@ class KeyValue extends WithDebug {
|
|
|
12527
12477
|
}
|
|
12528
12478
|
}
|
|
12529
12479
|
/** State ::= SEQUENCE OF KeyValue */
|
|
12530
|
-
const stateCodec =
|
|
12480
|
+
const stateCodec = sequenceVarLen(KeyValue.Codec);
|
|
12531
12481
|
/**
|
|
12532
12482
|
* Ancestry ::= SEQUENCE (SIZE(0..24)) OF AncestryItem
|
|
12533
12483
|
* Empty when `feature-ancestry` is not supported by both parties
|
|
12534
12484
|
*/
|
|
12535
|
-
const ancestryCodec =
|
|
12485
|
+
const ancestryCodec = sequenceVarLen(AncestryItem.Codec, {
|
|
12536
12486
|
minLength: 0,
|
|
12537
12487
|
maxLength: 24,
|
|
12538
12488
|
});
|
|
@@ -12547,7 +12497,7 @@ class Initialize extends WithDebug {
|
|
|
12547
12497
|
header;
|
|
12548
12498
|
keyvals;
|
|
12549
12499
|
ancestry;
|
|
12550
|
-
static Codec =
|
|
12500
|
+
static Codec = Class(Initialize, {
|
|
12551
12501
|
header: Header.Codec,
|
|
12552
12502
|
keyvals: stateCodec,
|
|
12553
12503
|
ancestry: ancestryCodec,
|
|
@@ -12563,14 +12513,14 @@ class Initialize extends WithDebug {
|
|
|
12563
12513
|
}
|
|
12564
12514
|
}
|
|
12565
12515
|
/** GetState ::= HeaderHash */
|
|
12566
|
-
const getStateCodec =
|
|
12516
|
+
const getStateCodec = bytes(HASH_SIZE).asOpaque();
|
|
12567
12517
|
/** StateRoot ::= StateRootHash */
|
|
12568
|
-
const stateRootCodec =
|
|
12518
|
+
const stateRootCodec = bytes(HASH_SIZE).asOpaque();
|
|
12569
12519
|
/** Error ::= UTF8String */
|
|
12570
12520
|
class ErrorMessage extends WithDebug {
|
|
12571
12521
|
message;
|
|
12572
|
-
static Codec =
|
|
12573
|
-
message:
|
|
12522
|
+
static Codec = Class(ErrorMessage, {
|
|
12523
|
+
message: string,
|
|
12574
12524
|
});
|
|
12575
12525
|
static create({ message }) {
|
|
12576
12526
|
return new ErrorMessage(message);
|
|
@@ -12602,7 +12552,7 @@ var MessageType;
|
|
|
12602
12552
|
* error [255] Error
|
|
12603
12553
|
* }
|
|
12604
12554
|
*/
|
|
12605
|
-
const messageCodec =
|
|
12555
|
+
const messageCodec = custom({
|
|
12606
12556
|
name: "Message",
|
|
12607
12557
|
sizeHint: { bytes: 1, isExact: false },
|
|
12608
12558
|
}, (e, msg) => {
|
|
@@ -18087,7 +18037,7 @@ class Assign {
|
|
|
18087
18037
|
// NOTE: Here we know the core index is valid
|
|
18088
18038
|
const coreIndex = tryAsCoreIndex(Number(maybeCoreIndex));
|
|
18089
18039
|
const decoder = Decoder.fromBlob(res);
|
|
18090
|
-
const authQueue = decoder.sequenceFixLen(
|
|
18040
|
+
const authQueue = decoder.sequenceFixLen(bytes(HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE);
|
|
18091
18041
|
const fixedSizeAuthQueue = FixedSizeArray.new(authQueue, AUTHORIZATION_QUEUE_SIZE);
|
|
18092
18042
|
const result = this.partialState.updateAuthorizationQueue(coreIndex, fixedSizeAuthQueue, assigners);
|
|
18093
18043
|
if (result.isOk) {
|
|
@@ -18111,9 +18061,9 @@ class Assign {
|
|
|
18111
18061
|
}
|
|
18112
18062
|
|
|
18113
18063
|
const IN_OUT_REG$m = 7;
|
|
18114
|
-
const serviceIdAndGasCodec =
|
|
18115
|
-
serviceId:
|
|
18116
|
-
gas:
|
|
18064
|
+
const serviceIdAndGasCodec = object({
|
|
18065
|
+
serviceId: u32.convert((i) => i, (o) => asOpaqueType(o)),
|
|
18066
|
+
gas: u64.convert((i) => tryAsU64(i), (o) => tryAsServiceGas(o)),
|
|
18117
18067
|
});
|
|
18118
18068
|
/**
|
|
18119
18069
|
* Modify privileged services and services that auto-accumulate every block.
|
|
@@ -18171,7 +18121,7 @@ class Bless {
|
|
|
18171
18121
|
memIndex = tryAsU64(memIndex + tryAsU64(decoder.bytesRead()));
|
|
18172
18122
|
}
|
|
18173
18123
|
// https://graypaper.fluffylabs.dev/#/7e6ff6a/367200367200?v=0.6.7
|
|
18174
|
-
const res = safeAllocUint8Array(tryAsExactBytes(
|
|
18124
|
+
const res = safeAllocUint8Array(tryAsExactBytes(u32.sizeHint) * this.chainSpec.coresCount);
|
|
18175
18125
|
const authorizersDecoder = Decoder.fromBlob(res);
|
|
18176
18126
|
const memoryReadResult = memory.loadInto(res, authorization);
|
|
18177
18127
|
if (memoryReadResult.isError) {
|
|
@@ -18179,7 +18129,7 @@ class Bless {
|
|
|
18179
18129
|
return PvmExecution.Panic;
|
|
18180
18130
|
}
|
|
18181
18131
|
// `a`
|
|
18182
|
-
const authorizers = tryAsPerCore(authorizersDecoder.sequenceFixLen(
|
|
18132
|
+
const authorizers = tryAsPerCore(authorizersDecoder.sequenceFixLen(u32.asOpaque(), this.chainSpec.coresCount), this.chainSpec);
|
|
18183
18133
|
const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers, delegator, registrar, autoAccumulate);
|
|
18184
18134
|
if (updateResult.isOk) {
|
|
18185
18135
|
logger$7.trace `[${this.currentServiceId}] BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- OK`;
|
|
@@ -18789,12 +18739,12 @@ class PendingTransfer {
|
|
|
18789
18739
|
amount;
|
|
18790
18740
|
memo;
|
|
18791
18741
|
gas;
|
|
18792
|
-
static Codec =
|
|
18793
|
-
source:
|
|
18794
|
-
destination:
|
|
18795
|
-
amount:
|
|
18796
|
-
memo:
|
|
18797
|
-
gas:
|
|
18742
|
+
static Codec = Class(PendingTransfer, {
|
|
18743
|
+
source: u32.asOpaque(),
|
|
18744
|
+
destination: u32.asOpaque(),
|
|
18745
|
+
amount: u64,
|
|
18746
|
+
memo: bytes(TRANSFER_MEMO_BYTES),
|
|
18747
|
+
gas: u64.asOpaque(),
|
|
18798
18748
|
});
|
|
18799
18749
|
constructor(
|
|
18800
18750
|
/** `s`: sending service */
|
|
@@ -19092,18 +19042,18 @@ class Info {
|
|
|
19092
19042
|
*
|
|
19093
19043
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/33920033b500?v=0.7.2
|
|
19094
19044
|
*/
|
|
19095
|
-
const codecServiceAccountInfoWithThresholdBalance =
|
|
19096
|
-
codeHash:
|
|
19097
|
-
balance:
|
|
19098
|
-
thresholdBalance:
|
|
19099
|
-
accumulateMinGas:
|
|
19100
|
-
onTransferMinGas:
|
|
19101
|
-
storageUtilisationBytes:
|
|
19102
|
-
storageUtilisationCount:
|
|
19103
|
-
gratisStorage:
|
|
19104
|
-
created:
|
|
19105
|
-
lastAccumulation:
|
|
19106
|
-
parentService:
|
|
19045
|
+
const codecServiceAccountInfoWithThresholdBalance = object({
|
|
19046
|
+
codeHash: bytes(HASH_SIZE),
|
|
19047
|
+
balance: u64,
|
|
19048
|
+
thresholdBalance: u64,
|
|
19049
|
+
accumulateMinGas: u64.convert((i) => i, tryAsServiceGas),
|
|
19050
|
+
onTransferMinGas: u64.convert((i) => i, tryAsServiceGas),
|
|
19051
|
+
storageUtilisationBytes: u64,
|
|
19052
|
+
storageUtilisationCount: u32,
|
|
19053
|
+
gratisStorage: u64,
|
|
19054
|
+
created: u32.convert((x) => x, tryAsTimeSlot),
|
|
19055
|
+
lastAccumulation: u32.convert((x) => x, tryAsTimeSlot),
|
|
19056
|
+
parentService: u32.convert((x) => x, tryAsServiceId),
|
|
19107
19057
|
}, "ServiceAccountInfoWithThresholdBalance");
|
|
19108
19058
|
|
|
19109
19059
|
const decoder = new TextDecoder("utf8");
|
|
@@ -19479,9 +19429,9 @@ class HistoricalLookup {
|
|
|
19479
19429
|
|
|
19480
19430
|
const IN_OUT_REG_1 = 7;
|
|
19481
19431
|
const IN_OUT_REG_2 = 8;
|
|
19482
|
-
const gasAndRegistersCodec =
|
|
19483
|
-
gas:
|
|
19484
|
-
registers:
|
|
19432
|
+
const gasAndRegistersCodec = object({
|
|
19433
|
+
gas: i64,
|
|
19434
|
+
registers: bytes(NO_OF_REGISTERS$1 * REGISTER_BYTE_SIZE),
|
|
19485
19435
|
});
|
|
19486
19436
|
const GAS_REGISTERS_SIZE = tryAsExactBytes(gasAndRegistersCodec.sizeHint);
|
|
19487
19437
|
/**
|
|
@@ -20327,21 +20277,21 @@ const GAS_TO_INVOKE_WORK_REPORT = 10000000n;
|
|
|
20327
20277
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/176b00176b00?v=0.7.2
|
|
20328
20278
|
*/
|
|
20329
20279
|
class Operand extends WithDebug {
|
|
20330
|
-
static Codec =
|
|
20280
|
+
static Codec = Class(Operand, {
|
|
20331
20281
|
// h
|
|
20332
|
-
hash:
|
|
20282
|
+
hash: bytes(HASH_SIZE).asOpaque(),
|
|
20333
20283
|
// e
|
|
20334
|
-
exportsRoot:
|
|
20284
|
+
exportsRoot: bytes(HASH_SIZE).asOpaque(),
|
|
20335
20285
|
// a
|
|
20336
|
-
authorizerHash:
|
|
20286
|
+
authorizerHash: bytes(HASH_SIZE).asOpaque(),
|
|
20337
20287
|
// y
|
|
20338
|
-
payloadHash:
|
|
20288
|
+
payloadHash: bytes(HASH_SIZE),
|
|
20339
20289
|
// g
|
|
20340
|
-
gas:
|
|
20290
|
+
gas: varU64.asOpaque(),
|
|
20341
20291
|
// d
|
|
20342
20292
|
result: WorkExecResult.Codec,
|
|
20343
20293
|
// o
|
|
20344
|
-
authorizationOutput:
|
|
20294
|
+
authorizationOutput: blob,
|
|
20345
20295
|
});
|
|
20346
20296
|
/**
|
|
20347
20297
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/18680118eb01?v=0.7.2
|
|
@@ -20612,11 +20562,7 @@ function verifyReportsBasic(input) {
|
|
|
20612
20562
|
const authOutputSize = reportView.authorizationOutput.view().length;
|
|
20613
20563
|
let totalOutputsSize = 0;
|
|
20614
20564
|
for (const item of reportView.results.view()) {
|
|
20615
|
-
|
|
20616
|
-
const result = workItemView.result.materialize();
|
|
20617
|
-
if (result.kind === WorkExecResultKind.ok) {
|
|
20618
|
-
totalOutputsSize += result.okBlob?.raw.length ?? 0;
|
|
20619
|
-
}
|
|
20565
|
+
totalOutputsSize += item.view().result.view().okBlob?.raw.length ?? 0;
|
|
20620
20566
|
}
|
|
20621
20567
|
if (authOutputSize + totalOutputsSize > MAX_WORK_REPORT_SIZE_BYTES) {
|
|
20622
20568
|
return Result$1.error(ReportsError.WorkReportTooBig, () => `Work report at ${reportView.coreIndex.materialize()} too big. Got ${authOutputSize} + ${totalOutputsSize}, max: ${MAX_WORK_REPORT_SIZE_BYTES}`);
|
|
@@ -20630,47 +20576,75 @@ var TransferOperandKind;
|
|
|
20630
20576
|
TransferOperandKind[TransferOperandKind["OPERAND"] = 0] = "OPERAND";
|
|
20631
20577
|
TransferOperandKind[TransferOperandKind["TRANSFER"] = 1] = "TRANSFER";
|
|
20632
20578
|
})(TransferOperandKind || (TransferOperandKind = {}));
|
|
20633
|
-
const TRANSFER_OR_OPERAND =
|
|
20634
|
-
|
|
20635
|
-
|
|
20579
|
+
const TRANSFER_OR_OPERAND = custom({
|
|
20580
|
+
name: "TransferOrOperand",
|
|
20581
|
+
sizeHint: { bytes: 1, isExact: false },
|
|
20582
|
+
}, (e, x) => {
|
|
20583
|
+
e.varU32(tryAsU32(x.kind));
|
|
20584
|
+
if (x.kind === TransferOperandKind.OPERAND) {
|
|
20585
|
+
e.object(Operand.Codec, x.value);
|
|
20586
|
+
}
|
|
20587
|
+
if (x.kind === TransferOperandKind.TRANSFER) {
|
|
20588
|
+
e.object(PendingTransfer.Codec, x.value);
|
|
20589
|
+
}
|
|
20590
|
+
}, (d) => {
|
|
20591
|
+
const kind = d.varU32();
|
|
20592
|
+
if (kind === TransferOperandKind.OPERAND) {
|
|
20593
|
+
return {
|
|
20594
|
+
kind: TransferOperandKind.OPERAND,
|
|
20595
|
+
value: d.object(Operand.Codec),
|
|
20596
|
+
};
|
|
20597
|
+
}
|
|
20598
|
+
if (kind === TransferOperandKind.TRANSFER) {
|
|
20599
|
+
return { kind: TransferOperandKind.TRANSFER, value: d.object(PendingTransfer.Codec) };
|
|
20600
|
+
}
|
|
20601
|
+
throw new Error(`Unable to decode TransferOrOperand. Invalid kind: ${kind}.`);
|
|
20602
|
+
}, (s) => {
|
|
20603
|
+
const kind = s.decoder.varU32();
|
|
20604
|
+
if (kind === TransferOperandKind.OPERAND) {
|
|
20605
|
+
s.object(Operand.Codec);
|
|
20606
|
+
}
|
|
20607
|
+
if (kind === TransferOperandKind.TRANSFER) {
|
|
20608
|
+
s.object(PendingTransfer.Codec);
|
|
20609
|
+
}
|
|
20636
20610
|
});
|
|
20637
|
-
const TRANSFERS_AND_OPERANDS =
|
|
20611
|
+
const TRANSFERS_AND_OPERANDS = sequenceVarLen(TRANSFER_OR_OPERAND);
|
|
20638
20612
|
// https://github.com/gavofyork/graypaper/pull/414
|
|
20639
20613
|
// 0.7.0 encoding is used for prior versions as well.
|
|
20640
|
-
const CONSTANTS_CODEC =
|
|
20641
|
-
B_I:
|
|
20642
|
-
B_L:
|
|
20643
|
-
B_S:
|
|
20644
|
-
C:
|
|
20645
|
-
D:
|
|
20646
|
-
E:
|
|
20647
|
-
G_A:
|
|
20648
|
-
G_I:
|
|
20649
|
-
G_R:
|
|
20650
|
-
G_T:
|
|
20651
|
-
H:
|
|
20652
|
-
I:
|
|
20653
|
-
J:
|
|
20654
|
-
K:
|
|
20655
|
-
L:
|
|
20656
|
-
N:
|
|
20657
|
-
O:
|
|
20658
|
-
P:
|
|
20659
|
-
Q:
|
|
20660
|
-
R:
|
|
20661
|
-
T:
|
|
20662
|
-
U:
|
|
20663
|
-
V:
|
|
20664
|
-
W_A:
|
|
20665
|
-
W_B:
|
|
20666
|
-
W_C:
|
|
20667
|
-
W_E:
|
|
20668
|
-
W_M:
|
|
20669
|
-
W_P:
|
|
20670
|
-
W_R:
|
|
20671
|
-
W_T:
|
|
20672
|
-
W_X:
|
|
20673
|
-
Y:
|
|
20614
|
+
const CONSTANTS_CODEC = object({
|
|
20615
|
+
B_I: u64,
|
|
20616
|
+
B_L: u64,
|
|
20617
|
+
B_S: u64,
|
|
20618
|
+
C: u16,
|
|
20619
|
+
D: u32,
|
|
20620
|
+
E: u32,
|
|
20621
|
+
G_A: u64,
|
|
20622
|
+
G_I: u64,
|
|
20623
|
+
G_R: u64,
|
|
20624
|
+
G_T: u64,
|
|
20625
|
+
H: u16,
|
|
20626
|
+
I: u16,
|
|
20627
|
+
J: u16,
|
|
20628
|
+
K: u16,
|
|
20629
|
+
L: u32,
|
|
20630
|
+
N: u16,
|
|
20631
|
+
O: u16,
|
|
20632
|
+
P: u16,
|
|
20633
|
+
Q: u16,
|
|
20634
|
+
R: u16,
|
|
20635
|
+
T: u16,
|
|
20636
|
+
U: u16,
|
|
20637
|
+
V: u16,
|
|
20638
|
+
W_A: u32,
|
|
20639
|
+
W_B: u32,
|
|
20640
|
+
W_C: u32,
|
|
20641
|
+
W_E: u32,
|
|
20642
|
+
W_M: u32,
|
|
20643
|
+
W_P: u32,
|
|
20644
|
+
W_R: u32,
|
|
20645
|
+
W_T: u32,
|
|
20646
|
+
W_X: u32,
|
|
20647
|
+
Y: u32,
|
|
20674
20648
|
});
|
|
20675
20649
|
const encodedConstantsCache = new Map();
|
|
20676
20650
|
function getEncodedConstants(chainSpec) {
|
|
@@ -20783,7 +20757,7 @@ class FetchExternalities {
|
|
|
20783
20757
|
allOperands() {
|
|
20784
20758
|
if (this.fetchData.context === FetchContext.LegacyAccumulate) {
|
|
20785
20759
|
const operands = this.fetchData.operands;
|
|
20786
|
-
return Encoder.encodeObject(
|
|
20760
|
+
return Encoder.encodeObject(sequenceVarLen(Operand.Codec), operands, this.chainSpec);
|
|
20787
20761
|
}
|
|
20788
20762
|
return null;
|
|
20789
20763
|
}
|
|
@@ -20804,7 +20778,7 @@ class FetchExternalities {
|
|
|
20804
20778
|
allTransfers() {
|
|
20805
20779
|
if (this.fetchData.context === FetchContext.LegacyOnTransfer) {
|
|
20806
20780
|
const { transfers } = this.fetchData;
|
|
20807
|
-
return Encoder.encodeObject(
|
|
20781
|
+
return Encoder.encodeObject(sequenceVarLen(PendingTransfer.Codec), transfers, this.chainSpec);
|
|
20808
20782
|
}
|
|
20809
20783
|
return null;
|
|
20810
20784
|
}
|
|
@@ -21035,10 +21009,10 @@ function getWorkPackageHashes(reports) {
|
|
|
21035
21009
|
const workPackageHashes = reports.map((report) => report.workPackageSpec.hash);
|
|
21036
21010
|
return HashSet.from(workPackageHashes);
|
|
21037
21011
|
}
|
|
21038
|
-
const NEXT_ID_CODEC =
|
|
21039
|
-
serviceId:
|
|
21040
|
-
entropy:
|
|
21041
|
-
timeslot:
|
|
21012
|
+
const NEXT_ID_CODEC = object({
|
|
21013
|
+
serviceId: varU32.asOpaque(),
|
|
21014
|
+
entropy: bytes(HASH_SIZE).asOpaque(),
|
|
21015
|
+
timeslot: varU32.asOpaque(),
|
|
21042
21016
|
});
|
|
21043
21017
|
/**
|
|
21044
21018
|
* Generate a next service id.
|
|
@@ -21436,10 +21410,10 @@ var PvmInvocationError;
|
|
|
21436
21410
|
PvmInvocationError[PvmInvocationError["PreimageTooLong"] = 2] = "PreimageTooLong";
|
|
21437
21411
|
})(PvmInvocationError || (PvmInvocationError = {}));
|
|
21438
21412
|
const logger$5 = Logger.new(undefined, "accumulate");
|
|
21439
|
-
const ARGS_CODEC$1 =
|
|
21440
|
-
slot:
|
|
21441
|
-
serviceId:
|
|
21442
|
-
argsLength:
|
|
21413
|
+
const ARGS_CODEC$1 = object({
|
|
21414
|
+
slot: varU32.asOpaque(),
|
|
21415
|
+
serviceId: varU32.asOpaque(),
|
|
21416
|
+
argsLength: varU32,
|
|
21443
21417
|
});
|
|
21444
21418
|
class Accumulate {
|
|
21445
21419
|
chainSpec;
|
|
@@ -21849,10 +21823,10 @@ class Accumulate {
|
|
|
21849
21823
|
}
|
|
21850
21824
|
}
|
|
21851
21825
|
|
|
21852
|
-
const ARGS_CODEC =
|
|
21853
|
-
timeslot:
|
|
21854
|
-
serviceId:
|
|
21855
|
-
transfersLength:
|
|
21826
|
+
const ARGS_CODEC = object({
|
|
21827
|
+
timeslot: varU32.asOpaque(),
|
|
21828
|
+
serviceId: varU32.asOpaque(),
|
|
21829
|
+
transfersLength: varU32,
|
|
21856
21830
|
});
|
|
21857
21831
|
var DeferredTransfersErrorCode;
|
|
21858
21832
|
(function (DeferredTransfersErrorCode) {
|
|
@@ -24581,7 +24555,7 @@ class TransitionHasher {
|
|
|
24581
24555
|
extrinsic(extrinsicView) {
|
|
24582
24556
|
// https://graypaper.fluffylabs.dev/#/cc517d7/0cfb000cfb00?v=0.6.5
|
|
24583
24557
|
const guaranteesCount = tryAsU32(extrinsicView.guarantees.view().length);
|
|
24584
|
-
const countEncoded = Encoder.encodeObject(
|
|
24558
|
+
const countEncoded = Encoder.encodeObject(varU32, guaranteesCount);
|
|
24585
24559
|
const guaranteesBlobs = extrinsicView.guarantees
|
|
24586
24560
|
.view()
|
|
24587
24561
|
.map((g) => g.view())
|
|
@@ -26295,7 +26269,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
26295
26269
|
startSameThread: startSameThread
|
|
26296
26270
|
});
|
|
26297
26271
|
|
|
26298
|
-
const importBlockResultCodec = (hashName) =>
|
|
26272
|
+
const importBlockResultCodec = (hashName) => custom({
|
|
26299
26273
|
name: `Result<${hashName}, string>`,
|
|
26300
26274
|
sizeHint: { bytes: 1, isExact: false },
|
|
26301
26275
|
}, (e, x) => {
|
|
@@ -26333,33 +26307,33 @@ const importBlockResultCodec = (hashName) => codec.custom({
|
|
|
26333
26307
|
const protocol = createProtocol("importer", {
|
|
26334
26308
|
toWorker: {
|
|
26335
26309
|
getStateEntries: {
|
|
26336
|
-
request:
|
|
26337
|
-
response:
|
|
26310
|
+
request: bytes(HASH_SIZE).asOpaque(),
|
|
26311
|
+
response: optional(StateEntries.Codec),
|
|
26338
26312
|
},
|
|
26339
26313
|
getBestStateRootHash: {
|
|
26340
|
-
request:
|
|
26341
|
-
response:
|
|
26314
|
+
request: nothing,
|
|
26315
|
+
response: bytes(HASH_SIZE).asOpaque(),
|
|
26342
26316
|
},
|
|
26343
26317
|
importBlock: {
|
|
26344
26318
|
request: Block.Codec.View,
|
|
26345
26319
|
response: importBlockResultCodec("HeaderHash"),
|
|
26346
26320
|
},
|
|
26347
26321
|
finish: {
|
|
26348
|
-
request:
|
|
26349
|
-
response:
|
|
26322
|
+
request: nothing,
|
|
26323
|
+
response: nothing,
|
|
26350
26324
|
},
|
|
26351
26325
|
},
|
|
26352
26326
|
fromWorker: {
|
|
26353
26327
|
bestHeaderAnnouncement: {
|
|
26354
26328
|
request: headerViewWithHashCodec,
|
|
26355
|
-
response:
|
|
26329
|
+
response: nothing,
|
|
26356
26330
|
},
|
|
26357
26331
|
},
|
|
26358
26332
|
});
|
|
26359
26333
|
class ImporterConfig {
|
|
26360
26334
|
pvm;
|
|
26361
|
-
static Codec =
|
|
26362
|
-
pvm:
|
|
26335
|
+
static Codec = Class(ImporterConfig, {
|
|
26336
|
+
pvm: u8.convert((i) => tryAsU8(i), (o) => {
|
|
26363
26337
|
if (o === PvmBackend.BuiltIn) {
|
|
26364
26338
|
return PvmBackend.BuiltIn;
|
|
26365
26339
|
}
|
|
@@ -26377,7 +26351,7 @@ class ImporterConfig {
|
|
|
26377
26351
|
}
|
|
26378
26352
|
}
|
|
26379
26353
|
|
|
26380
|
-
const WORKER = new URL("./bootstrap-importer.mjs"
|
|
26354
|
+
const WORKER = new URL(undefined("./bootstrap-importer.mjs"));
|
|
26381
26355
|
|
|
26382
26356
|
var index$2 = /*#__PURE__*/Object.freeze({
|
|
26383
26357
|
__proto__: null,
|
|
@@ -26824,11 +26798,11 @@ class TestState {
|
|
|
26824
26798
|
state_root: fromJson.bytes32(),
|
|
26825
26799
|
keyvals: json.array(StateKeyVal.fromJson),
|
|
26826
26800
|
};
|
|
26827
|
-
static Codec =
|
|
26828
|
-
state_root:
|
|
26829
|
-
keyvals:
|
|
26830
|
-
key:
|
|
26831
|
-
value:
|
|
26801
|
+
static Codec = object({
|
|
26802
|
+
state_root: bytes(HASH_SIZE).asOpaque(),
|
|
26803
|
+
keyvals: sequenceVarLen(object({
|
|
26804
|
+
key: bytes(TRUNCATED_HASH_SIZE),
|
|
26805
|
+
value: blob,
|
|
26832
26806
|
})),
|
|
26833
26807
|
});
|
|
26834
26808
|
state_root;
|
|
@@ -26839,7 +26813,7 @@ class StateTransitionGenesis {
|
|
|
26839
26813
|
header: headerFromJson,
|
|
26840
26814
|
state: TestState.fromJson,
|
|
26841
26815
|
};
|
|
26842
|
-
static Codec =
|
|
26816
|
+
static Codec = object({
|
|
26843
26817
|
header: Header.Codec,
|
|
26844
26818
|
state: TestState.Codec,
|
|
26845
26819
|
});
|
|
@@ -26852,7 +26826,7 @@ class StateTransition {
|
|
|
26852
26826
|
post_state: TestState.fromJson,
|
|
26853
26827
|
block: blockFromJson(tinyChainSpec),
|
|
26854
26828
|
};
|
|
26855
|
-
static Codec =
|
|
26829
|
+
static Codec = object({
|
|
26856
26830
|
pre_state: TestState.Codec,
|
|
26857
26831
|
block: Block.Codec,
|
|
26858
26832
|
post_state: TestState.Codec,
|