@typeberry/lib 0.5.0-d7595f1 → 0.5.1-1dda9d6
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 +645 -604
- package/index.d.ts +310 -40
- package/{index.js → index.mjs} +645 -604
- package/package.json +5 -3
package/index.cjs
CHANGED
|
@@ -1584,7 +1584,7 @@ function addSizeHints(a, b) {
|
|
|
1584
1584
|
};
|
|
1585
1585
|
}
|
|
1586
1586
|
const DEFAULT_START_LENGTH = 512; // 512B
|
|
1587
|
-
const MAX_LENGTH$1 =
|
|
1587
|
+
const MAX_LENGTH$1 = 20 * 1024 * 1024; // 20MB
|
|
1588
1588
|
/**
|
|
1589
1589
|
* JAM encoder.
|
|
1590
1590
|
*/
|
|
@@ -1937,7 +1937,7 @@ class Encoder {
|
|
|
1937
1937
|
if (options.silent) {
|
|
1938
1938
|
return;
|
|
1939
1939
|
}
|
|
1940
|
-
throw new Error(`The encoded size would reach the maximum of ${MAX_LENGTH$1}.`);
|
|
1940
|
+
throw new Error(`The encoded size (${newLength}) would reach the maximum of ${MAX_LENGTH$1}.`);
|
|
1941
1941
|
}
|
|
1942
1942
|
if (newLength > this.destination.length) {
|
|
1943
1943
|
// we can try to resize the underlying buffer
|
|
@@ -2382,6 +2382,48 @@ 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
|
+
};
|
|
2385
2427
|
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
2386
2428
|
const select = ({ name, sizeHint, }, chooser) => {
|
|
2387
2429
|
const Self = chooser(null);
|
|
@@ -2557,24 +2599,59 @@ var descriptors = /*#__PURE__*/Object.freeze({
|
|
|
2557
2599
|
u32: u32,
|
|
2558
2600
|
u64: u64,
|
|
2559
2601
|
u8: u8,
|
|
2602
|
+
union: union,
|
|
2560
2603
|
varU32: varU32,
|
|
2561
2604
|
varU64: varU64
|
|
2562
2605
|
});
|
|
2563
2606
|
|
|
2607
|
+
const codec = descriptors;
|
|
2608
|
+
|
|
2564
2609
|
var index$x = /*#__PURE__*/Object.freeze({
|
|
2565
2610
|
__proto__: null,
|
|
2611
|
+
Class: Class,
|
|
2566
2612
|
Decoder: Decoder,
|
|
2567
2613
|
Descriptor: Descriptor,
|
|
2568
2614
|
Encoder: Encoder,
|
|
2569
2615
|
EndOfDataError: EndOfDataError,
|
|
2570
2616
|
ObjectView: ObjectView,
|
|
2571
2617
|
SequenceView: SequenceView,
|
|
2618
|
+
TYPICAL_DICTIONARY_LENGTH: TYPICAL_DICTIONARY_LENGTH,
|
|
2572
2619
|
ViewField: ViewField,
|
|
2573
2620
|
addSizeHints: addSizeHints,
|
|
2574
|
-
|
|
2621
|
+
bitVecFixLen: bitVecFixLen,
|
|
2622
|
+
bitVecVarLen: bitVecVarLen,
|
|
2623
|
+
blob: blob,
|
|
2624
|
+
bool: bool,
|
|
2625
|
+
bytes: bytes,
|
|
2626
|
+
codec: codec,
|
|
2627
|
+
custom: custom,
|
|
2575
2628
|
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,
|
|
2576
2645
|
tryAsExactBytes: tryAsExactBytes,
|
|
2577
|
-
|
|
2646
|
+
u16: u16,
|
|
2647
|
+
u24: u24,
|
|
2648
|
+
u32: u32,
|
|
2649
|
+
u64: u64,
|
|
2650
|
+
u8: u8,
|
|
2651
|
+
union: union,
|
|
2652
|
+
validateLength: validateLength,
|
|
2653
|
+
varU32: varU32,
|
|
2654
|
+
varU64: varU64
|
|
2578
2655
|
});
|
|
2579
2656
|
|
|
2580
2657
|
//#region rolldown:runtime
|
|
@@ -5785,7 +5862,7 @@ function codecWithContext(chooser) {
|
|
|
5785
5862
|
const defaultContext = fullChainSpec;
|
|
5786
5863
|
const { name, sizeHint } = chooser(defaultContext);
|
|
5787
5864
|
const cache = new Map();
|
|
5788
|
-
return select({
|
|
5865
|
+
return codec.select({
|
|
5789
5866
|
name,
|
|
5790
5867
|
sizeHint: { bytes: sizeHint.bytes, isExact: false },
|
|
5791
5868
|
}, (context) => {
|
|
@@ -5812,9 +5889,9 @@ function codecWithContext(chooser) {
|
|
|
5812
5889
|
/** Codec for a known-size array with length validation. */
|
|
5813
5890
|
const codecKnownSizeArray = (val, options, _id) => {
|
|
5814
5891
|
if ("fixedLength" in options) {
|
|
5815
|
-
return readonlyArray(sequenceFixLen(val, options.fixedLength)).convert(seeThrough, asKnownSize);
|
|
5892
|
+
return codec.readonlyArray(codec.sequenceFixLen(val, options.fixedLength)).convert(seeThrough, asKnownSize);
|
|
5816
5893
|
}
|
|
5817
|
-
return readonlyArray(sequenceVarLen(val, options)).convert(seeThrough, asKnownSize);
|
|
5894
|
+
return codec.readonlyArray(codec.sequenceVarLen(val, options)).convert(seeThrough, asKnownSize);
|
|
5818
5895
|
};
|
|
5819
5896
|
/** Codec for a fixed-size array with length validation. */
|
|
5820
5897
|
const codecFixedSizeArray = (val, len) => {
|
|
@@ -5823,7 +5900,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
5823
5900
|
throw new Error(`[${val.name}] Invalid size of fixed-size array. Got ${actual}, expected: ${len}`);
|
|
5824
5901
|
}
|
|
5825
5902
|
};
|
|
5826
|
-
return sequenceFixLen(val, len).convert((i) => {
|
|
5903
|
+
return codec.sequenceFixLen(val, len).convert((i) => {
|
|
5827
5904
|
checkLength(i.length);
|
|
5828
5905
|
return i;
|
|
5829
5906
|
}, (o) => {
|
|
@@ -5832,7 +5909,7 @@ const codecFixedSizeArray = (val, len) => {
|
|
|
5832
5909
|
});
|
|
5833
5910
|
};
|
|
5834
5911
|
/** Codec for a hash-dictionary. */
|
|
5835
|
-
const codecHashDictionary = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
|
|
5912
|
+
const codecHashDictionary = (value, extractKey, { typicalLength = codec.TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
|
|
5836
5913
|
return Descriptor.new(`HashDictionary<${value.name}>[?]`, {
|
|
5837
5914
|
bytes: typicalLength * value.sizeHint.bytes,
|
|
5838
5915
|
isExact: false,
|
|
@@ -5886,13 +5963,13 @@ class AvailabilityAssurance extends WithDebug {
|
|
|
5886
5963
|
bitfield;
|
|
5887
5964
|
validatorIndex;
|
|
5888
5965
|
signature;
|
|
5889
|
-
static Codec = Class(AvailabilityAssurance, {
|
|
5890
|
-
anchor: bytes(HASH_SIZE).asOpaque(),
|
|
5966
|
+
static Codec = codec.Class(AvailabilityAssurance, {
|
|
5967
|
+
anchor: codec.bytes(HASH_SIZE).asOpaque(),
|
|
5891
5968
|
bitfield: codecWithContext((context) => {
|
|
5892
|
-
return bitVecFixLen(context.coresCount);
|
|
5969
|
+
return codec.bitVecFixLen(context.coresCount);
|
|
5893
5970
|
}),
|
|
5894
|
-
validatorIndex: u16.asOpaque(),
|
|
5895
|
-
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
5971
|
+
validatorIndex: codec.u16.asOpaque(),
|
|
5972
|
+
signature: codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
5896
5973
|
});
|
|
5897
5974
|
static create({ anchor, bitfield, validatorIndex, signature }) {
|
|
5898
5975
|
return new AvailabilityAssurance(anchor, bitfield, validatorIndex, signature);
|
|
@@ -5977,11 +6054,11 @@ class Fault extends WithDebug {
|
|
|
5977
6054
|
wasConsideredValid;
|
|
5978
6055
|
key;
|
|
5979
6056
|
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(),
|
|
6057
|
+
static Codec = codec.Class(Fault, {
|
|
6058
|
+
workReportHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6059
|
+
wasConsideredValid: codec.bool,
|
|
6060
|
+
key: codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
6061
|
+
signature: codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
5985
6062
|
});
|
|
5986
6063
|
static create({ workReportHash, wasConsideredValid, key, signature }) {
|
|
5987
6064
|
return new Fault(workReportHash, wasConsideredValid, key, signature);
|
|
@@ -6009,10 +6086,10 @@ class Culprit extends WithDebug {
|
|
|
6009
6086
|
workReportHash;
|
|
6010
6087
|
key;
|
|
6011
6088
|
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(),
|
|
6089
|
+
static Codec = codec.Class(Culprit, {
|
|
6090
|
+
workReportHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6091
|
+
key: codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
6092
|
+
signature: codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
6016
6093
|
});
|
|
6017
6094
|
static create({ workReportHash, key, signature }) {
|
|
6018
6095
|
return new Culprit(workReportHash, key, signature);
|
|
@@ -6037,10 +6114,10 @@ class Judgement extends WithDebug {
|
|
|
6037
6114
|
isWorkReportValid;
|
|
6038
6115
|
index;
|
|
6039
6116
|
signature;
|
|
6040
|
-
static Codec = Class(Judgement, {
|
|
6041
|
-
isWorkReportValid: bool,
|
|
6042
|
-
index: u16.asOpaque(),
|
|
6043
|
-
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
6117
|
+
static Codec = codec.Class(Judgement, {
|
|
6118
|
+
isWorkReportValid: codec.bool,
|
|
6119
|
+
index: codec.u16.asOpaque(),
|
|
6120
|
+
signature: codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
6044
6121
|
});
|
|
6045
6122
|
static create({ isWorkReportValid, index, signature }) {
|
|
6046
6123
|
return new Judgement(isWorkReportValid, index, signature);
|
|
@@ -6069,11 +6146,12 @@ class Verdict extends WithDebug {
|
|
|
6069
6146
|
workReportHash;
|
|
6070
6147
|
votesEpoch;
|
|
6071
6148
|
votes;
|
|
6072
|
-
static Codec = Class(Verdict, {
|
|
6073
|
-
workReportHash: bytes(HASH_SIZE).asOpaque(),
|
|
6074
|
-
votesEpoch: u32.asOpaque(),
|
|
6149
|
+
static Codec = codec.Class(Verdict, {
|
|
6150
|
+
workReportHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6151
|
+
votesEpoch: codec.u32.asOpaque(),
|
|
6075
6152
|
votes: codecWithContext((context) => {
|
|
6076
|
-
return
|
|
6153
|
+
return codec
|
|
6154
|
+
.readonlyArray(codec.sequenceFixLen(Judgement.Codec, context.validatorsSuperMajority))
|
|
6077
6155
|
.convert(seeThrough, asKnownSize);
|
|
6078
6156
|
}),
|
|
6079
6157
|
});
|
|
@@ -6115,10 +6193,10 @@ class DisputesExtrinsic extends WithDebug {
|
|
|
6115
6193
|
verdicts;
|
|
6116
6194
|
culprits;
|
|
6117
6195
|
faults;
|
|
6118
|
-
static Codec = Class(DisputesExtrinsic, {
|
|
6119
|
-
verdicts: sequenceVarLen(Verdict.Codec),
|
|
6120
|
-
culprits: sequenceVarLen(Culprit.Codec),
|
|
6121
|
-
faults: sequenceVarLen(Fault.Codec),
|
|
6196
|
+
static Codec = codec.Class(DisputesExtrinsic, {
|
|
6197
|
+
verdicts: codec.sequenceVarLen(Verdict.Codec),
|
|
6198
|
+
culprits: codec.sequenceVarLen(Culprit.Codec),
|
|
6199
|
+
faults: codec.sequenceVarLen(Fault.Codec),
|
|
6122
6200
|
});
|
|
6123
6201
|
static create({ verdicts, culprits, faults }) {
|
|
6124
6202
|
return new DisputesExtrinsic(verdicts, culprits, faults);
|
|
@@ -6169,9 +6247,9 @@ var disputes = /*#__PURE__*/Object.freeze({
|
|
|
6169
6247
|
class WorkPackageInfo extends WithDebug {
|
|
6170
6248
|
workPackageHash;
|
|
6171
6249
|
segmentTreeRoot;
|
|
6172
|
-
static Codec = Class(WorkPackageInfo, {
|
|
6173
|
-
workPackageHash: bytes(HASH_SIZE).asOpaque(),
|
|
6174
|
-
segmentTreeRoot: bytes(HASH_SIZE).asOpaque(),
|
|
6250
|
+
static Codec = codec.Class(WorkPackageInfo, {
|
|
6251
|
+
workPackageHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6252
|
+
segmentTreeRoot: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6175
6253
|
});
|
|
6176
6254
|
constructor(
|
|
6177
6255
|
/** Hash of the described work package. */
|
|
@@ -6199,13 +6277,13 @@ class RefineContext extends WithDebug {
|
|
|
6199
6277
|
lookupAnchor;
|
|
6200
6278
|
lookupAnchorSlot;
|
|
6201
6279
|
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()),
|
|
6280
|
+
static Codec = codec.Class(RefineContext, {
|
|
6281
|
+
anchor: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6282
|
+
stateRoot: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6283
|
+
beefyRoot: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6284
|
+
lookupAnchor: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6285
|
+
lookupAnchorSlot: codec.u32.asOpaque(),
|
|
6286
|
+
prerequisites: codec.sequenceVarLen(codec.bytes(HASH_SIZE).asOpaque()),
|
|
6209
6287
|
});
|
|
6210
6288
|
static create({ anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites, }) {
|
|
6211
6289
|
return new RefineContext(anchor, stateRoot, beefyRoot, lookupAnchor, lookupAnchorSlot, prerequisites);
|
|
@@ -6257,9 +6335,9 @@ const tryAsSegmentIndex = (v) => asOpaqueType(tryAsU16(v));
|
|
|
6257
6335
|
class ImportSpec extends WithDebug {
|
|
6258
6336
|
treeRoot;
|
|
6259
6337
|
index;
|
|
6260
|
-
static Codec = Class(ImportSpec, {
|
|
6261
|
-
treeRoot: bytes(HASH_SIZE),
|
|
6262
|
-
index: u16.asOpaque(),
|
|
6338
|
+
static Codec = codec.Class(ImportSpec, {
|
|
6339
|
+
treeRoot: codec.bytes(HASH_SIZE),
|
|
6340
|
+
index: codec.u16.asOpaque(),
|
|
6263
6341
|
});
|
|
6264
6342
|
static create({ treeRoot, index }) {
|
|
6265
6343
|
return new ImportSpec(treeRoot, index);
|
|
@@ -6281,9 +6359,9 @@ class ImportSpec extends WithDebug {
|
|
|
6281
6359
|
class WorkItemExtrinsicSpec extends WithDebug {
|
|
6282
6360
|
hash;
|
|
6283
6361
|
len;
|
|
6284
|
-
static Codec = Class(WorkItemExtrinsicSpec, {
|
|
6285
|
-
hash: bytes(HASH_SIZE).asOpaque(),
|
|
6286
|
-
len: u32,
|
|
6362
|
+
static Codec = codec.Class(WorkItemExtrinsicSpec, {
|
|
6363
|
+
hash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6364
|
+
len: codec.u32,
|
|
6287
6365
|
});
|
|
6288
6366
|
static create({ hash, len }) {
|
|
6289
6367
|
return new WorkItemExtrinsicSpec(hash, len);
|
|
@@ -6313,7 +6391,7 @@ function workItemExtrinsicsCodec(workItems) {
|
|
|
6313
6391
|
if (sum.overflow) {
|
|
6314
6392
|
throw new Error("Unable to create a decoder, because the length of extrinsics overflows!");
|
|
6315
6393
|
}
|
|
6316
|
-
return custom({
|
|
6394
|
+
return codec.custom({
|
|
6317
6395
|
name: "WorkItemExtrinsics",
|
|
6318
6396
|
sizeHint: { bytes: sum.value, isExact: true },
|
|
6319
6397
|
}, (e, val) => {
|
|
@@ -6343,19 +6421,19 @@ class WorkItem extends WithDebug {
|
|
|
6343
6421
|
importSegments;
|
|
6344
6422
|
extrinsic;
|
|
6345
6423
|
exportCount;
|
|
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,
|
|
6424
|
+
static Codec = codec.Class(WorkItem, {
|
|
6425
|
+
service: codec.u32.asOpaque(),
|
|
6426
|
+
codeHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6427
|
+
refineGasLimit: codec.u64.asOpaque(),
|
|
6428
|
+
accumulateGasLimit: codec.u64.asOpaque(),
|
|
6429
|
+
exportCount: codec.u16,
|
|
6430
|
+
payload: codec.blob,
|
|
6353
6431
|
importSegments: codecKnownSizeArray(ImportSpec.Codec, {
|
|
6354
6432
|
minLength: 0,
|
|
6355
6433
|
maxLength: MAX_NUMBER_OF_SEGMENTS,
|
|
6356
6434
|
typicalLength: MAX_NUMBER_OF_SEGMENTS,
|
|
6357
6435
|
}),
|
|
6358
|
-
extrinsic: sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
6436
|
+
extrinsic: codec.sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
6359
6437
|
});
|
|
6360
6438
|
static create({ service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount, }) {
|
|
6361
6439
|
return new WorkItem(service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount);
|
|
@@ -6428,13 +6506,13 @@ class WorkPackage extends WithDebug {
|
|
|
6428
6506
|
parametrization;
|
|
6429
6507
|
context;
|
|
6430
6508
|
items;
|
|
6431
|
-
static Codec = Class(WorkPackage, {
|
|
6432
|
-
authCodeHost: u32.asOpaque(),
|
|
6433
|
-
authCodeHash: bytes(HASH_SIZE).asOpaque(),
|
|
6509
|
+
static Codec = codec.Class(WorkPackage, {
|
|
6510
|
+
authCodeHost: codec.u32.asOpaque(),
|
|
6511
|
+
authCodeHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6434
6512
|
context: RefineContext.Codec,
|
|
6435
|
-
authorization: blob,
|
|
6436
|
-
parametrization: blob,
|
|
6437
|
-
items: sequenceVarLen(WorkItem.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
6513
|
+
authorization: codec.blob,
|
|
6514
|
+
parametrization: codec.blob,
|
|
6515
|
+
items: codec.sequenceVarLen(WorkItem.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
6438
6516
|
});
|
|
6439
6517
|
static create({ authorization, authCodeHost, authCodeHash, parametrization, context, items, }) {
|
|
6440
6518
|
return new WorkPackage(authorization, authCodeHost, authCodeHash, parametrization, context, items);
|
|
@@ -6497,30 +6575,22 @@ var WorkExecResultKind;
|
|
|
6497
6575
|
class WorkExecResult extends WithDebug {
|
|
6498
6576
|
kind;
|
|
6499
6577
|
okBlob;
|
|
6500
|
-
static Codec =
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
}
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
return
|
|
6513
|
-
}
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
}
|
|
6517
|
-
return new WorkExecResult(kind);
|
|
6518
|
-
}, (s) => {
|
|
6519
|
-
const kind = s.decoder.varU32();
|
|
6520
|
-
if (kind === WorkExecResultKind.ok) {
|
|
6521
|
-
s.bytesBlob();
|
|
6522
|
-
}
|
|
6523
|
-
});
|
|
6578
|
+
static Codec = codec
|
|
6579
|
+
.union("WorkExecResult", {
|
|
6580
|
+
[WorkExecResultKind.ok]: codec.object({ okBlob: codec.blob }),
|
|
6581
|
+
[WorkExecResultKind.outOfGas]: codec.object({}),
|
|
6582
|
+
[WorkExecResultKind.panic]: codec.object({}),
|
|
6583
|
+
[WorkExecResultKind.incorrectNumberOfExports]: codec.object({}),
|
|
6584
|
+
[WorkExecResultKind.digestTooBig]: codec.object({}),
|
|
6585
|
+
[WorkExecResultKind.badCode]: codec.object({}),
|
|
6586
|
+
[WorkExecResultKind.codeOversize]: codec.object({}),
|
|
6587
|
+
})
|
|
6588
|
+
.convert((x) => {
|
|
6589
|
+
if (x.kind === WorkExecResultKind.ok) {
|
|
6590
|
+
return { kind: WorkExecResultKind.ok, okBlob: x.okBlob ?? BytesBlob.empty() };
|
|
6591
|
+
}
|
|
6592
|
+
return { kind: x.kind };
|
|
6593
|
+
}, (x) => new WorkExecResult(x.kind, x.kind === WorkExecResultKind.ok ? x.okBlob : null));
|
|
6524
6594
|
constructor(
|
|
6525
6595
|
/** The execution result tag. */
|
|
6526
6596
|
kind,
|
|
@@ -6544,12 +6614,12 @@ class WorkRefineLoad extends WithDebug {
|
|
|
6544
6614
|
extrinsicCount;
|
|
6545
6615
|
extrinsicSize;
|
|
6546
6616
|
exportedSegments;
|
|
6547
|
-
static Codec = Class(WorkRefineLoad, {
|
|
6548
|
-
gasUsed: varU64.asOpaque(),
|
|
6549
|
-
importedSegments: varU32,
|
|
6550
|
-
extrinsicCount: varU32,
|
|
6551
|
-
extrinsicSize: varU32,
|
|
6552
|
-
exportedSegments: varU32,
|
|
6617
|
+
static Codec = codec.Class(WorkRefineLoad, {
|
|
6618
|
+
gasUsed: codec.varU64.asOpaque(),
|
|
6619
|
+
importedSegments: codec.varU32,
|
|
6620
|
+
extrinsicCount: codec.varU32,
|
|
6621
|
+
extrinsicSize: codec.varU32,
|
|
6622
|
+
exportedSegments: codec.varU32,
|
|
6553
6623
|
});
|
|
6554
6624
|
static create({ gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments, }) {
|
|
6555
6625
|
return new WorkRefineLoad(gasUsed, importedSegments, extrinsicCount, extrinsicSize, exportedSegments);
|
|
@@ -6585,11 +6655,11 @@ class WorkResult {
|
|
|
6585
6655
|
gas;
|
|
6586
6656
|
result;
|
|
6587
6657
|
load;
|
|
6588
|
-
static Codec = Class(WorkResult, {
|
|
6589
|
-
serviceId: u32.asOpaque(),
|
|
6590
|
-
codeHash: bytes(HASH_SIZE).asOpaque(),
|
|
6591
|
-
payloadHash: bytes(HASH_SIZE),
|
|
6592
|
-
gas: u64.asOpaque(),
|
|
6658
|
+
static Codec = codec.Class(WorkResult, {
|
|
6659
|
+
serviceId: codec.u32.asOpaque(),
|
|
6660
|
+
codeHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6661
|
+
payloadHash: codec.bytes(HASH_SIZE),
|
|
6662
|
+
gas: codec.u64.asOpaque(),
|
|
6593
6663
|
result: WorkExecResult.Codec,
|
|
6594
6664
|
load: WorkRefineLoad.Codec,
|
|
6595
6665
|
});
|
|
@@ -6654,12 +6724,12 @@ class WorkPackageSpec extends WithDebug {
|
|
|
6654
6724
|
erasureRoot;
|
|
6655
6725
|
exportsRoot;
|
|
6656
6726
|
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,
|
|
6727
|
+
static Codec = codec.Class(WorkPackageSpec, {
|
|
6728
|
+
hash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6729
|
+
length: codec.u32,
|
|
6730
|
+
erasureRoot: codec.bytes(HASH_SIZE),
|
|
6731
|
+
exportsRoot: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6732
|
+
exportsCount: codec.u16,
|
|
6663
6733
|
});
|
|
6664
6734
|
static create({ hash, length, erasureRoot, exportsRoot, exportsCount }) {
|
|
6665
6735
|
return new WorkPackageSpec(hash, length, erasureRoot, exportsRoot, exportsCount);
|
|
@@ -6697,20 +6767,20 @@ class WorkReport extends WithDebug {
|
|
|
6697
6767
|
segmentRootLookup;
|
|
6698
6768
|
results;
|
|
6699
6769
|
authorizationGasUsed;
|
|
6700
|
-
static Codec = Class(WorkReport, {
|
|
6770
|
+
static Codec = codec.Class(WorkReport, {
|
|
6701
6771
|
workPackageSpec: WorkPackageSpec.Codec,
|
|
6702
6772
|
context: RefineContext.Codec,
|
|
6703
|
-
coreIndex: varU32.convert((o) => tryAsU32(o), (i) => {
|
|
6773
|
+
coreIndex: codec.varU32.convert((o) => tryAsU32(o), (i) => {
|
|
6704
6774
|
if (!isU16(i)) {
|
|
6705
6775
|
throw new Error(`Core index exceeds U16: ${i}`);
|
|
6706
6776
|
}
|
|
6707
6777
|
return tryAsCoreIndex(i);
|
|
6708
6778
|
}),
|
|
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))),
|
|
6779
|
+
authorizerHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6780
|
+
authorizationGasUsed: codec.varU64.asOpaque(),
|
|
6781
|
+
authorizationOutput: codec.blob,
|
|
6782
|
+
segmentRootLookup: codec.readonlyArray(codec.sequenceVarLen(WorkPackageInfo.Codec)),
|
|
6783
|
+
results: codec.sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
6714
6784
|
});
|
|
6715
6785
|
static create({ workPackageSpec, context, coreIndex, authorizerHash, authorizationOutput, segmentRootLookup, results, authorizationGasUsed, }) {
|
|
6716
6786
|
return new WorkReport(workPackageSpec, context, coreIndex, authorizerHash, authorizationOutput, segmentRootLookup, results, authorizationGasUsed);
|
|
@@ -6758,9 +6828,9 @@ const REQUIRED_CREDENTIALS_RANGE = [2, 3];
|
|
|
6758
6828
|
class Credential extends WithDebug {
|
|
6759
6829
|
validatorIndex;
|
|
6760
6830
|
signature;
|
|
6761
|
-
static Codec = Class(Credential, {
|
|
6762
|
-
validatorIndex: u16.asOpaque(),
|
|
6763
|
-
signature: bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
6831
|
+
static Codec = codec.Class(Credential, {
|
|
6832
|
+
validatorIndex: codec.u16.asOpaque(),
|
|
6833
|
+
signature: codec.bytes(ED25519_SIGNATURE_BYTES).asOpaque(),
|
|
6764
6834
|
});
|
|
6765
6835
|
static create({ validatorIndex, signature }) {
|
|
6766
6836
|
return new Credential(validatorIndex, signature);
|
|
@@ -6778,15 +6848,15 @@ class Credential extends WithDebug {
|
|
|
6778
6848
|
/**
|
|
6779
6849
|
* Tuple of work-report, a credential and it's corresponding timeslot.
|
|
6780
6850
|
*
|
|
6781
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
6851
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/15df00150301?v=0.7.2
|
|
6782
6852
|
*/
|
|
6783
6853
|
class ReportGuarantee extends WithDebug {
|
|
6784
6854
|
report;
|
|
6785
6855
|
slot;
|
|
6786
6856
|
credentials;
|
|
6787
|
-
static Codec = Class(ReportGuarantee, {
|
|
6857
|
+
static Codec = codec.Class(ReportGuarantee, {
|
|
6788
6858
|
report: WorkReport.Codec,
|
|
6789
|
-
slot: u32.asOpaque(),
|
|
6859
|
+
slot: codec.u32.asOpaque(),
|
|
6790
6860
|
credentials: codecKnownSizeArray(Credential.Codec, {
|
|
6791
6861
|
minLength: REQUIRED_CREDENTIALS_RANGE[0],
|
|
6792
6862
|
maxLength: REQUIRED_CREDENTIALS_RANGE[1],
|
|
@@ -6806,7 +6876,7 @@ class ReportGuarantee extends WithDebug {
|
|
|
6806
6876
|
* validator index and a signature.
|
|
6807
6877
|
* Credentials must be ordered by their validator index.
|
|
6808
6878
|
*
|
|
6809
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
6879
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/152b01152d01?v=0.7.2
|
|
6810
6880
|
*/
|
|
6811
6881
|
credentials) {
|
|
6812
6882
|
super();
|
|
@@ -6838,10 +6908,10 @@ function tryAsTicketAttempt(x) {
|
|
|
6838
6908
|
class SignedTicket extends WithDebug {
|
|
6839
6909
|
attempt;
|
|
6840
6910
|
signature;
|
|
6841
|
-
static Codec = Class(SignedTicket, {
|
|
6911
|
+
static Codec = codec.Class(SignedTicket, {
|
|
6842
6912
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
6843
|
-
attempt: u8.asOpaque(),
|
|
6844
|
-
signature: bytes(BANDERSNATCH_PROOF_BYTES).asOpaque(),
|
|
6913
|
+
attempt: codec.u8.asOpaque(),
|
|
6914
|
+
signature: codec.bytes(BANDERSNATCH_PROOF_BYTES).asOpaque(),
|
|
6845
6915
|
});
|
|
6846
6916
|
static create({ attempt, signature }) {
|
|
6847
6917
|
return new SignedTicket(attempt, signature);
|
|
@@ -6860,10 +6930,10 @@ class SignedTicket extends WithDebug {
|
|
|
6860
6930
|
class Ticket extends WithDebug {
|
|
6861
6931
|
id;
|
|
6862
6932
|
attempt;
|
|
6863
|
-
static Codec = Class(Ticket, {
|
|
6864
|
-
id: bytes(HASH_SIZE),
|
|
6933
|
+
static Codec = codec.Class(Ticket, {
|
|
6934
|
+
id: codec.bytes(HASH_SIZE),
|
|
6865
6935
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
6866
|
-
attempt: u8.asOpaque(),
|
|
6936
|
+
attempt: codec.u8.asOpaque(),
|
|
6867
6937
|
});
|
|
6868
6938
|
static create({ id, attempt }) {
|
|
6869
6939
|
return new Ticket(id, attempt);
|
|
@@ -6905,9 +6975,9 @@ var tickets = /*#__PURE__*/Object.freeze({
|
|
|
6905
6975
|
class ValidatorKeys extends WithDebug {
|
|
6906
6976
|
bandersnatch;
|
|
6907
6977
|
ed25519;
|
|
6908
|
-
static Codec = Class(ValidatorKeys, {
|
|
6909
|
-
bandersnatch: bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
6910
|
-
ed25519: bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
6978
|
+
static Codec = codec.Class(ValidatorKeys, {
|
|
6979
|
+
bandersnatch: codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
6980
|
+
ed25519: codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
6911
6981
|
});
|
|
6912
6982
|
static create({ bandersnatch, ed25519 }) {
|
|
6913
6983
|
return new ValidatorKeys(bandersnatch, ed25519);
|
|
@@ -6924,7 +6994,7 @@ class ValidatorKeys extends WithDebug {
|
|
|
6924
6994
|
}
|
|
6925
6995
|
class TicketsMarker extends WithDebug {
|
|
6926
6996
|
tickets;
|
|
6927
|
-
static Codec = Class(TicketsMarker, {
|
|
6997
|
+
static Codec = codec.Class(TicketsMarker, {
|
|
6928
6998
|
tickets: codecPerEpochBlock(Ticket.Codec),
|
|
6929
6999
|
});
|
|
6930
7000
|
static create({ tickets }) {
|
|
@@ -6946,9 +7016,9 @@ class EpochMarker extends WithDebug {
|
|
|
6946
7016
|
entropy;
|
|
6947
7017
|
ticketsEntropy;
|
|
6948
7018
|
validators;
|
|
6949
|
-
static Codec = Class(EpochMarker, {
|
|
6950
|
-
entropy: bytes(HASH_SIZE).asOpaque(),
|
|
6951
|
-
ticketsEntropy: bytes(HASH_SIZE).asOpaque(),
|
|
7019
|
+
static Codec = codec.Class(EpochMarker, {
|
|
7020
|
+
entropy: codec.bytes(HASH_SIZE).asOpaque(),
|
|
7021
|
+
ticketsEntropy: codec.bytes(HASH_SIZE).asOpaque(),
|
|
6952
7022
|
validators: codecPerValidator(ValidatorKeys.Codec),
|
|
6953
7023
|
});
|
|
6954
7024
|
static create({ entropy, ticketsEntropy, validators }) {
|
|
@@ -6985,17 +7055,17 @@ const encodeUnsealedHeader = (view) => {
|
|
|
6985
7055
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/0c66000c7200?v=0.7.2
|
|
6986
7056
|
*/
|
|
6987
7057
|
class Header extends WithDebug {
|
|
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(),
|
|
7058
|
+
static Codec = codec.Class(Header, {
|
|
7059
|
+
parentHeaderHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
7060
|
+
priorStateRoot: codec.bytes(HASH_SIZE).asOpaque(),
|
|
7061
|
+
extrinsicHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
7062
|
+
timeSlotIndex: codec.u32.asOpaque(),
|
|
7063
|
+
epochMarker: codec.optional(EpochMarker.Codec),
|
|
7064
|
+
ticketsMarker: codec.optional(TicketsMarker.Codec),
|
|
7065
|
+
bandersnatchBlockAuthorIndex: codec.u16.asOpaque(),
|
|
7066
|
+
entropySource: codec.bytes(BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
7067
|
+
offendersMarker: codec.sequenceVarLen(codec.bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
7068
|
+
seal: codec.bytes(BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
6999
7069
|
});
|
|
7000
7070
|
static create(h) {
|
|
7001
7071
|
return Object.assign(Header.empty(), h);
|
|
@@ -7050,8 +7120,8 @@ class Header extends WithDebug {
|
|
|
7050
7120
|
* `DescriptorRecord` or `CodecRecord` for some reason.
|
|
7051
7121
|
*/
|
|
7052
7122
|
class HeaderViewWithHash extends WithHash {
|
|
7053
|
-
static Codec = Class(HeaderViewWithHash, {
|
|
7054
|
-
hash: bytes(HASH_SIZE).asOpaque(),
|
|
7123
|
+
static Codec = codec.Class(HeaderViewWithHash, {
|
|
7124
|
+
hash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
7055
7125
|
data: Header.Codec.View,
|
|
7056
7126
|
});
|
|
7057
7127
|
static create({ hash, data }) {
|
|
@@ -7069,9 +7139,9 @@ const headerViewWithHashCodec = HeaderViewWithHash.Codec;
|
|
|
7069
7139
|
class Preimage extends WithDebug {
|
|
7070
7140
|
requester;
|
|
7071
7141
|
blob;
|
|
7072
|
-
static Codec = Class(Preimage, {
|
|
7073
|
-
requester: u32.asOpaque(),
|
|
7074
|
-
blob: blob,
|
|
7142
|
+
static Codec = codec.Class(Preimage, {
|
|
7143
|
+
requester: codec.u32.asOpaque(),
|
|
7144
|
+
blob: codec.blob,
|
|
7075
7145
|
});
|
|
7076
7146
|
static create({ requester, blob }) {
|
|
7077
7147
|
return new Preimage(requester, blob);
|
|
@@ -7086,7 +7156,7 @@ class Preimage extends WithDebug {
|
|
|
7086
7156
|
this.blob = blob;
|
|
7087
7157
|
}
|
|
7088
7158
|
}
|
|
7089
|
-
const preimagesExtrinsicCodec = sequenceVarLen(Preimage.Codec);
|
|
7159
|
+
const preimagesExtrinsicCodec = codec.sequenceVarLen(Preimage.Codec);
|
|
7090
7160
|
|
|
7091
7161
|
var preimage = /*#__PURE__*/Object.freeze({
|
|
7092
7162
|
__proto__: null,
|
|
@@ -7107,7 +7177,7 @@ class Extrinsic extends WithDebug {
|
|
|
7107
7177
|
guarantees;
|
|
7108
7178
|
assurances;
|
|
7109
7179
|
disputes;
|
|
7110
|
-
static Codec = Class(Extrinsic, {
|
|
7180
|
+
static Codec = codec.Class(Extrinsic, {
|
|
7111
7181
|
tickets: ticketsExtrinsicCodec,
|
|
7112
7182
|
preimages: preimagesExtrinsicCodec,
|
|
7113
7183
|
guarantees: guaranteesExtrinsicCodec,
|
|
@@ -7160,7 +7230,7 @@ class Extrinsic extends WithDebug {
|
|
|
7160
7230
|
class Block extends WithDebug {
|
|
7161
7231
|
header;
|
|
7162
7232
|
extrinsic;
|
|
7163
|
-
static Codec = Class(Block, {
|
|
7233
|
+
static Codec = codec.Class(Block, {
|
|
7164
7234
|
header: Header.Codec,
|
|
7165
7235
|
extrinsic: Extrinsic.Codec,
|
|
7166
7236
|
});
|
|
@@ -7581,8 +7651,9 @@ const workExecResultFromJson = json.object({
|
|
|
7581
7651
|
panic: json.optional(json.fromAny(() => null)),
|
|
7582
7652
|
bad_code: json.optional(json.fromAny(() => null)),
|
|
7583
7653
|
code_oversize: json.optional(json.fromAny(() => null)),
|
|
7654
|
+
output_oversize: json.optional(json.fromAny(() => null)),
|
|
7584
7655
|
}, (val) => {
|
|
7585
|
-
const { ok, out_of_gas, panic, bad_code, code_oversize } = val;
|
|
7656
|
+
const { ok, out_of_gas, panic, bad_code, code_oversize, output_oversize } = val;
|
|
7586
7657
|
if (ok !== undefined) {
|
|
7587
7658
|
return new WorkExecResult(tryAsU32(WorkExecResultKind.ok), ok);
|
|
7588
7659
|
}
|
|
@@ -7598,6 +7669,9 @@ const workExecResultFromJson = json.object({
|
|
|
7598
7669
|
if (code_oversize === null) {
|
|
7599
7670
|
return new WorkExecResult(tryAsU32(WorkExecResultKind.codeOversize));
|
|
7600
7671
|
}
|
|
7672
|
+
if (output_oversize === null) {
|
|
7673
|
+
return new WorkExecResult(tryAsU32(WorkExecResultKind.digestTooBig));
|
|
7674
|
+
}
|
|
7601
7675
|
throw new Error("Invalid WorkExecResult");
|
|
7602
7676
|
});
|
|
7603
7677
|
const workRefineLoadFromJson = json.object({
|
|
@@ -7862,14 +7936,14 @@ var chain_spec$1 = {
|
|
|
7862
7936
|
ff000000000000000000000000000000000000000000000000000000000000: "00d1b097b4410b3a63446d7c57d093972a9744fcd2d74f4a5e2ec163610e6d6327ffffffffffffffff0a000000000000000a000000000000003418020000000000ffffffffffffffff04000000000000000000000000000000"
|
|
7863
7937
|
}
|
|
7864
7938
|
};
|
|
7865
|
-
var database_base_path
|
|
7939
|
+
var database_base_path = "./database";
|
|
7866
7940
|
var defaultConfig = {
|
|
7867
7941
|
$schema: $schema$1,
|
|
7868
7942
|
version: version$2,
|
|
7869
7943
|
flavor: flavor$1,
|
|
7870
7944
|
authorship: authorship$1,
|
|
7871
7945
|
chain_spec: chain_spec$1,
|
|
7872
|
-
database_base_path: database_base_path
|
|
7946
|
+
database_base_path: database_base_path
|
|
7873
7947
|
};
|
|
7874
7948
|
|
|
7875
7949
|
var $schema = "https://fluffylabs.dev/typeberry/schemas/config-v1.schema.json";
|
|
@@ -7907,14 +7981,12 @@ var chain_spec = {
|
|
|
7907
7981
|
ff000000000000000000000000000000000000000000000000000000000000: "00d1b097b4410b3a63446d7c57d093972a9744fcd2d74f4a5e2ec163610e6d6327ffffffffffffffff0a000000000000000a000000000000003418020000000000ffffffffffffffff04000000000000000000000000000000"
|
|
7908
7982
|
}
|
|
7909
7983
|
};
|
|
7910
|
-
var database_base_path = "./database";
|
|
7911
7984
|
var devConfig = {
|
|
7912
7985
|
$schema: $schema,
|
|
7913
7986
|
version: version$1,
|
|
7914
7987
|
flavor: flavor,
|
|
7915
7988
|
authorship: authorship,
|
|
7916
|
-
chain_spec: chain_spec
|
|
7917
|
-
database_base_path: database_base_path
|
|
7989
|
+
chain_spec: chain_spec
|
|
7918
7990
|
};
|
|
7919
7991
|
|
|
7920
7992
|
const configs = {
|
|
@@ -8656,9 +8728,9 @@ function legacyServiceNested(serviceId, hash) {
|
|
|
8656
8728
|
class AccumulationOutput {
|
|
8657
8729
|
serviceId;
|
|
8658
8730
|
output;
|
|
8659
|
-
static Codec = Class(AccumulationOutput, {
|
|
8660
|
-
serviceId: u32.asOpaque(),
|
|
8661
|
-
output: bytes(HASH_SIZE),
|
|
8731
|
+
static Codec = codec.Class(AccumulationOutput, {
|
|
8732
|
+
serviceId: codec.u32.asOpaque(),
|
|
8733
|
+
output: codec.bytes(HASH_SIZE),
|
|
8662
8734
|
});
|
|
8663
8735
|
static create(a) {
|
|
8664
8736
|
return new AccumulationOutput(a.serviceId, a.output);
|
|
@@ -8707,8 +8779,6 @@ const W_B = Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) ? 13_791_360 : 13_7
|
|
|
8707
8779
|
const W_C = 4_000_000;
|
|
8708
8780
|
/** `W_M`: The maximum number of imports in a work-package. */
|
|
8709
8781
|
const W_M = 3_072;
|
|
8710
|
-
/** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
|
|
8711
|
-
const W_R = 49_152;
|
|
8712
8782
|
/** `W_T`: The size of a transfer memo in octets. */
|
|
8713
8783
|
const W_T = 128;
|
|
8714
8784
|
/** `W_M`: The maximum number of exports in a work-package. */
|
|
@@ -8736,9 +8806,9 @@ const MAX_REPORT_DEPENDENCIES = 8;
|
|
|
8736
8806
|
class NotYetAccumulatedReport extends WithDebug {
|
|
8737
8807
|
report;
|
|
8738
8808
|
dependencies;
|
|
8739
|
-
static Codec = Class(NotYetAccumulatedReport, {
|
|
8809
|
+
static Codec = codec.Class(NotYetAccumulatedReport, {
|
|
8740
8810
|
report: WorkReport.Codec,
|
|
8741
|
-
dependencies: codecKnownSizeArray(bytes(HASH_SIZE).asOpaque(), {
|
|
8811
|
+
dependencies: codecKnownSizeArray(codec.bytes(HASH_SIZE).asOpaque(), {
|
|
8742
8812
|
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
8743
8813
|
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
8744
8814
|
minLength: 0,
|
|
@@ -8765,7 +8835,7 @@ class NotYetAccumulatedReport extends WithDebug {
|
|
|
8765
8835
|
this.dependencies = dependencies;
|
|
8766
8836
|
}
|
|
8767
8837
|
}
|
|
8768
|
-
const accumulationQueueCodec = codecPerEpochBlock(readonlyArray(sequenceVarLen(NotYetAccumulatedReport.Codec)));
|
|
8838
|
+
const accumulationQueueCodec = codecPerEpochBlock(codec.readonlyArray(codec.sequenceVarLen(NotYetAccumulatedReport.Codec)));
|
|
8769
8839
|
|
|
8770
8840
|
/** Check if given array has correct length before casting to the opaque type. */
|
|
8771
8841
|
function tryAsPerCore(array, spec) {
|
|
@@ -8790,9 +8860,9 @@ const codecPerCore = (val) => codecWithContext((context) => {
|
|
|
8790
8860
|
class AvailabilityAssignment extends WithDebug {
|
|
8791
8861
|
workReport;
|
|
8792
8862
|
timeout;
|
|
8793
|
-
static Codec = Class(AvailabilityAssignment, {
|
|
8863
|
+
static Codec = codec.Class(AvailabilityAssignment, {
|
|
8794
8864
|
workReport: WorkReport.Codec,
|
|
8795
|
-
timeout: u32.asOpaque(),
|
|
8865
|
+
timeout: codec.u32.asOpaque(),
|
|
8796
8866
|
});
|
|
8797
8867
|
static create({ workReport, timeout }) {
|
|
8798
8868
|
return new AvailabilityAssignment(workReport, timeout);
|
|
@@ -8807,20 +8877,20 @@ class AvailabilityAssignment extends WithDebug {
|
|
|
8807
8877
|
this.timeout = timeout;
|
|
8808
8878
|
}
|
|
8809
8879
|
}
|
|
8810
|
-
const availabilityAssignmentsCodec = codecPerCore(optional(AvailabilityAssignment.Codec));
|
|
8880
|
+
const availabilityAssignmentsCodec = codecPerCore(codec.optional(AvailabilityAssignment.Codec));
|
|
8811
8881
|
|
|
8812
8882
|
/** `O`: Maximal authorization pool size. */
|
|
8813
8883
|
const MAX_AUTH_POOL_SIZE = O;
|
|
8814
8884
|
/** `Q`: Size of the authorization queue. */
|
|
8815
8885
|
const AUTHORIZATION_QUEUE_SIZE = Q;
|
|
8816
|
-
const authPoolsCodec = codecPerCore(codecKnownSizeArray(bytes(HASH_SIZE).asOpaque(), {
|
|
8886
|
+
const authPoolsCodec = codecPerCore(codecKnownSizeArray(codec.bytes(HASH_SIZE).asOpaque(), {
|
|
8817
8887
|
minLength: 0,
|
|
8818
8888
|
maxLength: MAX_AUTH_POOL_SIZE,
|
|
8819
8889
|
typicalLength: MAX_AUTH_POOL_SIZE,
|
|
8820
8890
|
}));
|
|
8821
|
-
const authQueuesCodec = codecPerCore(codecFixedSizeArray(bytes(HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE));
|
|
8891
|
+
const authQueuesCodec = codecPerCore(codecFixedSizeArray(codec.bytes(HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE));
|
|
8822
8892
|
|
|
8823
|
-
const sortedSetCodec = () => readonlyArray(sequenceVarLen(bytes(HASH_SIZE))).convert((input) => input.array, (output) => {
|
|
8893
|
+
const sortedSetCodec = () => codec.readonlyArray(codec.sequenceVarLen(codec.bytes(HASH_SIZE))).convert((input) => input.array, (output) => {
|
|
8824
8894
|
const typed = output.map((x) => x.asOpaque());
|
|
8825
8895
|
return SortedSet.fromSortedArray(hashComparator, typed);
|
|
8826
8896
|
});
|
|
@@ -8835,7 +8905,7 @@ class DisputesRecords {
|
|
|
8835
8905
|
badSet;
|
|
8836
8906
|
wonkySet;
|
|
8837
8907
|
punishSet;
|
|
8838
|
-
static Codec = Class(DisputesRecords, {
|
|
8908
|
+
static Codec = codec.Class(DisputesRecords, {
|
|
8839
8909
|
goodSet: workReportsSortedSetCodec,
|
|
8840
8910
|
badSet: workReportsSortedSetCodec,
|
|
8841
8911
|
wonkySet: workReportsSortedSetCodec,
|
|
@@ -8900,10 +8970,10 @@ class BlockState extends WithDebug {
|
|
|
8900
8970
|
accumulationResult;
|
|
8901
8971
|
postStateRoot;
|
|
8902
8972
|
reported;
|
|
8903
|
-
static Codec = Class(BlockState, {
|
|
8904
|
-
headerHash: bytes(HASH_SIZE).asOpaque(),
|
|
8905
|
-
accumulationResult: bytes(HASH_SIZE),
|
|
8906
|
-
postStateRoot: bytes(HASH_SIZE).asOpaque(),
|
|
8973
|
+
static Codec = codec.Class(BlockState, {
|
|
8974
|
+
headerHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
8975
|
+
accumulationResult: codec.bytes(HASH_SIZE),
|
|
8976
|
+
postStateRoot: codec.bytes(HASH_SIZE).asOpaque(),
|
|
8907
8977
|
reported: codecHashDictionary(WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
8908
8978
|
});
|
|
8909
8979
|
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
@@ -8933,14 +9003,14 @@ class BlockState extends WithDebug {
|
|
|
8933
9003
|
class RecentBlocks extends WithDebug {
|
|
8934
9004
|
blocks;
|
|
8935
9005
|
accumulationLog;
|
|
8936
|
-
static Codec = Class(RecentBlocks, {
|
|
9006
|
+
static Codec = codec.Class(RecentBlocks, {
|
|
8937
9007
|
blocks: codecKnownSizeArray(BlockState.Codec, {
|
|
8938
9008
|
minLength: 0,
|
|
8939
9009
|
maxLength: MAX_RECENT_HISTORY,
|
|
8940
9010
|
typicalLength: MAX_RECENT_HISTORY,
|
|
8941
9011
|
}),
|
|
8942
|
-
accumulationLog: object({
|
|
8943
|
-
peaks: readonlyArray(sequenceVarLen(optional(bytes(HASH_SIZE)))),
|
|
9012
|
+
accumulationLog: codec.object({
|
|
9013
|
+
peaks: codec.readonlyArray(codec.sequenceVarLen(codec.optional(codec.bytes(HASH_SIZE)))),
|
|
8944
9014
|
}),
|
|
8945
9015
|
});
|
|
8946
9016
|
static empty() {
|
|
@@ -8968,7 +9038,7 @@ class RecentBlocks extends WithDebug {
|
|
|
8968
9038
|
}
|
|
8969
9039
|
}
|
|
8970
9040
|
|
|
8971
|
-
const recentlyAccumulatedCodec = codecPerEpochBlock(sequenceVarLen(bytes(HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x)));
|
|
9041
|
+
const recentlyAccumulatedCodec = codecPerEpochBlock(codec.sequenceVarLen(codec.bytes(HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x)));
|
|
8972
9042
|
|
|
8973
9043
|
/**
|
|
8974
9044
|
* Fixed size of validator metadata.
|
|
@@ -8986,11 +9056,11 @@ class ValidatorData extends WithDebug {
|
|
|
8986
9056
|
ed25519;
|
|
8987
9057
|
bls;
|
|
8988
9058
|
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),
|
|
9059
|
+
static Codec = codec.Class(ValidatorData, {
|
|
9060
|
+
bandersnatch: codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
9061
|
+
ed25519: codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
9062
|
+
bls: codec.bytes(BLS_KEY_BYTES).asOpaque(),
|
|
9063
|
+
metadata: codec.bytes(VALIDATOR_META_BYTES),
|
|
8994
9064
|
});
|
|
8995
9065
|
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
8996
9066
|
return new ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
@@ -9018,46 +9088,26 @@ var SafroleSealingKeysKind;
|
|
|
9018
9088
|
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
9019
9089
|
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
9020
9090
|
})(SafroleSealingKeysKind || (SafroleSealingKeysKind = {}));
|
|
9021
|
-
const codecBandersnatchKey = bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
9091
|
+
const codecBandersnatchKey = codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
9022
9092
|
class SafroleSealingKeysData extends WithDebug {
|
|
9023
9093
|
kind;
|
|
9024
9094
|
keys;
|
|
9025
9095
|
tickets;
|
|
9026
9096
|
static Codec = codecWithContext((context) => {
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9097
|
+
const keysCodec = codec
|
|
9098
|
+
.sequenceFixLen(codecBandersnatchKey, context.epochLength)
|
|
9099
|
+
.convert((keys) => Array.from(keys), (keys) => tryAsPerEpochBlock(keys, context));
|
|
9100
|
+
const ticketsCodec = codec.sequenceFixLen(Ticket.Codec, context.epochLength).convert((tickets) => Array.from(tickets), (tickets) => tryAsPerEpochBlock(tickets, context));
|
|
9101
|
+
return codec
|
|
9102
|
+
.union("SafroleSealingKeys", {
|
|
9103
|
+
[SafroleSealingKeysKind.Keys]: codec.object({ keys: keysCodec }),
|
|
9104
|
+
[SafroleSealingKeysKind.Tickets]: codec.object({ tickets: ticketsCodec }),
|
|
9105
|
+
})
|
|
9106
|
+
.convert((x) => x, (x) => {
|
|
9032
9107
|
if (x.kind === SafroleSealingKeysKind.Keys) {
|
|
9033
|
-
|
|
9108
|
+
return SafroleSealingKeysData.keys(x.keys);
|
|
9034
9109
|
}
|
|
9035
|
-
|
|
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}`);
|
|
9110
|
+
return SafroleSealingKeysData.tickets(x.tickets);
|
|
9061
9111
|
});
|
|
9062
9112
|
});
|
|
9063
9113
|
static keys(keys) {
|
|
@@ -9078,11 +9128,11 @@ class SafroleData {
|
|
|
9078
9128
|
epochRoot;
|
|
9079
9129
|
sealingKeySeries;
|
|
9080
9130
|
ticketsAccumulator;
|
|
9081
|
-
static Codec = Class(SafroleData, {
|
|
9131
|
+
static Codec = codec.Class(SafroleData, {
|
|
9082
9132
|
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
9083
|
-
epochRoot: bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
9133
|
+
epochRoot: codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
9084
9134
|
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
9085
|
-
ticketsAccumulator: readonlyArray(sequenceVarLen(Ticket.Codec)).convert(seeThrough, asKnownSize),
|
|
9135
|
+
ticketsAccumulator: codec.readonlyArray(codec.sequenceVarLen(Ticket.Codec)).convert(seeThrough, asKnownSize),
|
|
9086
9136
|
});
|
|
9087
9137
|
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
9088
9138
|
return new SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
@@ -9160,17 +9210,17 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
9160
9210
|
created;
|
|
9161
9211
|
lastAccumulation;
|
|
9162
9212
|
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),
|
|
9213
|
+
static Codec = codec.Class(ServiceAccountInfo, {
|
|
9214
|
+
codeHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
9215
|
+
balance: codec.u64,
|
|
9216
|
+
accumulateMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
|
|
9217
|
+
onTransferMinGas: codec.u64.convert((x) => x, tryAsServiceGas),
|
|
9218
|
+
storageUtilisationBytes: codec.u64,
|
|
9219
|
+
gratisStorage: codec.u64,
|
|
9220
|
+
storageUtilisationCount: codec.u32,
|
|
9221
|
+
created: codec.u32.convert((x) => x, tryAsTimeSlot),
|
|
9222
|
+
lastAccumulation: codec.u32.convert((x) => x, tryAsTimeSlot),
|
|
9223
|
+
parentService: codec.u32.convert((x) => x, tryAsServiceId),
|
|
9174
9224
|
});
|
|
9175
9225
|
static create(a) {
|
|
9176
9226
|
return new ServiceAccountInfo(a.codeHash, a.balance, a.accumulateMinGas, a.onTransferMinGas, a.storageUtilisationBytes, a.gratisStorage, a.storageUtilisationCount, a.created, a.lastAccumulation, a.parentService);
|
|
@@ -9226,9 +9276,9 @@ class ServiceAccountInfo extends WithDebug {
|
|
|
9226
9276
|
class PreimageItem extends WithDebug {
|
|
9227
9277
|
hash;
|
|
9228
9278
|
blob;
|
|
9229
|
-
static Codec = Class(PreimageItem, {
|
|
9230
|
-
hash: bytes(HASH_SIZE).asOpaque(),
|
|
9231
|
-
blob: blob,
|
|
9279
|
+
static Codec = codec.Class(PreimageItem, {
|
|
9280
|
+
hash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
9281
|
+
blob: codec.blob,
|
|
9232
9282
|
});
|
|
9233
9283
|
static create({ hash, blob }) {
|
|
9234
9284
|
return new PreimageItem(hash, blob);
|
|
@@ -9242,9 +9292,9 @@ class PreimageItem extends WithDebug {
|
|
|
9242
9292
|
class StorageItem extends WithDebug {
|
|
9243
9293
|
key;
|
|
9244
9294
|
value;
|
|
9245
|
-
static Codec = Class(StorageItem, {
|
|
9246
|
-
key: blob.convert((i) => i, (o) => asOpaqueType(o)),
|
|
9247
|
-
value: blob,
|
|
9295
|
+
static Codec = codec.Class(StorageItem, {
|
|
9296
|
+
key: codec.blob.convert((i) => i, (o) => asOpaqueType(o)),
|
|
9297
|
+
value: codec.blob,
|
|
9248
9298
|
});
|
|
9249
9299
|
static create({ key, value }) {
|
|
9250
9300
|
return new StorageItem(key, value);
|
|
@@ -9298,13 +9348,13 @@ class ValidatorStatistics {
|
|
|
9298
9348
|
preImagesSize;
|
|
9299
9349
|
guarantees;
|
|
9300
9350
|
assurances;
|
|
9301
|
-
static Codec = Class(ValidatorStatistics, {
|
|
9302
|
-
blocks: u32,
|
|
9303
|
-
tickets: u32,
|
|
9304
|
-
preImages: u32,
|
|
9305
|
-
preImagesSize: u32,
|
|
9306
|
-
guarantees: u32,
|
|
9307
|
-
assurances: u32,
|
|
9351
|
+
static Codec = codec.Class(ValidatorStatistics, {
|
|
9352
|
+
blocks: codec.u32,
|
|
9353
|
+
tickets: codec.u32,
|
|
9354
|
+
preImages: codec.u32,
|
|
9355
|
+
preImagesSize: codec.u32,
|
|
9356
|
+
guarantees: codec.u32,
|
|
9357
|
+
assurances: codec.u32,
|
|
9308
9358
|
});
|
|
9309
9359
|
static create({ blocks, tickets, preImages, preImagesSize, guarantees, assurances, }) {
|
|
9310
9360
|
return new ValidatorStatistics(blocks, tickets, preImages, preImagesSize, guarantees, assurances);
|
|
@@ -9334,9 +9384,9 @@ class ValidatorStatistics {
|
|
|
9334
9384
|
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
9335
9385
|
}
|
|
9336
9386
|
}
|
|
9337
|
-
const codecVarU16 = varU32.convert((i) => tryAsU32(i), (o) => tryAsU16(o));
|
|
9387
|
+
const codecVarU16 = codec.varU32.convert((i) => tryAsU32(i), (o) => tryAsU16(o));
|
|
9338
9388
|
/** Encode/decode unsigned gas. */
|
|
9339
|
-
const codecVarGas = varU64.convert((g) => tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
9389
|
+
const codecVarGas = codec.varU64.convert((g) => tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
9340
9390
|
/**
|
|
9341
9391
|
* Single core statistics.
|
|
9342
9392
|
* Updated per block, based on incoming work reports (`w`).
|
|
@@ -9353,14 +9403,14 @@ class CoreStatistics {
|
|
|
9353
9403
|
extrinsicCount;
|
|
9354
9404
|
bundleSize;
|
|
9355
9405
|
gasUsed;
|
|
9356
|
-
static Codec = Class(CoreStatistics, {
|
|
9357
|
-
dataAvailabilityLoad: varU32,
|
|
9406
|
+
static Codec = codec.Class(CoreStatistics, {
|
|
9407
|
+
dataAvailabilityLoad: codec.varU32,
|
|
9358
9408
|
popularity: codecVarU16,
|
|
9359
9409
|
imports: codecVarU16,
|
|
9360
9410
|
extrinsicCount: codecVarU16,
|
|
9361
|
-
extrinsicSize: varU32,
|
|
9411
|
+
extrinsicSize: codec.varU32,
|
|
9362
9412
|
exports: codecVarU16,
|
|
9363
|
-
bundleSize: varU32,
|
|
9413
|
+
bundleSize: codec.varU32,
|
|
9364
9414
|
gasUsed: codecVarGas,
|
|
9365
9415
|
});
|
|
9366
9416
|
static create(v) {
|
|
@@ -9419,31 +9469,31 @@ class ServiceStatistics {
|
|
|
9419
9469
|
onTransfersCount;
|
|
9420
9470
|
onTransfersGasUsed;
|
|
9421
9471
|
static Codec = Compatibility.selectIfGreaterOrEqual({
|
|
9422
|
-
fallback: Class(ServiceStatistics, {
|
|
9472
|
+
fallback: codec.Class(ServiceStatistics, {
|
|
9423
9473
|
providedCount: codecVarU16,
|
|
9424
|
-
providedSize: varU32,
|
|
9425
|
-
refinementCount: varU32,
|
|
9474
|
+
providedSize: codec.varU32,
|
|
9475
|
+
refinementCount: codec.varU32,
|
|
9426
9476
|
refinementGasUsed: codecVarGas,
|
|
9427
9477
|
imports: codecVarU16,
|
|
9428
9478
|
extrinsicCount: codecVarU16,
|
|
9429
|
-
extrinsicSize: varU32,
|
|
9479
|
+
extrinsicSize: codec.varU32,
|
|
9430
9480
|
exports: codecVarU16,
|
|
9431
|
-
accumulateCount: varU32,
|
|
9481
|
+
accumulateCount: codec.varU32,
|
|
9432
9482
|
accumulateGasUsed: codecVarGas,
|
|
9433
|
-
onTransfersCount: varU32,
|
|
9483
|
+
onTransfersCount: codec.varU32,
|
|
9434
9484
|
onTransfersGasUsed: codecVarGas,
|
|
9435
9485
|
}),
|
|
9436
9486
|
versions: {
|
|
9437
|
-
[GpVersion.V0_7_1]: Class(ServiceStatistics, {
|
|
9487
|
+
[GpVersion.V0_7_1]: codec.Class(ServiceStatistics, {
|
|
9438
9488
|
providedCount: codecVarU16,
|
|
9439
|
-
providedSize: varU32,
|
|
9440
|
-
refinementCount: varU32,
|
|
9489
|
+
providedSize: codec.varU32,
|
|
9490
|
+
refinementCount: codec.varU32,
|
|
9441
9491
|
refinementGasUsed: codecVarGas,
|
|
9442
9492
|
imports: codecVarU16,
|
|
9443
9493
|
extrinsicCount: codecVarU16,
|
|
9444
|
-
extrinsicSize: varU32,
|
|
9494
|
+
extrinsicSize: codec.varU32,
|
|
9445
9495
|
exports: codecVarU16,
|
|
9446
|
-
accumulateCount: varU32,
|
|
9496
|
+
accumulateCount: codec.varU32,
|
|
9447
9497
|
accumulateGasUsed: codecVarGas,
|
|
9448
9498
|
onTransfersCount: ignoreValueWithDefault(tryAsU32(0)),
|
|
9449
9499
|
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
@@ -9504,11 +9554,11 @@ class StatisticsData {
|
|
|
9504
9554
|
previous;
|
|
9505
9555
|
cores;
|
|
9506
9556
|
services;
|
|
9507
|
-
static Codec = Class(StatisticsData, {
|
|
9557
|
+
static Codec = codec.Class(StatisticsData, {
|
|
9508
9558
|
current: codecPerValidator(ValidatorStatistics.Codec),
|
|
9509
9559
|
previous: codecPerValidator(ValidatorStatistics.Codec),
|
|
9510
9560
|
cores: codecPerCore(CoreStatistics.Codec),
|
|
9511
|
-
services: dictionary(u32.asOpaque(), ServiceStatistics.Codec, {
|
|
9561
|
+
services: codec.dictionary(codec.u32.asOpaque(), ServiceStatistics.Codec, {
|
|
9512
9562
|
sortKeys: (a, b) => a - b,
|
|
9513
9563
|
}),
|
|
9514
9564
|
});
|
|
@@ -9590,14 +9640,14 @@ class PrivilegedServices {
|
|
|
9590
9640
|
assigners;
|
|
9591
9641
|
autoAccumulateServices;
|
|
9592
9642
|
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
9593
|
-
static Codec = Class(PrivilegedServices, {
|
|
9594
|
-
manager: u32.asOpaque(),
|
|
9595
|
-
assigners: codecPerCore(u32.asOpaque()),
|
|
9596
|
-
delegator: u32.asOpaque(),
|
|
9643
|
+
static Codec = codec.Class(PrivilegedServices, {
|
|
9644
|
+
manager: codec.u32.asOpaque(),
|
|
9645
|
+
assigners: codecPerCore(codec.u32.asOpaque()),
|
|
9646
|
+
delegator: codec.u32.asOpaque(),
|
|
9597
9647
|
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
9598
|
-
? u32.asOpaque()
|
|
9648
|
+
? codec.u32.asOpaque()
|
|
9599
9649
|
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
9600
|
-
autoAccumulateServices: dictionary(u32.asOpaque(), u64.asOpaque(), {
|
|
9650
|
+
autoAccumulateServices: codec.dictionary(codec.u32.asOpaque(), codec.u64.asOpaque(), {
|
|
9601
9651
|
sortKeys: (a, b) => a - b,
|
|
9602
9652
|
}),
|
|
9603
9653
|
});
|
|
@@ -10242,15 +10292,15 @@ class InMemoryState extends WithDebug {
|
|
|
10242
10292
|
});
|
|
10243
10293
|
}
|
|
10244
10294
|
}
|
|
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,
|
|
10295
|
+
const serviceEntriesCodec = codec.object({
|
|
10296
|
+
storageKeys: codec.sequenceVarLen(codec.blob.convert((i) => i, (o) => asOpaqueType(o))),
|
|
10297
|
+
preimages: codec.sequenceVarLen(codec.bytes(HASH_SIZE).asOpaque()),
|
|
10298
|
+
lookupHistory: codec.sequenceVarLen(codec.object({
|
|
10299
|
+
hash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
10300
|
+
length: codec.u32,
|
|
10251
10301
|
})),
|
|
10252
10302
|
});
|
|
10253
|
-
const serviceDataCodec = dictionary(u32.asOpaque(), serviceEntriesCodec, {
|
|
10303
|
+
const serviceDataCodec = codec.dictionary(codec.u32.asOpaque(), serviceEntriesCodec, {
|
|
10254
10304
|
sortKeys: (a, b) => a - b,
|
|
10255
10305
|
});
|
|
10256
10306
|
|
|
@@ -10353,7 +10403,7 @@ var serialize;
|
|
|
10353
10403
|
/** C(6): https://graypaper.fluffylabs.dev/#/7e6ff6a/3bf3013bf301?v=0.6.7 */
|
|
10354
10404
|
serialize.entropy = {
|
|
10355
10405
|
key: stateKeys.index(StateKeyIdx.Eta),
|
|
10356
|
-
Codec: codecFixedSizeArray(bytes(HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
10406
|
+
Codec: codecFixedSizeArray(codec.bytes(HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
10357
10407
|
extract: (s) => s.entropy,
|
|
10358
10408
|
};
|
|
10359
10409
|
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
@@ -10383,7 +10433,7 @@ var serialize;
|
|
|
10383
10433
|
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
10384
10434
|
serialize.timeslot = {
|
|
10385
10435
|
key: stateKeys.index(StateKeyIdx.Tau),
|
|
10386
|
-
Codec: u32.asOpaque(),
|
|
10436
|
+
Codec: codec.u32.asOpaque(),
|
|
10387
10437
|
extract: (s) => s.timeslot,
|
|
10388
10438
|
};
|
|
10389
10439
|
/** C(12): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b4c023b4c02?v=0.6.7 */
|
|
@@ -10413,7 +10463,7 @@ var serialize;
|
|
|
10413
10463
|
/** C(16): https://graypaper.fluffylabs.dev/#/38c4e62/3b46033b4603?v=0.7.0 */
|
|
10414
10464
|
serialize.accumulationOutputLog = {
|
|
10415
10465
|
key: stateKeys.index(StateKeyIdx.Theta),
|
|
10416
|
-
Codec: sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
|
|
10466
|
+
Codec: codec.sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
|
|
10417
10467
|
extract: (s) => s.accumulationOutputLog,
|
|
10418
10468
|
};
|
|
10419
10469
|
/** C(255, s): https://graypaper.fluffylabs.dev/#/85129da/383103383103?v=0.6.3 */
|
|
@@ -10436,7 +10486,7 @@ var serialize;
|
|
|
10436
10486
|
/** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
|
|
10437
10487
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
10438
10488
|
key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
|
|
10439
|
-
Codec: readonlyArray(sequenceVarLen(u32)),
|
|
10489
|
+
Codec: codec.readonlyArray(codec.sequenceVarLen(codec.u32)),
|
|
10440
10490
|
});
|
|
10441
10491
|
})(serialize || (serialize = {}));
|
|
10442
10492
|
/**
|
|
@@ -11530,7 +11580,7 @@ function getSafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsA
|
|
|
11530
11580
|
|
|
11531
11581
|
const TYPICAL_STATE_ITEMS = 50;
|
|
11532
11582
|
const TYPICAL_STATE_ITEM_LEN = 50;
|
|
11533
|
-
const stateEntriesSequenceCodec = sequenceVarLen(pair(bytes(TRUNCATED_HASH_SIZE), blob));
|
|
11583
|
+
const stateEntriesSequenceCodec = codec.sequenceVarLen(codec.pair(codec.bytes(TRUNCATED_HASH_SIZE), codec.blob));
|
|
11534
11584
|
/**
|
|
11535
11585
|
* Full, in-memory state represented as serialized entries dictionary.
|
|
11536
11586
|
*
|
|
@@ -11538,7 +11588,7 @@ const stateEntriesSequenceCodec = sequenceVarLen(pair(bytes(TRUNCATED_HASH_SIZE)
|
|
|
11538
11588
|
*/
|
|
11539
11589
|
class StateEntries {
|
|
11540
11590
|
dictionary;
|
|
11541
|
-
static Codec = custom({
|
|
11591
|
+
static Codec = codec.custom({
|
|
11542
11592
|
name: "StateEntries",
|
|
11543
11593
|
sizeHint: {
|
|
11544
11594
|
isExact: false,
|
|
@@ -12358,10 +12408,10 @@ class Version extends WithDebug {
|
|
|
12358
12408
|
major;
|
|
12359
12409
|
minor;
|
|
12360
12410
|
patch;
|
|
12361
|
-
static Codec = Class(Version, {
|
|
12362
|
-
major: u8,
|
|
12363
|
-
minor: u8,
|
|
12364
|
-
patch: u8,
|
|
12411
|
+
static Codec = codec.Class(Version, {
|
|
12412
|
+
major: codec.u8,
|
|
12413
|
+
minor: codec.u8,
|
|
12414
|
+
patch: codec.u8,
|
|
12365
12415
|
});
|
|
12366
12416
|
static tryFromString(str) {
|
|
12367
12417
|
const parse = (v) => tryAsU8(Number(v));
|
|
@@ -12413,12 +12463,12 @@ class PeerInfo extends WithDebug {
|
|
|
12413
12463
|
jamVersion;
|
|
12414
12464
|
appVersion;
|
|
12415
12465
|
name;
|
|
12416
|
-
static Codec = Class(PeerInfo, {
|
|
12417
|
-
fuzzVersion: u8,
|
|
12418
|
-
features: u32,
|
|
12466
|
+
static Codec = codec.Class(PeerInfo, {
|
|
12467
|
+
fuzzVersion: codec.u8,
|
|
12468
|
+
features: codec.u32,
|
|
12419
12469
|
jamVersion: Version.Codec,
|
|
12420
12470
|
appVersion: Version.Codec,
|
|
12421
|
-
name: string,
|
|
12471
|
+
name: codec.string,
|
|
12422
12472
|
});
|
|
12423
12473
|
static create({ fuzzVersion, features, appVersion, jamVersion, name }) {
|
|
12424
12474
|
return new PeerInfo(fuzzVersion, features, jamVersion, appVersion, name);
|
|
@@ -12441,9 +12491,9 @@ class PeerInfo extends WithDebug {
|
|
|
12441
12491
|
class AncestryItem extends WithDebug {
|
|
12442
12492
|
slot;
|
|
12443
12493
|
headerHash;
|
|
12444
|
-
static Codec = Class(AncestryItem, {
|
|
12445
|
-
slot: u32.asOpaque(),
|
|
12446
|
-
headerHash: bytes(HASH_SIZE).asOpaque(),
|
|
12494
|
+
static Codec = codec.Class(AncestryItem, {
|
|
12495
|
+
slot: codec.u32.asOpaque(),
|
|
12496
|
+
headerHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
12447
12497
|
});
|
|
12448
12498
|
static create({ slot, headerHash }) {
|
|
12449
12499
|
return new AncestryItem(slot, headerHash);
|
|
@@ -12463,9 +12513,9 @@ class AncestryItem extends WithDebug {
|
|
|
12463
12513
|
class KeyValue extends WithDebug {
|
|
12464
12514
|
key;
|
|
12465
12515
|
value;
|
|
12466
|
-
static Codec = Class(KeyValue, {
|
|
12467
|
-
key: bytes(TRUNCATED_HASH_SIZE),
|
|
12468
|
-
value: blob,
|
|
12516
|
+
static Codec = codec.Class(KeyValue, {
|
|
12517
|
+
key: codec.bytes(TRUNCATED_HASH_SIZE),
|
|
12518
|
+
value: codec.blob,
|
|
12469
12519
|
});
|
|
12470
12520
|
static create({ key, value }) {
|
|
12471
12521
|
return new KeyValue(key, value);
|
|
@@ -12477,12 +12527,12 @@ class KeyValue extends WithDebug {
|
|
|
12477
12527
|
}
|
|
12478
12528
|
}
|
|
12479
12529
|
/** State ::= SEQUENCE OF KeyValue */
|
|
12480
|
-
const stateCodec = sequenceVarLen(KeyValue.Codec);
|
|
12530
|
+
const stateCodec = codec.sequenceVarLen(KeyValue.Codec);
|
|
12481
12531
|
/**
|
|
12482
12532
|
* Ancestry ::= SEQUENCE (SIZE(0..24)) OF AncestryItem
|
|
12483
12533
|
* Empty when `feature-ancestry` is not supported by both parties
|
|
12484
12534
|
*/
|
|
12485
|
-
const ancestryCodec = sequenceVarLen(AncestryItem.Codec, {
|
|
12535
|
+
const ancestryCodec = codec.sequenceVarLen(AncestryItem.Codec, {
|
|
12486
12536
|
minLength: 0,
|
|
12487
12537
|
maxLength: 24,
|
|
12488
12538
|
});
|
|
@@ -12497,7 +12547,7 @@ class Initialize extends WithDebug {
|
|
|
12497
12547
|
header;
|
|
12498
12548
|
keyvals;
|
|
12499
12549
|
ancestry;
|
|
12500
|
-
static Codec = Class(Initialize, {
|
|
12550
|
+
static Codec = codec.Class(Initialize, {
|
|
12501
12551
|
header: Header.Codec,
|
|
12502
12552
|
keyvals: stateCodec,
|
|
12503
12553
|
ancestry: ancestryCodec,
|
|
@@ -12513,14 +12563,14 @@ class Initialize extends WithDebug {
|
|
|
12513
12563
|
}
|
|
12514
12564
|
}
|
|
12515
12565
|
/** GetState ::= HeaderHash */
|
|
12516
|
-
const getStateCodec = bytes(HASH_SIZE).asOpaque();
|
|
12566
|
+
const getStateCodec = codec.bytes(HASH_SIZE).asOpaque();
|
|
12517
12567
|
/** StateRoot ::= StateRootHash */
|
|
12518
|
-
const stateRootCodec = bytes(HASH_SIZE).asOpaque();
|
|
12568
|
+
const stateRootCodec = codec.bytes(HASH_SIZE).asOpaque();
|
|
12519
12569
|
/** Error ::= UTF8String */
|
|
12520
12570
|
class ErrorMessage extends WithDebug {
|
|
12521
12571
|
message;
|
|
12522
|
-
static Codec = Class(ErrorMessage, {
|
|
12523
|
-
message: string,
|
|
12572
|
+
static Codec = codec.Class(ErrorMessage, {
|
|
12573
|
+
message: codec.string,
|
|
12524
12574
|
});
|
|
12525
12575
|
static create({ message }) {
|
|
12526
12576
|
return new ErrorMessage(message);
|
|
@@ -12552,7 +12602,7 @@ var MessageType;
|
|
|
12552
12602
|
* error [255] Error
|
|
12553
12603
|
* }
|
|
12554
12604
|
*/
|
|
12555
|
-
const messageCodec = custom({
|
|
12605
|
+
const messageCodec = codec.custom({
|
|
12556
12606
|
name: "Message",
|
|
12557
12607
|
sizeHint: { bytes: 1, isExact: false },
|
|
12558
12608
|
}, (e, msg) => {
|
|
@@ -18037,7 +18087,7 @@ class Assign {
|
|
|
18037
18087
|
// NOTE: Here we know the core index is valid
|
|
18038
18088
|
const coreIndex = tryAsCoreIndex(Number(maybeCoreIndex));
|
|
18039
18089
|
const decoder = Decoder.fromBlob(res);
|
|
18040
|
-
const authQueue = decoder.sequenceFixLen(bytes(HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE);
|
|
18090
|
+
const authQueue = decoder.sequenceFixLen(codec.bytes(HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE);
|
|
18041
18091
|
const fixedSizeAuthQueue = FixedSizeArray.new(authQueue, AUTHORIZATION_QUEUE_SIZE);
|
|
18042
18092
|
const result = this.partialState.updateAuthorizationQueue(coreIndex, fixedSizeAuthQueue, assigners);
|
|
18043
18093
|
if (result.isOk) {
|
|
@@ -18061,9 +18111,9 @@ class Assign {
|
|
|
18061
18111
|
}
|
|
18062
18112
|
|
|
18063
18113
|
const IN_OUT_REG$m = 7;
|
|
18064
|
-
const serviceIdAndGasCodec = object({
|
|
18065
|
-
serviceId: u32.convert((i) => i, (o) => asOpaqueType(o)),
|
|
18066
|
-
gas: u64.convert((i) => tryAsU64(i), (o) => tryAsServiceGas(o)),
|
|
18114
|
+
const serviceIdAndGasCodec = codec.object({
|
|
18115
|
+
serviceId: codec.u32.convert((i) => i, (o) => asOpaqueType(o)),
|
|
18116
|
+
gas: codec.u64.convert((i) => tryAsU64(i), (o) => tryAsServiceGas(o)),
|
|
18067
18117
|
});
|
|
18068
18118
|
/**
|
|
18069
18119
|
* Modify privileged services and services that auto-accumulate every block.
|
|
@@ -18121,7 +18171,7 @@ class Bless {
|
|
|
18121
18171
|
memIndex = tryAsU64(memIndex + tryAsU64(decoder.bytesRead()));
|
|
18122
18172
|
}
|
|
18123
18173
|
// https://graypaper.fluffylabs.dev/#/7e6ff6a/367200367200?v=0.6.7
|
|
18124
|
-
const res = safeAllocUint8Array(tryAsExactBytes(u32.sizeHint) * this.chainSpec.coresCount);
|
|
18174
|
+
const res = safeAllocUint8Array(tryAsExactBytes(codec.u32.sizeHint) * this.chainSpec.coresCount);
|
|
18125
18175
|
const authorizersDecoder = Decoder.fromBlob(res);
|
|
18126
18176
|
const memoryReadResult = memory.loadInto(res, authorization);
|
|
18127
18177
|
if (memoryReadResult.isError) {
|
|
@@ -18129,7 +18179,7 @@ class Bless {
|
|
|
18129
18179
|
return PvmExecution.Panic;
|
|
18130
18180
|
}
|
|
18131
18181
|
// `a`
|
|
18132
|
-
const authorizers = tryAsPerCore(authorizersDecoder.sequenceFixLen(u32.asOpaque(), this.chainSpec.coresCount), this.chainSpec);
|
|
18182
|
+
const authorizers = tryAsPerCore(authorizersDecoder.sequenceFixLen(codec.u32.asOpaque(), this.chainSpec.coresCount), this.chainSpec);
|
|
18133
18183
|
const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers, delegator, registrar, autoAccumulate);
|
|
18134
18184
|
if (updateResult.isOk) {
|
|
18135
18185
|
logger$7.trace `[${this.currentServiceId}] BLESS(m: ${manager}, a: [${authorizers}], v: ${delegator}, r: ${registrar}, ${lazyInspect(autoAccumulate)}) <- OK`;
|
|
@@ -18739,12 +18789,12 @@ class PendingTransfer {
|
|
|
18739
18789
|
amount;
|
|
18740
18790
|
memo;
|
|
18741
18791
|
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(),
|
|
18792
|
+
static Codec = codec.Class(PendingTransfer, {
|
|
18793
|
+
source: codec.u32.asOpaque(),
|
|
18794
|
+
destination: codec.u32.asOpaque(),
|
|
18795
|
+
amount: codec.u64,
|
|
18796
|
+
memo: codec.bytes(TRANSFER_MEMO_BYTES),
|
|
18797
|
+
gas: codec.u64.asOpaque(),
|
|
18748
18798
|
});
|
|
18749
18799
|
constructor(
|
|
18750
18800
|
/** `s`: sending service */
|
|
@@ -19042,18 +19092,18 @@ class Info {
|
|
|
19042
19092
|
*
|
|
19043
19093
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/33920033b500?v=0.7.2
|
|
19044
19094
|
*/
|
|
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),
|
|
19095
|
+
const codecServiceAccountInfoWithThresholdBalance = codec.object({
|
|
19096
|
+
codeHash: codec.bytes(HASH_SIZE),
|
|
19097
|
+
balance: codec.u64,
|
|
19098
|
+
thresholdBalance: codec.u64,
|
|
19099
|
+
accumulateMinGas: codec.u64.convert((i) => i, tryAsServiceGas),
|
|
19100
|
+
onTransferMinGas: codec.u64.convert((i) => i, tryAsServiceGas),
|
|
19101
|
+
storageUtilisationBytes: codec.u64,
|
|
19102
|
+
storageUtilisationCount: codec.u32,
|
|
19103
|
+
gratisStorage: codec.u64,
|
|
19104
|
+
created: codec.u32.convert((x) => x, tryAsTimeSlot),
|
|
19105
|
+
lastAccumulation: codec.u32.convert((x) => x, tryAsTimeSlot),
|
|
19106
|
+
parentService: codec.u32.convert((x) => x, tryAsServiceId),
|
|
19057
19107
|
}, "ServiceAccountInfoWithThresholdBalance");
|
|
19058
19108
|
|
|
19059
19109
|
const decoder = new TextDecoder("utf8");
|
|
@@ -19429,9 +19479,9 @@ class HistoricalLookup {
|
|
|
19429
19479
|
|
|
19430
19480
|
const IN_OUT_REG_1 = 7;
|
|
19431
19481
|
const IN_OUT_REG_2 = 8;
|
|
19432
|
-
const gasAndRegistersCodec = object({
|
|
19433
|
-
gas: i64,
|
|
19434
|
-
registers: bytes(NO_OF_REGISTERS$1 * REGISTER_BYTE_SIZE),
|
|
19482
|
+
const gasAndRegistersCodec = codec.object({
|
|
19483
|
+
gas: codec.i64,
|
|
19484
|
+
registers: codec.bytes(NO_OF_REGISTERS$1 * REGISTER_BYTE_SIZE),
|
|
19435
19485
|
});
|
|
19436
19486
|
const GAS_REGISTERS_SIZE = tryAsExactBytes(gasAndRegistersCodec.sizeHint);
|
|
19437
19487
|
/**
|
|
@@ -20277,21 +20327,21 @@ const GAS_TO_INVOKE_WORK_REPORT = 10000000n;
|
|
|
20277
20327
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/176b00176b00?v=0.7.2
|
|
20278
20328
|
*/
|
|
20279
20329
|
class Operand extends WithDebug {
|
|
20280
|
-
static Codec = Class(Operand, {
|
|
20330
|
+
static Codec = codec.Class(Operand, {
|
|
20281
20331
|
// h
|
|
20282
|
-
hash: bytes(HASH_SIZE).asOpaque(),
|
|
20332
|
+
hash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
20283
20333
|
// e
|
|
20284
|
-
exportsRoot: bytes(HASH_SIZE).asOpaque(),
|
|
20334
|
+
exportsRoot: codec.bytes(HASH_SIZE).asOpaque(),
|
|
20285
20335
|
// a
|
|
20286
|
-
authorizerHash: bytes(HASH_SIZE).asOpaque(),
|
|
20336
|
+
authorizerHash: codec.bytes(HASH_SIZE).asOpaque(),
|
|
20287
20337
|
// y
|
|
20288
|
-
payloadHash: bytes(HASH_SIZE),
|
|
20338
|
+
payloadHash: codec.bytes(HASH_SIZE),
|
|
20289
20339
|
// g
|
|
20290
|
-
gas: varU64.asOpaque(),
|
|
20340
|
+
gas: codec.varU64.asOpaque(),
|
|
20291
20341
|
// d
|
|
20292
20342
|
result: WorkExecResult.Codec,
|
|
20293
20343
|
// o
|
|
20294
|
-
authorizationOutput: blob,
|
|
20344
|
+
authorizationOutput: codec.blob,
|
|
20295
20345
|
});
|
|
20296
20346
|
/**
|
|
20297
20347
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/18680118eb01?v=0.7.2
|
|
@@ -20474,80 +20524,153 @@ function signingPayload$1(blake2b, anchor, blob) {
|
|
|
20474
20524
|
return BytesBlob.blobFromParts(JAM_AVAILABLE, blake2b.hashBytes(BytesBlob.blobFromParts(anchor.raw, blob.raw)).raw);
|
|
20475
20525
|
}
|
|
20476
20526
|
|
|
20527
|
+
/** Error that may happen during reports processing. */
|
|
20528
|
+
var ReportsError;
|
|
20529
|
+
(function (ReportsError) {
|
|
20530
|
+
/** Core index is greater than the number of available cores. */
|
|
20531
|
+
ReportsError[ReportsError["BadCoreIndex"] = 0] = "BadCoreIndex";
|
|
20532
|
+
/** The report slot is greater than the current block slot. */
|
|
20533
|
+
ReportsError[ReportsError["FutureReportSlot"] = 1] = "FutureReportSlot";
|
|
20534
|
+
/** Report is too old to be considered. */
|
|
20535
|
+
ReportsError[ReportsError["ReportEpochBeforeLast"] = 2] = "ReportEpochBeforeLast";
|
|
20536
|
+
/** Not enough credentials for the guarantee. */
|
|
20537
|
+
ReportsError[ReportsError["InsufficientGuarantees"] = 3] = "InsufficientGuarantees";
|
|
20538
|
+
/** Guarantees are not ordered by the core index. */
|
|
20539
|
+
ReportsError[ReportsError["OutOfOrderGuarantee"] = 4] = "OutOfOrderGuarantee";
|
|
20540
|
+
/** Credentials of guarantors are not sorted or unique. */
|
|
20541
|
+
ReportsError[ReportsError["NotSortedOrUniqueGuarantors"] = 5] = "NotSortedOrUniqueGuarantors";
|
|
20542
|
+
/** Validator in credentials is assigned to a different core. */
|
|
20543
|
+
ReportsError[ReportsError["WrongAssignment"] = 6] = "WrongAssignment";
|
|
20544
|
+
/** There is a report pending availability on that core already. */
|
|
20545
|
+
ReportsError[ReportsError["CoreEngaged"] = 7] = "CoreEngaged";
|
|
20546
|
+
/** Anchor block is not found in recent blocks. */
|
|
20547
|
+
ReportsError[ReportsError["AnchorNotRecent"] = 8] = "AnchorNotRecent";
|
|
20548
|
+
/** Service not foubd. */
|
|
20549
|
+
ReportsError[ReportsError["BadServiceId"] = 9] = "BadServiceId";
|
|
20550
|
+
/** Service code hash does not match the current one. */
|
|
20551
|
+
ReportsError[ReportsError["BadCodeHash"] = 10] = "BadCodeHash";
|
|
20552
|
+
/** Pre-requisite work package is missing in either recent blocks or lookup extrinsic. */
|
|
20553
|
+
ReportsError[ReportsError["DependencyMissing"] = 11] = "DependencyMissing";
|
|
20554
|
+
/** Results for the same package are in more than one report. */
|
|
20555
|
+
ReportsError[ReportsError["DuplicatePackage"] = 12] = "DuplicatePackage";
|
|
20556
|
+
/** Anchor block declared state root does not match the one we have in recent blocks. */
|
|
20557
|
+
ReportsError[ReportsError["BadStateRoot"] = 13] = "BadStateRoot";
|
|
20558
|
+
/** BEEFY super hash mmr mismatch. */
|
|
20559
|
+
ReportsError[ReportsError["BadBeefyMmrRoot"] = 14] = "BadBeefyMmrRoot";
|
|
20560
|
+
/** The authorization hash is not found in the authorization pool. */
|
|
20561
|
+
ReportsError[ReportsError["CoreUnauthorized"] = 15] = "CoreUnauthorized";
|
|
20562
|
+
/** Validator index is greater than the number of validators. */
|
|
20563
|
+
ReportsError[ReportsError["BadValidatorIndex"] = 16] = "BadValidatorIndex";
|
|
20564
|
+
/** Total gas of work report is too high. */
|
|
20565
|
+
ReportsError[ReportsError["WorkReportGasTooHigh"] = 17] = "WorkReportGasTooHigh";
|
|
20566
|
+
/** Work item has is smaller than required minimal accumulation gas of a service. */
|
|
20567
|
+
ReportsError[ReportsError["ServiceItemGasTooLow"] = 18] = "ServiceItemGasTooLow";
|
|
20568
|
+
/** The report has too many dependencies (prerequisites and/or segment-root lookups). */
|
|
20569
|
+
ReportsError[ReportsError["TooManyDependencies"] = 19] = "TooManyDependencies";
|
|
20570
|
+
/** Segment root lookup block has invalid time slot or is not found in the header chain. */
|
|
20571
|
+
ReportsError[ReportsError["SegmentRootLookupInvalid"] = 20] = "SegmentRootLookupInvalid";
|
|
20572
|
+
/** Signature in credentials is invalid. */
|
|
20573
|
+
ReportsError[ReportsError["BadSignature"] = 21] = "BadSignature";
|
|
20574
|
+
/** Size of authorizer output and all work-item successful output blobs is too big. */
|
|
20575
|
+
ReportsError[ReportsError["WorkReportTooBig"] = 22] = "WorkReportTooBig";
|
|
20576
|
+
/** Contains guarantee from validator that is proven to be an offender. */
|
|
20577
|
+
ReportsError[ReportsError["BannedValidator"] = 23] = "BannedValidator";
|
|
20578
|
+
})(ReportsError || (ReportsError = {}));
|
|
20579
|
+
|
|
20580
|
+
/**
|
|
20581
|
+
* `W_R = 48 * 2**10`: The maximum total size of all output blobs in a work-report, in octets.
|
|
20582
|
+
*
|
|
20583
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/41a60041aa00?v=0.6.2
|
|
20584
|
+
*/
|
|
20585
|
+
const MAX_WORK_REPORT_SIZE_BYTES = 48 * 2 ** 10;
|
|
20586
|
+
function verifyReportsBasic(input) {
|
|
20587
|
+
for (const guarantee of input) {
|
|
20588
|
+
const reportView = guarantee.view().report.view();
|
|
20589
|
+
/**
|
|
20590
|
+
* We limit the sum of the number of items in the
|
|
20591
|
+
* segment-root lookup dictionary and the number of
|
|
20592
|
+
* prerequisites to J = 8:
|
|
20593
|
+
*
|
|
20594
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/13fd0113ff01?v=0.7.2
|
|
20595
|
+
*/
|
|
20596
|
+
const noOfPrerequisites = reportView.context.view().prerequisites.view().length;
|
|
20597
|
+
const noOfSegmentRootLookups = reportView.segmentRootLookup.view().length;
|
|
20598
|
+
if (noOfPrerequisites + noOfSegmentRootLookups > MAX_REPORT_DEPENDENCIES) {
|
|
20599
|
+
return Result$1.error(ReportsError.TooManyDependencies, () => `Report at ${reportView.coreIndex.materialize()} has too many dependencies. Got ${noOfPrerequisites} + ${noOfSegmentRootLookups}, max: ${MAX_REPORT_DEPENDENCIES}`);
|
|
20600
|
+
}
|
|
20601
|
+
/**
|
|
20602
|
+
* In order to ensure fair use of a block’s extrinsic space,
|
|
20603
|
+
* work-reports are limited in the maximum total size of the
|
|
20604
|
+
* successful output blobs together with the authorizer output
|
|
20605
|
+
* blob, effectively limiting their overall size:
|
|
20606
|
+
*
|
|
20607
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/14a80014ab00?v=0.7.2
|
|
20608
|
+
*/
|
|
20609
|
+
// adding is safe here, since the total-encoded size of the report
|
|
20610
|
+
// is limited as well. Even though we just have a view, the size
|
|
20611
|
+
// should have been verified earlier.
|
|
20612
|
+
const authOutputSize = reportView.authorizationOutput.view().length;
|
|
20613
|
+
let totalOutputsSize = 0;
|
|
20614
|
+
for (const item of reportView.results.view()) {
|
|
20615
|
+
const workItemView = item.view();
|
|
20616
|
+
const result = workItemView.result.materialize();
|
|
20617
|
+
if (result.kind === WorkExecResultKind.ok) {
|
|
20618
|
+
totalOutputsSize += result.okBlob?.raw.length ?? 0;
|
|
20619
|
+
}
|
|
20620
|
+
}
|
|
20621
|
+
if (authOutputSize + totalOutputsSize > MAX_WORK_REPORT_SIZE_BYTES) {
|
|
20622
|
+
return Result$1.error(ReportsError.WorkReportTooBig, () => `Work report at ${reportView.coreIndex.materialize()} too big. Got ${authOutputSize} + ${totalOutputsSize}, max: ${MAX_WORK_REPORT_SIZE_BYTES}`);
|
|
20623
|
+
}
|
|
20624
|
+
}
|
|
20625
|
+
return Result$1.ok(OK);
|
|
20626
|
+
}
|
|
20627
|
+
|
|
20477
20628
|
var TransferOperandKind;
|
|
20478
20629
|
(function (TransferOperandKind) {
|
|
20479
20630
|
TransferOperandKind[TransferOperandKind["OPERAND"] = 0] = "OPERAND";
|
|
20480
20631
|
TransferOperandKind[TransferOperandKind["TRANSFER"] = 1] = "TRANSFER";
|
|
20481
20632
|
})(TransferOperandKind || (TransferOperandKind = {}));
|
|
20482
|
-
const TRANSFER_OR_OPERAND =
|
|
20483
|
-
|
|
20484
|
-
|
|
20485
|
-
}, (e, x) => {
|
|
20486
|
-
e.varU32(tryAsU32(x.kind));
|
|
20487
|
-
if (x.kind === TransferOperandKind.OPERAND) {
|
|
20488
|
-
e.object(Operand.Codec, x.value);
|
|
20489
|
-
}
|
|
20490
|
-
if (x.kind === TransferOperandKind.TRANSFER) {
|
|
20491
|
-
e.object(PendingTransfer.Codec, x.value);
|
|
20492
|
-
}
|
|
20493
|
-
}, (d) => {
|
|
20494
|
-
const kind = d.varU32();
|
|
20495
|
-
if (kind === TransferOperandKind.OPERAND) {
|
|
20496
|
-
return {
|
|
20497
|
-
kind: TransferOperandKind.OPERAND,
|
|
20498
|
-
value: d.object(Operand.Codec),
|
|
20499
|
-
};
|
|
20500
|
-
}
|
|
20501
|
-
if (kind === TransferOperandKind.TRANSFER) {
|
|
20502
|
-
return { kind: TransferOperandKind.TRANSFER, value: d.object(PendingTransfer.Codec) };
|
|
20503
|
-
}
|
|
20504
|
-
throw new Error(`Unable to decode TransferOrOperand. Invalid kind: ${kind}.`);
|
|
20505
|
-
}, (s) => {
|
|
20506
|
-
const kind = s.decoder.varU32();
|
|
20507
|
-
if (kind === TransferOperandKind.OPERAND) {
|
|
20508
|
-
s.object(Operand.Codec);
|
|
20509
|
-
}
|
|
20510
|
-
if (kind === TransferOperandKind.TRANSFER) {
|
|
20511
|
-
s.object(PendingTransfer.Codec);
|
|
20512
|
-
}
|
|
20633
|
+
const TRANSFER_OR_OPERAND = codec.union("TransferOrOperand", {
|
|
20634
|
+
[TransferOperandKind.OPERAND]: codec.object({ value: Operand.Codec }),
|
|
20635
|
+
[TransferOperandKind.TRANSFER]: codec.object({ value: PendingTransfer.Codec }),
|
|
20513
20636
|
});
|
|
20514
|
-
const TRANSFERS_AND_OPERANDS = sequenceVarLen(TRANSFER_OR_OPERAND);
|
|
20637
|
+
const TRANSFERS_AND_OPERANDS = codec.sequenceVarLen(TRANSFER_OR_OPERAND);
|
|
20515
20638
|
// https://github.com/gavofyork/graypaper/pull/414
|
|
20516
20639
|
// 0.7.0 encoding is used for prior versions as well.
|
|
20517
|
-
const CONSTANTS_CODEC = object({
|
|
20518
|
-
B_I: u64,
|
|
20519
|
-
B_L: u64,
|
|
20520
|
-
B_S: u64,
|
|
20521
|
-
C: u16,
|
|
20522
|
-
D: u32,
|
|
20523
|
-
E: u32,
|
|
20524
|
-
G_A: u64,
|
|
20525
|
-
G_I: u64,
|
|
20526
|
-
G_R: u64,
|
|
20527
|
-
G_T: u64,
|
|
20528
|
-
H: u16,
|
|
20529
|
-
I: u16,
|
|
20530
|
-
J: u16,
|
|
20531
|
-
K: u16,
|
|
20532
|
-
L: u32,
|
|
20533
|
-
N: u16,
|
|
20534
|
-
O: u16,
|
|
20535
|
-
P: u16,
|
|
20536
|
-
Q: u16,
|
|
20537
|
-
R: u16,
|
|
20538
|
-
T: u16,
|
|
20539
|
-
U: u16,
|
|
20540
|
-
V: u16,
|
|
20541
|
-
W_A: u32,
|
|
20542
|
-
W_B: u32,
|
|
20543
|
-
W_C: u32,
|
|
20544
|
-
W_E: u32,
|
|
20545
|
-
W_M: u32,
|
|
20546
|
-
W_P: u32,
|
|
20547
|
-
W_R: u32,
|
|
20548
|
-
W_T: u32,
|
|
20549
|
-
W_X: u32,
|
|
20550
|
-
Y: u32,
|
|
20640
|
+
const CONSTANTS_CODEC = codec.object({
|
|
20641
|
+
B_I: codec.u64,
|
|
20642
|
+
B_L: codec.u64,
|
|
20643
|
+
B_S: codec.u64,
|
|
20644
|
+
C: codec.u16,
|
|
20645
|
+
D: codec.u32,
|
|
20646
|
+
E: codec.u32,
|
|
20647
|
+
G_A: codec.u64,
|
|
20648
|
+
G_I: codec.u64,
|
|
20649
|
+
G_R: codec.u64,
|
|
20650
|
+
G_T: codec.u64,
|
|
20651
|
+
H: codec.u16,
|
|
20652
|
+
I: codec.u16,
|
|
20653
|
+
J: codec.u16,
|
|
20654
|
+
K: codec.u16,
|
|
20655
|
+
L: codec.u32,
|
|
20656
|
+
N: codec.u16,
|
|
20657
|
+
O: codec.u16,
|
|
20658
|
+
P: codec.u16,
|
|
20659
|
+
Q: codec.u16,
|
|
20660
|
+
R: codec.u16,
|
|
20661
|
+
T: codec.u16,
|
|
20662
|
+
U: codec.u16,
|
|
20663
|
+
V: codec.u16,
|
|
20664
|
+
W_A: codec.u32,
|
|
20665
|
+
W_B: codec.u32,
|
|
20666
|
+
W_C: codec.u32,
|
|
20667
|
+
W_E: codec.u32,
|
|
20668
|
+
W_M: codec.u32,
|
|
20669
|
+
W_P: codec.u32,
|
|
20670
|
+
W_R: codec.u32,
|
|
20671
|
+
W_T: codec.u32,
|
|
20672
|
+
W_X: codec.u32,
|
|
20673
|
+
Y: codec.u32,
|
|
20551
20674
|
});
|
|
20552
20675
|
const encodedConstantsCache = new Map();
|
|
20553
20676
|
function getEncodedConstants(chainSpec) {
|
|
@@ -20585,7 +20708,7 @@ function getEncodedConstants(chainSpec) {
|
|
|
20585
20708
|
W_E: tryAsU32(chainSpec.erasureCodedPieceSize),
|
|
20586
20709
|
W_M: tryAsU32(W_M),
|
|
20587
20710
|
W_P: tryAsU32(chainSpec.numberECPiecesPerSegment),
|
|
20588
|
-
W_R: tryAsU32(
|
|
20711
|
+
W_R: tryAsU32(MAX_WORK_REPORT_SIZE_BYTES),
|
|
20589
20712
|
W_T: tryAsU32(W_T),
|
|
20590
20713
|
W_X: tryAsU32(W_X),
|
|
20591
20714
|
Y: tryAsU32(chainSpec.contestLength),
|
|
@@ -20660,7 +20783,7 @@ class FetchExternalities {
|
|
|
20660
20783
|
allOperands() {
|
|
20661
20784
|
if (this.fetchData.context === FetchContext.LegacyAccumulate) {
|
|
20662
20785
|
const operands = this.fetchData.operands;
|
|
20663
|
-
return Encoder.encodeObject(sequenceVarLen(Operand.Codec), operands, this.chainSpec);
|
|
20786
|
+
return Encoder.encodeObject(codec.sequenceVarLen(Operand.Codec), operands, this.chainSpec);
|
|
20664
20787
|
}
|
|
20665
20788
|
return null;
|
|
20666
20789
|
}
|
|
@@ -20681,7 +20804,7 @@ class FetchExternalities {
|
|
|
20681
20804
|
allTransfers() {
|
|
20682
20805
|
if (this.fetchData.context === FetchContext.LegacyOnTransfer) {
|
|
20683
20806
|
const { transfers } = this.fetchData;
|
|
20684
|
-
return Encoder.encodeObject(sequenceVarLen(PendingTransfer.Codec), transfers, this.chainSpec);
|
|
20807
|
+
return Encoder.encodeObject(codec.sequenceVarLen(PendingTransfer.Codec), transfers, this.chainSpec);
|
|
20685
20808
|
}
|
|
20686
20809
|
return null;
|
|
20687
20810
|
}
|
|
@@ -20912,10 +21035,10 @@ function getWorkPackageHashes(reports) {
|
|
|
20912
21035
|
const workPackageHashes = reports.map((report) => report.workPackageSpec.hash);
|
|
20913
21036
|
return HashSet.from(workPackageHashes);
|
|
20914
21037
|
}
|
|
20915
|
-
const NEXT_ID_CODEC = object({
|
|
20916
|
-
serviceId: varU32.asOpaque(),
|
|
20917
|
-
entropy: bytes(HASH_SIZE).asOpaque(),
|
|
20918
|
-
timeslot: varU32.asOpaque(),
|
|
21038
|
+
const NEXT_ID_CODEC = codec.object({
|
|
21039
|
+
serviceId: codec.varU32.asOpaque(),
|
|
21040
|
+
entropy: codec.bytes(HASH_SIZE).asOpaque(),
|
|
21041
|
+
timeslot: codec.varU32.asOpaque(),
|
|
20919
21042
|
});
|
|
20920
21043
|
/**
|
|
20921
21044
|
* Generate a next service id.
|
|
@@ -21313,21 +21436,24 @@ var PvmInvocationError;
|
|
|
21313
21436
|
PvmInvocationError[PvmInvocationError["PreimageTooLong"] = 2] = "PreimageTooLong";
|
|
21314
21437
|
})(PvmInvocationError || (PvmInvocationError = {}));
|
|
21315
21438
|
const logger$5 = Logger.new(undefined, "accumulate");
|
|
21316
|
-
const ARGS_CODEC$1 = object({
|
|
21317
|
-
slot: varU32.asOpaque(),
|
|
21318
|
-
serviceId: varU32.asOpaque(),
|
|
21319
|
-
argsLength: varU32,
|
|
21439
|
+
const ARGS_CODEC$1 = codec.object({
|
|
21440
|
+
slot: codec.varU32.asOpaque(),
|
|
21441
|
+
serviceId: codec.varU32.asOpaque(),
|
|
21442
|
+
argsLength: codec.varU32,
|
|
21320
21443
|
});
|
|
21321
21444
|
class Accumulate {
|
|
21322
21445
|
chainSpec;
|
|
21323
21446
|
blake2b;
|
|
21324
21447
|
state;
|
|
21325
|
-
|
|
21326
|
-
constructor(chainSpec, blake2b, state,
|
|
21448
|
+
options;
|
|
21449
|
+
constructor(chainSpec, blake2b, state, options) {
|
|
21327
21450
|
this.chainSpec = chainSpec;
|
|
21328
21451
|
this.blake2b = blake2b;
|
|
21329
21452
|
this.state = state;
|
|
21330
|
-
this.
|
|
21453
|
+
this.options = options;
|
|
21454
|
+
if (options.accumulateSequentially === true) {
|
|
21455
|
+
logger$5.warn `⚠️ Parallel accumulation is disabled. Running in sequential mode.`;
|
|
21456
|
+
}
|
|
21331
21457
|
}
|
|
21332
21458
|
/**
|
|
21333
21459
|
* Returns an index that determines how many WorkReports can be processed before exceeding a given gasLimit.
|
|
@@ -21379,7 +21505,7 @@ class Accumulate {
|
|
|
21379
21505
|
serviceExternalities: partialState,
|
|
21380
21506
|
fetchExternalities,
|
|
21381
21507
|
};
|
|
21382
|
-
const executor = await PvmExecutor.createAccumulateExecutor(serviceId, code, externalities, this.chainSpec, this.pvm);
|
|
21508
|
+
const executor = await PvmExecutor.createAccumulateExecutor(serviceId, code, externalities, this.chainSpec, this.options.pvm);
|
|
21383
21509
|
const invocationArgs = Encoder.encodeObject(ARGS_CODEC$1, {
|
|
21384
21510
|
slot,
|
|
21385
21511
|
serviceId,
|
|
@@ -21596,6 +21722,9 @@ class Accumulate {
|
|
|
21596
21722
|
];
|
|
21597
21723
|
return resultEntry;
|
|
21598
21724
|
});
|
|
21725
|
+
if (this.options.accumulateSequentially === true) {
|
|
21726
|
+
await promise;
|
|
21727
|
+
}
|
|
21599
21728
|
resultPromises[serviceIndex] = promise;
|
|
21600
21729
|
}
|
|
21601
21730
|
return Promise.all(resultPromises).then((results) => new Map(results));
|
|
@@ -21720,10 +21849,10 @@ class Accumulate {
|
|
|
21720
21849
|
}
|
|
21721
21850
|
}
|
|
21722
21851
|
|
|
21723
|
-
const ARGS_CODEC = object({
|
|
21724
|
-
timeslot: varU32.asOpaque(),
|
|
21725
|
-
serviceId: varU32.asOpaque(),
|
|
21726
|
-
transfersLength: varU32,
|
|
21852
|
+
const ARGS_CODEC = codec.object({
|
|
21853
|
+
timeslot: codec.varU32.asOpaque(),
|
|
21854
|
+
serviceId: codec.varU32.asOpaque(),
|
|
21855
|
+
transfersLength: codec.varU32,
|
|
21727
21856
|
});
|
|
21728
21857
|
var DeferredTransfersErrorCode;
|
|
21729
21858
|
(function (DeferredTransfersErrorCode) {
|
|
@@ -21904,7 +22033,7 @@ class BlockVerifier {
|
|
|
21904
22033
|
}
|
|
21905
22034
|
}
|
|
21906
22035
|
// Check if extrinsic is valid.
|
|
21907
|
-
// https://graypaper.fluffylabs.dev/#/
|
|
22036
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/0cba000cba00?v=0.7.2
|
|
21908
22037
|
const extrinsicHash = headerView.extrinsicHash.materialize();
|
|
21909
22038
|
const extrinsicMerkleCommitment = this.hasher.extrinsic(block.extrinsic.view());
|
|
21910
22039
|
if (!extrinsicHash.isEqualTo(extrinsicMerkleCommitment.hash)) {
|
|
@@ -23230,59 +23359,6 @@ class RecentHistory {
|
|
|
23230
23359
|
}
|
|
23231
23360
|
}
|
|
23232
23361
|
|
|
23233
|
-
/** Error that may happen during reports processing. */
|
|
23234
|
-
var ReportsError;
|
|
23235
|
-
(function (ReportsError) {
|
|
23236
|
-
/** Core index is greater than the number of available cores. */
|
|
23237
|
-
ReportsError[ReportsError["BadCoreIndex"] = 0] = "BadCoreIndex";
|
|
23238
|
-
/** The report slot is greater than the current block slot. */
|
|
23239
|
-
ReportsError[ReportsError["FutureReportSlot"] = 1] = "FutureReportSlot";
|
|
23240
|
-
/** Report is too old to be considered. */
|
|
23241
|
-
ReportsError[ReportsError["ReportEpochBeforeLast"] = 2] = "ReportEpochBeforeLast";
|
|
23242
|
-
/** Not enough credentials for the guarantee. */
|
|
23243
|
-
ReportsError[ReportsError["InsufficientGuarantees"] = 3] = "InsufficientGuarantees";
|
|
23244
|
-
/** Guarantees are not ordered by the core index. */
|
|
23245
|
-
ReportsError[ReportsError["OutOfOrderGuarantee"] = 4] = "OutOfOrderGuarantee";
|
|
23246
|
-
/** Credentials of guarantors are not sorted or unique. */
|
|
23247
|
-
ReportsError[ReportsError["NotSortedOrUniqueGuarantors"] = 5] = "NotSortedOrUniqueGuarantors";
|
|
23248
|
-
/** Validator in credentials is assigned to a different core. */
|
|
23249
|
-
ReportsError[ReportsError["WrongAssignment"] = 6] = "WrongAssignment";
|
|
23250
|
-
/** There is a report pending availability on that core already. */
|
|
23251
|
-
ReportsError[ReportsError["CoreEngaged"] = 7] = "CoreEngaged";
|
|
23252
|
-
/** Anchor block is not found in recent blocks. */
|
|
23253
|
-
ReportsError[ReportsError["AnchorNotRecent"] = 8] = "AnchorNotRecent";
|
|
23254
|
-
/** Service not foubd. */
|
|
23255
|
-
ReportsError[ReportsError["BadServiceId"] = 9] = "BadServiceId";
|
|
23256
|
-
/** Service code hash does not match the current one. */
|
|
23257
|
-
ReportsError[ReportsError["BadCodeHash"] = 10] = "BadCodeHash";
|
|
23258
|
-
/** Pre-requisite work package is missing in either recent blocks or lookup extrinsic. */
|
|
23259
|
-
ReportsError[ReportsError["DependencyMissing"] = 11] = "DependencyMissing";
|
|
23260
|
-
/** Results for the same package are in more than one report. */
|
|
23261
|
-
ReportsError[ReportsError["DuplicatePackage"] = 12] = "DuplicatePackage";
|
|
23262
|
-
/** Anchor block declared state root does not match the one we have in recent blocks. */
|
|
23263
|
-
ReportsError[ReportsError["BadStateRoot"] = 13] = "BadStateRoot";
|
|
23264
|
-
/** BEEFY super hash mmr mismatch. */
|
|
23265
|
-
ReportsError[ReportsError["BadBeefyMmrRoot"] = 14] = "BadBeefyMmrRoot";
|
|
23266
|
-
/** The authorization hash is not found in the authorization pool. */
|
|
23267
|
-
ReportsError[ReportsError["CoreUnauthorized"] = 15] = "CoreUnauthorized";
|
|
23268
|
-
/** Validator index is greater than the number of validators. */
|
|
23269
|
-
ReportsError[ReportsError["BadValidatorIndex"] = 16] = "BadValidatorIndex";
|
|
23270
|
-
/** Total gas of work report is too high. */
|
|
23271
|
-
ReportsError[ReportsError["WorkReportGasTooHigh"] = 17] = "WorkReportGasTooHigh";
|
|
23272
|
-
/** Work item has is smaller than required minimal accumulation gas of a service. */
|
|
23273
|
-
ReportsError[ReportsError["ServiceItemGasTooLow"] = 18] = "ServiceItemGasTooLow";
|
|
23274
|
-
/** The report has too many dependencies (prerequisites and/or segment-root lookups). */
|
|
23275
|
-
ReportsError[ReportsError["TooManyDependencies"] = 19] = "TooManyDependencies";
|
|
23276
|
-
/** Segment root lookup block has invalid time slot or is not found in the header chain. */
|
|
23277
|
-
ReportsError[ReportsError["SegmentRootLookupInvalid"] = 20] = "SegmentRootLookupInvalid";
|
|
23278
|
-
/** Signature in credentials is invalid. */
|
|
23279
|
-
ReportsError[ReportsError["BadSignature"] = 21] = "BadSignature";
|
|
23280
|
-
/** Size of authorizer output and all work-item successful output blobs is too big. */
|
|
23281
|
-
ReportsError[ReportsError["WorkReportTooBig"] = 22] = "WorkReportTooBig";
|
|
23282
|
-
/** Contains guarantee from validator that is proven to be an offender. */
|
|
23283
|
-
ReportsError[ReportsError["BannedValidator"] = 23] = "BannedValidator";
|
|
23284
|
-
})(ReportsError || (ReportsError = {}));
|
|
23285
|
-
|
|
23286
23362
|
const ENTROPY_BYTES = 32;
|
|
23287
23363
|
/**
|
|
23288
23364
|
* Deterministic variant of the Fisher–Yates shuffle function
|
|
@@ -23331,17 +23407,17 @@ var index$5 = /*#__PURE__*/Object.freeze({
|
|
|
23331
23407
|
* reports for it. This is borne out with V= 1023 validators
|
|
23332
23408
|
* and C = 341 cores, since V/C = 3. The core index assigned to
|
|
23333
23409
|
* each of the validators, as well as the validators’ Ed25519
|
|
23334
|
-
* keys are denoted by
|
|
23410
|
+
* keys are denoted by M.
|
|
23335
23411
|
*
|
|
23336
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23412
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/144c02145402?v=0.7.2
|
|
23337
23413
|
*/
|
|
23338
23414
|
/**
|
|
23339
23415
|
* Returns core assignments for each validator index.
|
|
23340
23416
|
*
|
|
23341
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23417
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/155300155d00?v=0.7.2
|
|
23342
23418
|
*/
|
|
23343
23419
|
function generateCoreAssignment(spec, blake2b,
|
|
23344
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
23420
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/147102147102?v=0.7.2 */
|
|
23345
23421
|
eta2entropy,
|
|
23346
23422
|
/** timeslot */
|
|
23347
23423
|
slot) {
|
|
@@ -23351,7 +23427,7 @@ slot) {
|
|
|
23351
23427
|
function rotationIndex(slot, rotationPeriod) {
|
|
23352
23428
|
return asOpaqueType(Math.floor(slot / rotationPeriod));
|
|
23353
23429
|
}
|
|
23354
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
23430
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/151900151900?v=0.7.2 */
|
|
23355
23431
|
function permute(blake2b, entropy, slot, spec) {
|
|
23356
23432
|
const shift = rotationIndex(tryAsTimeSlot(slot % spec.epochLength), spec.rotationPeriod);
|
|
23357
23433
|
const initialAssignment = Array(spec.validatorsCount)
|
|
@@ -23366,58 +23442,14 @@ function permute(blake2b, entropy, slot, spec) {
|
|
|
23366
23442
|
// we are sure this is PerValidator, since that's the array we create earlier.
|
|
23367
23443
|
return asKnownSize(coreAssignment);
|
|
23368
23444
|
}
|
|
23369
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
23445
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/148002148002?v=0.7.2 */
|
|
23370
23446
|
function rotate(cores, n, noOfCores) {
|
|
23371
23447
|
// modulo `noOfCores` guarantees that we're within `CoreIndex` range.
|
|
23372
23448
|
return cores.map((x) => asOpaqueType((x + n) % noOfCores));
|
|
23373
23449
|
}
|
|
23374
23450
|
|
|
23375
|
-
/**
|
|
23376
|
-
* `W_R = 48 * 2**10`: The maximum total size of all output blobs in a work-report, in octets.
|
|
23377
|
-
*
|
|
23378
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/41a60041aa00?v=0.6.2
|
|
23379
|
-
*/
|
|
23380
|
-
const MAX_WORK_REPORT_SIZE_BYTES = 48 * 2 ** 10;
|
|
23381
|
-
function verifyReportsBasic(input) {
|
|
23382
|
-
for (const guarantee of input) {
|
|
23383
|
-
const reportView = guarantee.view().report.view();
|
|
23384
|
-
/**
|
|
23385
|
-
* We limit the sum of the number of items in the
|
|
23386
|
-
* segment-root lookup dictionary and the number of
|
|
23387
|
-
* prerequisites to J = 8:
|
|
23388
|
-
*
|
|
23389
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/13ab0013ad00?v=0.6.2
|
|
23390
|
-
*/
|
|
23391
|
-
const noOfPrerequisites = reportView.context.view().prerequisites.view().length;
|
|
23392
|
-
const noOfSegmentRootLookups = reportView.segmentRootLookup.view().length;
|
|
23393
|
-
if (noOfPrerequisites + noOfSegmentRootLookups > MAX_REPORT_DEPENDENCIES) {
|
|
23394
|
-
return Result$1.error(ReportsError.TooManyDependencies, () => `Report at ${reportView.coreIndex.materialize()} has too many dependencies. Got ${noOfPrerequisites} + ${noOfSegmentRootLookups}, max: ${MAX_REPORT_DEPENDENCIES}`);
|
|
23395
|
-
}
|
|
23396
|
-
/**
|
|
23397
|
-
* In order to ensure fair use of a block’s extrinsic space,
|
|
23398
|
-
* work-reports are limited in the maximum total size of the
|
|
23399
|
-
* successful output blobs together with the authorizer output
|
|
23400
|
-
* blob, effectively limiting their overall size:
|
|
23401
|
-
*
|
|
23402
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/141d00142000?v=0.6.2
|
|
23403
|
-
*/
|
|
23404
|
-
// adding is safe here, since the total-encoded size of the report
|
|
23405
|
-
// is limited as well. Even though we just have a view, the size
|
|
23406
|
-
// should have been verified earlier.
|
|
23407
|
-
const authOutputSize = reportView.authorizationOutput.view().length;
|
|
23408
|
-
let totalOutputsSize = 0;
|
|
23409
|
-
for (const item of reportView.results.view()) {
|
|
23410
|
-
totalOutputsSize += item.view().result.view().okBlob?.raw.length ?? 0;
|
|
23411
|
-
}
|
|
23412
|
-
if (authOutputSize + totalOutputsSize > MAX_WORK_REPORT_SIZE_BYTES) {
|
|
23413
|
-
return Result$1.error(ReportsError.WorkReportTooBig, () => `Work report at ${reportView.coreIndex.materialize()} too big. Got ${authOutputSize} + ${totalOutputsSize}, max: ${MAX_WORK_REPORT_SIZE_BYTES}`);
|
|
23414
|
-
}
|
|
23415
|
-
}
|
|
23416
|
-
return Result$1.ok(OK);
|
|
23417
|
-
}
|
|
23418
|
-
|
|
23419
23451
|
const logger$3 = Logger.new(undefined, "stf:reports");
|
|
23420
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
23452
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/158202158202?v=0.7.2 */
|
|
23421
23453
|
function verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge) {
|
|
23422
23454
|
const contexts = [];
|
|
23423
23455
|
// hashes of work packages reported in this extrinsic
|
|
@@ -23439,8 +23471,11 @@ function verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge)
|
|
|
23439
23471
|
if (service === null) {
|
|
23440
23472
|
return Result$1.error(ReportsError.BadServiceId, () => `No service with id: ${result.serviceId}`);
|
|
23441
23473
|
}
|
|
23442
|
-
|
|
23443
|
-
|
|
23474
|
+
/**
|
|
23475
|
+
* Check service code hash
|
|
23476
|
+
*
|
|
23477
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/150804150804?v=0.7.2
|
|
23478
|
+
*/
|
|
23444
23479
|
if (!result.codeHash.isEqualTo(service.getInfo().codeHash)) {
|
|
23445
23480
|
return Result$1.error(ReportsError.BadCodeHash, () => `Service (${result.serviceId}) code hash mismatch. Got: ${result.codeHash}, expected: ${service.getInfo().codeHash}`);
|
|
23446
23481
|
}
|
|
@@ -23450,7 +23485,7 @@ function verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge)
|
|
|
23450
23485
|
* There must be no duplicate work-package hashes (i.e.
|
|
23451
23486
|
* two work-reports of the same package).
|
|
23452
23487
|
*
|
|
23453
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23488
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/159c02159e02?v=0.7.2
|
|
23454
23489
|
*/
|
|
23455
23490
|
if (currentWorkPackages.size !== input.guarantees.length) {
|
|
23456
23491
|
return Result$1.error(ReportsError.DuplicatePackage, () => "Duplicate work package detected.");
|
|
@@ -23504,7 +23539,7 @@ function verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge)
|
|
|
23504
23539
|
}
|
|
23505
23540
|
return Result$1.ok(currentWorkPackages);
|
|
23506
23541
|
}
|
|
23507
|
-
/** https://graypaper.fluffylabs.dev/#/
|
|
23542
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/15cd0215cd02?v=0.7.2 */
|
|
23508
23543
|
function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate, headerChain) {
|
|
23509
23544
|
// TODO [ToDr] [opti] This could be cached and updated efficiently between runs.
|
|
23510
23545
|
const recentBlocks = HashDictionary.new();
|
|
@@ -23515,9 +23550,9 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
|
|
|
23515
23550
|
/**
|
|
23516
23551
|
* We require that the anchor block be within the last H
|
|
23517
23552
|
* blocks and that its details be correct by ensuring that it
|
|
23518
|
-
* appears within our most recent blocks
|
|
23553
|
+
* appears within our most recent blocks β†:
|
|
23519
23554
|
*
|
|
23520
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23555
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/15ad0215af02?v=0.7.2
|
|
23521
23556
|
*/
|
|
23522
23557
|
const recentBlock = recentBlocks.get(context.anchor);
|
|
23523
23558
|
if (recentBlock === undefined) {
|
|
@@ -23536,7 +23571,7 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
|
|
|
23536
23571
|
* We require that each lookup-anchor block be within the
|
|
23537
23572
|
* last L timeslots.
|
|
23538
23573
|
*
|
|
23539
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23574
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/15ce0215cf02?v=0.7.2
|
|
23540
23575
|
*/
|
|
23541
23576
|
if (context.lookupAnchorSlot < minLookupSlot) {
|
|
23542
23577
|
return Result$1.error(ReportsError.SegmentRootLookupInvalid, () => `Lookup anchor slot's too old. Got: ${context.lookupAnchorSlot}, minimal: ${minLookupSlot}`);
|
|
@@ -23547,7 +23582,7 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
|
|
|
23547
23582
|
* on-chain state and must be checked by virtue of retaini
|
|
23548
23583
|
* ing the series of the last L headers as the ancestor set A.
|
|
23549
23584
|
*
|
|
23550
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23585
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/15e40215e702?v=0.7.2
|
|
23551
23586
|
*/
|
|
23552
23587
|
const isInChain = recentBlocks.has(context.lookupAnchor) ||
|
|
23553
23588
|
headerChain.isAncestor(context.lookupAnchorSlot, context.lookupAnchor, context.anchor);
|
|
@@ -23570,7 +23605,7 @@ function verifyDependencies({ currentWorkPackages, recentlyReported, prerequisit
|
|
|
23570
23605
|
* segment-root lookup, be either in the extrinsic or in our
|
|
23571
23606
|
* recent history.
|
|
23572
23607
|
*
|
|
23573
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23608
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/156b03156e03?v=0.7.2
|
|
23574
23609
|
*/
|
|
23575
23610
|
for (const preReqHash of dependencies) {
|
|
23576
23611
|
if (currentWorkPackages.has(preReqHash)) {
|
|
@@ -23599,7 +23634,7 @@ function verifyWorkPackagesUniqueness(workPackageHashes, state) {
|
|
|
23599
23634
|
/**
|
|
23600
23635
|
* Make sure that the package does not appear anywhere in the pipeline.
|
|
23601
23636
|
*
|
|
23602
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23637
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/152803152803?v=0.7.2
|
|
23603
23638
|
*/
|
|
23604
23639
|
// TODO [ToDr] [opti] this most likely should be cached and either
|
|
23605
23640
|
// re-computed on invalidity or we could maintain additional
|
|
@@ -23640,9 +23675,9 @@ function verifyCredentials(guarantees,
|
|
|
23640
23675
|
workReportHashes, slot, getGuarantorAssignment) {
|
|
23641
23676
|
/**
|
|
23642
23677
|
* Collect signatures payload for later verification
|
|
23643
|
-
* and construct the `reporters set
|
|
23678
|
+
* and construct the `reporters set G` from that data.
|
|
23644
23679
|
*
|
|
23645
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23680
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/153002153002?v=0.7.2
|
|
23646
23681
|
*/
|
|
23647
23682
|
const signaturesToVerify = [];
|
|
23648
23683
|
const headerTimeSlot = slot;
|
|
@@ -23656,7 +23691,7 @@ workReportHashes, slot, getGuarantorAssignment) {
|
|
|
23656
23691
|
* The credential is a sequence of two or three tuples of a
|
|
23657
23692
|
* unique validator index and a signature.
|
|
23658
23693
|
*
|
|
23659
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23694
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/152b01152d01?v=0.7.2
|
|
23660
23695
|
*/
|
|
23661
23696
|
const credentialsView = guaranteeView.credentials.view();
|
|
23662
23697
|
if (credentialsView.length < REQUIRED_CREDENTIALS_RANGE[0] ||
|
|
@@ -23686,7 +23721,8 @@ workReportHashes, slot, getGuarantorAssignment) {
|
|
|
23686
23721
|
}
|
|
23687
23722
|
/**
|
|
23688
23723
|
* Verify core assignment.
|
|
23689
|
-
*
|
|
23724
|
+
*
|
|
23725
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/155201155401?v=0.7.2
|
|
23690
23726
|
*/
|
|
23691
23727
|
if (guarantorData.core !== coreIndex) {
|
|
23692
23728
|
return Result$1.error(ReportsError.WrongAssignment, () => `Invalid core assignment for validator ${validatorIndex}. Expected: ${guarantorData.core}, got: ${coreIndex}`);
|
|
@@ -23705,7 +23741,7 @@ const JAM_GUARANTEE = BytesBlob.blobFromString("jam_guarantee").raw;
|
|
|
23705
23741
|
* The signature [...] whose message is the serialization of the hash
|
|
23706
23742
|
* of the work-report.
|
|
23707
23743
|
*
|
|
23708
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23744
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/15a20115a201?v=0.7.2
|
|
23709
23745
|
*/
|
|
23710
23746
|
function signingPayload(hash) {
|
|
23711
23747
|
return BytesBlob.blobFromParts(JAM_GUARANTEE, hash.raw);
|
|
@@ -23716,7 +23752,7 @@ function verifyReportsOrder(input, chainSpec) {
|
|
|
23716
23752
|
* The core index of each guarantee must be unique and
|
|
23717
23753
|
* guarantees must be in ascending order of this.
|
|
23718
23754
|
*
|
|
23719
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23755
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/15d60015d700?v=0.7.2
|
|
23720
23756
|
*/
|
|
23721
23757
|
const noOfCores = chainSpec.coresCount;
|
|
23722
23758
|
let lastCoreIndex = -1;
|
|
@@ -23745,7 +23781,7 @@ function verifyPostSignatureChecks(input, availabilityAssignment, authPools, ser
|
|
|
23745
23781
|
* No reports may be placed on cores with a report pending
|
|
23746
23782
|
* availability on it.
|
|
23747
23783
|
*
|
|
23748
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23784
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/155002155002?v=0.7.2
|
|
23749
23785
|
*/
|
|
23750
23786
|
if (availabilityAssignment[coreIndex] !== null) {
|
|
23751
23787
|
return Result$1.error(ReportsError.CoreEngaged, () => `Report pending availability at core: ${coreIndex}`);
|
|
@@ -23755,7 +23791,7 @@ function verifyPostSignatureChecks(input, availabilityAssignment, authPools, ser
|
|
|
23755
23791
|
* in the authorizer pool of the core on which the work is
|
|
23756
23792
|
* reported.
|
|
23757
23793
|
*
|
|
23758
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23794
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/155102155302?v=0.7.2
|
|
23759
23795
|
*/
|
|
23760
23796
|
const authorizerHash = report.authorizerHash;
|
|
23761
23797
|
const authorizerPool = authPools.get(coreIndex);
|
|
@@ -23765,10 +23801,10 @@ function verifyPostSignatureChecks(input, availabilityAssignment, authPools, ser
|
|
|
23765
23801
|
}
|
|
23766
23802
|
/**
|
|
23767
23803
|
* We require that the gas allotted for accumulation of each
|
|
23768
|
-
* work
|
|
23804
|
+
* work-digest in each work-report respects its service’s
|
|
23769
23805
|
* minimum gas requirements.
|
|
23770
23806
|
*
|
|
23771
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23807
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/156602156802?v=0.7.2
|
|
23772
23808
|
*/
|
|
23773
23809
|
for (const result of report.results) {
|
|
23774
23810
|
const service = services(result.serviceId);
|
|
@@ -23840,10 +23876,11 @@ class Reports {
|
|
|
23840
23876
|
/**
|
|
23841
23877
|
* ρ′ - equivalent to ρ‡, except where the extrinsic replaced
|
|
23842
23878
|
* an entry. In the case an entry is replaced, the new value
|
|
23843
|
-
* includes the present time τ
|
|
23879
|
+
* includes the present time τ' allowing for the value to be
|
|
23844
23880
|
* replaced without respect to its availability once sufficient
|
|
23845
23881
|
* time has elapsed.
|
|
23846
|
-
*
|
|
23882
|
+
*
|
|
23883
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/161e00165900?v=0.7.2
|
|
23847
23884
|
*/
|
|
23848
23885
|
const availabilityAssignment = input.assurancesAvailAssignment.slice();
|
|
23849
23886
|
for (const guarantee of input.guarantees) {
|
|
@@ -23873,7 +23910,7 @@ class Reports {
|
|
|
23873
23910
|
return asKnownSize(workReportHashes);
|
|
23874
23911
|
}
|
|
23875
23912
|
verifyCredentials(input, workReportHashes) {
|
|
23876
|
-
return verifyCredentials(input.guarantees, workReportHashes, input.slot, (headerTimeSlot, guaranteeTimeSlot) => this.getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, input.newEntropy));
|
|
23913
|
+
return verifyCredentials(input.guarantees, workReportHashes, input.slot, (headerTimeSlot, guaranteeTimeSlot) => this.getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, input.newEntropy, input.currentValidatorData, input.previousValidatorData));
|
|
23877
23914
|
}
|
|
23878
23915
|
verifyPostSignatureChecks(input, assurancesAvailAssignment) {
|
|
23879
23916
|
const authPoolsView = this.state.view().authPoolsView();
|
|
@@ -23901,15 +23938,15 @@ class Reports {
|
|
|
23901
23938
|
* Get the guarantor assignment (both core and validator data)
|
|
23902
23939
|
* depending on the rotation.
|
|
23903
23940
|
*
|
|
23904
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23941
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/15df0115df01?v=0.7.2
|
|
23905
23942
|
*/
|
|
23906
|
-
getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, newEntropy) {
|
|
23943
|
+
getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, newEntropy, currentValidatorData, previousValidatorData) {
|
|
23907
23944
|
const epochLength = this.chainSpec.epochLength;
|
|
23908
23945
|
const rotationPeriod = this.chainSpec.rotationPeriod;
|
|
23909
23946
|
const headerRotation = rotationIndex(headerTimeSlot, rotationPeriod);
|
|
23910
23947
|
const guaranteeRotation = rotationIndex(guaranteeTimeSlot, rotationPeriod);
|
|
23911
23948
|
const minTimeSlot = Math.max(0, headerRotation - 1) * rotationPeriod;
|
|
23912
|
-
// https://graypaper.fluffylabs.dev/#/
|
|
23949
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/15980115be01?v=0.7.2
|
|
23913
23950
|
if (guaranteeTimeSlot > headerTimeSlot) {
|
|
23914
23951
|
return Result$1.error(ReportsError.FutureReportSlot, () => `Report slot is in future. Block ${headerTimeSlot}, Report: ${guaranteeTimeSlot}`);
|
|
23915
23952
|
}
|
|
@@ -23917,10 +23954,10 @@ class Reports {
|
|
|
23917
23954
|
return Result$1.error(ReportsError.ReportEpochBeforeLast, () => `Report slot is too old. Block ${headerTimeSlot}, Report: ${guaranteeTimeSlot}`);
|
|
23918
23955
|
}
|
|
23919
23956
|
// TODO [ToDr] [opti] below code needs cache.
|
|
23920
|
-
// The `
|
|
23957
|
+
// The `M` and `M*` sets should only be computed once per rotation.
|
|
23921
23958
|
// Default data for the current rotation
|
|
23922
23959
|
let entropy = newEntropy[2];
|
|
23923
|
-
let validatorData =
|
|
23960
|
+
let validatorData = currentValidatorData;
|
|
23924
23961
|
let timeSlot = headerTimeSlot;
|
|
23925
23962
|
// we might need a different set of data
|
|
23926
23963
|
if (headerRotation > guaranteeRotation) {
|
|
@@ -23930,11 +23967,11 @@ class Reports {
|
|
|
23930
23967
|
// if the epoch changed, we need to take previous entropy and previous validator data.
|
|
23931
23968
|
if (isPreviousRotationPreviousEpoch(timeSlot, headerTimeSlot, epochLength)) {
|
|
23932
23969
|
entropy = newEntropy[3];
|
|
23933
|
-
validatorData =
|
|
23970
|
+
validatorData = previousValidatorData;
|
|
23934
23971
|
}
|
|
23935
23972
|
}
|
|
23936
23973
|
// we know which entropy, timeSlot and validatorData should be used,
|
|
23937
|
-
// so we can compute `
|
|
23974
|
+
// so we can compute `M` or `M*` here.
|
|
23938
23975
|
const coreAssignment = generateCoreAssignment(this.chainSpec, this.blake2b, entropy, timeSlot);
|
|
23939
23976
|
return Result$1.ok(zip(coreAssignment, validatorData, (core, validator) => ({
|
|
23940
23977
|
core,
|
|
@@ -24102,22 +24139,23 @@ class Statistics {
|
|
|
24102
24139
|
const newPreImagesSize = current[authorIndex].preImagesSize + preImagesSize;
|
|
24103
24140
|
current[authorIndex].preImagesSize = tryAsU32(newPreImagesSize);
|
|
24104
24141
|
/**
|
|
24105
|
-
*
|
|
24106
|
-
* Kappa' is not needed because we can use validator indexes directly from guarantees extrinsic.
|
|
24107
|
-
* I asked a question to ensure it is true but I didn't get any response yet:
|
|
24108
|
-
* https://github.com/w3f/jamtestvectors/pull/28#discussion_r190723700
|
|
24142
|
+
* Update guarantees
|
|
24109
24143
|
*
|
|
24110
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
24144
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/19ea0119f201?v=0.7.2
|
|
24111
24145
|
*/
|
|
24112
|
-
const
|
|
24113
|
-
for (const
|
|
24114
|
-
|
|
24115
|
-
|
|
24116
|
-
|
|
24117
|
-
|
|
24118
|
-
|
|
24119
|
-
|
|
24146
|
+
const validatorKeys = input.currentValidatorData.map((v) => v.ed25519);
|
|
24147
|
+
for (const reporter of input.reporters) {
|
|
24148
|
+
const index = validatorKeys.findIndex((x) => x.isEqualTo(reporter));
|
|
24149
|
+
if (index === -1) {
|
|
24150
|
+
/**
|
|
24151
|
+
* it should never happen because:
|
|
24152
|
+
* 1. the extrinsic is verified in reports transition
|
|
24153
|
+
* 2. we use current validators set from safrole
|
|
24154
|
+
*/
|
|
24155
|
+
continue;
|
|
24120
24156
|
}
|
|
24157
|
+
const newGuaranteesCount = current[index].guarantees + 1;
|
|
24158
|
+
current[index].guarantees = tryAsU32(newGuaranteesCount);
|
|
24121
24159
|
}
|
|
24122
24160
|
for (const { validatorIndex } of extrinsic.assurances) {
|
|
24123
24161
|
const newAssurancesCount = current[validatorIndex].assurances + 1;
|
|
@@ -24272,7 +24310,7 @@ class OnChain {
|
|
|
24272
24310
|
// chapter 13: https://graypaper.fluffylabs.dev/#/68eaa1f/18b60118b601?v=0.6.4
|
|
24273
24311
|
statistics;
|
|
24274
24312
|
isReadyForNextEpoch = Promise.resolve(false);
|
|
24275
|
-
constructor(chainSpec, state, hasher,
|
|
24313
|
+
constructor(chainSpec, state, hasher, options, headerChain) {
|
|
24276
24314
|
this.chainSpec = chainSpec;
|
|
24277
24315
|
this.state = state;
|
|
24278
24316
|
this.hasher = hasher;
|
|
@@ -24284,9 +24322,9 @@ class OnChain {
|
|
|
24284
24322
|
this.disputes = new Disputes(chainSpec, hasher.blake2b, state);
|
|
24285
24323
|
this.reports = new Reports(chainSpec, hasher.blake2b, state, headerChain);
|
|
24286
24324
|
this.assurances = new Assurances(chainSpec, state, hasher.blake2b);
|
|
24287
|
-
this.accumulate = new Accumulate(chainSpec, hasher.blake2b, state,
|
|
24325
|
+
this.accumulate = new Accumulate(chainSpec, hasher.blake2b, state, options);
|
|
24288
24326
|
this.accumulateOutput = new AccumulateOutput();
|
|
24289
|
-
this.deferredTransfers = new DeferredTransfers(chainSpec, hasher.blake2b, state, pvm);
|
|
24327
|
+
this.deferredTransfers = new DeferredTransfers(chainSpec, hasher.blake2b, state, options.pvm);
|
|
24290
24328
|
this.preimages = new Preimages(state, hasher.blake2b);
|
|
24291
24329
|
this.authorization = new Authorization(chainSpec, state);
|
|
24292
24330
|
}
|
|
@@ -24370,12 +24408,13 @@ class OnChain {
|
|
|
24370
24408
|
recentBlocksPartialUpdate,
|
|
24371
24409
|
assurancesAvailAssignment,
|
|
24372
24410
|
offenders: offendersMark,
|
|
24411
|
+
currentValidatorData,
|
|
24412
|
+
previousValidatorData,
|
|
24373
24413
|
});
|
|
24374
24414
|
if (reportsResult.isError) {
|
|
24375
24415
|
return stfError(StfErrorKind.Reports, reportsResult);
|
|
24376
24416
|
}
|
|
24377
|
-
|
|
24378
|
-
const { reported: workPackages, reporters: _, stateUpdate: reportsUpdate, ...reportsRest } = reportsResult.ok;
|
|
24417
|
+
const { reported: workPackages, reporters, stateUpdate: reportsUpdate, ...reportsRest } = reportsResult.ok;
|
|
24379
24418
|
assertEmpty(reportsRest);
|
|
24380
24419
|
const { availabilityAssignment: reportsAvailAssignment, ...reportsUpdateRest } = reportsUpdate;
|
|
24381
24420
|
assertEmpty(reportsUpdateRest);
|
|
@@ -24389,7 +24428,7 @@ class OnChain {
|
|
|
24389
24428
|
}
|
|
24390
24429
|
const { preimages, ...preimagesRest } = preimagesResult.ok;
|
|
24391
24430
|
assertEmpty(preimagesRest);
|
|
24392
|
-
const timerAccumulate = measure(`import:accumulate (${PvmBackend[this.accumulate.pvm]})`);
|
|
24431
|
+
const timerAccumulate = measure(`import:accumulate (${PvmBackend[this.accumulate.options.pvm]})`);
|
|
24393
24432
|
// accumulate
|
|
24394
24433
|
const accumulateResult = await this.accumulate.transition({
|
|
24395
24434
|
slot: timeSlot,
|
|
@@ -24449,6 +24488,8 @@ class OnChain {
|
|
|
24449
24488
|
availableReports,
|
|
24450
24489
|
accumulationStatistics,
|
|
24451
24490
|
transferStatistics,
|
|
24491
|
+
reporters: reporters,
|
|
24492
|
+
currentValidatorData,
|
|
24452
24493
|
});
|
|
24453
24494
|
const { statistics, ...statisticsRest } = statisticsUpdate;
|
|
24454
24495
|
assertEmpty(statisticsRest);
|
|
@@ -24540,7 +24581,7 @@ class TransitionHasher {
|
|
|
24540
24581
|
extrinsic(extrinsicView) {
|
|
24541
24582
|
// https://graypaper.fluffylabs.dev/#/cc517d7/0cfb000cfb00?v=0.6.5
|
|
24542
24583
|
const guaranteesCount = tryAsU32(extrinsicView.guarantees.view().length);
|
|
24543
|
-
const countEncoded = Encoder.encodeObject(varU32, guaranteesCount);
|
|
24584
|
+
const countEncoded = Encoder.encodeObject(codec.varU32, guaranteesCount);
|
|
24544
24585
|
const guaranteesBlobs = extrinsicView.guarantees
|
|
24545
24586
|
.view()
|
|
24546
24587
|
.map((g) => g.view())
|
|
@@ -25381,7 +25422,7 @@ var MetricsAPI = /** @class */ (function () {
|
|
|
25381
25422
|
var metrics = MetricsAPI.getInstance();
|
|
25382
25423
|
|
|
25383
25424
|
var name = "@typeberry/importer";
|
|
25384
|
-
var version = "0.5.
|
|
25425
|
+
var version = "0.5.1";
|
|
25385
25426
|
var packageJson = {
|
|
25386
25427
|
name: name,
|
|
25387
25428
|
version: version};
|
|
@@ -25491,7 +25532,7 @@ class Importer {
|
|
|
25491
25532
|
throw new Error(`Unable to load best state from header hash: ${currentBestHeaderHash}.`);
|
|
25492
25533
|
}
|
|
25493
25534
|
this.verifier = new BlockVerifier(hasher, blocks);
|
|
25494
|
-
this.stf = new OnChain(spec, state, hasher, pvm, DbHeaderChain.new(blocks));
|
|
25535
|
+
this.stf = new OnChain(spec, state, hasher, { pvm, accumulateSequentially: false }, DbHeaderChain.new(blocks));
|
|
25495
25536
|
this.state = state;
|
|
25496
25537
|
this.currentHash = currentBestHeaderHash;
|
|
25497
25538
|
this.prepareForNextEpoch();
|
|
@@ -25637,11 +25678,11 @@ const blake2b = Blake2b.createHasher();
|
|
|
25637
25678
|
async function createImporter(config) {
|
|
25638
25679
|
const chainSpec = config.chainSpec;
|
|
25639
25680
|
const db = config.openDatabase({ readonly: false });
|
|
25640
|
-
const
|
|
25681
|
+
const pvm = config.workerParams.pvm;
|
|
25641
25682
|
const blocks = db.getBlocksDb();
|
|
25642
25683
|
const states = db.getStatesDb();
|
|
25643
25684
|
const hasher = new TransitionHasher(await keccakHasher, await blake2b);
|
|
25644
|
-
const importer = new Importer(chainSpec,
|
|
25685
|
+
const importer = new Importer(chainSpec, pvm, hasher, logger$1, blocks, states);
|
|
25645
25686
|
return {
|
|
25646
25687
|
importer,
|
|
25647
25688
|
db,
|
|
@@ -25810,7 +25851,7 @@ class DirectWorkerConfig {
|
|
|
25810
25851
|
workerParams;
|
|
25811
25852
|
blocksDb;
|
|
25812
25853
|
statesDb;
|
|
25813
|
-
static new({ nodeName, chainSpec, blocksDb, statesDb, params, }) {
|
|
25854
|
+
static new({ nodeName, chainSpec, blocksDb, statesDb, workerParams: params, }) {
|
|
25814
25855
|
return new DirectWorkerConfig(nodeName, chainSpec, params, blocksDb, statesDb);
|
|
25815
25856
|
}
|
|
25816
25857
|
constructor(nodeName, chainSpec, workerParams, blocksDb, statesDb) {
|
|
@@ -26254,7 +26295,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
26254
26295
|
startSameThread: startSameThread
|
|
26255
26296
|
});
|
|
26256
26297
|
|
|
26257
|
-
const importBlockResultCodec = (hashName) => custom({
|
|
26298
|
+
const importBlockResultCodec = (hashName) => codec.custom({
|
|
26258
26299
|
name: `Result<${hashName}, string>`,
|
|
26259
26300
|
sizeHint: { bytes: 1, isExact: false },
|
|
26260
26301
|
}, (e, x) => {
|
|
@@ -26292,33 +26333,33 @@ const importBlockResultCodec = (hashName) => custom({
|
|
|
26292
26333
|
const protocol = createProtocol("importer", {
|
|
26293
26334
|
toWorker: {
|
|
26294
26335
|
getStateEntries: {
|
|
26295
|
-
request: bytes(HASH_SIZE).asOpaque(),
|
|
26296
|
-
response: optional(StateEntries.Codec),
|
|
26336
|
+
request: codec.bytes(HASH_SIZE).asOpaque(),
|
|
26337
|
+
response: codec.optional(StateEntries.Codec),
|
|
26297
26338
|
},
|
|
26298
26339
|
getBestStateRootHash: {
|
|
26299
|
-
request: nothing,
|
|
26300
|
-
response: bytes(HASH_SIZE).asOpaque(),
|
|
26340
|
+
request: codec.nothing,
|
|
26341
|
+
response: codec.bytes(HASH_SIZE).asOpaque(),
|
|
26301
26342
|
},
|
|
26302
26343
|
importBlock: {
|
|
26303
26344
|
request: Block.Codec.View,
|
|
26304
26345
|
response: importBlockResultCodec("HeaderHash"),
|
|
26305
26346
|
},
|
|
26306
26347
|
finish: {
|
|
26307
|
-
request: nothing,
|
|
26308
|
-
response: nothing,
|
|
26348
|
+
request: codec.nothing,
|
|
26349
|
+
response: codec.nothing,
|
|
26309
26350
|
},
|
|
26310
26351
|
},
|
|
26311
26352
|
fromWorker: {
|
|
26312
26353
|
bestHeaderAnnouncement: {
|
|
26313
26354
|
request: headerViewWithHashCodec,
|
|
26314
|
-
response: nothing,
|
|
26355
|
+
response: codec.nothing,
|
|
26315
26356
|
},
|
|
26316
26357
|
},
|
|
26317
26358
|
});
|
|
26318
26359
|
class ImporterConfig {
|
|
26319
26360
|
pvm;
|
|
26320
|
-
static Codec = Class(ImporterConfig, {
|
|
26321
|
-
pvm: u8.convert((i) => tryAsU8(i), (o) => {
|
|
26361
|
+
static Codec = codec.Class(ImporterConfig, {
|
|
26362
|
+
pvm: codec.u8.convert((i) => tryAsU8(i), (o) => {
|
|
26322
26363
|
if (o === PvmBackend.BuiltIn) {
|
|
26323
26364
|
return PvmBackend.BuiltIn;
|
|
26324
26365
|
}
|
|
@@ -26336,7 +26377,7 @@ class ImporterConfig {
|
|
|
26336
26377
|
}
|
|
26337
26378
|
}
|
|
26338
26379
|
|
|
26339
|
-
const WORKER = new URL(
|
|
26380
|
+
const WORKER = new URL("./bootstrap-importer.mjs", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
26340
26381
|
|
|
26341
26382
|
var index$2 = /*#__PURE__*/Object.freeze({
|
|
26342
26383
|
__proto__: null,
|
|
@@ -26783,11 +26824,11 @@ class TestState {
|
|
|
26783
26824
|
state_root: fromJson.bytes32(),
|
|
26784
26825
|
keyvals: json.array(StateKeyVal.fromJson),
|
|
26785
26826
|
};
|
|
26786
|
-
static Codec = object({
|
|
26787
|
-
state_root: bytes(HASH_SIZE).asOpaque(),
|
|
26788
|
-
keyvals: sequenceVarLen(object({
|
|
26789
|
-
key: bytes(TRUNCATED_HASH_SIZE),
|
|
26790
|
-
value: blob,
|
|
26827
|
+
static Codec = codec.object({
|
|
26828
|
+
state_root: codec.bytes(HASH_SIZE).asOpaque(),
|
|
26829
|
+
keyvals: codec.sequenceVarLen(codec.object({
|
|
26830
|
+
key: codec.bytes(TRUNCATED_HASH_SIZE),
|
|
26831
|
+
value: codec.blob,
|
|
26791
26832
|
})),
|
|
26792
26833
|
});
|
|
26793
26834
|
state_root;
|
|
@@ -26798,7 +26839,7 @@ class StateTransitionGenesis {
|
|
|
26798
26839
|
header: headerFromJson,
|
|
26799
26840
|
state: TestState.fromJson,
|
|
26800
26841
|
};
|
|
26801
|
-
static Codec = object({
|
|
26842
|
+
static Codec = codec.object({
|
|
26802
26843
|
header: Header.Codec,
|
|
26803
26844
|
state: TestState.Codec,
|
|
26804
26845
|
});
|
|
@@ -26811,7 +26852,7 @@ class StateTransition {
|
|
|
26811
26852
|
post_state: TestState.fromJson,
|
|
26812
26853
|
block: blockFromJson(tinyChainSpec),
|
|
26813
26854
|
};
|
|
26814
|
-
static Codec = object({
|
|
26855
|
+
static Codec = codec.object({
|
|
26815
26856
|
pre_state: TestState.Codec,
|
|
26816
26857
|
block: Block.Codec,
|
|
26817
26858
|
post_state: TestState.Codec,
|