@typeberry/jam 0.2.0-b6e3410 → 0.2.0-e767e74
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/bootstrap-generator.mjs +1059 -880
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +1097 -913
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +993 -814
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +1096 -915
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-network.mjs
CHANGED
|
@@ -26103,6 +26103,9 @@ class ObjectView {
|
|
|
26103
26103
|
toString() {
|
|
26104
26104
|
return `View<${this.materializedConstructor.name}>(cache: ${this.cache.size})`;
|
|
26105
26105
|
}
|
|
26106
|
+
[TEST_COMPARE_USING]() {
|
|
26107
|
+
return this.materialize();
|
|
26108
|
+
}
|
|
26106
26109
|
}
|
|
26107
26110
|
/**
|
|
26108
26111
|
* A lazy-evaluated decoder of a sequence.
|
|
@@ -26235,7 +26238,7 @@ const TYPICAL_DICTIONARY_LENGTH = 32;
|
|
|
26235
26238
|
* It's not true in a general case, but should be good enough for us.
|
|
26236
26239
|
*
|
|
26237
26240
|
*/
|
|
26238
|
-
function
|
|
26241
|
+
function descriptors_readonlyArray(desc) {
|
|
26239
26242
|
return desc.convert((x) => {
|
|
26240
26243
|
debug_check `
|
|
26241
26244
|
${Array.isArray(x)}
|
|
@@ -26397,7 +26400,15 @@ var descriptors_codec;
|
|
|
26397
26400
|
/** Custom encoding / decoding logic. */
|
|
26398
26401
|
codec.custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
26399
26402
|
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
26400
|
-
codec.select = ({ name, sizeHint, }, chooser) =>
|
|
26403
|
+
codec.select = ({ name, sizeHint, }, chooser) => {
|
|
26404
|
+
const Self = chooser(null);
|
|
26405
|
+
return Descriptor.withView(name, sizeHint, (e, x) => chooser(e.getContext()).encode(e, x), (d) => chooser(d.getContext()).decode(d), (s) => chooser(s.decoder.getContext()).skip(s), hasUniqueView(Self)
|
|
26406
|
+
? codec.select({
|
|
26407
|
+
name: Self.View.name,
|
|
26408
|
+
sizeHint: Self.View.sizeHint,
|
|
26409
|
+
}, (ctx) => chooser(ctx).View)
|
|
26410
|
+
: Self.View);
|
|
26411
|
+
};
|
|
26401
26412
|
/**
|
|
26402
26413
|
* A descriptor for a more complex POJO.
|
|
26403
26414
|
*
|
|
@@ -27219,7 +27230,7 @@ const BANDERSNATCH_KEY_BYTES = 32;
|
|
|
27219
27230
|
/** Bandersnatch VRF signature size */
|
|
27220
27231
|
const bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES = 96;
|
|
27221
27232
|
/** Bandersnatch ring commitment size */
|
|
27222
|
-
const
|
|
27233
|
+
const bandersnatch_BANDERSNATCH_RING_ROOT_BYTES = 144;
|
|
27223
27234
|
/** Bandersnatch proof size */
|
|
27224
27235
|
const BANDERSNATCH_PROOF_BYTES = 784;
|
|
27225
27236
|
/** BLS public key size. */
|
|
@@ -28800,9 +28811,9 @@ function codecWithContext(chooser) {
|
|
|
28800
28811
|
/** Codec for a known-size array with length validation. */
|
|
28801
28812
|
const codecKnownSizeArray = (val, options, _id) => {
|
|
28802
28813
|
if ("fixedLength" in options) {
|
|
28803
|
-
return
|
|
28814
|
+
return descriptors_readonlyArray(descriptors_codec.sequenceFixLen(val, options.fixedLength)).convert(seeThrough, sized_array_asKnownSize);
|
|
28804
28815
|
}
|
|
28805
|
-
return
|
|
28816
|
+
return descriptors_readonlyArray(descriptors_codec.sequenceVarLen(val, options)).convert(seeThrough, sized_array_asKnownSize);
|
|
28806
28817
|
};
|
|
28807
28818
|
/** Codec for a fixed-size array with length validation. */
|
|
28808
28819
|
const codecFixedSizeArray = (val, len) => {
|
|
@@ -29176,16 +29187,16 @@ class SignedTicket extends WithDebug {
|
|
|
29176
29187
|
}
|
|
29177
29188
|
}
|
|
29178
29189
|
/** Anonymous? entry into the ticket contest. */
|
|
29179
|
-
class
|
|
29190
|
+
class tickets_Ticket extends WithDebug {
|
|
29180
29191
|
id;
|
|
29181
29192
|
attempt;
|
|
29182
|
-
static Codec = descriptors_codec.Class(
|
|
29193
|
+
static Codec = descriptors_codec.Class(tickets_Ticket, {
|
|
29183
29194
|
id: descriptors_codec.bytes(hash_HASH_SIZE),
|
|
29184
29195
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
29185
29196
|
attempt: descriptors_codec.u8.asOpaque(),
|
|
29186
29197
|
});
|
|
29187
29198
|
static create({ id, attempt }) {
|
|
29188
|
-
return new
|
|
29199
|
+
return new tickets_Ticket(id, attempt);
|
|
29189
29200
|
}
|
|
29190
29201
|
constructor(
|
|
29191
29202
|
/**
|
|
@@ -29297,7 +29308,7 @@ function tryAsPerValidator(array, spec) {
|
|
|
29297
29308
|
`;
|
|
29298
29309
|
return sized_array_asKnownSize(array);
|
|
29299
29310
|
}
|
|
29300
|
-
const
|
|
29311
|
+
const common_codecPerValidator = (val) => codecWithContext((context) => {
|
|
29301
29312
|
return codecKnownSizeArray(val, {
|
|
29302
29313
|
fixedLength: context.validatorsCount,
|
|
29303
29314
|
});
|
|
@@ -29424,7 +29435,7 @@ class Verdict extends WithDebug {
|
|
|
29424
29435
|
workReportHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
29425
29436
|
votesEpoch: descriptors_codec.u32.asOpaque(),
|
|
29426
29437
|
votes: codecWithContext((context) => {
|
|
29427
|
-
return
|
|
29438
|
+
return descriptors_readonlyArray(descriptors_codec.sequenceFixLen(Judgement.Codec, context.validatorsSuperMajority)).convert(seeThrough, sized_array_asKnownSize);
|
|
29428
29439
|
}),
|
|
29429
29440
|
});
|
|
29430
29441
|
static create({ workReportHash, votesEpoch, votes }) {
|
|
@@ -30116,7 +30127,7 @@ const WorkReportCodec = descriptors_codec.Class(WorkReportNoCodec, {
|
|
|
30116
30127
|
authorizerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
30117
30128
|
authorizationGasUsed: descriptors_codec.varU64.asOpaque(),
|
|
30118
30129
|
authorizationOutput: descriptors_codec.blob,
|
|
30119
|
-
segmentRootLookup:
|
|
30130
|
+
segmentRootLookup: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(WorkPackageInfo.Codec)),
|
|
30120
30131
|
results: descriptors_codec.sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
30121
30132
|
});
|
|
30122
30133
|
const WorkReportCodecPre070 = descriptors_codec.Class(WorkReportNoCodec, {
|
|
@@ -30130,7 +30141,7 @@ const WorkReportCodecPre070 = descriptors_codec.Class(WorkReportNoCodec, {
|
|
|
30130
30141
|
}),
|
|
30131
30142
|
authorizerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
30132
30143
|
authorizationOutput: descriptors_codec.blob,
|
|
30133
|
-
segmentRootLookup:
|
|
30144
|
+
segmentRootLookup: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(WorkPackageInfo.Codec)),
|
|
30134
30145
|
results: descriptors_codec.sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
30135
30146
|
authorizationGasUsed: descriptors_codec.varU64.asOpaque(),
|
|
30136
30147
|
});
|
|
@@ -30251,7 +30262,7 @@ class ValidatorKeys extends WithDebug {
|
|
|
30251
30262
|
class TicketsMarker extends WithDebug {
|
|
30252
30263
|
tickets;
|
|
30253
30264
|
static Codec = descriptors_codec.Class(TicketsMarker, {
|
|
30254
|
-
tickets: codecPerEpochBlock(
|
|
30265
|
+
tickets: codecPerEpochBlock(tickets_Ticket.Codec),
|
|
30255
30266
|
});
|
|
30256
30267
|
static create({ tickets }) {
|
|
30257
30268
|
return new TicketsMarker(tickets);
|
|
@@ -30275,7 +30286,7 @@ class EpochMarker extends WithDebug {
|
|
|
30275
30286
|
static Codec = descriptors_codec.Class(EpochMarker, {
|
|
30276
30287
|
entropy: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
30277
30288
|
ticketsEntropy: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
30278
|
-
validators:
|
|
30289
|
+
validators: common_codecPerValidator(ValidatorKeys.Codec),
|
|
30279
30290
|
});
|
|
30280
30291
|
static create({ entropy, ticketsEntropy, validators }) {
|
|
30281
30292
|
return new EpochMarker(entropy, ticketsEntropy, validators);
|
|
@@ -30547,6 +30558,19 @@ function emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
|
30547
30558
|
});
|
|
30548
30559
|
}
|
|
30549
30560
|
|
|
30561
|
+
;// CONCATENATED MODULE: ./packages/jam/block/utils.ts
|
|
30562
|
+
|
|
30563
|
+
/**
|
|
30564
|
+
* Take an input data and re-encode that data as view.
|
|
30565
|
+
*
|
|
30566
|
+
* NOTE: this function should NEVER be used in any production code,
|
|
30567
|
+
* it's only a test helper.
|
|
30568
|
+
*/
|
|
30569
|
+
function reencodeAsView(codec, object, chainSpec) {
|
|
30570
|
+
const encoded = encoder_Encoder.encodeObject(codec, object, chainSpec);
|
|
30571
|
+
return decoder_Decoder.decodeObject(codec.View, encoded, chainSpec);
|
|
30572
|
+
}
|
|
30573
|
+
|
|
30550
30574
|
;// CONCATENATED MODULE: ./packages/jam/block/index.ts
|
|
30551
30575
|
|
|
30552
30576
|
|
|
@@ -30565,6 +30589,7 @@ function emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
|
30565
30589
|
|
|
30566
30590
|
|
|
30567
30591
|
|
|
30592
|
+
|
|
30568
30593
|
;// CONCATENATED MODULE: ./packages/jam/block-json/disputes-extrinsic.ts
|
|
30569
30594
|
|
|
30570
30595
|
|
|
@@ -30804,7 +30829,7 @@ const epochMark = descriptors_json.object({
|
|
|
30804
30829
|
const ticket = descriptors_json.object({
|
|
30805
30830
|
id: common_fromJson.bytes32(),
|
|
30806
30831
|
attempt: common_fromJson.ticketAttempt,
|
|
30807
|
-
}, (x) =>
|
|
30832
|
+
}, (x) => tickets_Ticket.create({ id: x.id, attempt: x.attempt }));
|
|
30808
30833
|
const header_headerFromJson = descriptors_json.object({
|
|
30809
30834
|
parent: common_fromJson.bytes32(),
|
|
30810
30835
|
parent_state_root: common_fromJson.bytes32(),
|
|
@@ -31728,10 +31753,128 @@ function accumulationOutputComparator(a, b) {
|
|
|
31728
31753
|
return Ordering.Equal;
|
|
31729
31754
|
}
|
|
31730
31755
|
|
|
31756
|
+
;// CONCATENATED MODULE: ./packages/jam/block/gp-constants.ts
|
|
31757
|
+
|
|
31758
|
+
/**
|
|
31759
|
+
* This file lists all of the constants defined in the GrayPaper appendix.
|
|
31760
|
+
*
|
|
31761
|
+
* NOTE: Avoid using the constants directly, prefer "named" constants defined
|
|
31762
|
+
* in a semantical proximity to where they are used.
|
|
31763
|
+
*
|
|
31764
|
+
* NOTE: This file will most likely be removed in the future. The constants
|
|
31765
|
+
* here are only temporarily for convenience. When we figure out better names
|
|
31766
|
+
* and places for these this file will be eradicated.
|
|
31767
|
+
*
|
|
31768
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/413000413000
|
|
31769
|
+
*/
|
|
31770
|
+
/** `G_I`: The gas allocated to invoke a work-package’s Is-Authorized logic. */
|
|
31771
|
+
const G_I = 50_000_000;
|
|
31772
|
+
/** `I`: Maximum number of work items in a package. */
|
|
31773
|
+
const gp_constants_I = (/* unused pure expression or super */ null && (MAX_NUMBER_OF_WORK_ITEMS));
|
|
31774
|
+
/** `O`: Maximum number of items in the authorizations pool. */
|
|
31775
|
+
const O = 8;
|
|
31776
|
+
/** `Q`: The number of items in the authorizations queue. */
|
|
31777
|
+
const Q = 80;
|
|
31778
|
+
/** `S`: The maximum number of entries in the accumulation queue. */
|
|
31779
|
+
const S = 1024;
|
|
31780
|
+
/** `T`: The maximum number of extrinsics in a work-package. */
|
|
31781
|
+
const T = 128;
|
|
31782
|
+
/** `W_A`: The maximum size of is-authorized code in octets. */
|
|
31783
|
+
const W_A = 64_000;
|
|
31784
|
+
/** `W_B`: The maximum size of an encoded work-package with extrinsic data and imports. */
|
|
31785
|
+
const W_B = 13_794_305;
|
|
31786
|
+
/** `W_C`: The maximum size of service code in octets. */
|
|
31787
|
+
const W_C = 4_000_000;
|
|
31788
|
+
/** `W_M`: The maximum number of imports in a work-package. */
|
|
31789
|
+
const W_M = 3_072;
|
|
31790
|
+
/** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
|
|
31791
|
+
const W_R = 49_152;
|
|
31792
|
+
/** `W_T`: The size of a transfer memo in octets. */
|
|
31793
|
+
const W_T = 128;
|
|
31794
|
+
/** `W_M`: The maximum number of exports in a work-package. */
|
|
31795
|
+
const W_X = 3_072;
|
|
31796
|
+
// TODO [ToDr] Not sure where these should live yet :(
|
|
31797
|
+
/**
|
|
31798
|
+
* `S`: The minimum public service index.
|
|
31799
|
+
* Services of indices below these may only be created by the Registrar.
|
|
31800
|
+
*
|
|
31801
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/447a00447a00?v=0.7.2
|
|
31802
|
+
*/
|
|
31803
|
+
const MIN_PUBLIC_SERVICE_INDEX = (/* unused pure expression or super */ null && (2 ** 16));
|
|
31804
|
+
/**
|
|
31805
|
+
* `J`: The maximum sum of dependency items in a work-report.
|
|
31806
|
+
*
|
|
31807
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/416a00416a00?v=0.6.2
|
|
31808
|
+
*/
|
|
31809
|
+
const MAX_REPORT_DEPENDENCIES = 8;
|
|
31810
|
+
|
|
31811
|
+
;// CONCATENATED MODULE: ./packages/jam/state/accumulation-queue.ts
|
|
31812
|
+
|
|
31813
|
+
|
|
31814
|
+
|
|
31815
|
+
|
|
31816
|
+
|
|
31817
|
+
|
|
31818
|
+
|
|
31819
|
+
/**
|
|
31820
|
+
* Ready (i.e. available and/or audited) but not-yet-accumulated work-reports.
|
|
31821
|
+
*
|
|
31822
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/165300165400
|
|
31823
|
+
*/
|
|
31824
|
+
class NotYetAccumulatedReport extends WithDebug {
|
|
31825
|
+
report;
|
|
31826
|
+
dependencies;
|
|
31827
|
+
static Codec = descriptors_codec.Class(NotYetAccumulatedReport, {
|
|
31828
|
+
report: WorkReport.Codec,
|
|
31829
|
+
dependencies: codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
31830
|
+
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
31831
|
+
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
31832
|
+
minLength: 0,
|
|
31833
|
+
}),
|
|
31834
|
+
});
|
|
31835
|
+
static create({ report, dependencies }) {
|
|
31836
|
+
return new NotYetAccumulatedReport(report, dependencies);
|
|
31837
|
+
}
|
|
31838
|
+
constructor(
|
|
31839
|
+
/**
|
|
31840
|
+
* Each of these were made available at most one epoch ago
|
|
31841
|
+
* but have or had unfulfilled dependencies.
|
|
31842
|
+
*/
|
|
31843
|
+
report,
|
|
31844
|
+
/**
|
|
31845
|
+
* Alongside the work-report itself, we retain its un-accumulated
|
|
31846
|
+
* dependencies, a set of work-package hashes.
|
|
31847
|
+
*
|
|
31848
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/165800165800
|
|
31849
|
+
*/
|
|
31850
|
+
dependencies) {
|
|
31851
|
+
super();
|
|
31852
|
+
this.report = report;
|
|
31853
|
+
this.dependencies = dependencies;
|
|
31854
|
+
}
|
|
31855
|
+
}
|
|
31856
|
+
const accumulationQueueCodec = codecPerEpochBlock(descriptors_readonlyArray(descriptors_codec.sequenceVarLen(NotYetAccumulatedReport.Codec)));
|
|
31857
|
+
|
|
31858
|
+
;// CONCATENATED MODULE: ./packages/jam/state/common.ts
|
|
31859
|
+
|
|
31860
|
+
|
|
31861
|
+
/** Check if given array has correct length before casting to the opaque type. */
|
|
31862
|
+
function tryAsPerCore(array, spec) {
|
|
31863
|
+
debug_check `
|
|
31864
|
+
${array.length === spec.coresCount}
|
|
31865
|
+
Invalid per-core array length. Expected ${spec.coresCount}, got: ${array.length}
|
|
31866
|
+
`;
|
|
31867
|
+
return opaque_asOpaqueType(array);
|
|
31868
|
+
}
|
|
31869
|
+
const codecPerCore = (val) => codecWithContext((context) => {
|
|
31870
|
+
return codecKnownSizeArray(val, { fixedLength: context.coresCount });
|
|
31871
|
+
});
|
|
31872
|
+
|
|
31731
31873
|
;// CONCATENATED MODULE: ./packages/jam/state/assurances.ts
|
|
31732
31874
|
|
|
31733
31875
|
|
|
31734
31876
|
|
|
31877
|
+
|
|
31735
31878
|
/**
|
|
31736
31879
|
* Assignment of particular work report to a core.
|
|
31737
31880
|
*
|
|
@@ -31760,27 +31903,30 @@ class AvailabilityAssignment extends WithDebug {
|
|
|
31760
31903
|
this.timeout = timeout;
|
|
31761
31904
|
}
|
|
31762
31905
|
}
|
|
31906
|
+
const availabilityAssignmentsCodec = codecPerCore(descriptors_codec.optional(AvailabilityAssignment.Codec));
|
|
31763
31907
|
|
|
31764
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
31908
|
+
;// CONCATENATED MODULE: ./packages/jam/state/auth.ts
|
|
31765
31909
|
|
|
31766
31910
|
|
|
31767
|
-
|
|
31768
|
-
|
|
31769
|
-
|
|
31770
|
-
|
|
31771
|
-
|
|
31772
|
-
|
|
31773
|
-
|
|
31774
|
-
|
|
31775
|
-
|
|
31776
|
-
|
|
31777
|
-
|
|
31911
|
+
|
|
31912
|
+
|
|
31913
|
+
|
|
31914
|
+
/** `O`: Maximal authorization pool size. */
|
|
31915
|
+
const MAX_AUTH_POOL_SIZE = O;
|
|
31916
|
+
/** `Q`: Size of the authorization queue. */
|
|
31917
|
+
const AUTHORIZATION_QUEUE_SIZE = Q;
|
|
31918
|
+
const authPoolsCodec = codecPerCore(codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
31919
|
+
minLength: 0,
|
|
31920
|
+
maxLength: MAX_AUTH_POOL_SIZE,
|
|
31921
|
+
typicalLength: MAX_AUTH_POOL_SIZE,
|
|
31922
|
+
}));
|
|
31923
|
+
const authQueuesCodec = codecPerCore(codecFixedSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE));
|
|
31778
31924
|
|
|
31779
31925
|
;// CONCATENATED MODULE: ./packages/jam/state/disputes.ts
|
|
31780
31926
|
|
|
31781
31927
|
|
|
31782
31928
|
|
|
31783
|
-
const sortedSetCodec = () =>
|
|
31929
|
+
const sortedSetCodec = () => descriptors_readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.bytes(hash_HASH_SIZE))).convert((input) => input.array, (output) => {
|
|
31784
31930
|
const typed = output.map((x) => x.asOpaque());
|
|
31785
31931
|
return sorted_set_SortedSet.fromSortedArray(hashComparator, typed);
|
|
31786
31932
|
});
|
|
@@ -31842,65 +31988,6 @@ function hashComparator(a, b) {
|
|
|
31842
31988
|
return a.compare(b);
|
|
31843
31989
|
}
|
|
31844
31990
|
|
|
31845
|
-
;// CONCATENATED MODULE: ./packages/jam/block/gp-constants.ts
|
|
31846
|
-
|
|
31847
|
-
/**
|
|
31848
|
-
* This file lists all of the constants defined in the GrayPaper appendix.
|
|
31849
|
-
*
|
|
31850
|
-
* NOTE: Avoid using the constants directly, prefer "named" constants defined
|
|
31851
|
-
* in a semantical proximity to where they are used.
|
|
31852
|
-
*
|
|
31853
|
-
* NOTE: This file will most likely be removed in the future. The constants
|
|
31854
|
-
* here are only temporarily for convenience. When we figure out better names
|
|
31855
|
-
* and places for these this file will be eradicated.
|
|
31856
|
-
*
|
|
31857
|
-
* https://graypaper.fluffylabs.dev/#/579bd12/413000413000
|
|
31858
|
-
*/
|
|
31859
|
-
/** `G_I`: The gas allocated to invoke a work-package’s Is-Authorized logic. */
|
|
31860
|
-
const G_I = 50_000_000;
|
|
31861
|
-
/** `I`: Maximum number of work items in a package. */
|
|
31862
|
-
const gp_constants_I = (/* unused pure expression or super */ null && (MAX_NUMBER_OF_WORK_ITEMS));
|
|
31863
|
-
/** `O`: Maximum number of items in the authorizations pool. */
|
|
31864
|
-
const O = 8;
|
|
31865
|
-
/** `Q`: The number of items in the authorizations queue. */
|
|
31866
|
-
const Q = 80;
|
|
31867
|
-
/** `S`: The maximum number of entries in the accumulation queue. */
|
|
31868
|
-
const S = 1024;
|
|
31869
|
-
/** `T`: The maximum number of extrinsics in a work-package. */
|
|
31870
|
-
const T = 128;
|
|
31871
|
-
/** `W_A`: The maximum size of is-authorized code in octets. */
|
|
31872
|
-
const W_A = 64_000;
|
|
31873
|
-
/** `W_B`: The maximum size of an encoded work-package with extrinsic data and imports. */
|
|
31874
|
-
const W_B = 13_794_305;
|
|
31875
|
-
/** `W_C`: The maximum size of service code in octets. */
|
|
31876
|
-
const W_C = 4_000_000;
|
|
31877
|
-
/** `W_M`: The maximum number of imports in a work-package. */
|
|
31878
|
-
const W_M = 3_072;
|
|
31879
|
-
/** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
|
|
31880
|
-
const W_R = 49_152;
|
|
31881
|
-
/** `W_T`: The size of a transfer memo in octets. */
|
|
31882
|
-
const W_T = 128;
|
|
31883
|
-
/** `W_M`: The maximum number of exports in a work-package. */
|
|
31884
|
-
const W_X = 3_072;
|
|
31885
|
-
// TODO [ToDr] Not sure where these should live yet :(
|
|
31886
|
-
/**
|
|
31887
|
-
* `S`: The minimum public service index.
|
|
31888
|
-
* Services of indices below these may only be created by the Registrar.
|
|
31889
|
-
*
|
|
31890
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/447a00447a00?v=0.7.2
|
|
31891
|
-
*/
|
|
31892
|
-
const MIN_PUBLIC_SERVICE_INDEX = (/* unused pure expression or super */ null && (2 ** 16));
|
|
31893
|
-
/**
|
|
31894
|
-
* `J`: The maximum sum of dependency items in a work-report.
|
|
31895
|
-
*
|
|
31896
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/416a00416a00?v=0.6.2
|
|
31897
|
-
*/
|
|
31898
|
-
const MAX_REPORT_DEPENDENCIES = 8;
|
|
31899
|
-
/** `Q`: Size of the authorization queue. */
|
|
31900
|
-
const AUTHORIZATION_QUEUE_SIZE = Q;
|
|
31901
|
-
/** `O`: Maximal authorization pool size. */
|
|
31902
|
-
const MAX_AUTH_POOL_SIZE = O;
|
|
31903
|
-
|
|
31904
31991
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/ops/math-consts.ts
|
|
31905
31992
|
const MAX_VALUE = 4294967295;
|
|
31906
31993
|
const math_consts_MAX_VALUE_U64 = (/* unused pure expression or super */ null && (2n ** 63n));
|
|
@@ -31908,7 +31995,7 @@ const MIN_VALUE = (/* unused pure expression or super */ null && (-(2 ** 31)));
|
|
|
31908
31995
|
const MAX_SHIFT_U32 = 32;
|
|
31909
31996
|
const MAX_SHIFT_U64 = 64n;
|
|
31910
31997
|
|
|
31911
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
31998
|
+
;// CONCATENATED MODULE: ./packages/jam/state/recent-blocks.ts
|
|
31912
31999
|
|
|
31913
32000
|
|
|
31914
32001
|
|
|
@@ -31916,23 +32003,267 @@ const MAX_SHIFT_U64 = 64n;
|
|
|
31916
32003
|
|
|
31917
32004
|
|
|
31918
32005
|
/**
|
|
31919
|
-
* `
|
|
31920
|
-
*
|
|
31921
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
31922
|
-
*/
|
|
31923
|
-
const BASE_SERVICE_BALANCE = 100n;
|
|
31924
|
-
/**
|
|
31925
|
-
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
32006
|
+
* `H = 8`: The size of recent history, in blocks.
|
|
31926
32007
|
*
|
|
31927
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
32008
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/416300416500
|
|
31928
32009
|
*/
|
|
31929
|
-
const
|
|
32010
|
+
const MAX_RECENT_HISTORY = 8;
|
|
32011
|
+
/** Recent history of a single block. */
|
|
32012
|
+
class BlockState extends WithDebug {
|
|
32013
|
+
headerHash;
|
|
32014
|
+
accumulationResult;
|
|
32015
|
+
postStateRoot;
|
|
32016
|
+
reported;
|
|
32017
|
+
static Codec = descriptors_codec.Class(BlockState, {
|
|
32018
|
+
headerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
32019
|
+
accumulationResult: descriptors_codec.bytes(hash_HASH_SIZE),
|
|
32020
|
+
postStateRoot: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
32021
|
+
reported: codecHashDictionary(WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
32022
|
+
});
|
|
32023
|
+
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
32024
|
+
return new BlockState(headerHash, accumulationResult, postStateRoot, reported);
|
|
32025
|
+
}
|
|
32026
|
+
constructor(
|
|
32027
|
+
/** Header hash. */
|
|
32028
|
+
headerHash,
|
|
32029
|
+
/** Merkle mountain belt of accumulation result. */
|
|
32030
|
+
accumulationResult,
|
|
32031
|
+
/** Posterior state root filled in with a 1-block delay. */
|
|
32032
|
+
postStateRoot,
|
|
32033
|
+
/** Reported work packages (no more than number of cores). */
|
|
32034
|
+
reported) {
|
|
32035
|
+
super();
|
|
32036
|
+
this.headerHash = headerHash;
|
|
32037
|
+
this.accumulationResult = accumulationResult;
|
|
32038
|
+
this.postStateRoot = postStateRoot;
|
|
32039
|
+
this.reported = reported;
|
|
32040
|
+
}
|
|
32041
|
+
}
|
|
31930
32042
|
/**
|
|
31931
|
-
*
|
|
32043
|
+
* Recent history of blocks.
|
|
31932
32044
|
*
|
|
31933
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/
|
|
32045
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fc9010fc901?v=0.6.7
|
|
31934
32046
|
*/
|
|
31935
|
-
|
|
32047
|
+
class RecentBlocks extends WithDebug {
|
|
32048
|
+
blocks;
|
|
32049
|
+
accumulationLog;
|
|
32050
|
+
static Codec = descriptors_codec.Class(RecentBlocks, {
|
|
32051
|
+
blocks: codecKnownSizeArray(BlockState.Codec, {
|
|
32052
|
+
minLength: 0,
|
|
32053
|
+
maxLength: MAX_RECENT_HISTORY,
|
|
32054
|
+
typicalLength: MAX_RECENT_HISTORY,
|
|
32055
|
+
}),
|
|
32056
|
+
accumulationLog: descriptors_codec.object({
|
|
32057
|
+
peaks: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.optional(descriptors_codec.bytes(hash_HASH_SIZE)))),
|
|
32058
|
+
}),
|
|
32059
|
+
});
|
|
32060
|
+
static empty() {
|
|
32061
|
+
return new RecentBlocks(sized_array_asKnownSize([]), {
|
|
32062
|
+
peaks: [],
|
|
32063
|
+
});
|
|
32064
|
+
}
|
|
32065
|
+
static create(a) {
|
|
32066
|
+
return new RecentBlocks(a.blocks, a.accumulationLog);
|
|
32067
|
+
}
|
|
32068
|
+
constructor(
|
|
32069
|
+
/**
|
|
32070
|
+
* Most recent blocks.
|
|
32071
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fea010fea01?v=0.6.7
|
|
32072
|
+
*/
|
|
32073
|
+
blocks,
|
|
32074
|
+
/**
|
|
32075
|
+
* Accumulation output log.
|
|
32076
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0f02020f0202?v=0.6.7
|
|
32077
|
+
*/
|
|
32078
|
+
accumulationLog) {
|
|
32079
|
+
super();
|
|
32080
|
+
this.blocks = blocks;
|
|
32081
|
+
this.accumulationLog = accumulationLog;
|
|
32082
|
+
}
|
|
32083
|
+
}
|
|
32084
|
+
|
|
32085
|
+
;// CONCATENATED MODULE: ./packages/jam/state/recently-accumulated.ts
|
|
32086
|
+
|
|
32087
|
+
|
|
32088
|
+
|
|
32089
|
+
|
|
32090
|
+
const recentlyAccumulatedCodec = codecPerEpochBlock(descriptors_codec.sequenceVarLen(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x)));
|
|
32091
|
+
|
|
32092
|
+
;// CONCATENATED MODULE: ./packages/jam/state/validator-data.ts
|
|
32093
|
+
|
|
32094
|
+
|
|
32095
|
+
|
|
32096
|
+
|
|
32097
|
+
/**
|
|
32098
|
+
* Fixed size of validator metadata.
|
|
32099
|
+
*
|
|
32100
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/0d55010d5501
|
|
32101
|
+
*/
|
|
32102
|
+
const VALIDATOR_META_BYTES = 128;
|
|
32103
|
+
/**
|
|
32104
|
+
* Details about validators' identity.
|
|
32105
|
+
*
|
|
32106
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/0d4b010d4c01
|
|
32107
|
+
*/
|
|
32108
|
+
class validator_data_ValidatorData extends WithDebug {
|
|
32109
|
+
bandersnatch;
|
|
32110
|
+
ed25519;
|
|
32111
|
+
bls;
|
|
32112
|
+
metadata;
|
|
32113
|
+
static Codec = descriptors_codec.Class(validator_data_ValidatorData, {
|
|
32114
|
+
bandersnatch: descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
32115
|
+
ed25519: descriptors_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
32116
|
+
bls: descriptors_codec.bytes(BLS_KEY_BYTES).asOpaque(),
|
|
32117
|
+
metadata: descriptors_codec.bytes(VALIDATOR_META_BYTES),
|
|
32118
|
+
});
|
|
32119
|
+
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
32120
|
+
return new validator_data_ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
32121
|
+
}
|
|
32122
|
+
constructor(
|
|
32123
|
+
/** Bandersnatch public key. */
|
|
32124
|
+
bandersnatch,
|
|
32125
|
+
/** ED25519 key data. */
|
|
32126
|
+
ed25519,
|
|
32127
|
+
/** BLS public key. */
|
|
32128
|
+
bls,
|
|
32129
|
+
/** Validator-defined additional metdata. */
|
|
32130
|
+
metadata) {
|
|
32131
|
+
super();
|
|
32132
|
+
this.bandersnatch = bandersnatch;
|
|
32133
|
+
this.ed25519 = ed25519;
|
|
32134
|
+
this.bls = bls;
|
|
32135
|
+
this.metadata = metadata;
|
|
32136
|
+
}
|
|
32137
|
+
}
|
|
32138
|
+
const validatorsDataCodec = common_codecPerValidator(validator_data_ValidatorData.Codec);
|
|
32139
|
+
|
|
32140
|
+
;// CONCATENATED MODULE: ./packages/jam/state/safrole-data.ts
|
|
32141
|
+
|
|
32142
|
+
|
|
32143
|
+
|
|
32144
|
+
|
|
32145
|
+
|
|
32146
|
+
|
|
32147
|
+
|
|
32148
|
+
|
|
32149
|
+
|
|
32150
|
+
|
|
32151
|
+
|
|
32152
|
+
var SafroleSealingKeysKind;
|
|
32153
|
+
(function (SafroleSealingKeysKind) {
|
|
32154
|
+
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
32155
|
+
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
32156
|
+
})(SafroleSealingKeysKind || (SafroleSealingKeysKind = {}));
|
|
32157
|
+
const codecBandersnatchKey = descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
32158
|
+
class safrole_data_SafroleSealingKeysData extends WithDebug {
|
|
32159
|
+
kind;
|
|
32160
|
+
keys;
|
|
32161
|
+
tickets;
|
|
32162
|
+
static Codec = codecWithContext((context) => {
|
|
32163
|
+
return descriptors_codec.custom({
|
|
32164
|
+
name: "SafroleSealingKeys",
|
|
32165
|
+
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
32166
|
+
}, (e, x) => {
|
|
32167
|
+
e.varU32(numbers_tryAsU32(x.kind));
|
|
32168
|
+
if (x.kind === SafroleSealingKeysKind.Keys) {
|
|
32169
|
+
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
32170
|
+
}
|
|
32171
|
+
else {
|
|
32172
|
+
e.sequenceFixLen(tickets_Ticket.Codec, x.tickets);
|
|
32173
|
+
}
|
|
32174
|
+
}, (d) => {
|
|
32175
|
+
const epochLength = context.epochLength;
|
|
32176
|
+
const kind = d.varU32();
|
|
32177
|
+
if (kind === SafroleSealingKeysKind.Keys) {
|
|
32178
|
+
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
32179
|
+
return safrole_data_SafroleSealingKeysData.keys(tryAsPerEpochBlock(keys, context));
|
|
32180
|
+
}
|
|
32181
|
+
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
32182
|
+
const tickets = d.sequenceFixLen(tickets_Ticket.Codec, epochLength);
|
|
32183
|
+
return safrole_data_SafroleSealingKeysData.tickets(tryAsPerEpochBlock(tickets, context));
|
|
32184
|
+
}
|
|
32185
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
32186
|
+
}, (s) => {
|
|
32187
|
+
const kind = s.decoder.varU32();
|
|
32188
|
+
if (kind === SafroleSealingKeysKind.Keys) {
|
|
32189
|
+
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
32190
|
+
return;
|
|
32191
|
+
}
|
|
32192
|
+
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
32193
|
+
s.sequenceFixLen(tickets_Ticket.Codec, context.epochLength);
|
|
32194
|
+
return;
|
|
32195
|
+
}
|
|
32196
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
32197
|
+
});
|
|
32198
|
+
});
|
|
32199
|
+
static keys(keys) {
|
|
32200
|
+
return new safrole_data_SafroleSealingKeysData(SafroleSealingKeysKind.Keys, keys, undefined);
|
|
32201
|
+
}
|
|
32202
|
+
static tickets(tickets) {
|
|
32203
|
+
return new safrole_data_SafroleSealingKeysData(SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
32204
|
+
}
|
|
32205
|
+
constructor(kind, keys, tickets) {
|
|
32206
|
+
super();
|
|
32207
|
+
this.kind = kind;
|
|
32208
|
+
this.keys = keys;
|
|
32209
|
+
this.tickets = tickets;
|
|
32210
|
+
}
|
|
32211
|
+
}
|
|
32212
|
+
class safrole_data_SafroleData {
|
|
32213
|
+
nextValidatorData;
|
|
32214
|
+
epochRoot;
|
|
32215
|
+
sealingKeySeries;
|
|
32216
|
+
ticketsAccumulator;
|
|
32217
|
+
static Codec = descriptors_codec.Class(safrole_data_SafroleData, {
|
|
32218
|
+
nextValidatorData: common_codecPerValidator(validator_data_ValidatorData.Codec),
|
|
32219
|
+
epochRoot: descriptors_codec.bytes(bandersnatch_BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
32220
|
+
sealingKeySeries: safrole_data_SafroleSealingKeysData.Codec,
|
|
32221
|
+
ticketsAccumulator: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(tickets_Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
32222
|
+
});
|
|
32223
|
+
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
32224
|
+
return new safrole_data_SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
32225
|
+
}
|
|
32226
|
+
constructor(
|
|
32227
|
+
/** gamma_k */
|
|
32228
|
+
nextValidatorData,
|
|
32229
|
+
/** gamma_z */
|
|
32230
|
+
epochRoot,
|
|
32231
|
+
/** gamma_s */
|
|
32232
|
+
sealingKeySeries,
|
|
32233
|
+
/** gamma_a */
|
|
32234
|
+
ticketsAccumulator) {
|
|
32235
|
+
this.nextValidatorData = nextValidatorData;
|
|
32236
|
+
this.epochRoot = epochRoot;
|
|
32237
|
+
this.sealingKeySeries = sealingKeySeries;
|
|
32238
|
+
this.ticketsAccumulator = ticketsAccumulator;
|
|
32239
|
+
}
|
|
32240
|
+
}
|
|
32241
|
+
|
|
32242
|
+
;// CONCATENATED MODULE: ./packages/jam/state/service.ts
|
|
32243
|
+
|
|
32244
|
+
|
|
32245
|
+
|
|
32246
|
+
|
|
32247
|
+
|
|
32248
|
+
|
|
32249
|
+
/**
|
|
32250
|
+
* `B_S`: The basic minimum balance which all services require.
|
|
32251
|
+
*
|
|
32252
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
32253
|
+
*/
|
|
32254
|
+
const BASE_SERVICE_BALANCE = 100n;
|
|
32255
|
+
/**
|
|
32256
|
+
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
32257
|
+
*
|
|
32258
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445000445000?v=0.6.7
|
|
32259
|
+
*/
|
|
32260
|
+
const ELECTIVE_ITEM_BALANCE = 10n;
|
|
32261
|
+
/**
|
|
32262
|
+
* `B_L`: The additional minimum balance required per octet of elective service state.
|
|
32263
|
+
*
|
|
32264
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445400445400?v=0.6.7
|
|
32265
|
+
*/
|
|
32266
|
+
const ELECTIVE_BYTE_BALANCE = 1n;
|
|
31936
32267
|
const zeroSizeHint = {
|
|
31937
32268
|
bytes: 0,
|
|
31938
32269
|
isExact: true,
|
|
@@ -32098,358 +32429,418 @@ class LookupHistoryItem {
|
|
|
32098
32429
|
}
|
|
32099
32430
|
}
|
|
32100
32431
|
|
|
32101
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
32432
|
+
;// CONCATENATED MODULE: ./packages/jam/state/statistics.ts
|
|
32102
32433
|
|
|
32103
32434
|
|
|
32104
32435
|
|
|
32105
32436
|
|
|
32106
32437
|
|
|
32107
|
-
|
|
32108
|
-
|
|
32109
|
-
|
|
32110
|
-
|
|
32111
|
-
|
|
32112
|
-
|
|
32113
|
-
|
|
32438
|
+
|
|
32439
|
+
const codecServiceId = compatibility_Compatibility.isSuite(TestSuite.W3F_DAVXY) || compatibility_Compatibility.isSuite(TestSuite.JAMDUNA, compatibility_GpVersion.V0_6_7)
|
|
32440
|
+
? descriptors_codec.u32.asOpaque()
|
|
32441
|
+
: descriptors_codec.varU32.convert((s) => numbers_tryAsU32(s), (i) => tryAsServiceId(i));
|
|
32442
|
+
/**
|
|
32443
|
+
* Activity Record of a single validator.
|
|
32444
|
+
*
|
|
32445
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/183701183701
|
|
32446
|
+
*/
|
|
32447
|
+
class ValidatorStatistics {
|
|
32448
|
+
blocks;
|
|
32449
|
+
tickets;
|
|
32450
|
+
preImages;
|
|
32451
|
+
preImagesSize;
|
|
32452
|
+
guarantees;
|
|
32453
|
+
assurances;
|
|
32454
|
+
static Codec = descriptors_codec.Class(ValidatorStatistics, {
|
|
32455
|
+
blocks: descriptors_codec.u32,
|
|
32456
|
+
tickets: descriptors_codec.u32,
|
|
32457
|
+
preImages: descriptors_codec.u32,
|
|
32458
|
+
preImagesSize: descriptors_codec.u32,
|
|
32459
|
+
guarantees: descriptors_codec.u32,
|
|
32460
|
+
assurances: descriptors_codec.u32,
|
|
32114
32461
|
});
|
|
32115
|
-
static create({
|
|
32116
|
-
return new
|
|
32462
|
+
static create({ blocks, tickets, preImages, preImagesSize, guarantees, assurances, }) {
|
|
32463
|
+
return new ValidatorStatistics(blocks, tickets, preImages, preImagesSize, guarantees, assurances);
|
|
32117
32464
|
}
|
|
32118
32465
|
constructor(
|
|
32119
|
-
/**
|
|
32120
|
-
|
|
32121
|
-
/**
|
|
32122
|
-
|
|
32123
|
-
|
|
32124
|
-
|
|
32125
|
-
|
|
32126
|
-
|
|
32127
|
-
/**
|
|
32128
|
-
|
|
32129
|
-
*/
|
|
32130
|
-
|
|
32131
|
-
|
|
32132
|
-
|
|
32133
|
-
|
|
32134
|
-
|
|
32135
|
-
|
|
32136
|
-
|
|
32137
|
-
static Codec = descriptors_codec.Class(PrivilegedServices, {
|
|
32138
|
-
manager: descriptors_codec.u32.asOpaque(),
|
|
32139
|
-
assigners: codecPerCore(descriptors_codec.u32.asOpaque()),
|
|
32140
|
-
delegator: descriptors_codec.u32.asOpaque(),
|
|
32141
|
-
registrar: compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1)
|
|
32142
|
-
? descriptors_codec.u32.asOpaque()
|
|
32143
|
-
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
32144
|
-
autoAccumulateServices: readonlyArray(descriptors_codec.sequenceVarLen(AutoAccumulate.Codec)),
|
|
32145
|
-
});
|
|
32146
|
-
static create(a) {
|
|
32147
|
-
return new PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
32466
|
+
/** The number of blocks produced by the validator. */
|
|
32467
|
+
blocks,
|
|
32468
|
+
/** The number of tickets introduced by the validator. */
|
|
32469
|
+
tickets,
|
|
32470
|
+
/** The number of preimages introduced by the validator. */
|
|
32471
|
+
preImages,
|
|
32472
|
+
/** The total number of octets across all preimages introduced by the validator. */
|
|
32473
|
+
preImagesSize,
|
|
32474
|
+
/** The number of reports guaranteed by the validator. */
|
|
32475
|
+
guarantees,
|
|
32476
|
+
/** The number of availability assurances made by the validator. */
|
|
32477
|
+
assurances) {
|
|
32478
|
+
this.blocks = blocks;
|
|
32479
|
+
this.tickets = tickets;
|
|
32480
|
+
this.preImages = preImages;
|
|
32481
|
+
this.preImagesSize = preImagesSize;
|
|
32482
|
+
this.guarantees = guarantees;
|
|
32483
|
+
this.assurances = assurances;
|
|
32148
32484
|
}
|
|
32149
|
-
|
|
32150
|
-
|
|
32151
|
-
|
|
32152
|
-
* as well as bestow services with storage deposit credits.
|
|
32153
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111502111902?v=0.7.2
|
|
32154
|
-
*/
|
|
32155
|
-
manager,
|
|
32156
|
-
/** `χ_V`: Managers validator keys. */
|
|
32157
|
-
delegator,
|
|
32158
|
-
/**
|
|
32159
|
-
* `χ_R`: Manages the creation of services in protected range.
|
|
32160
|
-
*
|
|
32161
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111b02111d02?v=0.7.2
|
|
32162
|
-
*/
|
|
32163
|
-
registrar,
|
|
32164
|
-
/** `χ_A`: Manages authorization queue one for each core. */
|
|
32165
|
-
assigners,
|
|
32166
|
-
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
32167
|
-
autoAccumulateServices) {
|
|
32168
|
-
this.manager = manager;
|
|
32169
|
-
this.delegator = delegator;
|
|
32170
|
-
this.registrar = registrar;
|
|
32171
|
-
this.assigners = assigners;
|
|
32172
|
-
this.autoAccumulateServices = autoAccumulateServices;
|
|
32485
|
+
static empty() {
|
|
32486
|
+
const zero = numbers_tryAsU32(0);
|
|
32487
|
+
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
32173
32488
|
}
|
|
32174
32489
|
}
|
|
32175
|
-
|
|
32176
|
-
|
|
32177
|
-
|
|
32178
|
-
|
|
32179
|
-
|
|
32180
|
-
|
|
32181
|
-
|
|
32182
|
-
|
|
32490
|
+
const codecVarU16 = descriptors_codec.varU32.convert((i) => numbers_tryAsU32(i), (o) => numbers_tryAsU16(o));
|
|
32491
|
+
/** Encode/decode unsigned gas. */
|
|
32492
|
+
const codecVarGas = descriptors_codec.varU64.convert((g) => tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
32183
32493
|
/**
|
|
32184
|
-
*
|
|
32494
|
+
* Single core statistics.
|
|
32495
|
+
* Updated per block, based on incoming work reports (`w`).
|
|
32185
32496
|
*
|
|
32186
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
32497
|
+
* https://graypaper.fluffylabs.dev/#/68eaa1f/18f10318f103?v=0.6.4
|
|
32498
|
+
* https://github.com/gavofyork/graypaper/blob/9bffb08f3ea7b67832019176754df4fb36b9557d/text/statistics.tex#L65
|
|
32187
32499
|
*/
|
|
32188
|
-
|
|
32189
|
-
|
|
32190
|
-
|
|
32191
|
-
|
|
32192
|
-
|
|
32193
|
-
|
|
32194
|
-
|
|
32195
|
-
|
|
32196
|
-
|
|
32197
|
-
|
|
32198
|
-
|
|
32199
|
-
|
|
32200
|
-
|
|
32201
|
-
|
|
32202
|
-
|
|
32500
|
+
class CoreStatistics {
|
|
32501
|
+
dataAvailabilityLoad;
|
|
32502
|
+
popularity;
|
|
32503
|
+
imports;
|
|
32504
|
+
exports;
|
|
32505
|
+
extrinsicSize;
|
|
32506
|
+
extrinsicCount;
|
|
32507
|
+
bundleSize;
|
|
32508
|
+
gasUsed;
|
|
32509
|
+
static Codec = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_0)
|
|
32510
|
+
? descriptors_codec.Class(CoreStatistics, {
|
|
32511
|
+
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
32512
|
+
popularity: codecVarU16,
|
|
32513
|
+
imports: codecVarU16,
|
|
32514
|
+
extrinsicCount: codecVarU16,
|
|
32515
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32516
|
+
exports: codecVarU16,
|
|
32517
|
+
bundleSize: descriptors_codec.varU32,
|
|
32518
|
+
gasUsed: codecVarGas,
|
|
32519
|
+
})
|
|
32520
|
+
: descriptors_codec.Class(CoreStatistics, {
|
|
32521
|
+
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
32522
|
+
popularity: codecVarU16,
|
|
32523
|
+
imports: codecVarU16,
|
|
32524
|
+
exports: codecVarU16,
|
|
32525
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32526
|
+
extrinsicCount: codecVarU16,
|
|
32527
|
+
bundleSize: descriptors_codec.varU32,
|
|
32528
|
+
gasUsed: codecVarGas,
|
|
32529
|
+
});
|
|
32530
|
+
static create(v) {
|
|
32531
|
+
return new CoreStatistics(v.dataAvailabilityLoad, v.popularity, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.bundleSize, v.gasUsed);
|
|
32203
32532
|
}
|
|
32204
32533
|
constructor(
|
|
32205
|
-
/**
|
|
32206
|
-
|
|
32207
|
-
/**
|
|
32208
|
-
|
|
32209
|
-
/**
|
|
32210
|
-
|
|
32211
|
-
/**
|
|
32212
|
-
|
|
32213
|
-
|
|
32214
|
-
|
|
32215
|
-
|
|
32216
|
-
|
|
32217
|
-
|
|
32218
|
-
|
|
32219
|
-
|
|
32220
|
-
|
|
32221
|
-
|
|
32222
|
-
|
|
32223
|
-
|
|
32224
|
-
|
|
32225
|
-
|
|
32226
|
-
|
|
32227
|
-
|
|
32228
|
-
|
|
32229
|
-
accumulationLog: descriptors_codec.object({
|
|
32230
|
-
peaks: readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.optional(descriptors_codec.bytes(hash_HASH_SIZE)))),
|
|
32231
|
-
}),
|
|
32232
|
-
});
|
|
32233
|
-
static create(a) {
|
|
32234
|
-
return new RecentBlocks(a.blocks, a.accumulationLog);
|
|
32534
|
+
/** `d` */
|
|
32535
|
+
dataAvailabilityLoad,
|
|
32536
|
+
/** `p` */
|
|
32537
|
+
popularity,
|
|
32538
|
+
/** `i` */
|
|
32539
|
+
imports,
|
|
32540
|
+
/** `e` */
|
|
32541
|
+
exports,
|
|
32542
|
+
/** `z` */
|
|
32543
|
+
extrinsicSize,
|
|
32544
|
+
/** `x` */
|
|
32545
|
+
extrinsicCount,
|
|
32546
|
+
/** `b` */
|
|
32547
|
+
bundleSize,
|
|
32548
|
+
/** `u` */
|
|
32549
|
+
gasUsed) {
|
|
32550
|
+
this.dataAvailabilityLoad = dataAvailabilityLoad;
|
|
32551
|
+
this.popularity = popularity;
|
|
32552
|
+
this.imports = imports;
|
|
32553
|
+
this.exports = exports;
|
|
32554
|
+
this.extrinsicSize = extrinsicSize;
|
|
32555
|
+
this.extrinsicCount = extrinsicCount;
|
|
32556
|
+
this.bundleSize = bundleSize;
|
|
32557
|
+
this.gasUsed = gasUsed;
|
|
32235
32558
|
}
|
|
32236
|
-
|
|
32237
|
-
|
|
32238
|
-
|
|
32239
|
-
|
|
32240
|
-
|
|
32241
|
-
blocks,
|
|
32242
|
-
/**
|
|
32243
|
-
* Accumulation output log.
|
|
32244
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0f02020f0202?v=0.6.7
|
|
32245
|
-
*/
|
|
32246
|
-
accumulationLog) {
|
|
32247
|
-
super();
|
|
32248
|
-
this.blocks = blocks;
|
|
32249
|
-
this.accumulationLog = accumulationLog;
|
|
32559
|
+
static empty() {
|
|
32560
|
+
const zero = numbers_tryAsU32(0);
|
|
32561
|
+
const zero16 = numbers_tryAsU16(0);
|
|
32562
|
+
const zeroGas = tryAsServiceGas(0);
|
|
32563
|
+
return new CoreStatistics(zero, zero16, zero16, zero16, zero, zero16, zero, zeroGas);
|
|
32250
32564
|
}
|
|
32251
32565
|
}
|
|
32252
32566
|
/**
|
|
32253
|
-
*
|
|
32567
|
+
* Service statistics.
|
|
32568
|
+
* Updated per block, based on available work reports (`W`).
|
|
32254
32569
|
*
|
|
32255
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
32570
|
+
* https://graypaper.fluffylabs.dev/#/1c979cb/199802199802?v=0.7.1
|
|
32256
32571
|
*/
|
|
32257
|
-
class
|
|
32258
|
-
|
|
32259
|
-
|
|
32260
|
-
|
|
32261
|
-
|
|
32262
|
-
|
|
32263
|
-
|
|
32572
|
+
class ServiceStatistics {
|
|
32573
|
+
providedCount;
|
|
32574
|
+
providedSize;
|
|
32575
|
+
refinementCount;
|
|
32576
|
+
refinementGasUsed;
|
|
32577
|
+
imports;
|
|
32578
|
+
exports;
|
|
32579
|
+
extrinsicSize;
|
|
32580
|
+
extrinsicCount;
|
|
32581
|
+
accumulateCount;
|
|
32582
|
+
accumulateGasUsed;
|
|
32583
|
+
onTransfersCount;
|
|
32584
|
+
onTransfersGasUsed;
|
|
32585
|
+
static Codec = compatibility_Compatibility.selectIfGreaterOrEqual({
|
|
32586
|
+
fallback: descriptors_codec.Class(ServiceStatistics, {
|
|
32587
|
+
providedCount: codecVarU16,
|
|
32588
|
+
providedSize: descriptors_codec.varU32,
|
|
32589
|
+
refinementCount: descriptors_codec.varU32,
|
|
32590
|
+
refinementGasUsed: codecVarGas,
|
|
32591
|
+
imports: codecVarU16,
|
|
32592
|
+
exports: codecVarU16,
|
|
32593
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32594
|
+
extrinsicCount: codecVarU16,
|
|
32595
|
+
accumulateCount: descriptors_codec.varU32,
|
|
32596
|
+
accumulateGasUsed: codecVarGas,
|
|
32597
|
+
onTransfersCount: descriptors_codec.varU32,
|
|
32598
|
+
onTransfersGasUsed: codecVarGas,
|
|
32599
|
+
}),
|
|
32600
|
+
versions: {
|
|
32601
|
+
[compatibility_GpVersion.V0_7_0]: descriptors_codec.Class(ServiceStatistics, {
|
|
32602
|
+
providedCount: codecVarU16,
|
|
32603
|
+
providedSize: descriptors_codec.varU32,
|
|
32604
|
+
refinementCount: descriptors_codec.varU32,
|
|
32605
|
+
refinementGasUsed: codecVarGas,
|
|
32606
|
+
imports: codecVarU16,
|
|
32607
|
+
extrinsicCount: codecVarU16,
|
|
32608
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32609
|
+
exports: codecVarU16,
|
|
32610
|
+
accumulateCount: descriptors_codec.varU32,
|
|
32611
|
+
accumulateGasUsed: codecVarGas,
|
|
32612
|
+
onTransfersCount: descriptors_codec.varU32,
|
|
32613
|
+
onTransfersGasUsed: codecVarGas,
|
|
32614
|
+
}),
|
|
32615
|
+
[compatibility_GpVersion.V0_7_1]: descriptors_codec.Class(ServiceStatistics, {
|
|
32616
|
+
providedCount: codecVarU16,
|
|
32617
|
+
providedSize: descriptors_codec.varU32,
|
|
32618
|
+
refinementCount: descriptors_codec.varU32,
|
|
32619
|
+
refinementGasUsed: codecVarGas,
|
|
32620
|
+
imports: codecVarU16,
|
|
32621
|
+
extrinsicCount: codecVarU16,
|
|
32622
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32623
|
+
exports: codecVarU16,
|
|
32624
|
+
accumulateCount: descriptors_codec.varU32,
|
|
32625
|
+
accumulateGasUsed: codecVarGas,
|
|
32626
|
+
onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
|
|
32627
|
+
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
32628
|
+
}),
|
|
32629
|
+
},
|
|
32264
32630
|
});
|
|
32265
|
-
static create(
|
|
32266
|
-
return new
|
|
32631
|
+
static create(v) {
|
|
32632
|
+
return new ServiceStatistics(v.providedCount, v.providedSize, v.refinementCount, v.refinementGasUsed, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.accumulateCount, v.accumulateGasUsed, v.onTransfersCount, v.onTransfersGasUsed);
|
|
32633
|
+
}
|
|
32634
|
+
constructor(
|
|
32635
|
+
/** `p.0` */
|
|
32636
|
+
providedCount,
|
|
32637
|
+
/** `p.1` */
|
|
32638
|
+
providedSize,
|
|
32639
|
+
/** `r.0` */
|
|
32640
|
+
refinementCount,
|
|
32641
|
+
/** `r.1` */
|
|
32642
|
+
refinementGasUsed,
|
|
32643
|
+
/** `i` */
|
|
32644
|
+
imports,
|
|
32645
|
+
/** `e` */
|
|
32646
|
+
exports,
|
|
32647
|
+
/** `z` */
|
|
32648
|
+
extrinsicSize,
|
|
32649
|
+
/** `x` */
|
|
32650
|
+
extrinsicCount,
|
|
32651
|
+
/** `a.0` */
|
|
32652
|
+
accumulateCount,
|
|
32653
|
+
/** `a.1` */
|
|
32654
|
+
accumulateGasUsed,
|
|
32655
|
+
/** `t.0` @deprecated since 0.7.1 */
|
|
32656
|
+
onTransfersCount,
|
|
32657
|
+
/** `t.1` @deprecated since 0.7.1 */
|
|
32658
|
+
onTransfersGasUsed) {
|
|
32659
|
+
this.providedCount = providedCount;
|
|
32660
|
+
this.providedSize = providedSize;
|
|
32661
|
+
this.refinementCount = refinementCount;
|
|
32662
|
+
this.refinementGasUsed = refinementGasUsed;
|
|
32663
|
+
this.imports = imports;
|
|
32664
|
+
this.exports = exports;
|
|
32665
|
+
this.extrinsicSize = extrinsicSize;
|
|
32666
|
+
this.extrinsicCount = extrinsicCount;
|
|
32667
|
+
this.accumulateCount = accumulateCount;
|
|
32668
|
+
this.accumulateGasUsed = accumulateGasUsed;
|
|
32669
|
+
this.onTransfersCount = onTransfersCount;
|
|
32670
|
+
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
32267
32671
|
}
|
|
32268
32672
|
static empty() {
|
|
32269
|
-
|
|
32270
|
-
|
|
32271
|
-
|
|
32272
|
-
|
|
32673
|
+
const zero = numbers_tryAsU32(0);
|
|
32674
|
+
const zero16 = numbers_tryAsU16(0);
|
|
32675
|
+
const zeroGas = tryAsServiceGas(0);
|
|
32676
|
+
return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas, zero, zeroGas);
|
|
32273
32677
|
}
|
|
32274
|
-
|
|
32275
|
-
|
|
32276
|
-
|
|
32277
|
-
|
|
32278
|
-
|
|
32678
|
+
}
|
|
32679
|
+
/** `pi`: Statistics of each validator, cores statistics and services statistics. */
|
|
32680
|
+
class StatisticsData {
|
|
32681
|
+
current;
|
|
32682
|
+
previous;
|
|
32683
|
+
cores;
|
|
32684
|
+
services;
|
|
32685
|
+
static Codec = descriptors_codec.Class(StatisticsData, {
|
|
32686
|
+
current: common_codecPerValidator(ValidatorStatistics.Codec),
|
|
32687
|
+
previous: common_codecPerValidator(ValidatorStatistics.Codec),
|
|
32688
|
+
cores: codecPerCore(CoreStatistics.Codec),
|
|
32689
|
+
services: descriptors_codec.dictionary(codecServiceId, ServiceStatistics.Codec, {
|
|
32690
|
+
sortKeys: (a, b) => a - b,
|
|
32691
|
+
}),
|
|
32692
|
+
});
|
|
32693
|
+
static create(v) {
|
|
32694
|
+
return new StatisticsData(v.current, v.previous, v.cores, v.services);
|
|
32279
32695
|
}
|
|
32280
|
-
constructor(current) {
|
|
32281
|
-
super();
|
|
32696
|
+
constructor(current, previous, cores, services) {
|
|
32282
32697
|
this.current = current;
|
|
32283
|
-
|
|
32284
|
-
|
|
32285
|
-
|
|
32286
|
-
if (this.current !== null) {
|
|
32287
|
-
return this.current.blocks;
|
|
32288
|
-
}
|
|
32289
|
-
throw new Error("RecentBlocksHistory is in invalid state");
|
|
32290
|
-
}
|
|
32291
|
-
asCurrent() {
|
|
32292
|
-
if (this.current === null) {
|
|
32293
|
-
throw new Error("Cannot access current RecentBlocks format");
|
|
32294
|
-
}
|
|
32295
|
-
return this.current;
|
|
32296
|
-
}
|
|
32297
|
-
updateBlocks(blocks) {
|
|
32298
|
-
if (this.current !== null) {
|
|
32299
|
-
return RecentBlocksHistory.create(RecentBlocks.create({
|
|
32300
|
-
...this.current,
|
|
32301
|
-
blocks: opaque_asOpaqueType(blocks),
|
|
32302
|
-
}));
|
|
32303
|
-
}
|
|
32304
|
-
throw new Error("RecentBlocksHistory is in invalid state. Cannot be updated!");
|
|
32698
|
+
this.previous = previous;
|
|
32699
|
+
this.cores = cores;
|
|
32700
|
+
this.services = services;
|
|
32305
32701
|
}
|
|
32306
32702
|
}
|
|
32307
32703
|
|
|
32308
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
32704
|
+
;// CONCATENATED MODULE: ./packages/jam/state/in-memory-state-view.ts
|
|
32309
32705
|
|
|
32310
32706
|
|
|
32311
32707
|
|
|
32312
|
-
/**
|
|
32313
|
-
* Fixed size of validator metadata.
|
|
32314
|
-
*
|
|
32315
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/0d55010d5501
|
|
32316
|
-
*/
|
|
32317
|
-
const VALIDATOR_META_BYTES = 128;
|
|
32318
|
-
/**
|
|
32319
|
-
* Details about validators' identity.
|
|
32320
|
-
*
|
|
32321
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/0d4b010d4c01
|
|
32322
|
-
*/
|
|
32323
|
-
class ValidatorData extends WithDebug {
|
|
32324
|
-
bandersnatch;
|
|
32325
|
-
ed25519;
|
|
32326
|
-
bls;
|
|
32327
|
-
metadata;
|
|
32328
|
-
static Codec = descriptors_codec.Class(ValidatorData, {
|
|
32329
|
-
bandersnatch: descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
32330
|
-
ed25519: descriptors_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
32331
|
-
bls: descriptors_codec.bytes(BLS_KEY_BYTES).asOpaque(),
|
|
32332
|
-
metadata: descriptors_codec.bytes(VALIDATOR_META_BYTES),
|
|
32333
|
-
});
|
|
32334
|
-
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
32335
|
-
return new ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
32336
|
-
}
|
|
32337
|
-
constructor(
|
|
32338
|
-
/** Bandersnatch public key. */
|
|
32339
|
-
bandersnatch,
|
|
32340
|
-
/** ED25519 key data. */
|
|
32341
|
-
ed25519,
|
|
32342
|
-
/** BLS public key. */
|
|
32343
|
-
bls,
|
|
32344
|
-
/** Validator-defined additional metdata. */
|
|
32345
|
-
metadata) {
|
|
32346
|
-
super();
|
|
32347
|
-
this.bandersnatch = bandersnatch;
|
|
32348
|
-
this.ed25519 = ed25519;
|
|
32349
|
-
this.bls = bls;
|
|
32350
|
-
this.metadata = metadata;
|
|
32351
|
-
}
|
|
32352
|
-
}
|
|
32353
32708
|
|
|
32354
|
-
;// CONCATENATED MODULE: ./packages/jam/state/safrole-data.ts
|
|
32355
32709
|
|
|
32356
32710
|
|
|
32357
32711
|
|
|
32358
32712
|
|
|
32359
32713
|
|
|
32360
32714
|
|
|
32715
|
+
class InMemoryStateView {
|
|
32716
|
+
chainSpec;
|
|
32717
|
+
state;
|
|
32718
|
+
constructor(chainSpec, state) {
|
|
32719
|
+
this.chainSpec = chainSpec;
|
|
32720
|
+
this.state = state;
|
|
32721
|
+
}
|
|
32722
|
+
availabilityAssignmentView() {
|
|
32723
|
+
return reencodeAsView(availabilityAssignmentsCodec, this.state.availabilityAssignment, this.chainSpec);
|
|
32724
|
+
}
|
|
32725
|
+
designatedValidatorDataView() {
|
|
32726
|
+
return reencodeAsView(validatorsDataCodec, this.state.designatedValidatorData, this.chainSpec);
|
|
32727
|
+
}
|
|
32728
|
+
currentValidatorDataView() {
|
|
32729
|
+
return reencodeAsView(validatorsDataCodec, this.state.currentValidatorData, this.chainSpec);
|
|
32730
|
+
}
|
|
32731
|
+
previousValidatorDataView() {
|
|
32732
|
+
return reencodeAsView(validatorsDataCodec, this.state.previousValidatorData, this.chainSpec);
|
|
32733
|
+
}
|
|
32734
|
+
authPoolsView() {
|
|
32735
|
+
return reencodeAsView(authPoolsCodec, this.state.authPools, this.chainSpec);
|
|
32736
|
+
}
|
|
32737
|
+
authQueuesView() {
|
|
32738
|
+
return reencodeAsView(authQueuesCodec, this.state.authQueues, this.chainSpec);
|
|
32739
|
+
}
|
|
32740
|
+
recentBlocksView() {
|
|
32741
|
+
return reencodeAsView(RecentBlocks.Codec, this.state.recentBlocks, this.chainSpec);
|
|
32742
|
+
}
|
|
32743
|
+
statisticsView() {
|
|
32744
|
+
return reencodeAsView(StatisticsData.Codec, this.state.statistics, this.chainSpec);
|
|
32745
|
+
}
|
|
32746
|
+
accumulationQueueView() {
|
|
32747
|
+
return reencodeAsView(accumulationQueueCodec, this.state.accumulationQueue, this.chainSpec);
|
|
32748
|
+
}
|
|
32749
|
+
recentlyAccumulatedView() {
|
|
32750
|
+
return reencodeAsView(recentlyAccumulatedCodec, this.state.recentlyAccumulated, this.chainSpec);
|
|
32751
|
+
}
|
|
32752
|
+
safroleDataView() {
|
|
32753
|
+
// TODO [ToDr] Consider exposting `safrole` from state
|
|
32754
|
+
// instead of individual fields
|
|
32755
|
+
const safrole = safrole_data_SafroleData.create({
|
|
32756
|
+
nextValidatorData: this.state.nextValidatorData,
|
|
32757
|
+
epochRoot: this.state.epochRoot,
|
|
32758
|
+
sealingKeySeries: this.state.sealingKeySeries,
|
|
32759
|
+
ticketsAccumulator: this.state.ticketsAccumulator,
|
|
32760
|
+
});
|
|
32761
|
+
return reencodeAsView(safrole_data_SafroleData.Codec, safrole, this.chainSpec);
|
|
32762
|
+
}
|
|
32763
|
+
getServiceInfoView(id) {
|
|
32764
|
+
const service = this.state.getService(id);
|
|
32765
|
+
if (service === null) {
|
|
32766
|
+
return null;
|
|
32767
|
+
}
|
|
32768
|
+
return reencodeAsView(ServiceAccountInfo.Codec, service.getInfo(), this.chainSpec);
|
|
32769
|
+
}
|
|
32770
|
+
}
|
|
32361
32771
|
|
|
32772
|
+
;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
|
|
32362
32773
|
|
|
32363
32774
|
|
|
32364
32775
|
|
|
32365
32776
|
|
|
32366
|
-
|
|
32367
|
-
|
|
32368
|
-
|
|
32369
|
-
|
|
32370
|
-
|
|
32371
|
-
|
|
32372
|
-
|
|
32373
|
-
|
|
32374
|
-
|
|
32375
|
-
|
|
32376
|
-
|
|
32377
|
-
return descriptors_codec.custom({
|
|
32378
|
-
name: "SafroleSealingKeys",
|
|
32379
|
-
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
32380
|
-
}, (e, x) => {
|
|
32381
|
-
e.varU32(numbers_tryAsU32(x.kind));
|
|
32382
|
-
if (x.kind === SafroleSealingKeysKind.Keys) {
|
|
32383
|
-
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
32384
|
-
}
|
|
32385
|
-
else {
|
|
32386
|
-
e.sequenceFixLen(Ticket.Codec, x.tickets);
|
|
32387
|
-
}
|
|
32388
|
-
}, (d) => {
|
|
32389
|
-
const epochLength = context.epochLength;
|
|
32390
|
-
const kind = d.varU32();
|
|
32391
|
-
if (kind === SafroleSealingKeysKind.Keys) {
|
|
32392
|
-
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
32393
|
-
return SafroleSealingKeysData.keys(tryAsPerEpochBlock(keys, context));
|
|
32394
|
-
}
|
|
32395
|
-
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
32396
|
-
const tickets = d.sequenceFixLen(Ticket.Codec, epochLength);
|
|
32397
|
-
return SafroleSealingKeysData.tickets(tryAsPerEpochBlock(tickets, context));
|
|
32398
|
-
}
|
|
32399
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
32400
|
-
}, (s) => {
|
|
32401
|
-
const kind = s.decoder.varU32();
|
|
32402
|
-
if (kind === SafroleSealingKeysKind.Keys) {
|
|
32403
|
-
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
32404
|
-
return;
|
|
32405
|
-
}
|
|
32406
|
-
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
32407
|
-
s.sequenceFixLen(Ticket.Codec, context.epochLength);
|
|
32408
|
-
return;
|
|
32409
|
-
}
|
|
32410
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
32411
|
-
});
|
|
32412
|
-
});
|
|
32413
|
-
static keys(keys) {
|
|
32414
|
-
return new SafroleSealingKeysData(SafroleSealingKeysKind.Keys, keys, undefined);
|
|
32415
|
-
}
|
|
32416
|
-
static tickets(tickets) {
|
|
32417
|
-
return new SafroleSealingKeysData(SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
32777
|
+
|
|
32778
|
+
/** Dictionary entry of services that auto-accumulate every block. */
|
|
32779
|
+
class AutoAccumulate {
|
|
32780
|
+
service;
|
|
32781
|
+
gasLimit;
|
|
32782
|
+
static Codec = descriptors_codec.Class(AutoAccumulate, {
|
|
32783
|
+
service: descriptors_codec.u32.asOpaque(),
|
|
32784
|
+
gasLimit: descriptors_codec.u64.asOpaque(),
|
|
32785
|
+
});
|
|
32786
|
+
static create({ service, gasLimit }) {
|
|
32787
|
+
return new AutoAccumulate(service, gasLimit);
|
|
32418
32788
|
}
|
|
32419
|
-
constructor(
|
|
32420
|
-
|
|
32421
|
-
|
|
32422
|
-
|
|
32423
|
-
|
|
32789
|
+
constructor(
|
|
32790
|
+
/** Service id that auto-accumulates. */
|
|
32791
|
+
service,
|
|
32792
|
+
/** Gas limit for auto-accumulation. */
|
|
32793
|
+
gasLimit) {
|
|
32794
|
+
this.service = service;
|
|
32795
|
+
this.gasLimit = gasLimit;
|
|
32424
32796
|
}
|
|
32425
32797
|
}
|
|
32426
|
-
|
|
32427
|
-
|
|
32428
|
-
|
|
32429
|
-
|
|
32430
|
-
|
|
32431
|
-
|
|
32432
|
-
|
|
32433
|
-
|
|
32434
|
-
|
|
32435
|
-
|
|
32798
|
+
/**
|
|
32799
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
32800
|
+
*/
|
|
32801
|
+
class PrivilegedServices {
|
|
32802
|
+
manager;
|
|
32803
|
+
delegator;
|
|
32804
|
+
registrar;
|
|
32805
|
+
assigners;
|
|
32806
|
+
autoAccumulateServices;
|
|
32807
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
32808
|
+
static Codec = descriptors_codec.Class(PrivilegedServices, {
|
|
32809
|
+
manager: descriptors_codec.u32.asOpaque(),
|
|
32810
|
+
assigners: codecPerCore(descriptors_codec.u32.asOpaque()),
|
|
32811
|
+
delegator: descriptors_codec.u32.asOpaque(),
|
|
32812
|
+
registrar: compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1)
|
|
32813
|
+
? descriptors_codec.u32.asOpaque()
|
|
32814
|
+
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
32815
|
+
autoAccumulateServices: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(AutoAccumulate.Codec)),
|
|
32436
32816
|
});
|
|
32437
|
-
static create(
|
|
32438
|
-
return new
|
|
32817
|
+
static create(a) {
|
|
32818
|
+
return new PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
32439
32819
|
}
|
|
32440
32820
|
constructor(
|
|
32441
|
-
/**
|
|
32442
|
-
|
|
32443
|
-
|
|
32444
|
-
|
|
32445
|
-
|
|
32446
|
-
|
|
32447
|
-
/**
|
|
32448
|
-
|
|
32449
|
-
|
|
32450
|
-
|
|
32451
|
-
|
|
32452
|
-
|
|
32821
|
+
/**
|
|
32822
|
+
* `χ_M`: Manages alteration of χ from block to block,
|
|
32823
|
+
* as well as bestow services with storage deposit credits.
|
|
32824
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111502111902?v=0.7.2
|
|
32825
|
+
*/
|
|
32826
|
+
manager,
|
|
32827
|
+
/** `χ_V`: Managers validator keys. */
|
|
32828
|
+
delegator,
|
|
32829
|
+
/**
|
|
32830
|
+
* `χ_R`: Manages the creation of services in protected range.
|
|
32831
|
+
*
|
|
32832
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111b02111d02?v=0.7.2
|
|
32833
|
+
*/
|
|
32834
|
+
registrar,
|
|
32835
|
+
/** `χ_A`: Manages authorization queue one for each core. */
|
|
32836
|
+
assigners,
|
|
32837
|
+
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
32838
|
+
autoAccumulateServices) {
|
|
32839
|
+
this.manager = manager;
|
|
32840
|
+
this.delegator = delegator;
|
|
32841
|
+
this.registrar = registrar;
|
|
32842
|
+
this.assigners = assigners;
|
|
32843
|
+
this.autoAccumulateServices = autoAccumulateServices;
|
|
32453
32844
|
}
|
|
32454
32845
|
}
|
|
32455
32846
|
|
|
@@ -32567,322 +32958,50 @@ class UpdateService {
|
|
|
32567
32958
|
});
|
|
32568
32959
|
}
|
|
32569
32960
|
static create({ serviceId, serviceInfo, lookupHistory, }) {
|
|
32570
|
-
return new UpdateService(serviceId, {
|
|
32571
|
-
kind: state_update_UpdateServiceKind.Create,
|
|
32572
|
-
account: serviceInfo,
|
|
32573
|
-
lookupHistory,
|
|
32574
|
-
});
|
|
32575
|
-
}
|
|
32576
|
-
}
|
|
32577
|
-
/** Update service storage kind. */
|
|
32578
|
-
var state_update_UpdateStorageKind;
|
|
32579
|
-
(function (UpdateStorageKind) {
|
|
32580
|
-
/** Set a storage value. */
|
|
32581
|
-
UpdateStorageKind[UpdateStorageKind["Set"] = 0] = "Set";
|
|
32582
|
-
/** Remove a storage value. */
|
|
32583
|
-
UpdateStorageKind[UpdateStorageKind["Remove"] = 1] = "Remove";
|
|
32584
|
-
})(state_update_UpdateStorageKind || (state_update_UpdateStorageKind = {}));
|
|
32585
|
-
/**
|
|
32586
|
-
* Update service storage item.
|
|
32587
|
-
*
|
|
32588
|
-
* Can either create/modify an entry or remove it.
|
|
32589
|
-
*/
|
|
32590
|
-
class UpdateStorage {
|
|
32591
|
-
serviceId;
|
|
32592
|
-
action;
|
|
32593
|
-
constructor(serviceId, action) {
|
|
32594
|
-
this.serviceId = serviceId;
|
|
32595
|
-
this.action = action;
|
|
32596
|
-
}
|
|
32597
|
-
static set({ serviceId, storage }) {
|
|
32598
|
-
return new UpdateStorage(serviceId, { kind: state_update_UpdateStorageKind.Set, storage });
|
|
32599
|
-
}
|
|
32600
|
-
static remove({ serviceId, key }) {
|
|
32601
|
-
return new UpdateStorage(serviceId, { kind: state_update_UpdateStorageKind.Remove, key });
|
|
32602
|
-
}
|
|
32603
|
-
get key() {
|
|
32604
|
-
if (this.action.kind === state_update_UpdateStorageKind.Remove) {
|
|
32605
|
-
return this.action.key;
|
|
32606
|
-
}
|
|
32607
|
-
return this.action.storage.key;
|
|
32608
|
-
}
|
|
32609
|
-
get value() {
|
|
32610
|
-
if (this.action.kind === state_update_UpdateStorageKind.Remove) {
|
|
32611
|
-
return null;
|
|
32612
|
-
}
|
|
32613
|
-
return this.action.storage.value;
|
|
32614
|
-
}
|
|
32615
|
-
}
|
|
32616
|
-
|
|
32617
|
-
;// CONCATENATED MODULE: ./packages/jam/state/statistics.ts
|
|
32618
|
-
|
|
32619
|
-
|
|
32620
|
-
|
|
32621
|
-
|
|
32622
|
-
|
|
32623
|
-
|
|
32624
|
-
const codecServiceId = compatibility_Compatibility.isSuite(TestSuite.W3F_DAVXY) || compatibility_Compatibility.isSuite(TestSuite.JAMDUNA, compatibility_GpVersion.V0_6_7)
|
|
32625
|
-
? descriptors_codec.u32.asOpaque()
|
|
32626
|
-
: descriptors_codec.varU32.convert((s) => numbers_tryAsU32(s), (i) => tryAsServiceId(i));
|
|
32627
|
-
/**
|
|
32628
|
-
* Activity Record of a single validator.
|
|
32629
|
-
*
|
|
32630
|
-
* https://graypaper.fluffylabs.dev/#/579bd12/183701183701
|
|
32631
|
-
*/
|
|
32632
|
-
class ValidatorStatistics {
|
|
32633
|
-
blocks;
|
|
32634
|
-
tickets;
|
|
32635
|
-
preImages;
|
|
32636
|
-
preImagesSize;
|
|
32637
|
-
guarantees;
|
|
32638
|
-
assurances;
|
|
32639
|
-
static Codec = descriptors_codec.Class(ValidatorStatistics, {
|
|
32640
|
-
blocks: descriptors_codec.u32,
|
|
32641
|
-
tickets: descriptors_codec.u32,
|
|
32642
|
-
preImages: descriptors_codec.u32,
|
|
32643
|
-
preImagesSize: descriptors_codec.u32,
|
|
32644
|
-
guarantees: descriptors_codec.u32,
|
|
32645
|
-
assurances: descriptors_codec.u32,
|
|
32646
|
-
});
|
|
32647
|
-
static create({ blocks, tickets, preImages, preImagesSize, guarantees, assurances, }) {
|
|
32648
|
-
return new ValidatorStatistics(blocks, tickets, preImages, preImagesSize, guarantees, assurances);
|
|
32649
|
-
}
|
|
32650
|
-
constructor(
|
|
32651
|
-
/** The number of blocks produced by the validator. */
|
|
32652
|
-
blocks,
|
|
32653
|
-
/** The number of tickets introduced by the validator. */
|
|
32654
|
-
tickets,
|
|
32655
|
-
/** The number of preimages introduced by the validator. */
|
|
32656
|
-
preImages,
|
|
32657
|
-
/** The total number of octets across all preimages introduced by the validator. */
|
|
32658
|
-
preImagesSize,
|
|
32659
|
-
/** The number of reports guaranteed by the validator. */
|
|
32660
|
-
guarantees,
|
|
32661
|
-
/** The number of availability assurances made by the validator. */
|
|
32662
|
-
assurances) {
|
|
32663
|
-
this.blocks = blocks;
|
|
32664
|
-
this.tickets = tickets;
|
|
32665
|
-
this.preImages = preImages;
|
|
32666
|
-
this.preImagesSize = preImagesSize;
|
|
32667
|
-
this.guarantees = guarantees;
|
|
32668
|
-
this.assurances = assurances;
|
|
32669
|
-
}
|
|
32670
|
-
static empty() {
|
|
32671
|
-
const zero = numbers_tryAsU32(0);
|
|
32672
|
-
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
32673
|
-
}
|
|
32674
|
-
}
|
|
32675
|
-
const codecVarU16 = descriptors_codec.varU32.convert((i) => numbers_tryAsU32(i), (o) => numbers_tryAsU16(o));
|
|
32676
|
-
/** Encode/decode unsigned gas. */
|
|
32677
|
-
const codecVarGas = descriptors_codec.varU64.convert((g) => tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
32678
|
-
/**
|
|
32679
|
-
* Single core statistics.
|
|
32680
|
-
* Updated per block, based on incoming work reports (`w`).
|
|
32681
|
-
*
|
|
32682
|
-
* https://graypaper.fluffylabs.dev/#/68eaa1f/18f10318f103?v=0.6.4
|
|
32683
|
-
* https://github.com/gavofyork/graypaper/blob/9bffb08f3ea7b67832019176754df4fb36b9557d/text/statistics.tex#L65
|
|
32684
|
-
*/
|
|
32685
|
-
class CoreStatistics {
|
|
32686
|
-
dataAvailabilityLoad;
|
|
32687
|
-
popularity;
|
|
32688
|
-
imports;
|
|
32689
|
-
exports;
|
|
32690
|
-
extrinsicSize;
|
|
32691
|
-
extrinsicCount;
|
|
32692
|
-
bundleSize;
|
|
32693
|
-
gasUsed;
|
|
32694
|
-
static Codec = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_0)
|
|
32695
|
-
? descriptors_codec.Class(CoreStatistics, {
|
|
32696
|
-
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
32697
|
-
popularity: codecVarU16,
|
|
32698
|
-
imports: codecVarU16,
|
|
32699
|
-
extrinsicCount: codecVarU16,
|
|
32700
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
32701
|
-
exports: codecVarU16,
|
|
32702
|
-
bundleSize: descriptors_codec.varU32,
|
|
32703
|
-
gasUsed: codecVarGas,
|
|
32704
|
-
})
|
|
32705
|
-
: descriptors_codec.Class(CoreStatistics, {
|
|
32706
|
-
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
32707
|
-
popularity: codecVarU16,
|
|
32708
|
-
imports: codecVarU16,
|
|
32709
|
-
exports: codecVarU16,
|
|
32710
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
32711
|
-
extrinsicCount: codecVarU16,
|
|
32712
|
-
bundleSize: descriptors_codec.varU32,
|
|
32713
|
-
gasUsed: codecVarGas,
|
|
32714
|
-
});
|
|
32715
|
-
static create(v) {
|
|
32716
|
-
return new CoreStatistics(v.dataAvailabilityLoad, v.popularity, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.bundleSize, v.gasUsed);
|
|
32717
|
-
}
|
|
32718
|
-
constructor(
|
|
32719
|
-
/** `d` */
|
|
32720
|
-
dataAvailabilityLoad,
|
|
32721
|
-
/** `p` */
|
|
32722
|
-
popularity,
|
|
32723
|
-
/** `i` */
|
|
32724
|
-
imports,
|
|
32725
|
-
/** `e` */
|
|
32726
|
-
exports,
|
|
32727
|
-
/** `z` */
|
|
32728
|
-
extrinsicSize,
|
|
32729
|
-
/** `x` */
|
|
32730
|
-
extrinsicCount,
|
|
32731
|
-
/** `b` */
|
|
32732
|
-
bundleSize,
|
|
32733
|
-
/** `u` */
|
|
32734
|
-
gasUsed) {
|
|
32735
|
-
this.dataAvailabilityLoad = dataAvailabilityLoad;
|
|
32736
|
-
this.popularity = popularity;
|
|
32737
|
-
this.imports = imports;
|
|
32738
|
-
this.exports = exports;
|
|
32739
|
-
this.extrinsicSize = extrinsicSize;
|
|
32740
|
-
this.extrinsicCount = extrinsicCount;
|
|
32741
|
-
this.bundleSize = bundleSize;
|
|
32742
|
-
this.gasUsed = gasUsed;
|
|
32743
|
-
}
|
|
32744
|
-
static empty() {
|
|
32745
|
-
const zero = numbers_tryAsU32(0);
|
|
32746
|
-
const zero16 = numbers_tryAsU16(0);
|
|
32747
|
-
const zeroGas = tryAsServiceGas(0);
|
|
32748
|
-
return new CoreStatistics(zero, zero16, zero16, zero16, zero, zero16, zero, zeroGas);
|
|
32961
|
+
return new UpdateService(serviceId, {
|
|
32962
|
+
kind: state_update_UpdateServiceKind.Create,
|
|
32963
|
+
account: serviceInfo,
|
|
32964
|
+
lookupHistory,
|
|
32965
|
+
});
|
|
32749
32966
|
}
|
|
32750
32967
|
}
|
|
32968
|
+
/** Update service storage kind. */
|
|
32969
|
+
var state_update_UpdateStorageKind;
|
|
32970
|
+
(function (UpdateStorageKind) {
|
|
32971
|
+
/** Set a storage value. */
|
|
32972
|
+
UpdateStorageKind[UpdateStorageKind["Set"] = 0] = "Set";
|
|
32973
|
+
/** Remove a storage value. */
|
|
32974
|
+
UpdateStorageKind[UpdateStorageKind["Remove"] = 1] = "Remove";
|
|
32975
|
+
})(state_update_UpdateStorageKind || (state_update_UpdateStorageKind = {}));
|
|
32751
32976
|
/**
|
|
32752
|
-
*
|
|
32753
|
-
* Updated per block, based on available work reports (`W`).
|
|
32977
|
+
* Update service storage item.
|
|
32754
32978
|
*
|
|
32755
|
-
*
|
|
32979
|
+
* Can either create/modify an entry or remove it.
|
|
32756
32980
|
*/
|
|
32757
|
-
class
|
|
32758
|
-
|
|
32759
|
-
|
|
32760
|
-
|
|
32761
|
-
|
|
32762
|
-
|
|
32763
|
-
exports;
|
|
32764
|
-
extrinsicSize;
|
|
32765
|
-
extrinsicCount;
|
|
32766
|
-
accumulateCount;
|
|
32767
|
-
accumulateGasUsed;
|
|
32768
|
-
onTransfersCount;
|
|
32769
|
-
onTransfersGasUsed;
|
|
32770
|
-
static Codec = compatibility_Compatibility.selectIfGreaterOrEqual({
|
|
32771
|
-
fallback: descriptors_codec.Class(ServiceStatistics, {
|
|
32772
|
-
providedCount: codecVarU16,
|
|
32773
|
-
providedSize: descriptors_codec.varU32,
|
|
32774
|
-
refinementCount: descriptors_codec.varU32,
|
|
32775
|
-
refinementGasUsed: codecVarGas,
|
|
32776
|
-
imports: codecVarU16,
|
|
32777
|
-
exports: codecVarU16,
|
|
32778
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
32779
|
-
extrinsicCount: codecVarU16,
|
|
32780
|
-
accumulateCount: descriptors_codec.varU32,
|
|
32781
|
-
accumulateGasUsed: codecVarGas,
|
|
32782
|
-
onTransfersCount: descriptors_codec.varU32,
|
|
32783
|
-
onTransfersGasUsed: codecVarGas,
|
|
32784
|
-
}),
|
|
32785
|
-
versions: {
|
|
32786
|
-
[compatibility_GpVersion.V0_7_0]: descriptors_codec.Class(ServiceStatistics, {
|
|
32787
|
-
providedCount: codecVarU16,
|
|
32788
|
-
providedSize: descriptors_codec.varU32,
|
|
32789
|
-
refinementCount: descriptors_codec.varU32,
|
|
32790
|
-
refinementGasUsed: codecVarGas,
|
|
32791
|
-
imports: codecVarU16,
|
|
32792
|
-
extrinsicCount: codecVarU16,
|
|
32793
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
32794
|
-
exports: codecVarU16,
|
|
32795
|
-
accumulateCount: descriptors_codec.varU32,
|
|
32796
|
-
accumulateGasUsed: codecVarGas,
|
|
32797
|
-
onTransfersCount: descriptors_codec.varU32,
|
|
32798
|
-
onTransfersGasUsed: codecVarGas,
|
|
32799
|
-
}),
|
|
32800
|
-
[compatibility_GpVersion.V0_7_1]: descriptors_codec.Class(ServiceStatistics, {
|
|
32801
|
-
providedCount: codecVarU16,
|
|
32802
|
-
providedSize: descriptors_codec.varU32,
|
|
32803
|
-
refinementCount: descriptors_codec.varU32,
|
|
32804
|
-
refinementGasUsed: codecVarGas,
|
|
32805
|
-
imports: codecVarU16,
|
|
32806
|
-
extrinsicCount: codecVarU16,
|
|
32807
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
32808
|
-
exports: codecVarU16,
|
|
32809
|
-
accumulateCount: descriptors_codec.varU32,
|
|
32810
|
-
accumulateGasUsed: codecVarGas,
|
|
32811
|
-
onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
|
|
32812
|
-
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
32813
|
-
}),
|
|
32814
|
-
},
|
|
32815
|
-
});
|
|
32816
|
-
static create(v) {
|
|
32817
|
-
return new ServiceStatistics(v.providedCount, v.providedSize, v.refinementCount, v.refinementGasUsed, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.accumulateCount, v.accumulateGasUsed, v.onTransfersCount, v.onTransfersGasUsed);
|
|
32981
|
+
class UpdateStorage {
|
|
32982
|
+
serviceId;
|
|
32983
|
+
action;
|
|
32984
|
+
constructor(serviceId, action) {
|
|
32985
|
+
this.serviceId = serviceId;
|
|
32986
|
+
this.action = action;
|
|
32818
32987
|
}
|
|
32819
|
-
|
|
32820
|
-
|
|
32821
|
-
providedCount,
|
|
32822
|
-
/** `p.1` */
|
|
32823
|
-
providedSize,
|
|
32824
|
-
/** `r.0` */
|
|
32825
|
-
refinementCount,
|
|
32826
|
-
/** `r.1` */
|
|
32827
|
-
refinementGasUsed,
|
|
32828
|
-
/** `i` */
|
|
32829
|
-
imports,
|
|
32830
|
-
/** `e` */
|
|
32831
|
-
exports,
|
|
32832
|
-
/** `z` */
|
|
32833
|
-
extrinsicSize,
|
|
32834
|
-
/** `x` */
|
|
32835
|
-
extrinsicCount,
|
|
32836
|
-
/** `a.0` */
|
|
32837
|
-
accumulateCount,
|
|
32838
|
-
/** `a.1` */
|
|
32839
|
-
accumulateGasUsed,
|
|
32840
|
-
/** `t.0` @deprecated since 0.7.1 */
|
|
32841
|
-
onTransfersCount,
|
|
32842
|
-
/** `t.1` @deprecated since 0.7.1 */
|
|
32843
|
-
onTransfersGasUsed) {
|
|
32844
|
-
this.providedCount = providedCount;
|
|
32845
|
-
this.providedSize = providedSize;
|
|
32846
|
-
this.refinementCount = refinementCount;
|
|
32847
|
-
this.refinementGasUsed = refinementGasUsed;
|
|
32848
|
-
this.imports = imports;
|
|
32849
|
-
this.exports = exports;
|
|
32850
|
-
this.extrinsicSize = extrinsicSize;
|
|
32851
|
-
this.extrinsicCount = extrinsicCount;
|
|
32852
|
-
this.accumulateCount = accumulateCount;
|
|
32853
|
-
this.accumulateGasUsed = accumulateGasUsed;
|
|
32854
|
-
this.onTransfersCount = onTransfersCount;
|
|
32855
|
-
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
32988
|
+
static set({ serviceId, storage }) {
|
|
32989
|
+
return new UpdateStorage(serviceId, { kind: state_update_UpdateStorageKind.Set, storage });
|
|
32856
32990
|
}
|
|
32857
|
-
static
|
|
32858
|
-
|
|
32859
|
-
const zero16 = numbers_tryAsU16(0);
|
|
32860
|
-
const zeroGas = tryAsServiceGas(0);
|
|
32861
|
-
return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas, zero, zeroGas);
|
|
32991
|
+
static remove({ serviceId, key }) {
|
|
32992
|
+
return new UpdateStorage(serviceId, { kind: state_update_UpdateStorageKind.Remove, key });
|
|
32862
32993
|
}
|
|
32863
|
-
|
|
32864
|
-
|
|
32865
|
-
|
|
32866
|
-
|
|
32867
|
-
|
|
32868
|
-
cores;
|
|
32869
|
-
services;
|
|
32870
|
-
static Codec = descriptors_codec.Class(StatisticsData, {
|
|
32871
|
-
current: codecPerValidator(ValidatorStatistics.Codec),
|
|
32872
|
-
previous: codecPerValidator(ValidatorStatistics.Codec),
|
|
32873
|
-
cores: codecPerCore(CoreStatistics.Codec),
|
|
32874
|
-
services: descriptors_codec.dictionary(codecServiceId, ServiceStatistics.Codec, {
|
|
32875
|
-
sortKeys: (a, b) => a - b,
|
|
32876
|
-
}),
|
|
32877
|
-
});
|
|
32878
|
-
static create(v) {
|
|
32879
|
-
return new StatisticsData(v.current, v.previous, v.cores, v.services);
|
|
32994
|
+
get key() {
|
|
32995
|
+
if (this.action.kind === state_update_UpdateStorageKind.Remove) {
|
|
32996
|
+
return this.action.key;
|
|
32997
|
+
}
|
|
32998
|
+
return this.action.storage.key;
|
|
32880
32999
|
}
|
|
32881
|
-
|
|
32882
|
-
this.
|
|
32883
|
-
|
|
32884
|
-
|
|
32885
|
-
this.
|
|
33000
|
+
get value() {
|
|
33001
|
+
if (this.action.kind === state_update_UpdateStorageKind.Remove) {
|
|
33002
|
+
return null;
|
|
33003
|
+
}
|
|
33004
|
+
return this.action.storage.value;
|
|
32886
33005
|
}
|
|
32887
33006
|
}
|
|
32888
33007
|
|
|
@@ -32907,6 +33026,7 @@ class StatisticsData {
|
|
|
32907
33026
|
|
|
32908
33027
|
|
|
32909
33028
|
|
|
33029
|
+
|
|
32910
33030
|
|
|
32911
33031
|
|
|
32912
33032
|
var in_memory_state_UpdateError;
|
|
@@ -33007,10 +33127,11 @@ class InMemoryService extends WithDebug {
|
|
|
33007
33127
|
/**
|
|
33008
33128
|
* A special version of state, stored fully in-memory.
|
|
33009
33129
|
*/
|
|
33010
|
-
class
|
|
33130
|
+
class in_memory_state_InMemoryState extends WithDebug {
|
|
33131
|
+
chainSpec;
|
|
33011
33132
|
/** Create a new `InMemoryState` by providing all required fields. */
|
|
33012
|
-
static
|
|
33013
|
-
return new
|
|
33133
|
+
static new(chainSpec, state) {
|
|
33134
|
+
return new in_memory_state_InMemoryState(chainSpec, state);
|
|
33014
33135
|
}
|
|
33015
33136
|
/**
|
|
33016
33137
|
* Create a new `InMemoryState` with a partial state override.
|
|
@@ -33019,14 +33140,14 @@ class InMemoryState extends WithDebug {
|
|
|
33019
33140
|
* not-necessarily coherent values.
|
|
33020
33141
|
*/
|
|
33021
33142
|
static partial(spec, partial) {
|
|
33022
|
-
const state =
|
|
33143
|
+
const state = in_memory_state_InMemoryState.empty(spec);
|
|
33023
33144
|
Object.assign(state, partial);
|
|
33024
33145
|
return state;
|
|
33025
33146
|
}
|
|
33026
33147
|
/**
|
|
33027
33148
|
* Create a new `InMemoryState` from some other state object.
|
|
33028
33149
|
*/
|
|
33029
|
-
static copyFrom(other, servicesData) {
|
|
33150
|
+
static copyFrom(chainSpec, other, servicesData) {
|
|
33030
33151
|
const services = new Map();
|
|
33031
33152
|
for (const [id, entries] of servicesData.entries()) {
|
|
33032
33153
|
const service = other.getService(id);
|
|
@@ -33036,7 +33157,7 @@ class InMemoryState extends WithDebug {
|
|
|
33036
33157
|
const inMemService = InMemoryService.copyFrom(service, entries);
|
|
33037
33158
|
services.set(id, inMemService);
|
|
33038
33159
|
}
|
|
33039
|
-
return
|
|
33160
|
+
return in_memory_state_InMemoryState.new(chainSpec, {
|
|
33040
33161
|
availabilityAssignment: other.availabilityAssignment,
|
|
33041
33162
|
accumulationQueue: other.accumulationQueue,
|
|
33042
33163
|
designatedValidatorData: other.designatedValidatorData,
|
|
@@ -33233,8 +33354,9 @@ class InMemoryState extends WithDebug {
|
|
|
33233
33354
|
getService(id) {
|
|
33234
33355
|
return this.services.get(id) ?? null;
|
|
33235
33356
|
}
|
|
33236
|
-
constructor(s) {
|
|
33357
|
+
constructor(chainSpec, s) {
|
|
33237
33358
|
super();
|
|
33359
|
+
this.chainSpec = chainSpec;
|
|
33238
33360
|
this.availabilityAssignment = s.availabilityAssignment;
|
|
33239
33361
|
this.designatedValidatorData = s.designatedValidatorData;
|
|
33240
33362
|
this.nextValidatorData = s.nextValidatorData;
|
|
@@ -33256,31 +33378,34 @@ class InMemoryState extends WithDebug {
|
|
|
33256
33378
|
this.accumulationOutputLog = s.accumulationOutputLog;
|
|
33257
33379
|
this.services = s.services;
|
|
33258
33380
|
}
|
|
33381
|
+
view() {
|
|
33382
|
+
return new InMemoryStateView(this.chainSpec, this);
|
|
33383
|
+
}
|
|
33259
33384
|
/**
|
|
33260
33385
|
* Create an empty and possibly incoherent `InMemoryState`.
|
|
33261
33386
|
*/
|
|
33262
33387
|
static empty(spec) {
|
|
33263
|
-
return new
|
|
33388
|
+
return new in_memory_state_InMemoryState(spec, {
|
|
33264
33389
|
availabilityAssignment: tryAsPerCore(Array.from({ length: spec.coresCount }, () => null), spec),
|
|
33265
|
-
designatedValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
33390
|
+
designatedValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => validator_data_ValidatorData.create({
|
|
33266
33391
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
33267
33392
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
33268
33393
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
33269
33394
|
metadata: bytes_Bytes.zero(VALIDATOR_META_BYTES).asOpaque(),
|
|
33270
33395
|
})), spec),
|
|
33271
|
-
nextValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
33396
|
+
nextValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => validator_data_ValidatorData.create({
|
|
33272
33397
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
33273
33398
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
33274
33399
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
33275
33400
|
metadata: bytes_Bytes.zero(VALIDATOR_META_BYTES).asOpaque(),
|
|
33276
33401
|
})), spec),
|
|
33277
|
-
currentValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
33402
|
+
currentValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => validator_data_ValidatorData.create({
|
|
33278
33403
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
33279
33404
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
33280
33405
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
33281
33406
|
metadata: bytes_Bytes.zero(VALIDATOR_META_BYTES).asOpaque(),
|
|
33282
33407
|
})), spec),
|
|
33283
|
-
previousValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
33408
|
+
previousValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => validator_data_ValidatorData.create({
|
|
33284
33409
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
33285
33410
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
33286
33411
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
@@ -33296,7 +33421,7 @@ class InMemoryState extends WithDebug {
|
|
|
33296
33421
|
entropy: FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
33297
33422
|
authPools: tryAsPerCore(Array.from({ length: spec.coresCount }, () => sized_array_asKnownSize([])), spec),
|
|
33298
33423
|
authQueues: tryAsPerCore(Array.from({ length: spec.coresCount }, () => FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE)), spec),
|
|
33299
|
-
recentBlocks:
|
|
33424
|
+
recentBlocks: RecentBlocks.empty(),
|
|
33300
33425
|
statistics: StatisticsData.create({
|
|
33301
33426
|
current: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorStatistics.empty()), spec),
|
|
33302
33427
|
previous: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorStatistics.empty()), spec),
|
|
@@ -33306,8 +33431,8 @@ class InMemoryState extends WithDebug {
|
|
|
33306
33431
|
accumulationQueue: tryAsPerEpochBlock(Array.from({ length: spec.epochLength }, () => []), spec),
|
|
33307
33432
|
recentlyAccumulated: tryAsPerEpochBlock(Array.from({ length: spec.epochLength }, () => HashSet.new()), spec),
|
|
33308
33433
|
ticketsAccumulator: sized_array_asKnownSize([]),
|
|
33309
|
-
sealingKeySeries:
|
|
33310
|
-
epochRoot: bytes_Bytes.zero(
|
|
33434
|
+
sealingKeySeries: safrole_data_SafroleSealingKeysData.keys(tryAsPerEpochBlock(Array.from({ length: spec.epochLength }, () => bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque()), spec)),
|
|
33435
|
+
epochRoot: bytes_Bytes.zero(bandersnatch_BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
33311
33436
|
privilegedServices: PrivilegedServices.create({
|
|
33312
33437
|
manager: tryAsServiceId(0),
|
|
33313
33438
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
@@ -33347,51 +33472,10 @@ const serviceDataCodec = descriptors_codec.dictionary(descriptors_codec.u32.asOp
|
|
|
33347
33472
|
|
|
33348
33473
|
|
|
33349
33474
|
|
|
33350
|
-
;// CONCATENATED MODULE: ./packages/jam/state/not-yet-accumulated.ts
|
|
33351
|
-
|
|
33352
|
-
|
|
33353
33475
|
|
|
33354
33476
|
|
|
33355
33477
|
|
|
33356
33478
|
|
|
33357
|
-
/**
|
|
33358
|
-
* Ready (i.e. available and/or audited) but not-yet-accumulated work-reports.
|
|
33359
|
-
*
|
|
33360
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/165300165400
|
|
33361
|
-
*/
|
|
33362
|
-
class NotYetAccumulatedReport extends WithDebug {
|
|
33363
|
-
report;
|
|
33364
|
-
dependencies;
|
|
33365
|
-
static Codec = descriptors_codec.Class(NotYetAccumulatedReport, {
|
|
33366
|
-
report: WorkReport.Codec,
|
|
33367
|
-
dependencies: codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
33368
|
-
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
33369
|
-
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
33370
|
-
minLength: 0,
|
|
33371
|
-
}),
|
|
33372
|
-
});
|
|
33373
|
-
static create({ report, dependencies }) {
|
|
33374
|
-
return new NotYetAccumulatedReport(report, dependencies);
|
|
33375
|
-
}
|
|
33376
|
-
constructor(
|
|
33377
|
-
/**
|
|
33378
|
-
* Each of these were made available at most one epoch ago
|
|
33379
|
-
* but have or had unfulfilled dependencies.
|
|
33380
|
-
*/
|
|
33381
|
-
report,
|
|
33382
|
-
/**
|
|
33383
|
-
* Alongside the work-report itself, we retain its un-accumulated
|
|
33384
|
-
* dependencies, a set of work-package hashes.
|
|
33385
|
-
*
|
|
33386
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/165800165800
|
|
33387
|
-
*/
|
|
33388
|
-
dependencies) {
|
|
33389
|
-
super();
|
|
33390
|
-
this.report = report;
|
|
33391
|
-
this.dependencies = dependencies;
|
|
33392
|
-
}
|
|
33393
|
-
}
|
|
33394
|
-
|
|
33395
33479
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialize.ts
|
|
33396
33480
|
|
|
33397
33481
|
|
|
@@ -33404,26 +33488,19 @@ class NotYetAccumulatedReport extends WithDebug {
|
|
|
33404
33488
|
|
|
33405
33489
|
|
|
33406
33490
|
|
|
33407
|
-
|
|
33408
|
-
|
|
33409
|
-
|
|
33410
33491
|
/** Serialization for particular state entries. */
|
|
33411
33492
|
var serialize_serialize;
|
|
33412
33493
|
(function (serialize) {
|
|
33413
33494
|
/** C(1): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b15013b1501?v=0.6.7 */
|
|
33414
33495
|
serialize.authPools = {
|
|
33415
33496
|
key: stateKeys.index(StateKeyIdx.Alpha),
|
|
33416
|
-
Codec:
|
|
33417
|
-
minLength: 0,
|
|
33418
|
-
maxLength: MAX_AUTH_POOL_SIZE,
|
|
33419
|
-
typicalLength: MAX_AUTH_POOL_SIZE,
|
|
33420
|
-
})),
|
|
33497
|
+
Codec: authPoolsCodec,
|
|
33421
33498
|
extract: (s) => s.authPools,
|
|
33422
33499
|
};
|
|
33423
33500
|
/** C(2): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b31013b3101?v=0.6.7 */
|
|
33424
33501
|
serialize.authQueues = {
|
|
33425
33502
|
key: stateKeys.index(StateKeyIdx.Phi),
|
|
33426
|
-
Codec:
|
|
33503
|
+
Codec: authQueuesCodec,
|
|
33427
33504
|
extract: (s) => s.authQueues,
|
|
33428
33505
|
};
|
|
33429
33506
|
/**
|
|
@@ -33432,7 +33509,7 @@ var serialize_serialize;
|
|
|
33432
33509
|
*/
|
|
33433
33510
|
serialize.recentBlocks = {
|
|
33434
33511
|
key: stateKeys.index(StateKeyIdx.Beta),
|
|
33435
|
-
Codec:
|
|
33512
|
+
Codec: RecentBlocks.Codec,
|
|
33436
33513
|
extract: (s) => s.recentBlocks,
|
|
33437
33514
|
};
|
|
33438
33515
|
/** C(4): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b63013b6301?v=0.6.7 */
|
|
@@ -33461,25 +33538,25 @@ var serialize_serialize;
|
|
|
33461
33538
|
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
33462
33539
|
serialize.designatedValidators = {
|
|
33463
33540
|
key: stateKeys.index(StateKeyIdx.Iota),
|
|
33464
|
-
Codec:
|
|
33541
|
+
Codec: validatorsDataCodec,
|
|
33465
33542
|
extract: (s) => s.designatedValidatorData,
|
|
33466
33543
|
};
|
|
33467
33544
|
/** C(8): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b0d023b0d02?v=0.6.7 */
|
|
33468
33545
|
serialize.currentValidators = {
|
|
33469
33546
|
key: stateKeys.index(StateKeyIdx.Kappa),
|
|
33470
|
-
Codec:
|
|
33547
|
+
Codec: validatorsDataCodec,
|
|
33471
33548
|
extract: (s) => s.currentValidatorData,
|
|
33472
33549
|
};
|
|
33473
33550
|
/** C(9): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b1a023b1a02?v=0.6.7 */
|
|
33474
33551
|
serialize.previousValidators = {
|
|
33475
33552
|
key: stateKeys.index(StateKeyIdx.Lambda),
|
|
33476
|
-
Codec:
|
|
33553
|
+
Codec: validatorsDataCodec,
|
|
33477
33554
|
extract: (s) => s.previousValidatorData,
|
|
33478
33555
|
};
|
|
33479
33556
|
/** C(10): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b27023b2702?v=0.6.7 */
|
|
33480
33557
|
serialize.availabilityAssignment = {
|
|
33481
33558
|
key: stateKeys.index(StateKeyIdx.Rho),
|
|
33482
|
-
Codec:
|
|
33559
|
+
Codec: availabilityAssignmentsCodec,
|
|
33483
33560
|
extract: (s) => s.availabilityAssignment,
|
|
33484
33561
|
};
|
|
33485
33562
|
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
@@ -33503,13 +33580,13 @@ var serialize_serialize;
|
|
|
33503
33580
|
/** C(14): https://graypaper.fluffylabs.dev/#/1c979cb/3bf0023bf002?v=0.7.1 */
|
|
33504
33581
|
serialize.accumulationQueue = {
|
|
33505
33582
|
key: stateKeys.index(StateKeyIdx.Omega),
|
|
33506
|
-
Codec:
|
|
33583
|
+
Codec: accumulationQueueCodec,
|
|
33507
33584
|
extract: (s) => s.accumulationQueue,
|
|
33508
33585
|
};
|
|
33509
33586
|
/** C(15): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b96023b9602?v=0.6.7 */
|
|
33510
33587
|
serialize.recentlyAccumulated = {
|
|
33511
33588
|
key: stateKeys.index(StateKeyIdx.Xi),
|
|
33512
|
-
Codec:
|
|
33589
|
+
Codec: recentlyAccumulatedCodec,
|
|
33513
33590
|
extract: (s) => s.recentlyAccumulated,
|
|
33514
33591
|
};
|
|
33515
33592
|
/** C(16): https://graypaper.fluffylabs.dev/#/38c4e62/3b46033b4603?v=0.7.0 */
|
|
@@ -33538,7 +33615,7 @@ var serialize_serialize;
|
|
|
33538
33615
|
/** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
|
|
33539
33616
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
33540
33617
|
key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
|
|
33541
|
-
Codec:
|
|
33618
|
+
Codec: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.u32)),
|
|
33542
33619
|
});
|
|
33543
33620
|
})(serialize_serialize || (serialize_serialize = {}));
|
|
33544
33621
|
/**
|
|
@@ -33550,6 +33627,87 @@ var serialize_serialize;
|
|
|
33550
33627
|
*/
|
|
33551
33628
|
const dumpCodec = Descriptor.new("Dump", { bytes: 64, isExact: false }, (e, v) => e.bytes(bytes_Bytes.fromBlob(v.raw, v.raw.length)), (d) => bytes_BytesBlob.blobFrom(d.bytes(d.source.length - d.bytesRead()).raw), (s) => s.bytes(s.decoder.source.length - s.decoder.bytesRead()));
|
|
33552
33629
|
|
|
33630
|
+
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state-view.ts
|
|
33631
|
+
|
|
33632
|
+
|
|
33633
|
+
class serialized_state_view_SerializedStateView {
|
|
33634
|
+
spec;
|
|
33635
|
+
backend;
|
|
33636
|
+
recentlyUsedServices;
|
|
33637
|
+
viewCache;
|
|
33638
|
+
constructor(spec, backend,
|
|
33639
|
+
/** Best-effort list of recently active services. */
|
|
33640
|
+
recentlyUsedServices, viewCache) {
|
|
33641
|
+
this.spec = spec;
|
|
33642
|
+
this.backend = backend;
|
|
33643
|
+
this.recentlyUsedServices = recentlyUsedServices;
|
|
33644
|
+
this.viewCache = viewCache;
|
|
33645
|
+
}
|
|
33646
|
+
retrieveView({ key, Codec }, description) {
|
|
33647
|
+
const cached = this.viewCache.get(key);
|
|
33648
|
+
if (cached !== undefined) {
|
|
33649
|
+
return cached;
|
|
33650
|
+
}
|
|
33651
|
+
const bytes = this.backend.get(key);
|
|
33652
|
+
if (bytes === null) {
|
|
33653
|
+
throw new Error(`Required state entry for ${description} is missing!. Accessing view of key: ${key}`);
|
|
33654
|
+
}
|
|
33655
|
+
// NOTE [ToDr] we are not using `Decoder.decodeObject` here because
|
|
33656
|
+
// it needs to get to the end of the data (skip), yet that's expensive.
|
|
33657
|
+
// we assume that the state data is correct and coherent anyway, so
|
|
33658
|
+
// for performance reasons we simply create the view here.
|
|
33659
|
+
const d = Decoder.fromBytesBlob(bytes);
|
|
33660
|
+
d.attachContext(this.spec);
|
|
33661
|
+
const view = Codec.View.decode(d);
|
|
33662
|
+
this.viewCache.set(key, view);
|
|
33663
|
+
return view;
|
|
33664
|
+
}
|
|
33665
|
+
availabilityAssignmentView() {
|
|
33666
|
+
return this.retrieveView(serialize.availabilityAssignment, "availabilityAssignmentView");
|
|
33667
|
+
}
|
|
33668
|
+
designatedValidatorDataView() {
|
|
33669
|
+
return this.retrieveView(serialize.designatedValidators, "designatedValidatorsView");
|
|
33670
|
+
}
|
|
33671
|
+
currentValidatorDataView() {
|
|
33672
|
+
return this.retrieveView(serialize.currentValidators, "currentValidatorsView");
|
|
33673
|
+
}
|
|
33674
|
+
previousValidatorDataView() {
|
|
33675
|
+
return this.retrieveView(serialize.previousValidators, "previousValidatorsView");
|
|
33676
|
+
}
|
|
33677
|
+
authPoolsView() {
|
|
33678
|
+
return this.retrieveView(serialize.authPools, "authPoolsView");
|
|
33679
|
+
}
|
|
33680
|
+
authQueuesView() {
|
|
33681
|
+
return this.retrieveView(serialize.authQueues, "authQueuesView");
|
|
33682
|
+
}
|
|
33683
|
+
recentBlocksView() {
|
|
33684
|
+
return this.retrieveView(serialize.recentBlocks, "recentBlocksView");
|
|
33685
|
+
}
|
|
33686
|
+
statisticsView() {
|
|
33687
|
+
return this.retrieveView(serialize.statistics, "statisticsView");
|
|
33688
|
+
}
|
|
33689
|
+
accumulationQueueView() {
|
|
33690
|
+
return this.retrieveView(serialize.accumulationQueue, "accumulationQueueView");
|
|
33691
|
+
}
|
|
33692
|
+
recentlyAccumulatedView() {
|
|
33693
|
+
return this.retrieveView(serialize.recentlyAccumulated, "recentlyAccumulatedView");
|
|
33694
|
+
}
|
|
33695
|
+
safroleDataView() {
|
|
33696
|
+
return this.retrieveView(serialize.safrole, "safroleDataView");
|
|
33697
|
+
}
|
|
33698
|
+
getServiceInfoView(id) {
|
|
33699
|
+
const serviceData = serialize.serviceData(id);
|
|
33700
|
+
const bytes = this.backend.get(serviceData.key);
|
|
33701
|
+
if (bytes === null) {
|
|
33702
|
+
return null;
|
|
33703
|
+
}
|
|
33704
|
+
if (!this.recentlyUsedServices.includes(id)) {
|
|
33705
|
+
this.recentlyUsedServices.push(id);
|
|
33706
|
+
}
|
|
33707
|
+
return Decoder.decodeObject(serviceData.Codec.View, bytes, this.spec);
|
|
33708
|
+
}
|
|
33709
|
+
}
|
|
33710
|
+
|
|
33553
33711
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state.ts
|
|
33554
33712
|
|
|
33555
33713
|
|
|
@@ -33558,6 +33716,8 @@ const dumpCodec = Descriptor.new("Dump", { bytes: 64, isExact: false }, (e, v) =
|
|
|
33558
33716
|
|
|
33559
33717
|
|
|
33560
33718
|
|
|
33719
|
+
|
|
33720
|
+
|
|
33561
33721
|
/**
|
|
33562
33722
|
* State object which reads it's entries from some backend.
|
|
33563
33723
|
*
|
|
@@ -33570,7 +33730,7 @@ class serialized_state_SerializedState {
|
|
|
33570
33730
|
spec;
|
|
33571
33731
|
blake2b;
|
|
33572
33732
|
backend;
|
|
33573
|
-
|
|
33733
|
+
recentlyUsedServices;
|
|
33574
33734
|
/** Create a state-like object from collection of serialized entries. */
|
|
33575
33735
|
static fromStateEntries(spec, blake2b, state, recentServices = []) {
|
|
33576
33736
|
return new serialized_state_SerializedState(spec, blake2b, state, recentServices);
|
|
@@ -33579,49 +33739,63 @@ class serialized_state_SerializedState {
|
|
|
33579
33739
|
static new(spec, blake2b, db, recentServices = []) {
|
|
33580
33740
|
return new serialized_state_SerializedState(spec, blake2b, db, recentServices);
|
|
33581
33741
|
}
|
|
33742
|
+
dataCache = HashDictionary.new();
|
|
33743
|
+
viewCache = HashDictionary.new();
|
|
33582
33744
|
constructor(spec, blake2b, backend,
|
|
33583
33745
|
/** Best-effort list of recently active services. */
|
|
33584
|
-
|
|
33746
|
+
recentlyUsedServices) {
|
|
33585
33747
|
this.spec = spec;
|
|
33586
33748
|
this.blake2b = blake2b;
|
|
33587
33749
|
this.backend = backend;
|
|
33588
|
-
this.
|
|
33750
|
+
this.recentlyUsedServices = recentlyUsedServices;
|
|
33589
33751
|
}
|
|
33590
33752
|
/** Comparing the serialized states, just means comparing their backends. */
|
|
33591
33753
|
[TEST_COMPARE_USING]() {
|
|
33592
33754
|
return this.backend;
|
|
33593
33755
|
}
|
|
33756
|
+
/** Return a non-decoding version of the state. */
|
|
33757
|
+
view() {
|
|
33758
|
+
return new SerializedStateView(this.spec, this.backend, this.recentlyUsedServices, this.viewCache);
|
|
33759
|
+
}
|
|
33594
33760
|
// TODO [ToDr] Temporary method to update the state,
|
|
33595
33761
|
// without changing references.
|
|
33596
33762
|
updateBackend(newBackend) {
|
|
33597
33763
|
this.backend = newBackend;
|
|
33764
|
+
this.dataCache = HashDictionary.new();
|
|
33765
|
+
this.viewCache = HashDictionary.new();
|
|
33598
33766
|
}
|
|
33599
33767
|
recentServiceIds() {
|
|
33600
|
-
return this.
|
|
33768
|
+
return this.recentlyUsedServices;
|
|
33601
33769
|
}
|
|
33602
33770
|
getService(id) {
|
|
33603
33771
|
const serviceData = this.retrieveOptional(serialize.serviceData(id));
|
|
33604
33772
|
if (serviceData === undefined) {
|
|
33605
33773
|
return null;
|
|
33606
33774
|
}
|
|
33607
|
-
if (!this.
|
|
33608
|
-
this.
|
|
33775
|
+
if (!this.recentlyUsedServices.includes(id)) {
|
|
33776
|
+
this.recentlyUsedServices.push(id);
|
|
33609
33777
|
}
|
|
33610
33778
|
return new SerializedService(this.blake2b, id, serviceData, (key) => this.retrieveOptional(key));
|
|
33611
33779
|
}
|
|
33612
|
-
retrieve(
|
|
33613
|
-
const
|
|
33614
|
-
if (
|
|
33615
|
-
throw new Error(`Required state entry for ${description} is missing!. Accessing key: ${key}`);
|
|
33780
|
+
retrieve(k, description) {
|
|
33781
|
+
const data = this.retrieveOptional(k);
|
|
33782
|
+
if (data === undefined) {
|
|
33783
|
+
throw new Error(`Required state entry for ${description} is missing!. Accessing key: ${k.key}`);
|
|
33616
33784
|
}
|
|
33617
|
-
return
|
|
33785
|
+
return data;
|
|
33618
33786
|
}
|
|
33619
33787
|
retrieveOptional({ key, Codec }) {
|
|
33788
|
+
const cached = this.dataCache.get(key);
|
|
33789
|
+
if (cached !== undefined) {
|
|
33790
|
+
return cached;
|
|
33791
|
+
}
|
|
33620
33792
|
const bytes = this.backend.get(key);
|
|
33621
33793
|
if (bytes === null) {
|
|
33622
33794
|
return undefined;
|
|
33623
33795
|
}
|
|
33624
|
-
|
|
33796
|
+
const data = Decoder.decodeObject(Codec, bytes, this.spec);
|
|
33797
|
+
this.dataCache.set(key, data);
|
|
33798
|
+
return data;
|
|
33625
33799
|
}
|
|
33626
33800
|
get availabilityAssignment() {
|
|
33627
33801
|
return this.retrieve(serialize.availabilityAssignment, "availabilityAssignment");
|
|
@@ -34736,6 +34910,7 @@ function loadState(spec, blake2b, entries) {
|
|
|
34736
34910
|
|
|
34737
34911
|
|
|
34738
34912
|
|
|
34913
|
+
|
|
34739
34914
|
;// CONCATENATED MODULE: ./packages/jam/database/leaf-db.ts
|
|
34740
34915
|
|
|
34741
34916
|
|
|
@@ -34894,7 +35069,7 @@ const codecMap = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH
|
|
|
34894
35069
|
const lookupHistoryItemCodec = descriptors_codec.object({
|
|
34895
35070
|
hash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
34896
35071
|
length: descriptors_codec.u32,
|
|
34897
|
-
slots:
|
|
35072
|
+
slots: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.u32.asOpaque())).convert(seeThrough, service_tryAsLookupHistorySlots),
|
|
34898
35073
|
}, "LookupHistoryItem", ({ hash, length, slots }) => new LookupHistoryItem(hash, length, slots));
|
|
34899
35074
|
const lookupHistoryEntryCodec = descriptors_codec.object({
|
|
34900
35075
|
key: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
@@ -34937,47 +35112,51 @@ class ServiceWithCodec extends InMemoryService {
|
|
|
34937
35112
|
return new ServiceWithCodec(serviceId, data);
|
|
34938
35113
|
}
|
|
34939
35114
|
}
|
|
34940
|
-
const in_memory_state_codec_inMemoryStateCodec =
|
|
35115
|
+
const in_memory_state_codec_inMemoryStateCodec = (spec) => codec.Class(class State extends InMemoryState {
|
|
35116
|
+
static create(data) {
|
|
35117
|
+
return InMemoryState.new(spec, data);
|
|
35118
|
+
}
|
|
35119
|
+
}, {
|
|
34941
35120
|
// alpha
|
|
34942
|
-
authPools:
|
|
35121
|
+
authPools: serialize.authPools.Codec,
|
|
34943
35122
|
// phi
|
|
34944
|
-
authQueues:
|
|
35123
|
+
authQueues: serialize.authQueues.Codec,
|
|
34945
35124
|
// beta
|
|
34946
|
-
recentBlocks:
|
|
35125
|
+
recentBlocks: serialize.recentBlocks.Codec,
|
|
34947
35126
|
// gamma_k
|
|
34948
35127
|
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
34949
35128
|
// gamma_z
|
|
34950
|
-
epochRoot:
|
|
35129
|
+
epochRoot: codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
34951
35130
|
// gamma_s
|
|
34952
35131
|
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
34953
35132
|
// gamma_a
|
|
34954
|
-
ticketsAccumulator: readonlyArray(
|
|
35133
|
+
ticketsAccumulator: readonlyArray(codec.sequenceVarLen(Ticket.Codec)).convert((x) => x, asKnownSize),
|
|
34955
35134
|
// psi
|
|
34956
|
-
disputesRecords:
|
|
35135
|
+
disputesRecords: serialize.disputesRecords.Codec,
|
|
34957
35136
|
// eta
|
|
34958
|
-
entropy:
|
|
35137
|
+
entropy: serialize.entropy.Codec,
|
|
34959
35138
|
// iota
|
|
34960
|
-
designatedValidatorData:
|
|
35139
|
+
designatedValidatorData: serialize.designatedValidators.Codec,
|
|
34961
35140
|
// kappa
|
|
34962
|
-
currentValidatorData:
|
|
35141
|
+
currentValidatorData: serialize.currentValidators.Codec,
|
|
34963
35142
|
// lambda
|
|
34964
|
-
previousValidatorData:
|
|
35143
|
+
previousValidatorData: serialize.previousValidators.Codec,
|
|
34965
35144
|
// rho
|
|
34966
|
-
availabilityAssignment:
|
|
35145
|
+
availabilityAssignment: serialize.availabilityAssignment.Codec,
|
|
34967
35146
|
// tau
|
|
34968
|
-
timeslot:
|
|
35147
|
+
timeslot: serialize.timeslot.Codec,
|
|
34969
35148
|
// chi
|
|
34970
|
-
privilegedServices:
|
|
35149
|
+
privilegedServices: serialize.privilegedServices.Codec,
|
|
34971
35150
|
// pi
|
|
34972
|
-
statistics:
|
|
35151
|
+
statistics: serialize.statistics.Codec,
|
|
34973
35152
|
// omega
|
|
34974
|
-
accumulationQueue:
|
|
35153
|
+
accumulationQueue: serialize.accumulationQueue.Codec,
|
|
34975
35154
|
// xi
|
|
34976
|
-
recentlyAccumulated:
|
|
35155
|
+
recentlyAccumulated: serialize.recentlyAccumulated.Codec,
|
|
34977
35156
|
// theta
|
|
34978
|
-
accumulationOutputLog:
|
|
35157
|
+
accumulationOutputLog: serialize.accumulationOutputLog.Codec,
|
|
34979
35158
|
// delta
|
|
34980
|
-
services:
|
|
35159
|
+
services: codec.dictionary(codec.u32.asOpaque(), ServiceWithCodec.Codec, {
|
|
34981
35160
|
sortKeys: (a, b) => a - b,
|
|
34982
35161
|
}),
|
|
34983
35162
|
});
|
|
@@ -35024,7 +35203,7 @@ class InMemoryStates {
|
|
|
35024
35203
|
}
|
|
35025
35204
|
/** Insert a full state into the database. */
|
|
35026
35205
|
async insertState(headerHash, state) {
|
|
35027
|
-
const encoded = Encoder.encodeObject(inMemoryStateCodec, state, this.spec);
|
|
35206
|
+
const encoded = Encoder.encodeObject(inMemoryStateCodec(this.spec), state, this.spec);
|
|
35028
35207
|
this.db.set(headerHash, encoded);
|
|
35029
35208
|
return Result.ok(OK);
|
|
35030
35209
|
}
|
|
@@ -35033,7 +35212,7 @@ class InMemoryStates {
|
|
|
35033
35212
|
if (encodedState === undefined) {
|
|
35034
35213
|
return null;
|
|
35035
35214
|
}
|
|
35036
|
-
return Decoder.decodeObject(inMemoryStateCodec, encodedState, this.spec);
|
|
35215
|
+
return Decoder.decodeObject(inMemoryStateCodec(this.spec), encodedState, this.spec);
|
|
35037
35216
|
}
|
|
35038
35217
|
}
|
|
35039
35218
|
|