@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/index.js
CHANGED
|
@@ -26373,6 +26373,9 @@ class ObjectView {
|
|
|
26373
26373
|
toString() {
|
|
26374
26374
|
return `View<${this.materializedConstructor.name}>(cache: ${this.cache.size})`;
|
|
26375
26375
|
}
|
|
26376
|
+
[TEST_COMPARE_USING]() {
|
|
26377
|
+
return this.materialize();
|
|
26378
|
+
}
|
|
26376
26379
|
}
|
|
26377
26380
|
/**
|
|
26378
26381
|
* A lazy-evaluated decoder of a sequence.
|
|
@@ -26505,7 +26508,7 @@ const TYPICAL_DICTIONARY_LENGTH = 32;
|
|
|
26505
26508
|
* It's not true in a general case, but should be good enough for us.
|
|
26506
26509
|
*
|
|
26507
26510
|
*/
|
|
26508
|
-
function
|
|
26511
|
+
function descriptors_readonlyArray(desc) {
|
|
26509
26512
|
return desc.convert((x) => {
|
|
26510
26513
|
debug_check `
|
|
26511
26514
|
${Array.isArray(x)}
|
|
@@ -26667,7 +26670,15 @@ var descriptors_codec;
|
|
|
26667
26670
|
/** Custom encoding / decoding logic. */
|
|
26668
26671
|
codec.custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
26669
26672
|
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
26670
|
-
codec.select = ({ name, sizeHint, }, chooser) =>
|
|
26673
|
+
codec.select = ({ name, sizeHint, }, chooser) => {
|
|
26674
|
+
const Self = chooser(null);
|
|
26675
|
+
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)
|
|
26676
|
+
? codec.select({
|
|
26677
|
+
name: Self.View.name,
|
|
26678
|
+
sizeHint: Self.View.sizeHint,
|
|
26679
|
+
}, (ctx) => chooser(ctx).View)
|
|
26680
|
+
: Self.View);
|
|
26681
|
+
};
|
|
26671
26682
|
/**
|
|
26672
26683
|
* A descriptor for a more complex POJO.
|
|
26673
26684
|
*
|
|
@@ -27489,7 +27500,7 @@ const BANDERSNATCH_KEY_BYTES = 32;
|
|
|
27489
27500
|
/** Bandersnatch VRF signature size */
|
|
27490
27501
|
const BANDERSNATCH_VRF_SIGNATURE_BYTES = 96;
|
|
27491
27502
|
/** Bandersnatch ring commitment size */
|
|
27492
|
-
const
|
|
27503
|
+
const bandersnatch_BANDERSNATCH_RING_ROOT_BYTES = 144;
|
|
27493
27504
|
/** Bandersnatch proof size */
|
|
27494
27505
|
const BANDERSNATCH_PROOF_BYTES = 784;
|
|
27495
27506
|
/** BLS public key size. */
|
|
@@ -29070,9 +29081,9 @@ function codecWithContext(chooser) {
|
|
|
29070
29081
|
/** Codec for a known-size array with length validation. */
|
|
29071
29082
|
const codecKnownSizeArray = (val, options, _id) => {
|
|
29072
29083
|
if ("fixedLength" in options) {
|
|
29073
|
-
return
|
|
29084
|
+
return descriptors_readonlyArray(descriptors_codec.sequenceFixLen(val, options.fixedLength)).convert(seeThrough, sized_array_asKnownSize);
|
|
29074
29085
|
}
|
|
29075
|
-
return
|
|
29086
|
+
return descriptors_readonlyArray(descriptors_codec.sequenceVarLen(val, options)).convert(seeThrough, sized_array_asKnownSize);
|
|
29076
29087
|
};
|
|
29077
29088
|
/** Codec for a fixed-size array with length validation. */
|
|
29078
29089
|
const codecFixedSizeArray = (val, len) => {
|
|
@@ -29446,16 +29457,16 @@ class SignedTicket extends WithDebug {
|
|
|
29446
29457
|
}
|
|
29447
29458
|
}
|
|
29448
29459
|
/** Anonymous? entry into the ticket contest. */
|
|
29449
|
-
class
|
|
29460
|
+
class tickets_Ticket extends WithDebug {
|
|
29450
29461
|
id;
|
|
29451
29462
|
attempt;
|
|
29452
|
-
static Codec = descriptors_codec.Class(
|
|
29463
|
+
static Codec = descriptors_codec.Class(tickets_Ticket, {
|
|
29453
29464
|
id: descriptors_codec.bytes(hash_HASH_SIZE),
|
|
29454
29465
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
29455
29466
|
attempt: descriptors_codec.u8.asOpaque(),
|
|
29456
29467
|
});
|
|
29457
29468
|
static create({ id, attempt }) {
|
|
29458
|
-
return new
|
|
29469
|
+
return new tickets_Ticket(id, attempt);
|
|
29459
29470
|
}
|
|
29460
29471
|
constructor(
|
|
29461
29472
|
/**
|
|
@@ -29567,7 +29578,7 @@ function tryAsPerValidator(array, spec) {
|
|
|
29567
29578
|
`;
|
|
29568
29579
|
return sized_array_asKnownSize(array);
|
|
29569
29580
|
}
|
|
29570
|
-
const
|
|
29581
|
+
const common_codecPerValidator = (val) => codecWithContext((context) => {
|
|
29571
29582
|
return codecKnownSizeArray(val, {
|
|
29572
29583
|
fixedLength: context.validatorsCount,
|
|
29573
29584
|
});
|
|
@@ -29694,7 +29705,7 @@ class Verdict extends WithDebug {
|
|
|
29694
29705
|
workReportHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
29695
29706
|
votesEpoch: descriptors_codec.u32.asOpaque(),
|
|
29696
29707
|
votes: codecWithContext((context) => {
|
|
29697
|
-
return
|
|
29708
|
+
return descriptors_readonlyArray(descriptors_codec.sequenceFixLen(Judgement.Codec, context.validatorsSuperMajority)).convert(seeThrough, sized_array_asKnownSize);
|
|
29698
29709
|
}),
|
|
29699
29710
|
});
|
|
29700
29711
|
static create({ workReportHash, votesEpoch, votes }) {
|
|
@@ -30386,7 +30397,7 @@ const WorkReportCodec = descriptors_codec.Class(WorkReportNoCodec, {
|
|
|
30386
30397
|
authorizerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
30387
30398
|
authorizationGasUsed: descriptors_codec.varU64.asOpaque(),
|
|
30388
30399
|
authorizationOutput: descriptors_codec.blob,
|
|
30389
|
-
segmentRootLookup:
|
|
30400
|
+
segmentRootLookup: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(WorkPackageInfo.Codec)),
|
|
30390
30401
|
results: descriptors_codec.sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
30391
30402
|
});
|
|
30392
30403
|
const WorkReportCodecPre070 = descriptors_codec.Class(WorkReportNoCodec, {
|
|
@@ -30400,7 +30411,7 @@ const WorkReportCodecPre070 = descriptors_codec.Class(WorkReportNoCodec, {
|
|
|
30400
30411
|
}),
|
|
30401
30412
|
authorizerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
30402
30413
|
authorizationOutput: descriptors_codec.blob,
|
|
30403
|
-
segmentRootLookup:
|
|
30414
|
+
segmentRootLookup: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(WorkPackageInfo.Codec)),
|
|
30404
30415
|
results: descriptors_codec.sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
30405
30416
|
authorizationGasUsed: descriptors_codec.varU64.asOpaque(),
|
|
30406
30417
|
});
|
|
@@ -30521,7 +30532,7 @@ class ValidatorKeys extends WithDebug {
|
|
|
30521
30532
|
class TicketsMarker extends WithDebug {
|
|
30522
30533
|
tickets;
|
|
30523
30534
|
static Codec = descriptors_codec.Class(TicketsMarker, {
|
|
30524
|
-
tickets: codecPerEpochBlock(
|
|
30535
|
+
tickets: codecPerEpochBlock(tickets_Ticket.Codec),
|
|
30525
30536
|
});
|
|
30526
30537
|
static create({ tickets }) {
|
|
30527
30538
|
return new TicketsMarker(tickets);
|
|
@@ -30545,7 +30556,7 @@ class EpochMarker extends WithDebug {
|
|
|
30545
30556
|
static Codec = descriptors_codec.Class(EpochMarker, {
|
|
30546
30557
|
entropy: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
30547
30558
|
ticketsEntropy: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
30548
|
-
validators:
|
|
30559
|
+
validators: common_codecPerValidator(ValidatorKeys.Codec),
|
|
30549
30560
|
});
|
|
30550
30561
|
static create({ entropy, ticketsEntropy, validators }) {
|
|
30551
30562
|
return new EpochMarker(entropy, ticketsEntropy, validators);
|
|
@@ -30817,6 +30828,19 @@ function emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
|
30817
30828
|
});
|
|
30818
30829
|
}
|
|
30819
30830
|
|
|
30831
|
+
;// CONCATENATED MODULE: ./packages/jam/block/utils.ts
|
|
30832
|
+
|
|
30833
|
+
/**
|
|
30834
|
+
* Take an input data and re-encode that data as view.
|
|
30835
|
+
*
|
|
30836
|
+
* NOTE: this function should NEVER be used in any production code,
|
|
30837
|
+
* it's only a test helper.
|
|
30838
|
+
*/
|
|
30839
|
+
function reencodeAsView(codec, object, chainSpec) {
|
|
30840
|
+
const encoded = encoder_Encoder.encodeObject(codec, object, chainSpec);
|
|
30841
|
+
return decoder_Decoder.decodeObject(codec.View, encoded, chainSpec);
|
|
30842
|
+
}
|
|
30843
|
+
|
|
30820
30844
|
;// CONCATENATED MODULE: ./packages/jam/block/index.ts
|
|
30821
30845
|
|
|
30822
30846
|
|
|
@@ -30835,6 +30859,7 @@ function emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
|
30835
30859
|
|
|
30836
30860
|
|
|
30837
30861
|
|
|
30862
|
+
|
|
30838
30863
|
;// CONCATENATED MODULE: ./packages/jam/block-json/disputes-extrinsic.ts
|
|
30839
30864
|
|
|
30840
30865
|
|
|
@@ -31074,7 +31099,7 @@ const epochMark = json.object({
|
|
|
31074
31099
|
const ticket = json.object({
|
|
31075
31100
|
id: fromJson.bytes32(),
|
|
31076
31101
|
attempt: fromJson.ticketAttempt,
|
|
31077
|
-
}, (x) =>
|
|
31102
|
+
}, (x) => tickets_Ticket.create({ id: x.id, attempt: x.attempt }));
|
|
31078
31103
|
const headerFromJson = json.object({
|
|
31079
31104
|
parent: fromJson.bytes32(),
|
|
31080
31105
|
parent_state_root: fromJson.bytes32(),
|
|
@@ -31999,10 +32024,128 @@ function accumulationOutputComparator(a, b) {
|
|
|
31999
32024
|
return Ordering.Equal;
|
|
32000
32025
|
}
|
|
32001
32026
|
|
|
32027
|
+
;// CONCATENATED MODULE: ./packages/jam/block/gp-constants.ts
|
|
32028
|
+
|
|
32029
|
+
/**
|
|
32030
|
+
* This file lists all of the constants defined in the GrayPaper appendix.
|
|
32031
|
+
*
|
|
32032
|
+
* NOTE: Avoid using the constants directly, prefer "named" constants defined
|
|
32033
|
+
* in a semantical proximity to where they are used.
|
|
32034
|
+
*
|
|
32035
|
+
* NOTE: This file will most likely be removed in the future. The constants
|
|
32036
|
+
* here are only temporarily for convenience. When we figure out better names
|
|
32037
|
+
* and places for these this file will be eradicated.
|
|
32038
|
+
*
|
|
32039
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/413000413000
|
|
32040
|
+
*/
|
|
32041
|
+
/** `G_I`: The gas allocated to invoke a work-package’s Is-Authorized logic. */
|
|
32042
|
+
const G_I = 50_000_000;
|
|
32043
|
+
/** `I`: Maximum number of work items in a package. */
|
|
32044
|
+
const gp_constants_I = (/* unused pure expression or super */ null && (MAX_NUMBER_OF_WORK_ITEMS));
|
|
32045
|
+
/** `O`: Maximum number of items in the authorizations pool. */
|
|
32046
|
+
const O = 8;
|
|
32047
|
+
/** `Q`: The number of items in the authorizations queue. */
|
|
32048
|
+
const Q = 80;
|
|
32049
|
+
/** `S`: The maximum number of entries in the accumulation queue. */
|
|
32050
|
+
const S = 1024;
|
|
32051
|
+
/** `T`: The maximum number of extrinsics in a work-package. */
|
|
32052
|
+
const T = 128;
|
|
32053
|
+
/** `W_A`: The maximum size of is-authorized code in octets. */
|
|
32054
|
+
const W_A = 64_000;
|
|
32055
|
+
/** `W_B`: The maximum size of an encoded work-package with extrinsic data and imports. */
|
|
32056
|
+
const W_B = 13_794_305;
|
|
32057
|
+
/** `W_C`: The maximum size of service code in octets. */
|
|
32058
|
+
const W_C = 4_000_000;
|
|
32059
|
+
/** `W_M`: The maximum number of imports in a work-package. */
|
|
32060
|
+
const W_M = 3_072;
|
|
32061
|
+
/** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
|
|
32062
|
+
const W_R = 49_152;
|
|
32063
|
+
/** `W_T`: The size of a transfer memo in octets. */
|
|
32064
|
+
const W_T = 128;
|
|
32065
|
+
/** `W_M`: The maximum number of exports in a work-package. */
|
|
32066
|
+
const W_X = 3_072;
|
|
32067
|
+
// TODO [ToDr] Not sure where these should live yet :(
|
|
32068
|
+
/**
|
|
32069
|
+
* `S`: The minimum public service index.
|
|
32070
|
+
* Services of indices below these may only be created by the Registrar.
|
|
32071
|
+
*
|
|
32072
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/447a00447a00?v=0.7.2
|
|
32073
|
+
*/
|
|
32074
|
+
const MIN_PUBLIC_SERVICE_INDEX = 2 ** 16;
|
|
32075
|
+
/**
|
|
32076
|
+
* `J`: The maximum sum of dependency items in a work-report.
|
|
32077
|
+
*
|
|
32078
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/416a00416a00?v=0.6.2
|
|
32079
|
+
*/
|
|
32080
|
+
const MAX_REPORT_DEPENDENCIES = 8;
|
|
32081
|
+
|
|
32082
|
+
;// CONCATENATED MODULE: ./packages/jam/state/accumulation-queue.ts
|
|
32083
|
+
|
|
32084
|
+
|
|
32085
|
+
|
|
32086
|
+
|
|
32087
|
+
|
|
32088
|
+
|
|
32089
|
+
|
|
32090
|
+
/**
|
|
32091
|
+
* Ready (i.e. available and/or audited) but not-yet-accumulated work-reports.
|
|
32092
|
+
*
|
|
32093
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/165300165400
|
|
32094
|
+
*/
|
|
32095
|
+
class NotYetAccumulatedReport extends WithDebug {
|
|
32096
|
+
report;
|
|
32097
|
+
dependencies;
|
|
32098
|
+
static Codec = descriptors_codec.Class(NotYetAccumulatedReport, {
|
|
32099
|
+
report: WorkReport.Codec,
|
|
32100
|
+
dependencies: codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
32101
|
+
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
32102
|
+
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
32103
|
+
minLength: 0,
|
|
32104
|
+
}),
|
|
32105
|
+
});
|
|
32106
|
+
static create({ report, dependencies }) {
|
|
32107
|
+
return new NotYetAccumulatedReport(report, dependencies);
|
|
32108
|
+
}
|
|
32109
|
+
constructor(
|
|
32110
|
+
/**
|
|
32111
|
+
* Each of these were made available at most one epoch ago
|
|
32112
|
+
* but have or had unfulfilled dependencies.
|
|
32113
|
+
*/
|
|
32114
|
+
report,
|
|
32115
|
+
/**
|
|
32116
|
+
* Alongside the work-report itself, we retain its un-accumulated
|
|
32117
|
+
* dependencies, a set of work-package hashes.
|
|
32118
|
+
*
|
|
32119
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/165800165800
|
|
32120
|
+
*/
|
|
32121
|
+
dependencies) {
|
|
32122
|
+
super();
|
|
32123
|
+
this.report = report;
|
|
32124
|
+
this.dependencies = dependencies;
|
|
32125
|
+
}
|
|
32126
|
+
}
|
|
32127
|
+
const accumulationQueueCodec = codecPerEpochBlock(descriptors_readonlyArray(descriptors_codec.sequenceVarLen(NotYetAccumulatedReport.Codec)));
|
|
32128
|
+
|
|
32129
|
+
;// CONCATENATED MODULE: ./packages/jam/state/common.ts
|
|
32130
|
+
|
|
32131
|
+
|
|
32132
|
+
/** Check if given array has correct length before casting to the opaque type. */
|
|
32133
|
+
function tryAsPerCore(array, spec) {
|
|
32134
|
+
debug_check `
|
|
32135
|
+
${array.length === spec.coresCount}
|
|
32136
|
+
Invalid per-core array length. Expected ${spec.coresCount}, got: ${array.length}
|
|
32137
|
+
`;
|
|
32138
|
+
return opaque_asOpaqueType(array);
|
|
32139
|
+
}
|
|
32140
|
+
const codecPerCore = (val) => codecWithContext((context) => {
|
|
32141
|
+
return codecKnownSizeArray(val, { fixedLength: context.coresCount });
|
|
32142
|
+
});
|
|
32143
|
+
|
|
32002
32144
|
;// CONCATENATED MODULE: ./packages/jam/state/assurances.ts
|
|
32003
32145
|
|
|
32004
32146
|
|
|
32005
32147
|
|
|
32148
|
+
|
|
32006
32149
|
/**
|
|
32007
32150
|
* Assignment of particular work report to a core.
|
|
32008
32151
|
*
|
|
@@ -32031,27 +32174,30 @@ class AvailabilityAssignment extends WithDebug {
|
|
|
32031
32174
|
this.timeout = timeout;
|
|
32032
32175
|
}
|
|
32033
32176
|
}
|
|
32177
|
+
const availabilityAssignmentsCodec = codecPerCore(descriptors_codec.optional(AvailabilityAssignment.Codec));
|
|
32034
32178
|
|
|
32035
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
32179
|
+
;// CONCATENATED MODULE: ./packages/jam/state/auth.ts
|
|
32036
32180
|
|
|
32037
32181
|
|
|
32038
|
-
|
|
32039
|
-
|
|
32040
|
-
|
|
32041
|
-
|
|
32042
|
-
|
|
32043
|
-
|
|
32044
|
-
|
|
32045
|
-
|
|
32046
|
-
|
|
32047
|
-
|
|
32048
|
-
|
|
32182
|
+
|
|
32183
|
+
|
|
32184
|
+
|
|
32185
|
+
/** `O`: Maximal authorization pool size. */
|
|
32186
|
+
const MAX_AUTH_POOL_SIZE = O;
|
|
32187
|
+
/** `Q`: Size of the authorization queue. */
|
|
32188
|
+
const AUTHORIZATION_QUEUE_SIZE = Q;
|
|
32189
|
+
const authPoolsCodec = codecPerCore(codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
32190
|
+
minLength: 0,
|
|
32191
|
+
maxLength: MAX_AUTH_POOL_SIZE,
|
|
32192
|
+
typicalLength: MAX_AUTH_POOL_SIZE,
|
|
32193
|
+
}));
|
|
32194
|
+
const authQueuesCodec = codecPerCore(codecFixedSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE));
|
|
32049
32195
|
|
|
32050
32196
|
;// CONCATENATED MODULE: ./packages/jam/state/disputes.ts
|
|
32051
32197
|
|
|
32052
32198
|
|
|
32053
32199
|
|
|
32054
|
-
const sortedSetCodec = () =>
|
|
32200
|
+
const sortedSetCodec = () => descriptors_readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.bytes(hash_HASH_SIZE))).convert((input) => input.array, (output) => {
|
|
32055
32201
|
const typed = output.map((x) => x.asOpaque());
|
|
32056
32202
|
return SortedSet.fromSortedArray(hashComparator, typed);
|
|
32057
32203
|
});
|
|
@@ -32113,65 +32259,6 @@ function hashComparator(a, b) {
|
|
|
32113
32259
|
return a.compare(b);
|
|
32114
32260
|
}
|
|
32115
32261
|
|
|
32116
|
-
;// CONCATENATED MODULE: ./packages/jam/block/gp-constants.ts
|
|
32117
|
-
|
|
32118
|
-
/**
|
|
32119
|
-
* This file lists all of the constants defined in the GrayPaper appendix.
|
|
32120
|
-
*
|
|
32121
|
-
* NOTE: Avoid using the constants directly, prefer "named" constants defined
|
|
32122
|
-
* in a semantical proximity to where they are used.
|
|
32123
|
-
*
|
|
32124
|
-
* NOTE: This file will most likely be removed in the future. The constants
|
|
32125
|
-
* here are only temporarily for convenience. When we figure out better names
|
|
32126
|
-
* and places for these this file will be eradicated.
|
|
32127
|
-
*
|
|
32128
|
-
* https://graypaper.fluffylabs.dev/#/579bd12/413000413000
|
|
32129
|
-
*/
|
|
32130
|
-
/** `G_I`: The gas allocated to invoke a work-package’s Is-Authorized logic. */
|
|
32131
|
-
const G_I = 50_000_000;
|
|
32132
|
-
/** `I`: Maximum number of work items in a package. */
|
|
32133
|
-
const gp_constants_I = (/* unused pure expression or super */ null && (MAX_NUMBER_OF_WORK_ITEMS));
|
|
32134
|
-
/** `O`: Maximum number of items in the authorizations pool. */
|
|
32135
|
-
const O = 8;
|
|
32136
|
-
/** `Q`: The number of items in the authorizations queue. */
|
|
32137
|
-
const Q = 80;
|
|
32138
|
-
/** `S`: The maximum number of entries in the accumulation queue. */
|
|
32139
|
-
const S = 1024;
|
|
32140
|
-
/** `T`: The maximum number of extrinsics in a work-package. */
|
|
32141
|
-
const T = 128;
|
|
32142
|
-
/** `W_A`: The maximum size of is-authorized code in octets. */
|
|
32143
|
-
const W_A = 64_000;
|
|
32144
|
-
/** `W_B`: The maximum size of an encoded work-package with extrinsic data and imports. */
|
|
32145
|
-
const W_B = 13_794_305;
|
|
32146
|
-
/** `W_C`: The maximum size of service code in octets. */
|
|
32147
|
-
const W_C = 4_000_000;
|
|
32148
|
-
/** `W_M`: The maximum number of imports in a work-package. */
|
|
32149
|
-
const W_M = 3_072;
|
|
32150
|
-
/** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
|
|
32151
|
-
const W_R = 49_152;
|
|
32152
|
-
/** `W_T`: The size of a transfer memo in octets. */
|
|
32153
|
-
const W_T = 128;
|
|
32154
|
-
/** `W_M`: The maximum number of exports in a work-package. */
|
|
32155
|
-
const W_X = 3_072;
|
|
32156
|
-
// TODO [ToDr] Not sure where these should live yet :(
|
|
32157
|
-
/**
|
|
32158
|
-
* `S`: The minimum public service index.
|
|
32159
|
-
* Services of indices below these may only be created by the Registrar.
|
|
32160
|
-
*
|
|
32161
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/447a00447a00?v=0.7.2
|
|
32162
|
-
*/
|
|
32163
|
-
const MIN_PUBLIC_SERVICE_INDEX = 2 ** 16;
|
|
32164
|
-
/**
|
|
32165
|
-
* `J`: The maximum sum of dependency items in a work-report.
|
|
32166
|
-
*
|
|
32167
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/416a00416a00?v=0.6.2
|
|
32168
|
-
*/
|
|
32169
|
-
const MAX_REPORT_DEPENDENCIES = 8;
|
|
32170
|
-
/** `Q`: Size of the authorization queue. */
|
|
32171
|
-
const AUTHORIZATION_QUEUE_SIZE = Q;
|
|
32172
|
-
/** `O`: Maximal authorization pool size. */
|
|
32173
|
-
const MAX_AUTH_POOL_SIZE = O;
|
|
32174
|
-
|
|
32175
32262
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/ops/math-consts.ts
|
|
32176
32263
|
const MAX_VALUE = 4294967295;
|
|
32177
32264
|
const math_consts_MAX_VALUE_U64 = (/* unused pure expression or super */ null && (2n ** 63n));
|
|
@@ -32179,7 +32266,7 @@ const MIN_VALUE = -(2 ** 31);
|
|
|
32179
32266
|
const MAX_SHIFT_U32 = 32;
|
|
32180
32267
|
const MAX_SHIFT_U64 = 64n;
|
|
32181
32268
|
|
|
32182
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
32269
|
+
;// CONCATENATED MODULE: ./packages/jam/state/recent-blocks.ts
|
|
32183
32270
|
|
|
32184
32271
|
|
|
32185
32272
|
|
|
@@ -32187,23 +32274,267 @@ const MAX_SHIFT_U64 = 64n;
|
|
|
32187
32274
|
|
|
32188
32275
|
|
|
32189
32276
|
/**
|
|
32190
|
-
* `
|
|
32191
|
-
*
|
|
32192
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
32193
|
-
*/
|
|
32194
|
-
const BASE_SERVICE_BALANCE = 100n;
|
|
32195
|
-
/**
|
|
32196
|
-
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
32277
|
+
* `H = 8`: The size of recent history, in blocks.
|
|
32197
32278
|
*
|
|
32198
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
32279
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/416300416500
|
|
32199
32280
|
*/
|
|
32200
|
-
const
|
|
32281
|
+
const MAX_RECENT_HISTORY = 8;
|
|
32282
|
+
/** Recent history of a single block. */
|
|
32283
|
+
class BlockState extends WithDebug {
|
|
32284
|
+
headerHash;
|
|
32285
|
+
accumulationResult;
|
|
32286
|
+
postStateRoot;
|
|
32287
|
+
reported;
|
|
32288
|
+
static Codec = descriptors_codec.Class(BlockState, {
|
|
32289
|
+
headerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
32290
|
+
accumulationResult: descriptors_codec.bytes(hash_HASH_SIZE),
|
|
32291
|
+
postStateRoot: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
32292
|
+
reported: codecHashDictionary(WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
32293
|
+
});
|
|
32294
|
+
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
32295
|
+
return new BlockState(headerHash, accumulationResult, postStateRoot, reported);
|
|
32296
|
+
}
|
|
32297
|
+
constructor(
|
|
32298
|
+
/** Header hash. */
|
|
32299
|
+
headerHash,
|
|
32300
|
+
/** Merkle mountain belt of accumulation result. */
|
|
32301
|
+
accumulationResult,
|
|
32302
|
+
/** Posterior state root filled in with a 1-block delay. */
|
|
32303
|
+
postStateRoot,
|
|
32304
|
+
/** Reported work packages (no more than number of cores). */
|
|
32305
|
+
reported) {
|
|
32306
|
+
super();
|
|
32307
|
+
this.headerHash = headerHash;
|
|
32308
|
+
this.accumulationResult = accumulationResult;
|
|
32309
|
+
this.postStateRoot = postStateRoot;
|
|
32310
|
+
this.reported = reported;
|
|
32311
|
+
}
|
|
32312
|
+
}
|
|
32201
32313
|
/**
|
|
32202
|
-
*
|
|
32314
|
+
* Recent history of blocks.
|
|
32203
32315
|
*
|
|
32204
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/
|
|
32316
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fc9010fc901?v=0.6.7
|
|
32205
32317
|
*/
|
|
32206
|
-
|
|
32318
|
+
class RecentBlocks extends WithDebug {
|
|
32319
|
+
blocks;
|
|
32320
|
+
accumulationLog;
|
|
32321
|
+
static Codec = descriptors_codec.Class(RecentBlocks, {
|
|
32322
|
+
blocks: codecKnownSizeArray(BlockState.Codec, {
|
|
32323
|
+
minLength: 0,
|
|
32324
|
+
maxLength: MAX_RECENT_HISTORY,
|
|
32325
|
+
typicalLength: MAX_RECENT_HISTORY,
|
|
32326
|
+
}),
|
|
32327
|
+
accumulationLog: descriptors_codec.object({
|
|
32328
|
+
peaks: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.optional(descriptors_codec.bytes(hash_HASH_SIZE)))),
|
|
32329
|
+
}),
|
|
32330
|
+
});
|
|
32331
|
+
static empty() {
|
|
32332
|
+
return new RecentBlocks(sized_array_asKnownSize([]), {
|
|
32333
|
+
peaks: [],
|
|
32334
|
+
});
|
|
32335
|
+
}
|
|
32336
|
+
static create(a) {
|
|
32337
|
+
return new RecentBlocks(a.blocks, a.accumulationLog);
|
|
32338
|
+
}
|
|
32339
|
+
constructor(
|
|
32340
|
+
/**
|
|
32341
|
+
* Most recent blocks.
|
|
32342
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fea010fea01?v=0.6.7
|
|
32343
|
+
*/
|
|
32344
|
+
blocks,
|
|
32345
|
+
/**
|
|
32346
|
+
* Accumulation output log.
|
|
32347
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0f02020f0202?v=0.6.7
|
|
32348
|
+
*/
|
|
32349
|
+
accumulationLog) {
|
|
32350
|
+
super();
|
|
32351
|
+
this.blocks = blocks;
|
|
32352
|
+
this.accumulationLog = accumulationLog;
|
|
32353
|
+
}
|
|
32354
|
+
}
|
|
32355
|
+
|
|
32356
|
+
;// CONCATENATED MODULE: ./packages/jam/state/recently-accumulated.ts
|
|
32357
|
+
|
|
32358
|
+
|
|
32359
|
+
|
|
32360
|
+
|
|
32361
|
+
const recentlyAccumulatedCodec = codecPerEpochBlock(descriptors_codec.sequenceVarLen(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x)));
|
|
32362
|
+
|
|
32363
|
+
;// CONCATENATED MODULE: ./packages/jam/state/validator-data.ts
|
|
32364
|
+
|
|
32365
|
+
|
|
32366
|
+
|
|
32367
|
+
|
|
32368
|
+
/**
|
|
32369
|
+
* Fixed size of validator metadata.
|
|
32370
|
+
*
|
|
32371
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/0d55010d5501
|
|
32372
|
+
*/
|
|
32373
|
+
const VALIDATOR_META_BYTES = 128;
|
|
32374
|
+
/**
|
|
32375
|
+
* Details about validators' identity.
|
|
32376
|
+
*
|
|
32377
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/0d4b010d4c01
|
|
32378
|
+
*/
|
|
32379
|
+
class validator_data_ValidatorData extends WithDebug {
|
|
32380
|
+
bandersnatch;
|
|
32381
|
+
ed25519;
|
|
32382
|
+
bls;
|
|
32383
|
+
metadata;
|
|
32384
|
+
static Codec = descriptors_codec.Class(validator_data_ValidatorData, {
|
|
32385
|
+
bandersnatch: descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
32386
|
+
ed25519: descriptors_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
32387
|
+
bls: descriptors_codec.bytes(BLS_KEY_BYTES).asOpaque(),
|
|
32388
|
+
metadata: descriptors_codec.bytes(VALIDATOR_META_BYTES),
|
|
32389
|
+
});
|
|
32390
|
+
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
32391
|
+
return new validator_data_ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
32392
|
+
}
|
|
32393
|
+
constructor(
|
|
32394
|
+
/** Bandersnatch public key. */
|
|
32395
|
+
bandersnatch,
|
|
32396
|
+
/** ED25519 key data. */
|
|
32397
|
+
ed25519,
|
|
32398
|
+
/** BLS public key. */
|
|
32399
|
+
bls,
|
|
32400
|
+
/** Validator-defined additional metdata. */
|
|
32401
|
+
metadata) {
|
|
32402
|
+
super();
|
|
32403
|
+
this.bandersnatch = bandersnatch;
|
|
32404
|
+
this.ed25519 = ed25519;
|
|
32405
|
+
this.bls = bls;
|
|
32406
|
+
this.metadata = metadata;
|
|
32407
|
+
}
|
|
32408
|
+
}
|
|
32409
|
+
const validatorsDataCodec = common_codecPerValidator(validator_data_ValidatorData.Codec);
|
|
32410
|
+
|
|
32411
|
+
;// CONCATENATED MODULE: ./packages/jam/state/safrole-data.ts
|
|
32412
|
+
|
|
32413
|
+
|
|
32414
|
+
|
|
32415
|
+
|
|
32416
|
+
|
|
32417
|
+
|
|
32418
|
+
|
|
32419
|
+
|
|
32420
|
+
|
|
32421
|
+
|
|
32422
|
+
|
|
32423
|
+
var SafroleSealingKeysKind;
|
|
32424
|
+
(function (SafroleSealingKeysKind) {
|
|
32425
|
+
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
32426
|
+
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
32427
|
+
})(SafroleSealingKeysKind || (SafroleSealingKeysKind = {}));
|
|
32428
|
+
const codecBandersnatchKey = descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
32429
|
+
class safrole_data_SafroleSealingKeysData extends WithDebug {
|
|
32430
|
+
kind;
|
|
32431
|
+
keys;
|
|
32432
|
+
tickets;
|
|
32433
|
+
static Codec = codecWithContext((context) => {
|
|
32434
|
+
return descriptors_codec.custom({
|
|
32435
|
+
name: "SafroleSealingKeys",
|
|
32436
|
+
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
32437
|
+
}, (e, x) => {
|
|
32438
|
+
e.varU32(numbers_tryAsU32(x.kind));
|
|
32439
|
+
if (x.kind === SafroleSealingKeysKind.Keys) {
|
|
32440
|
+
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
32441
|
+
}
|
|
32442
|
+
else {
|
|
32443
|
+
e.sequenceFixLen(tickets_Ticket.Codec, x.tickets);
|
|
32444
|
+
}
|
|
32445
|
+
}, (d) => {
|
|
32446
|
+
const epochLength = context.epochLength;
|
|
32447
|
+
const kind = d.varU32();
|
|
32448
|
+
if (kind === SafroleSealingKeysKind.Keys) {
|
|
32449
|
+
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
32450
|
+
return safrole_data_SafroleSealingKeysData.keys(tryAsPerEpochBlock(keys, context));
|
|
32451
|
+
}
|
|
32452
|
+
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
32453
|
+
const tickets = d.sequenceFixLen(tickets_Ticket.Codec, epochLength);
|
|
32454
|
+
return safrole_data_SafroleSealingKeysData.tickets(tryAsPerEpochBlock(tickets, context));
|
|
32455
|
+
}
|
|
32456
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
32457
|
+
}, (s) => {
|
|
32458
|
+
const kind = s.decoder.varU32();
|
|
32459
|
+
if (kind === SafroleSealingKeysKind.Keys) {
|
|
32460
|
+
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
32461
|
+
return;
|
|
32462
|
+
}
|
|
32463
|
+
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
32464
|
+
s.sequenceFixLen(tickets_Ticket.Codec, context.epochLength);
|
|
32465
|
+
return;
|
|
32466
|
+
}
|
|
32467
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
32468
|
+
});
|
|
32469
|
+
});
|
|
32470
|
+
static keys(keys) {
|
|
32471
|
+
return new safrole_data_SafroleSealingKeysData(SafroleSealingKeysKind.Keys, keys, undefined);
|
|
32472
|
+
}
|
|
32473
|
+
static tickets(tickets) {
|
|
32474
|
+
return new safrole_data_SafroleSealingKeysData(SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
32475
|
+
}
|
|
32476
|
+
constructor(kind, keys, tickets) {
|
|
32477
|
+
super();
|
|
32478
|
+
this.kind = kind;
|
|
32479
|
+
this.keys = keys;
|
|
32480
|
+
this.tickets = tickets;
|
|
32481
|
+
}
|
|
32482
|
+
}
|
|
32483
|
+
class SafroleData {
|
|
32484
|
+
nextValidatorData;
|
|
32485
|
+
epochRoot;
|
|
32486
|
+
sealingKeySeries;
|
|
32487
|
+
ticketsAccumulator;
|
|
32488
|
+
static Codec = descriptors_codec.Class(SafroleData, {
|
|
32489
|
+
nextValidatorData: common_codecPerValidator(validator_data_ValidatorData.Codec),
|
|
32490
|
+
epochRoot: descriptors_codec.bytes(bandersnatch_BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
32491
|
+
sealingKeySeries: safrole_data_SafroleSealingKeysData.Codec,
|
|
32492
|
+
ticketsAccumulator: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(tickets_Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
32493
|
+
});
|
|
32494
|
+
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
32495
|
+
return new SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
32496
|
+
}
|
|
32497
|
+
constructor(
|
|
32498
|
+
/** gamma_k */
|
|
32499
|
+
nextValidatorData,
|
|
32500
|
+
/** gamma_z */
|
|
32501
|
+
epochRoot,
|
|
32502
|
+
/** gamma_s */
|
|
32503
|
+
sealingKeySeries,
|
|
32504
|
+
/** gamma_a */
|
|
32505
|
+
ticketsAccumulator) {
|
|
32506
|
+
this.nextValidatorData = nextValidatorData;
|
|
32507
|
+
this.epochRoot = epochRoot;
|
|
32508
|
+
this.sealingKeySeries = sealingKeySeries;
|
|
32509
|
+
this.ticketsAccumulator = ticketsAccumulator;
|
|
32510
|
+
}
|
|
32511
|
+
}
|
|
32512
|
+
|
|
32513
|
+
;// CONCATENATED MODULE: ./packages/jam/state/service.ts
|
|
32514
|
+
|
|
32515
|
+
|
|
32516
|
+
|
|
32517
|
+
|
|
32518
|
+
|
|
32519
|
+
|
|
32520
|
+
/**
|
|
32521
|
+
* `B_S`: The basic minimum balance which all services require.
|
|
32522
|
+
*
|
|
32523
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
32524
|
+
*/
|
|
32525
|
+
const BASE_SERVICE_BALANCE = 100n;
|
|
32526
|
+
/**
|
|
32527
|
+
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
32528
|
+
*
|
|
32529
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445000445000?v=0.6.7
|
|
32530
|
+
*/
|
|
32531
|
+
const ELECTIVE_ITEM_BALANCE = 10n;
|
|
32532
|
+
/**
|
|
32533
|
+
* `B_L`: The additional minimum balance required per octet of elective service state.
|
|
32534
|
+
*
|
|
32535
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445400445400?v=0.6.7
|
|
32536
|
+
*/
|
|
32537
|
+
const ELECTIVE_BYTE_BALANCE = 1n;
|
|
32207
32538
|
const zeroSizeHint = {
|
|
32208
32539
|
bytes: 0,
|
|
32209
32540
|
isExact: true,
|
|
@@ -32369,358 +32700,418 @@ class LookupHistoryItem {
|
|
|
32369
32700
|
}
|
|
32370
32701
|
}
|
|
32371
32702
|
|
|
32372
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
32703
|
+
;// CONCATENATED MODULE: ./packages/jam/state/statistics.ts
|
|
32373
32704
|
|
|
32374
32705
|
|
|
32375
32706
|
|
|
32376
32707
|
|
|
32377
32708
|
|
|
32378
|
-
|
|
32379
|
-
|
|
32380
|
-
|
|
32381
|
-
|
|
32382
|
-
|
|
32383
|
-
|
|
32384
|
-
|
|
32709
|
+
|
|
32710
|
+
const codecServiceId = Compatibility.isSuite(TestSuite.W3F_DAVXY) || Compatibility.isSuite(TestSuite.JAMDUNA, GpVersion.V0_6_7)
|
|
32711
|
+
? descriptors_codec.u32.asOpaque()
|
|
32712
|
+
: descriptors_codec.varU32.convert((s) => numbers_tryAsU32(s), (i) => tryAsServiceId(i));
|
|
32713
|
+
/**
|
|
32714
|
+
* Activity Record of a single validator.
|
|
32715
|
+
*
|
|
32716
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/183701183701
|
|
32717
|
+
*/
|
|
32718
|
+
class ValidatorStatistics {
|
|
32719
|
+
blocks;
|
|
32720
|
+
tickets;
|
|
32721
|
+
preImages;
|
|
32722
|
+
preImagesSize;
|
|
32723
|
+
guarantees;
|
|
32724
|
+
assurances;
|
|
32725
|
+
static Codec = descriptors_codec.Class(ValidatorStatistics, {
|
|
32726
|
+
blocks: descriptors_codec.u32,
|
|
32727
|
+
tickets: descriptors_codec.u32,
|
|
32728
|
+
preImages: descriptors_codec.u32,
|
|
32729
|
+
preImagesSize: descriptors_codec.u32,
|
|
32730
|
+
guarantees: descriptors_codec.u32,
|
|
32731
|
+
assurances: descriptors_codec.u32,
|
|
32385
32732
|
});
|
|
32386
|
-
static create({
|
|
32387
|
-
return new
|
|
32733
|
+
static create({ blocks, tickets, preImages, preImagesSize, guarantees, assurances, }) {
|
|
32734
|
+
return new ValidatorStatistics(blocks, tickets, preImages, preImagesSize, guarantees, assurances);
|
|
32388
32735
|
}
|
|
32389
32736
|
constructor(
|
|
32390
|
-
/**
|
|
32391
|
-
|
|
32392
|
-
/**
|
|
32393
|
-
|
|
32394
|
-
|
|
32395
|
-
|
|
32396
|
-
|
|
32397
|
-
|
|
32398
|
-
/**
|
|
32399
|
-
|
|
32400
|
-
*/
|
|
32401
|
-
|
|
32402
|
-
|
|
32403
|
-
|
|
32404
|
-
|
|
32405
|
-
|
|
32406
|
-
|
|
32407
|
-
|
|
32408
|
-
static Codec = descriptors_codec.Class(PrivilegedServices, {
|
|
32409
|
-
manager: descriptors_codec.u32.asOpaque(),
|
|
32410
|
-
assigners: codecPerCore(descriptors_codec.u32.asOpaque()),
|
|
32411
|
-
delegator: descriptors_codec.u32.asOpaque(),
|
|
32412
|
-
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
32413
|
-
? descriptors_codec.u32.asOpaque()
|
|
32414
|
-
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
32415
|
-
autoAccumulateServices: readonlyArray(descriptors_codec.sequenceVarLen(AutoAccumulate.Codec)),
|
|
32416
|
-
});
|
|
32417
|
-
static create(a) {
|
|
32418
|
-
return new PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
32737
|
+
/** The number of blocks produced by the validator. */
|
|
32738
|
+
blocks,
|
|
32739
|
+
/** The number of tickets introduced by the validator. */
|
|
32740
|
+
tickets,
|
|
32741
|
+
/** The number of preimages introduced by the validator. */
|
|
32742
|
+
preImages,
|
|
32743
|
+
/** The total number of octets across all preimages introduced by the validator. */
|
|
32744
|
+
preImagesSize,
|
|
32745
|
+
/** The number of reports guaranteed by the validator. */
|
|
32746
|
+
guarantees,
|
|
32747
|
+
/** The number of availability assurances made by the validator. */
|
|
32748
|
+
assurances) {
|
|
32749
|
+
this.blocks = blocks;
|
|
32750
|
+
this.tickets = tickets;
|
|
32751
|
+
this.preImages = preImages;
|
|
32752
|
+
this.preImagesSize = preImagesSize;
|
|
32753
|
+
this.guarantees = guarantees;
|
|
32754
|
+
this.assurances = assurances;
|
|
32419
32755
|
}
|
|
32420
|
-
|
|
32421
|
-
|
|
32422
|
-
|
|
32423
|
-
* as well as bestow services with storage deposit credits.
|
|
32424
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111502111902?v=0.7.2
|
|
32425
|
-
*/
|
|
32426
|
-
manager,
|
|
32427
|
-
/** `χ_V`: Managers validator keys. */
|
|
32428
|
-
delegator,
|
|
32429
|
-
/**
|
|
32430
|
-
* `χ_R`: Manages the creation of services in protected range.
|
|
32431
|
-
*
|
|
32432
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111b02111d02?v=0.7.2
|
|
32433
|
-
*/
|
|
32434
|
-
registrar,
|
|
32435
|
-
/** `χ_A`: Manages authorization queue one for each core. */
|
|
32436
|
-
assigners,
|
|
32437
|
-
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
32438
|
-
autoAccumulateServices) {
|
|
32439
|
-
this.manager = manager;
|
|
32440
|
-
this.delegator = delegator;
|
|
32441
|
-
this.registrar = registrar;
|
|
32442
|
-
this.assigners = assigners;
|
|
32443
|
-
this.autoAccumulateServices = autoAccumulateServices;
|
|
32756
|
+
static empty() {
|
|
32757
|
+
const zero = numbers_tryAsU32(0);
|
|
32758
|
+
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
32444
32759
|
}
|
|
32445
32760
|
}
|
|
32446
|
-
|
|
32447
|
-
|
|
32448
|
-
|
|
32449
|
-
|
|
32450
|
-
|
|
32451
|
-
|
|
32452
|
-
|
|
32453
|
-
|
|
32761
|
+
const codecVarU16 = descriptors_codec.varU32.convert((i) => numbers_tryAsU32(i), (o) => numbers_tryAsU16(o));
|
|
32762
|
+
/** Encode/decode unsigned gas. */
|
|
32763
|
+
const codecVarGas = descriptors_codec.varU64.convert((g) => numbers_tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
32454
32764
|
/**
|
|
32455
|
-
*
|
|
32765
|
+
* Single core statistics.
|
|
32766
|
+
* Updated per block, based on incoming work reports (`w`).
|
|
32456
32767
|
*
|
|
32457
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
32768
|
+
* https://graypaper.fluffylabs.dev/#/68eaa1f/18f10318f103?v=0.6.4
|
|
32769
|
+
* https://github.com/gavofyork/graypaper/blob/9bffb08f3ea7b67832019176754df4fb36b9557d/text/statistics.tex#L65
|
|
32458
32770
|
*/
|
|
32459
|
-
|
|
32460
|
-
|
|
32461
|
-
|
|
32462
|
-
|
|
32463
|
-
|
|
32464
|
-
|
|
32465
|
-
|
|
32466
|
-
|
|
32467
|
-
|
|
32468
|
-
|
|
32469
|
-
|
|
32470
|
-
|
|
32471
|
-
|
|
32472
|
-
|
|
32473
|
-
|
|
32771
|
+
class CoreStatistics {
|
|
32772
|
+
dataAvailabilityLoad;
|
|
32773
|
+
popularity;
|
|
32774
|
+
imports;
|
|
32775
|
+
exports;
|
|
32776
|
+
extrinsicSize;
|
|
32777
|
+
extrinsicCount;
|
|
32778
|
+
bundleSize;
|
|
32779
|
+
gasUsed;
|
|
32780
|
+
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
32781
|
+
? descriptors_codec.Class(CoreStatistics, {
|
|
32782
|
+
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
32783
|
+
popularity: codecVarU16,
|
|
32784
|
+
imports: codecVarU16,
|
|
32785
|
+
extrinsicCount: codecVarU16,
|
|
32786
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32787
|
+
exports: codecVarU16,
|
|
32788
|
+
bundleSize: descriptors_codec.varU32,
|
|
32789
|
+
gasUsed: codecVarGas,
|
|
32790
|
+
})
|
|
32791
|
+
: descriptors_codec.Class(CoreStatistics, {
|
|
32792
|
+
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
32793
|
+
popularity: codecVarU16,
|
|
32794
|
+
imports: codecVarU16,
|
|
32795
|
+
exports: codecVarU16,
|
|
32796
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32797
|
+
extrinsicCount: codecVarU16,
|
|
32798
|
+
bundleSize: descriptors_codec.varU32,
|
|
32799
|
+
gasUsed: codecVarGas,
|
|
32800
|
+
});
|
|
32801
|
+
static create(v) {
|
|
32802
|
+
return new CoreStatistics(v.dataAvailabilityLoad, v.popularity, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.bundleSize, v.gasUsed);
|
|
32474
32803
|
}
|
|
32475
32804
|
constructor(
|
|
32476
|
-
/**
|
|
32477
|
-
|
|
32478
|
-
/**
|
|
32479
|
-
|
|
32480
|
-
/**
|
|
32481
|
-
|
|
32482
|
-
/**
|
|
32483
|
-
|
|
32484
|
-
|
|
32485
|
-
|
|
32486
|
-
|
|
32487
|
-
|
|
32488
|
-
|
|
32489
|
-
|
|
32490
|
-
|
|
32491
|
-
|
|
32492
|
-
|
|
32493
|
-
|
|
32494
|
-
|
|
32495
|
-
|
|
32496
|
-
|
|
32497
|
-
|
|
32498
|
-
|
|
32499
|
-
|
|
32500
|
-
accumulationLog: descriptors_codec.object({
|
|
32501
|
-
peaks: readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.optional(descriptors_codec.bytes(hash_HASH_SIZE)))),
|
|
32502
|
-
}),
|
|
32503
|
-
});
|
|
32504
|
-
static create(a) {
|
|
32505
|
-
return new RecentBlocks(a.blocks, a.accumulationLog);
|
|
32805
|
+
/** `d` */
|
|
32806
|
+
dataAvailabilityLoad,
|
|
32807
|
+
/** `p` */
|
|
32808
|
+
popularity,
|
|
32809
|
+
/** `i` */
|
|
32810
|
+
imports,
|
|
32811
|
+
/** `e` */
|
|
32812
|
+
exports,
|
|
32813
|
+
/** `z` */
|
|
32814
|
+
extrinsicSize,
|
|
32815
|
+
/** `x` */
|
|
32816
|
+
extrinsicCount,
|
|
32817
|
+
/** `b` */
|
|
32818
|
+
bundleSize,
|
|
32819
|
+
/** `u` */
|
|
32820
|
+
gasUsed) {
|
|
32821
|
+
this.dataAvailabilityLoad = dataAvailabilityLoad;
|
|
32822
|
+
this.popularity = popularity;
|
|
32823
|
+
this.imports = imports;
|
|
32824
|
+
this.exports = exports;
|
|
32825
|
+
this.extrinsicSize = extrinsicSize;
|
|
32826
|
+
this.extrinsicCount = extrinsicCount;
|
|
32827
|
+
this.bundleSize = bundleSize;
|
|
32828
|
+
this.gasUsed = gasUsed;
|
|
32506
32829
|
}
|
|
32507
|
-
|
|
32508
|
-
|
|
32509
|
-
|
|
32510
|
-
|
|
32511
|
-
|
|
32512
|
-
blocks,
|
|
32513
|
-
/**
|
|
32514
|
-
* Accumulation output log.
|
|
32515
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0f02020f0202?v=0.6.7
|
|
32516
|
-
*/
|
|
32517
|
-
accumulationLog) {
|
|
32518
|
-
super();
|
|
32519
|
-
this.blocks = blocks;
|
|
32520
|
-
this.accumulationLog = accumulationLog;
|
|
32830
|
+
static empty() {
|
|
32831
|
+
const zero = numbers_tryAsU32(0);
|
|
32832
|
+
const zero16 = numbers_tryAsU16(0);
|
|
32833
|
+
const zeroGas = tryAsServiceGas(0);
|
|
32834
|
+
return new CoreStatistics(zero, zero16, zero16, zero16, zero, zero16, zero, zeroGas);
|
|
32521
32835
|
}
|
|
32522
32836
|
}
|
|
32523
32837
|
/**
|
|
32524
|
-
*
|
|
32838
|
+
* Service statistics.
|
|
32839
|
+
* Updated per block, based on available work reports (`W`).
|
|
32525
32840
|
*
|
|
32526
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
32841
|
+
* https://graypaper.fluffylabs.dev/#/1c979cb/199802199802?v=0.7.1
|
|
32527
32842
|
*/
|
|
32528
|
-
class
|
|
32529
|
-
|
|
32530
|
-
|
|
32531
|
-
|
|
32532
|
-
|
|
32533
|
-
|
|
32534
|
-
|
|
32843
|
+
class ServiceStatistics {
|
|
32844
|
+
providedCount;
|
|
32845
|
+
providedSize;
|
|
32846
|
+
refinementCount;
|
|
32847
|
+
refinementGasUsed;
|
|
32848
|
+
imports;
|
|
32849
|
+
exports;
|
|
32850
|
+
extrinsicSize;
|
|
32851
|
+
extrinsicCount;
|
|
32852
|
+
accumulateCount;
|
|
32853
|
+
accumulateGasUsed;
|
|
32854
|
+
onTransfersCount;
|
|
32855
|
+
onTransfersGasUsed;
|
|
32856
|
+
static Codec = Compatibility.selectIfGreaterOrEqual({
|
|
32857
|
+
fallback: descriptors_codec.Class(ServiceStatistics, {
|
|
32858
|
+
providedCount: codecVarU16,
|
|
32859
|
+
providedSize: descriptors_codec.varU32,
|
|
32860
|
+
refinementCount: descriptors_codec.varU32,
|
|
32861
|
+
refinementGasUsed: codecVarGas,
|
|
32862
|
+
imports: codecVarU16,
|
|
32863
|
+
exports: codecVarU16,
|
|
32864
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32865
|
+
extrinsicCount: codecVarU16,
|
|
32866
|
+
accumulateCount: descriptors_codec.varU32,
|
|
32867
|
+
accumulateGasUsed: codecVarGas,
|
|
32868
|
+
onTransfersCount: descriptors_codec.varU32,
|
|
32869
|
+
onTransfersGasUsed: codecVarGas,
|
|
32870
|
+
}),
|
|
32871
|
+
versions: {
|
|
32872
|
+
[GpVersion.V0_7_0]: descriptors_codec.Class(ServiceStatistics, {
|
|
32873
|
+
providedCount: codecVarU16,
|
|
32874
|
+
providedSize: descriptors_codec.varU32,
|
|
32875
|
+
refinementCount: descriptors_codec.varU32,
|
|
32876
|
+
refinementGasUsed: codecVarGas,
|
|
32877
|
+
imports: codecVarU16,
|
|
32878
|
+
extrinsicCount: codecVarU16,
|
|
32879
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32880
|
+
exports: codecVarU16,
|
|
32881
|
+
accumulateCount: descriptors_codec.varU32,
|
|
32882
|
+
accumulateGasUsed: codecVarGas,
|
|
32883
|
+
onTransfersCount: descriptors_codec.varU32,
|
|
32884
|
+
onTransfersGasUsed: codecVarGas,
|
|
32885
|
+
}),
|
|
32886
|
+
[GpVersion.V0_7_1]: descriptors_codec.Class(ServiceStatistics, {
|
|
32887
|
+
providedCount: codecVarU16,
|
|
32888
|
+
providedSize: descriptors_codec.varU32,
|
|
32889
|
+
refinementCount: descriptors_codec.varU32,
|
|
32890
|
+
refinementGasUsed: codecVarGas,
|
|
32891
|
+
imports: codecVarU16,
|
|
32892
|
+
extrinsicCount: codecVarU16,
|
|
32893
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
32894
|
+
exports: codecVarU16,
|
|
32895
|
+
accumulateCount: descriptors_codec.varU32,
|
|
32896
|
+
accumulateGasUsed: codecVarGas,
|
|
32897
|
+
onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
|
|
32898
|
+
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
32899
|
+
}),
|
|
32900
|
+
},
|
|
32535
32901
|
});
|
|
32536
|
-
static create(
|
|
32537
|
-
return new
|
|
32902
|
+
static create(v) {
|
|
32903
|
+
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);
|
|
32904
|
+
}
|
|
32905
|
+
constructor(
|
|
32906
|
+
/** `p.0` */
|
|
32907
|
+
providedCount,
|
|
32908
|
+
/** `p.1` */
|
|
32909
|
+
providedSize,
|
|
32910
|
+
/** `r.0` */
|
|
32911
|
+
refinementCount,
|
|
32912
|
+
/** `r.1` */
|
|
32913
|
+
refinementGasUsed,
|
|
32914
|
+
/** `i` */
|
|
32915
|
+
imports,
|
|
32916
|
+
/** `e` */
|
|
32917
|
+
exports,
|
|
32918
|
+
/** `z` */
|
|
32919
|
+
extrinsicSize,
|
|
32920
|
+
/** `x` */
|
|
32921
|
+
extrinsicCount,
|
|
32922
|
+
/** `a.0` */
|
|
32923
|
+
accumulateCount,
|
|
32924
|
+
/** `a.1` */
|
|
32925
|
+
accumulateGasUsed,
|
|
32926
|
+
/** `t.0` @deprecated since 0.7.1 */
|
|
32927
|
+
onTransfersCount,
|
|
32928
|
+
/** `t.1` @deprecated since 0.7.1 */
|
|
32929
|
+
onTransfersGasUsed) {
|
|
32930
|
+
this.providedCount = providedCount;
|
|
32931
|
+
this.providedSize = providedSize;
|
|
32932
|
+
this.refinementCount = refinementCount;
|
|
32933
|
+
this.refinementGasUsed = refinementGasUsed;
|
|
32934
|
+
this.imports = imports;
|
|
32935
|
+
this.exports = exports;
|
|
32936
|
+
this.extrinsicSize = extrinsicSize;
|
|
32937
|
+
this.extrinsicCount = extrinsicCount;
|
|
32938
|
+
this.accumulateCount = accumulateCount;
|
|
32939
|
+
this.accumulateGasUsed = accumulateGasUsed;
|
|
32940
|
+
this.onTransfersCount = onTransfersCount;
|
|
32941
|
+
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
32538
32942
|
}
|
|
32539
32943
|
static empty() {
|
|
32540
|
-
|
|
32541
|
-
|
|
32542
|
-
|
|
32543
|
-
|
|
32944
|
+
const zero = numbers_tryAsU32(0);
|
|
32945
|
+
const zero16 = numbers_tryAsU16(0);
|
|
32946
|
+
const zeroGas = tryAsServiceGas(0);
|
|
32947
|
+
return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas, zero, zeroGas);
|
|
32544
32948
|
}
|
|
32545
|
-
|
|
32546
|
-
|
|
32547
|
-
|
|
32548
|
-
|
|
32549
|
-
|
|
32949
|
+
}
|
|
32950
|
+
/** `pi`: Statistics of each validator, cores statistics and services statistics. */
|
|
32951
|
+
class StatisticsData {
|
|
32952
|
+
current;
|
|
32953
|
+
previous;
|
|
32954
|
+
cores;
|
|
32955
|
+
services;
|
|
32956
|
+
static Codec = descriptors_codec.Class(StatisticsData, {
|
|
32957
|
+
current: common_codecPerValidator(ValidatorStatistics.Codec),
|
|
32958
|
+
previous: common_codecPerValidator(ValidatorStatistics.Codec),
|
|
32959
|
+
cores: codecPerCore(CoreStatistics.Codec),
|
|
32960
|
+
services: descriptors_codec.dictionary(codecServiceId, ServiceStatistics.Codec, {
|
|
32961
|
+
sortKeys: (a, b) => a - b,
|
|
32962
|
+
}),
|
|
32963
|
+
});
|
|
32964
|
+
static create(v) {
|
|
32965
|
+
return new StatisticsData(v.current, v.previous, v.cores, v.services);
|
|
32550
32966
|
}
|
|
32551
|
-
constructor(current) {
|
|
32552
|
-
super();
|
|
32967
|
+
constructor(current, previous, cores, services) {
|
|
32553
32968
|
this.current = current;
|
|
32554
|
-
|
|
32555
|
-
|
|
32556
|
-
|
|
32557
|
-
if (this.current !== null) {
|
|
32558
|
-
return this.current.blocks;
|
|
32559
|
-
}
|
|
32560
|
-
throw new Error("RecentBlocksHistory is in invalid state");
|
|
32561
|
-
}
|
|
32562
|
-
asCurrent() {
|
|
32563
|
-
if (this.current === null) {
|
|
32564
|
-
throw new Error("Cannot access current RecentBlocks format");
|
|
32565
|
-
}
|
|
32566
|
-
return this.current;
|
|
32567
|
-
}
|
|
32568
|
-
updateBlocks(blocks) {
|
|
32569
|
-
if (this.current !== null) {
|
|
32570
|
-
return RecentBlocksHistory.create(RecentBlocks.create({
|
|
32571
|
-
...this.current,
|
|
32572
|
-
blocks: opaque_asOpaqueType(blocks),
|
|
32573
|
-
}));
|
|
32574
|
-
}
|
|
32575
|
-
throw new Error("RecentBlocksHistory is in invalid state. Cannot be updated!");
|
|
32969
|
+
this.previous = previous;
|
|
32970
|
+
this.cores = cores;
|
|
32971
|
+
this.services = services;
|
|
32576
32972
|
}
|
|
32577
32973
|
}
|
|
32578
32974
|
|
|
32579
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
32975
|
+
;// CONCATENATED MODULE: ./packages/jam/state/in-memory-state-view.ts
|
|
32976
|
+
|
|
32580
32977
|
|
|
32581
32978
|
|
|
32582
32979
|
|
|
32583
|
-
/**
|
|
32584
|
-
* Fixed size of validator metadata.
|
|
32585
|
-
*
|
|
32586
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/0d55010d5501
|
|
32587
|
-
*/
|
|
32588
|
-
const VALIDATOR_META_BYTES = 128;
|
|
32589
|
-
/**
|
|
32590
|
-
* Details about validators' identity.
|
|
32591
|
-
*
|
|
32592
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/0d4b010d4c01
|
|
32593
|
-
*/
|
|
32594
|
-
class ValidatorData extends WithDebug {
|
|
32595
|
-
bandersnatch;
|
|
32596
|
-
ed25519;
|
|
32597
|
-
bls;
|
|
32598
|
-
metadata;
|
|
32599
|
-
static Codec = descriptors_codec.Class(ValidatorData, {
|
|
32600
|
-
bandersnatch: descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
32601
|
-
ed25519: descriptors_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
32602
|
-
bls: descriptors_codec.bytes(BLS_KEY_BYTES).asOpaque(),
|
|
32603
|
-
metadata: descriptors_codec.bytes(VALIDATOR_META_BYTES),
|
|
32604
|
-
});
|
|
32605
|
-
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
32606
|
-
return new ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
32607
|
-
}
|
|
32608
|
-
constructor(
|
|
32609
|
-
/** Bandersnatch public key. */
|
|
32610
|
-
bandersnatch,
|
|
32611
|
-
/** ED25519 key data. */
|
|
32612
|
-
ed25519,
|
|
32613
|
-
/** BLS public key. */
|
|
32614
|
-
bls,
|
|
32615
|
-
/** Validator-defined additional metdata. */
|
|
32616
|
-
metadata) {
|
|
32617
|
-
super();
|
|
32618
|
-
this.bandersnatch = bandersnatch;
|
|
32619
|
-
this.ed25519 = ed25519;
|
|
32620
|
-
this.bls = bls;
|
|
32621
|
-
this.metadata = metadata;
|
|
32622
|
-
}
|
|
32623
|
-
}
|
|
32624
32980
|
|
|
32625
|
-
;// CONCATENATED MODULE: ./packages/jam/state/safrole-data.ts
|
|
32626
32981
|
|
|
32627
32982
|
|
|
32628
32983
|
|
|
32629
32984
|
|
|
32630
32985
|
|
|
32986
|
+
class InMemoryStateView {
|
|
32987
|
+
chainSpec;
|
|
32988
|
+
state;
|
|
32989
|
+
constructor(chainSpec, state) {
|
|
32990
|
+
this.chainSpec = chainSpec;
|
|
32991
|
+
this.state = state;
|
|
32992
|
+
}
|
|
32993
|
+
availabilityAssignmentView() {
|
|
32994
|
+
return reencodeAsView(availabilityAssignmentsCodec, this.state.availabilityAssignment, this.chainSpec);
|
|
32995
|
+
}
|
|
32996
|
+
designatedValidatorDataView() {
|
|
32997
|
+
return reencodeAsView(validatorsDataCodec, this.state.designatedValidatorData, this.chainSpec);
|
|
32998
|
+
}
|
|
32999
|
+
currentValidatorDataView() {
|
|
33000
|
+
return reencodeAsView(validatorsDataCodec, this.state.currentValidatorData, this.chainSpec);
|
|
33001
|
+
}
|
|
33002
|
+
previousValidatorDataView() {
|
|
33003
|
+
return reencodeAsView(validatorsDataCodec, this.state.previousValidatorData, this.chainSpec);
|
|
33004
|
+
}
|
|
33005
|
+
authPoolsView() {
|
|
33006
|
+
return reencodeAsView(authPoolsCodec, this.state.authPools, this.chainSpec);
|
|
33007
|
+
}
|
|
33008
|
+
authQueuesView() {
|
|
33009
|
+
return reencodeAsView(authQueuesCodec, this.state.authQueues, this.chainSpec);
|
|
33010
|
+
}
|
|
33011
|
+
recentBlocksView() {
|
|
33012
|
+
return reencodeAsView(RecentBlocks.Codec, this.state.recentBlocks, this.chainSpec);
|
|
33013
|
+
}
|
|
33014
|
+
statisticsView() {
|
|
33015
|
+
return reencodeAsView(StatisticsData.Codec, this.state.statistics, this.chainSpec);
|
|
33016
|
+
}
|
|
33017
|
+
accumulationQueueView() {
|
|
33018
|
+
return reencodeAsView(accumulationQueueCodec, this.state.accumulationQueue, this.chainSpec);
|
|
33019
|
+
}
|
|
33020
|
+
recentlyAccumulatedView() {
|
|
33021
|
+
return reencodeAsView(recentlyAccumulatedCodec, this.state.recentlyAccumulated, this.chainSpec);
|
|
33022
|
+
}
|
|
33023
|
+
safroleDataView() {
|
|
33024
|
+
// TODO [ToDr] Consider exposting `safrole` from state
|
|
33025
|
+
// instead of individual fields
|
|
33026
|
+
const safrole = SafroleData.create({
|
|
33027
|
+
nextValidatorData: this.state.nextValidatorData,
|
|
33028
|
+
epochRoot: this.state.epochRoot,
|
|
33029
|
+
sealingKeySeries: this.state.sealingKeySeries,
|
|
33030
|
+
ticketsAccumulator: this.state.ticketsAccumulator,
|
|
33031
|
+
});
|
|
33032
|
+
return reencodeAsView(SafroleData.Codec, safrole, this.chainSpec);
|
|
33033
|
+
}
|
|
33034
|
+
getServiceInfoView(id) {
|
|
33035
|
+
const service = this.state.getService(id);
|
|
33036
|
+
if (service === null) {
|
|
33037
|
+
return null;
|
|
33038
|
+
}
|
|
33039
|
+
return reencodeAsView(ServiceAccountInfo.Codec, service.getInfo(), this.chainSpec);
|
|
33040
|
+
}
|
|
33041
|
+
}
|
|
32631
33042
|
|
|
33043
|
+
;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
|
|
32632
33044
|
|
|
32633
33045
|
|
|
32634
33046
|
|
|
32635
33047
|
|
|
32636
33048
|
|
|
32637
|
-
|
|
32638
|
-
|
|
32639
|
-
|
|
32640
|
-
|
|
32641
|
-
|
|
32642
|
-
|
|
32643
|
-
|
|
32644
|
-
kind;
|
|
32645
|
-
keys;
|
|
32646
|
-
tickets;
|
|
32647
|
-
static Codec = codecWithContext((context) => {
|
|
32648
|
-
return descriptors_codec.custom({
|
|
32649
|
-
name: "SafroleSealingKeys",
|
|
32650
|
-
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
32651
|
-
}, (e, x) => {
|
|
32652
|
-
e.varU32(numbers_tryAsU32(x.kind));
|
|
32653
|
-
if (x.kind === SafroleSealingKeysKind.Keys) {
|
|
32654
|
-
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
32655
|
-
}
|
|
32656
|
-
else {
|
|
32657
|
-
e.sequenceFixLen(Ticket.Codec, x.tickets);
|
|
32658
|
-
}
|
|
32659
|
-
}, (d) => {
|
|
32660
|
-
const epochLength = context.epochLength;
|
|
32661
|
-
const kind = d.varU32();
|
|
32662
|
-
if (kind === SafroleSealingKeysKind.Keys) {
|
|
32663
|
-
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
32664
|
-
return SafroleSealingKeysData.keys(tryAsPerEpochBlock(keys, context));
|
|
32665
|
-
}
|
|
32666
|
-
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
32667
|
-
const tickets = d.sequenceFixLen(Ticket.Codec, epochLength);
|
|
32668
|
-
return SafroleSealingKeysData.tickets(tryAsPerEpochBlock(tickets, context));
|
|
32669
|
-
}
|
|
32670
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
32671
|
-
}, (s) => {
|
|
32672
|
-
const kind = s.decoder.varU32();
|
|
32673
|
-
if (kind === SafroleSealingKeysKind.Keys) {
|
|
32674
|
-
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
32675
|
-
return;
|
|
32676
|
-
}
|
|
32677
|
-
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
32678
|
-
s.sequenceFixLen(Ticket.Codec, context.epochLength);
|
|
32679
|
-
return;
|
|
32680
|
-
}
|
|
32681
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
32682
|
-
});
|
|
33049
|
+
/** Dictionary entry of services that auto-accumulate every block. */
|
|
33050
|
+
class AutoAccumulate {
|
|
33051
|
+
service;
|
|
33052
|
+
gasLimit;
|
|
33053
|
+
static Codec = descriptors_codec.Class(AutoAccumulate, {
|
|
33054
|
+
service: descriptors_codec.u32.asOpaque(),
|
|
33055
|
+
gasLimit: descriptors_codec.u64.asOpaque(),
|
|
32683
33056
|
});
|
|
32684
|
-
static
|
|
32685
|
-
return new
|
|
32686
|
-
}
|
|
32687
|
-
static tickets(tickets) {
|
|
32688
|
-
return new SafroleSealingKeysData(SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
33057
|
+
static create({ service, gasLimit }) {
|
|
33058
|
+
return new AutoAccumulate(service, gasLimit);
|
|
32689
33059
|
}
|
|
32690
|
-
constructor(
|
|
32691
|
-
|
|
32692
|
-
|
|
32693
|
-
|
|
32694
|
-
|
|
33060
|
+
constructor(
|
|
33061
|
+
/** Service id that auto-accumulates. */
|
|
33062
|
+
service,
|
|
33063
|
+
/** Gas limit for auto-accumulation. */
|
|
33064
|
+
gasLimit) {
|
|
33065
|
+
this.service = service;
|
|
33066
|
+
this.gasLimit = gasLimit;
|
|
32695
33067
|
}
|
|
32696
33068
|
}
|
|
32697
|
-
|
|
32698
|
-
|
|
32699
|
-
|
|
32700
|
-
|
|
32701
|
-
|
|
32702
|
-
|
|
32703
|
-
|
|
32704
|
-
|
|
32705
|
-
|
|
32706
|
-
|
|
33069
|
+
/**
|
|
33070
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
33071
|
+
*/
|
|
33072
|
+
class PrivilegedServices {
|
|
33073
|
+
manager;
|
|
33074
|
+
delegator;
|
|
33075
|
+
registrar;
|
|
33076
|
+
assigners;
|
|
33077
|
+
autoAccumulateServices;
|
|
33078
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
33079
|
+
static Codec = descriptors_codec.Class(PrivilegedServices, {
|
|
33080
|
+
manager: descriptors_codec.u32.asOpaque(),
|
|
33081
|
+
assigners: codecPerCore(descriptors_codec.u32.asOpaque()),
|
|
33082
|
+
delegator: descriptors_codec.u32.asOpaque(),
|
|
33083
|
+
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
33084
|
+
? descriptors_codec.u32.asOpaque()
|
|
33085
|
+
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
33086
|
+
autoAccumulateServices: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(AutoAccumulate.Codec)),
|
|
32707
33087
|
});
|
|
32708
|
-
static create(
|
|
32709
|
-
return new
|
|
33088
|
+
static create(a) {
|
|
33089
|
+
return new PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
32710
33090
|
}
|
|
32711
33091
|
constructor(
|
|
32712
|
-
/**
|
|
32713
|
-
|
|
32714
|
-
|
|
32715
|
-
|
|
32716
|
-
|
|
32717
|
-
|
|
32718
|
-
/**
|
|
32719
|
-
|
|
32720
|
-
|
|
32721
|
-
|
|
32722
|
-
|
|
32723
|
-
|
|
33092
|
+
/**
|
|
33093
|
+
* `χ_M`: Manages alteration of χ from block to block,
|
|
33094
|
+
* as well as bestow services with storage deposit credits.
|
|
33095
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111502111902?v=0.7.2
|
|
33096
|
+
*/
|
|
33097
|
+
manager,
|
|
33098
|
+
/** `χ_V`: Managers validator keys. */
|
|
33099
|
+
delegator,
|
|
33100
|
+
/**
|
|
33101
|
+
* `χ_R`: Manages the creation of services in protected range.
|
|
33102
|
+
*
|
|
33103
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111b02111d02?v=0.7.2
|
|
33104
|
+
*/
|
|
33105
|
+
registrar,
|
|
33106
|
+
/** `χ_A`: Manages authorization queue one for each core. */
|
|
33107
|
+
assigners,
|
|
33108
|
+
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
33109
|
+
autoAccumulateServices) {
|
|
33110
|
+
this.manager = manager;
|
|
33111
|
+
this.delegator = delegator;
|
|
33112
|
+
this.registrar = registrar;
|
|
33113
|
+
this.assigners = assigners;
|
|
33114
|
+
this.autoAccumulateServices = autoAccumulateServices;
|
|
32724
33115
|
}
|
|
32725
33116
|
}
|
|
32726
33117
|
|
|
@@ -32846,314 +33237,42 @@ class UpdateService {
|
|
|
32846
33237
|
}
|
|
32847
33238
|
}
|
|
32848
33239
|
/** Update service storage kind. */
|
|
32849
|
-
var UpdateStorageKind;
|
|
32850
|
-
(function (UpdateStorageKind) {
|
|
32851
|
-
/** Set a storage value. */
|
|
32852
|
-
UpdateStorageKind[UpdateStorageKind["Set"] = 0] = "Set";
|
|
32853
|
-
/** Remove a storage value. */
|
|
32854
|
-
UpdateStorageKind[UpdateStorageKind["Remove"] = 1] = "Remove";
|
|
32855
|
-
})(UpdateStorageKind || (UpdateStorageKind = {}));
|
|
32856
|
-
/**
|
|
32857
|
-
* Update service storage item.
|
|
32858
|
-
*
|
|
32859
|
-
* Can either create/modify an entry or remove it.
|
|
32860
|
-
*/
|
|
32861
|
-
class UpdateStorage {
|
|
32862
|
-
serviceId;
|
|
32863
|
-
action;
|
|
32864
|
-
constructor(serviceId, action) {
|
|
32865
|
-
this.serviceId = serviceId;
|
|
32866
|
-
this.action = action;
|
|
32867
|
-
}
|
|
32868
|
-
static set({ serviceId, storage }) {
|
|
32869
|
-
return new UpdateStorage(serviceId, { kind: UpdateStorageKind.Set, storage });
|
|
32870
|
-
}
|
|
32871
|
-
static remove({ serviceId, key }) {
|
|
32872
|
-
return new UpdateStorage(serviceId, { kind: UpdateStorageKind.Remove, key });
|
|
32873
|
-
}
|
|
32874
|
-
get key() {
|
|
32875
|
-
if (this.action.kind === UpdateStorageKind.Remove) {
|
|
32876
|
-
return this.action.key;
|
|
32877
|
-
}
|
|
32878
|
-
return this.action.storage.key;
|
|
32879
|
-
}
|
|
32880
|
-
get value() {
|
|
32881
|
-
if (this.action.kind === UpdateStorageKind.Remove) {
|
|
32882
|
-
return null;
|
|
32883
|
-
}
|
|
32884
|
-
return this.action.storage.value;
|
|
32885
|
-
}
|
|
32886
|
-
}
|
|
32887
|
-
|
|
32888
|
-
;// CONCATENATED MODULE: ./packages/jam/state/statistics.ts
|
|
32889
|
-
|
|
32890
|
-
|
|
32891
|
-
|
|
32892
|
-
|
|
32893
|
-
|
|
32894
|
-
|
|
32895
|
-
const codecServiceId = Compatibility.isSuite(TestSuite.W3F_DAVXY) || Compatibility.isSuite(TestSuite.JAMDUNA, GpVersion.V0_6_7)
|
|
32896
|
-
? descriptors_codec.u32.asOpaque()
|
|
32897
|
-
: descriptors_codec.varU32.convert((s) => numbers_tryAsU32(s), (i) => tryAsServiceId(i));
|
|
32898
|
-
/**
|
|
32899
|
-
* Activity Record of a single validator.
|
|
32900
|
-
*
|
|
32901
|
-
* https://graypaper.fluffylabs.dev/#/579bd12/183701183701
|
|
32902
|
-
*/
|
|
32903
|
-
class ValidatorStatistics {
|
|
32904
|
-
blocks;
|
|
32905
|
-
tickets;
|
|
32906
|
-
preImages;
|
|
32907
|
-
preImagesSize;
|
|
32908
|
-
guarantees;
|
|
32909
|
-
assurances;
|
|
32910
|
-
static Codec = descriptors_codec.Class(ValidatorStatistics, {
|
|
32911
|
-
blocks: descriptors_codec.u32,
|
|
32912
|
-
tickets: descriptors_codec.u32,
|
|
32913
|
-
preImages: descriptors_codec.u32,
|
|
32914
|
-
preImagesSize: descriptors_codec.u32,
|
|
32915
|
-
guarantees: descriptors_codec.u32,
|
|
32916
|
-
assurances: descriptors_codec.u32,
|
|
32917
|
-
});
|
|
32918
|
-
static create({ blocks, tickets, preImages, preImagesSize, guarantees, assurances, }) {
|
|
32919
|
-
return new ValidatorStatistics(blocks, tickets, preImages, preImagesSize, guarantees, assurances);
|
|
32920
|
-
}
|
|
32921
|
-
constructor(
|
|
32922
|
-
/** The number of blocks produced by the validator. */
|
|
32923
|
-
blocks,
|
|
32924
|
-
/** The number of tickets introduced by the validator. */
|
|
32925
|
-
tickets,
|
|
32926
|
-
/** The number of preimages introduced by the validator. */
|
|
32927
|
-
preImages,
|
|
32928
|
-
/** The total number of octets across all preimages introduced by the validator. */
|
|
32929
|
-
preImagesSize,
|
|
32930
|
-
/** The number of reports guaranteed by the validator. */
|
|
32931
|
-
guarantees,
|
|
32932
|
-
/** The number of availability assurances made by the validator. */
|
|
32933
|
-
assurances) {
|
|
32934
|
-
this.blocks = blocks;
|
|
32935
|
-
this.tickets = tickets;
|
|
32936
|
-
this.preImages = preImages;
|
|
32937
|
-
this.preImagesSize = preImagesSize;
|
|
32938
|
-
this.guarantees = guarantees;
|
|
32939
|
-
this.assurances = assurances;
|
|
32940
|
-
}
|
|
32941
|
-
static empty() {
|
|
32942
|
-
const zero = numbers_tryAsU32(0);
|
|
32943
|
-
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
32944
|
-
}
|
|
32945
|
-
}
|
|
32946
|
-
const codecVarU16 = descriptors_codec.varU32.convert((i) => numbers_tryAsU32(i), (o) => numbers_tryAsU16(o));
|
|
32947
|
-
/** Encode/decode unsigned gas. */
|
|
32948
|
-
const codecVarGas = descriptors_codec.varU64.convert((g) => numbers_tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
32949
|
-
/**
|
|
32950
|
-
* Single core statistics.
|
|
32951
|
-
* Updated per block, based on incoming work reports (`w`).
|
|
32952
|
-
*
|
|
32953
|
-
* https://graypaper.fluffylabs.dev/#/68eaa1f/18f10318f103?v=0.6.4
|
|
32954
|
-
* https://github.com/gavofyork/graypaper/blob/9bffb08f3ea7b67832019176754df4fb36b9557d/text/statistics.tex#L65
|
|
32955
|
-
*/
|
|
32956
|
-
class CoreStatistics {
|
|
32957
|
-
dataAvailabilityLoad;
|
|
32958
|
-
popularity;
|
|
32959
|
-
imports;
|
|
32960
|
-
exports;
|
|
32961
|
-
extrinsicSize;
|
|
32962
|
-
extrinsicCount;
|
|
32963
|
-
bundleSize;
|
|
32964
|
-
gasUsed;
|
|
32965
|
-
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
32966
|
-
? descriptors_codec.Class(CoreStatistics, {
|
|
32967
|
-
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
32968
|
-
popularity: codecVarU16,
|
|
32969
|
-
imports: codecVarU16,
|
|
32970
|
-
extrinsicCount: codecVarU16,
|
|
32971
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
32972
|
-
exports: codecVarU16,
|
|
32973
|
-
bundleSize: descriptors_codec.varU32,
|
|
32974
|
-
gasUsed: codecVarGas,
|
|
32975
|
-
})
|
|
32976
|
-
: descriptors_codec.Class(CoreStatistics, {
|
|
32977
|
-
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
32978
|
-
popularity: codecVarU16,
|
|
32979
|
-
imports: codecVarU16,
|
|
32980
|
-
exports: codecVarU16,
|
|
32981
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
32982
|
-
extrinsicCount: codecVarU16,
|
|
32983
|
-
bundleSize: descriptors_codec.varU32,
|
|
32984
|
-
gasUsed: codecVarGas,
|
|
32985
|
-
});
|
|
32986
|
-
static create(v) {
|
|
32987
|
-
return new CoreStatistics(v.dataAvailabilityLoad, v.popularity, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.bundleSize, v.gasUsed);
|
|
32988
|
-
}
|
|
32989
|
-
constructor(
|
|
32990
|
-
/** `d` */
|
|
32991
|
-
dataAvailabilityLoad,
|
|
32992
|
-
/** `p` */
|
|
32993
|
-
popularity,
|
|
32994
|
-
/** `i` */
|
|
32995
|
-
imports,
|
|
32996
|
-
/** `e` */
|
|
32997
|
-
exports,
|
|
32998
|
-
/** `z` */
|
|
32999
|
-
extrinsicSize,
|
|
33000
|
-
/** `x` */
|
|
33001
|
-
extrinsicCount,
|
|
33002
|
-
/** `b` */
|
|
33003
|
-
bundleSize,
|
|
33004
|
-
/** `u` */
|
|
33005
|
-
gasUsed) {
|
|
33006
|
-
this.dataAvailabilityLoad = dataAvailabilityLoad;
|
|
33007
|
-
this.popularity = popularity;
|
|
33008
|
-
this.imports = imports;
|
|
33009
|
-
this.exports = exports;
|
|
33010
|
-
this.extrinsicSize = extrinsicSize;
|
|
33011
|
-
this.extrinsicCount = extrinsicCount;
|
|
33012
|
-
this.bundleSize = bundleSize;
|
|
33013
|
-
this.gasUsed = gasUsed;
|
|
33014
|
-
}
|
|
33015
|
-
static empty() {
|
|
33016
|
-
const zero = numbers_tryAsU32(0);
|
|
33017
|
-
const zero16 = numbers_tryAsU16(0);
|
|
33018
|
-
const zeroGas = tryAsServiceGas(0);
|
|
33019
|
-
return new CoreStatistics(zero, zero16, zero16, zero16, zero, zero16, zero, zeroGas);
|
|
33020
|
-
}
|
|
33021
|
-
}
|
|
33240
|
+
var UpdateStorageKind;
|
|
33241
|
+
(function (UpdateStorageKind) {
|
|
33242
|
+
/** Set a storage value. */
|
|
33243
|
+
UpdateStorageKind[UpdateStorageKind["Set"] = 0] = "Set";
|
|
33244
|
+
/** Remove a storage value. */
|
|
33245
|
+
UpdateStorageKind[UpdateStorageKind["Remove"] = 1] = "Remove";
|
|
33246
|
+
})(UpdateStorageKind || (UpdateStorageKind = {}));
|
|
33022
33247
|
/**
|
|
33023
|
-
*
|
|
33024
|
-
* Updated per block, based on available work reports (`W`).
|
|
33248
|
+
* Update service storage item.
|
|
33025
33249
|
*
|
|
33026
|
-
*
|
|
33250
|
+
* Can either create/modify an entry or remove it.
|
|
33027
33251
|
*/
|
|
33028
|
-
class
|
|
33029
|
-
|
|
33030
|
-
|
|
33031
|
-
|
|
33032
|
-
|
|
33033
|
-
|
|
33034
|
-
exports;
|
|
33035
|
-
extrinsicSize;
|
|
33036
|
-
extrinsicCount;
|
|
33037
|
-
accumulateCount;
|
|
33038
|
-
accumulateGasUsed;
|
|
33039
|
-
onTransfersCount;
|
|
33040
|
-
onTransfersGasUsed;
|
|
33041
|
-
static Codec = Compatibility.selectIfGreaterOrEqual({
|
|
33042
|
-
fallback: descriptors_codec.Class(ServiceStatistics, {
|
|
33043
|
-
providedCount: codecVarU16,
|
|
33044
|
-
providedSize: descriptors_codec.varU32,
|
|
33045
|
-
refinementCount: descriptors_codec.varU32,
|
|
33046
|
-
refinementGasUsed: codecVarGas,
|
|
33047
|
-
imports: codecVarU16,
|
|
33048
|
-
exports: codecVarU16,
|
|
33049
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
33050
|
-
extrinsicCount: codecVarU16,
|
|
33051
|
-
accumulateCount: descriptors_codec.varU32,
|
|
33052
|
-
accumulateGasUsed: codecVarGas,
|
|
33053
|
-
onTransfersCount: descriptors_codec.varU32,
|
|
33054
|
-
onTransfersGasUsed: codecVarGas,
|
|
33055
|
-
}),
|
|
33056
|
-
versions: {
|
|
33057
|
-
[GpVersion.V0_7_0]: descriptors_codec.Class(ServiceStatistics, {
|
|
33058
|
-
providedCount: codecVarU16,
|
|
33059
|
-
providedSize: descriptors_codec.varU32,
|
|
33060
|
-
refinementCount: descriptors_codec.varU32,
|
|
33061
|
-
refinementGasUsed: codecVarGas,
|
|
33062
|
-
imports: codecVarU16,
|
|
33063
|
-
extrinsicCount: codecVarU16,
|
|
33064
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
33065
|
-
exports: codecVarU16,
|
|
33066
|
-
accumulateCount: descriptors_codec.varU32,
|
|
33067
|
-
accumulateGasUsed: codecVarGas,
|
|
33068
|
-
onTransfersCount: descriptors_codec.varU32,
|
|
33069
|
-
onTransfersGasUsed: codecVarGas,
|
|
33070
|
-
}),
|
|
33071
|
-
[GpVersion.V0_7_1]: descriptors_codec.Class(ServiceStatistics, {
|
|
33072
|
-
providedCount: codecVarU16,
|
|
33073
|
-
providedSize: descriptors_codec.varU32,
|
|
33074
|
-
refinementCount: descriptors_codec.varU32,
|
|
33075
|
-
refinementGasUsed: codecVarGas,
|
|
33076
|
-
imports: codecVarU16,
|
|
33077
|
-
extrinsicCount: codecVarU16,
|
|
33078
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
33079
|
-
exports: codecVarU16,
|
|
33080
|
-
accumulateCount: descriptors_codec.varU32,
|
|
33081
|
-
accumulateGasUsed: codecVarGas,
|
|
33082
|
-
onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
|
|
33083
|
-
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
33084
|
-
}),
|
|
33085
|
-
},
|
|
33086
|
-
});
|
|
33087
|
-
static create(v) {
|
|
33088
|
-
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);
|
|
33252
|
+
class UpdateStorage {
|
|
33253
|
+
serviceId;
|
|
33254
|
+
action;
|
|
33255
|
+
constructor(serviceId, action) {
|
|
33256
|
+
this.serviceId = serviceId;
|
|
33257
|
+
this.action = action;
|
|
33089
33258
|
}
|
|
33090
|
-
|
|
33091
|
-
|
|
33092
|
-
providedCount,
|
|
33093
|
-
/** `p.1` */
|
|
33094
|
-
providedSize,
|
|
33095
|
-
/** `r.0` */
|
|
33096
|
-
refinementCount,
|
|
33097
|
-
/** `r.1` */
|
|
33098
|
-
refinementGasUsed,
|
|
33099
|
-
/** `i` */
|
|
33100
|
-
imports,
|
|
33101
|
-
/** `e` */
|
|
33102
|
-
exports,
|
|
33103
|
-
/** `z` */
|
|
33104
|
-
extrinsicSize,
|
|
33105
|
-
/** `x` */
|
|
33106
|
-
extrinsicCount,
|
|
33107
|
-
/** `a.0` */
|
|
33108
|
-
accumulateCount,
|
|
33109
|
-
/** `a.1` */
|
|
33110
|
-
accumulateGasUsed,
|
|
33111
|
-
/** `t.0` @deprecated since 0.7.1 */
|
|
33112
|
-
onTransfersCount,
|
|
33113
|
-
/** `t.1` @deprecated since 0.7.1 */
|
|
33114
|
-
onTransfersGasUsed) {
|
|
33115
|
-
this.providedCount = providedCount;
|
|
33116
|
-
this.providedSize = providedSize;
|
|
33117
|
-
this.refinementCount = refinementCount;
|
|
33118
|
-
this.refinementGasUsed = refinementGasUsed;
|
|
33119
|
-
this.imports = imports;
|
|
33120
|
-
this.exports = exports;
|
|
33121
|
-
this.extrinsicSize = extrinsicSize;
|
|
33122
|
-
this.extrinsicCount = extrinsicCount;
|
|
33123
|
-
this.accumulateCount = accumulateCount;
|
|
33124
|
-
this.accumulateGasUsed = accumulateGasUsed;
|
|
33125
|
-
this.onTransfersCount = onTransfersCount;
|
|
33126
|
-
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
33259
|
+
static set({ serviceId, storage }) {
|
|
33260
|
+
return new UpdateStorage(serviceId, { kind: UpdateStorageKind.Set, storage });
|
|
33127
33261
|
}
|
|
33128
|
-
static
|
|
33129
|
-
|
|
33130
|
-
const zero16 = numbers_tryAsU16(0);
|
|
33131
|
-
const zeroGas = tryAsServiceGas(0);
|
|
33132
|
-
return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas, zero, zeroGas);
|
|
33262
|
+
static remove({ serviceId, key }) {
|
|
33263
|
+
return new UpdateStorage(serviceId, { kind: UpdateStorageKind.Remove, key });
|
|
33133
33264
|
}
|
|
33134
|
-
|
|
33135
|
-
|
|
33136
|
-
|
|
33137
|
-
|
|
33138
|
-
|
|
33139
|
-
cores;
|
|
33140
|
-
services;
|
|
33141
|
-
static Codec = descriptors_codec.Class(StatisticsData, {
|
|
33142
|
-
current: codecPerValidator(ValidatorStatistics.Codec),
|
|
33143
|
-
previous: codecPerValidator(ValidatorStatistics.Codec),
|
|
33144
|
-
cores: codecPerCore(CoreStatistics.Codec),
|
|
33145
|
-
services: descriptors_codec.dictionary(codecServiceId, ServiceStatistics.Codec, {
|
|
33146
|
-
sortKeys: (a, b) => a - b,
|
|
33147
|
-
}),
|
|
33148
|
-
});
|
|
33149
|
-
static create(v) {
|
|
33150
|
-
return new StatisticsData(v.current, v.previous, v.cores, v.services);
|
|
33265
|
+
get key() {
|
|
33266
|
+
if (this.action.kind === UpdateStorageKind.Remove) {
|
|
33267
|
+
return this.action.key;
|
|
33268
|
+
}
|
|
33269
|
+
return this.action.storage.key;
|
|
33151
33270
|
}
|
|
33152
|
-
|
|
33153
|
-
this.
|
|
33154
|
-
|
|
33155
|
-
|
|
33156
|
-
this.
|
|
33271
|
+
get value() {
|
|
33272
|
+
if (this.action.kind === UpdateStorageKind.Remove) {
|
|
33273
|
+
return null;
|
|
33274
|
+
}
|
|
33275
|
+
return this.action.storage.value;
|
|
33157
33276
|
}
|
|
33158
33277
|
}
|
|
33159
33278
|
|
|
@@ -33178,6 +33297,7 @@ class StatisticsData {
|
|
|
33178
33297
|
|
|
33179
33298
|
|
|
33180
33299
|
|
|
33300
|
+
|
|
33181
33301
|
|
|
33182
33302
|
|
|
33183
33303
|
var in_memory_state_UpdateError;
|
|
@@ -33278,10 +33398,11 @@ class InMemoryService extends WithDebug {
|
|
|
33278
33398
|
/**
|
|
33279
33399
|
* A special version of state, stored fully in-memory.
|
|
33280
33400
|
*/
|
|
33281
|
-
class
|
|
33401
|
+
class in_memory_state_InMemoryState extends WithDebug {
|
|
33402
|
+
chainSpec;
|
|
33282
33403
|
/** Create a new `InMemoryState` by providing all required fields. */
|
|
33283
|
-
static
|
|
33284
|
-
return new
|
|
33404
|
+
static new(chainSpec, state) {
|
|
33405
|
+
return new in_memory_state_InMemoryState(chainSpec, state);
|
|
33285
33406
|
}
|
|
33286
33407
|
/**
|
|
33287
33408
|
* Create a new `InMemoryState` with a partial state override.
|
|
@@ -33290,14 +33411,14 @@ class InMemoryState extends WithDebug {
|
|
|
33290
33411
|
* not-necessarily coherent values.
|
|
33291
33412
|
*/
|
|
33292
33413
|
static partial(spec, partial) {
|
|
33293
|
-
const state =
|
|
33414
|
+
const state = in_memory_state_InMemoryState.empty(spec);
|
|
33294
33415
|
Object.assign(state, partial);
|
|
33295
33416
|
return state;
|
|
33296
33417
|
}
|
|
33297
33418
|
/**
|
|
33298
33419
|
* Create a new `InMemoryState` from some other state object.
|
|
33299
33420
|
*/
|
|
33300
|
-
static copyFrom(other, servicesData) {
|
|
33421
|
+
static copyFrom(chainSpec, other, servicesData) {
|
|
33301
33422
|
const services = new Map();
|
|
33302
33423
|
for (const [id, entries] of servicesData.entries()) {
|
|
33303
33424
|
const service = other.getService(id);
|
|
@@ -33307,7 +33428,7 @@ class InMemoryState extends WithDebug {
|
|
|
33307
33428
|
const inMemService = InMemoryService.copyFrom(service, entries);
|
|
33308
33429
|
services.set(id, inMemService);
|
|
33309
33430
|
}
|
|
33310
|
-
return
|
|
33431
|
+
return in_memory_state_InMemoryState.new(chainSpec, {
|
|
33311
33432
|
availabilityAssignment: other.availabilityAssignment,
|
|
33312
33433
|
accumulationQueue: other.accumulationQueue,
|
|
33313
33434
|
designatedValidatorData: other.designatedValidatorData,
|
|
@@ -33504,8 +33625,9 @@ class InMemoryState extends WithDebug {
|
|
|
33504
33625
|
getService(id) {
|
|
33505
33626
|
return this.services.get(id) ?? null;
|
|
33506
33627
|
}
|
|
33507
|
-
constructor(s) {
|
|
33628
|
+
constructor(chainSpec, s) {
|
|
33508
33629
|
super();
|
|
33630
|
+
this.chainSpec = chainSpec;
|
|
33509
33631
|
this.availabilityAssignment = s.availabilityAssignment;
|
|
33510
33632
|
this.designatedValidatorData = s.designatedValidatorData;
|
|
33511
33633
|
this.nextValidatorData = s.nextValidatorData;
|
|
@@ -33527,31 +33649,34 @@ class InMemoryState extends WithDebug {
|
|
|
33527
33649
|
this.accumulationOutputLog = s.accumulationOutputLog;
|
|
33528
33650
|
this.services = s.services;
|
|
33529
33651
|
}
|
|
33652
|
+
view() {
|
|
33653
|
+
return new InMemoryStateView(this.chainSpec, this);
|
|
33654
|
+
}
|
|
33530
33655
|
/**
|
|
33531
33656
|
* Create an empty and possibly incoherent `InMemoryState`.
|
|
33532
33657
|
*/
|
|
33533
33658
|
static empty(spec) {
|
|
33534
|
-
return new
|
|
33659
|
+
return new in_memory_state_InMemoryState(spec, {
|
|
33535
33660
|
availabilityAssignment: tryAsPerCore(Array.from({ length: spec.coresCount }, () => null), spec),
|
|
33536
|
-
designatedValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
33661
|
+
designatedValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => validator_data_ValidatorData.create({
|
|
33537
33662
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
33538
33663
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
33539
33664
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
33540
33665
|
metadata: bytes_Bytes.zero(VALIDATOR_META_BYTES).asOpaque(),
|
|
33541
33666
|
})), spec),
|
|
33542
|
-
nextValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
33667
|
+
nextValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => validator_data_ValidatorData.create({
|
|
33543
33668
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
33544
33669
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
33545
33670
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
33546
33671
|
metadata: bytes_Bytes.zero(VALIDATOR_META_BYTES).asOpaque(),
|
|
33547
33672
|
})), spec),
|
|
33548
|
-
currentValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
33673
|
+
currentValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => validator_data_ValidatorData.create({
|
|
33549
33674
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
33550
33675
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
33551
33676
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
33552
33677
|
metadata: bytes_Bytes.zero(VALIDATOR_META_BYTES).asOpaque(),
|
|
33553
33678
|
})), spec),
|
|
33554
|
-
previousValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
33679
|
+
previousValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => validator_data_ValidatorData.create({
|
|
33555
33680
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
33556
33681
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
33557
33682
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
@@ -33567,7 +33692,7 @@ class InMemoryState extends WithDebug {
|
|
|
33567
33692
|
entropy: FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
33568
33693
|
authPools: tryAsPerCore(Array.from({ length: spec.coresCount }, () => sized_array_asKnownSize([])), spec),
|
|
33569
33694
|
authQueues: tryAsPerCore(Array.from({ length: spec.coresCount }, () => FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE)), spec),
|
|
33570
|
-
recentBlocks:
|
|
33695
|
+
recentBlocks: RecentBlocks.empty(),
|
|
33571
33696
|
statistics: StatisticsData.create({
|
|
33572
33697
|
current: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorStatistics.empty()), spec),
|
|
33573
33698
|
previous: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorStatistics.empty()), spec),
|
|
@@ -33577,8 +33702,8 @@ class InMemoryState extends WithDebug {
|
|
|
33577
33702
|
accumulationQueue: tryAsPerEpochBlock(Array.from({ length: spec.epochLength }, () => []), spec),
|
|
33578
33703
|
recentlyAccumulated: tryAsPerEpochBlock(Array.from({ length: spec.epochLength }, () => HashSet.new()), spec),
|
|
33579
33704
|
ticketsAccumulator: sized_array_asKnownSize([]),
|
|
33580
|
-
sealingKeySeries:
|
|
33581
|
-
epochRoot: bytes_Bytes.zero(
|
|
33705
|
+
sealingKeySeries: safrole_data_SafroleSealingKeysData.keys(tryAsPerEpochBlock(Array.from({ length: spec.epochLength }, () => bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque()), spec)),
|
|
33706
|
+
epochRoot: bytes_Bytes.zero(bandersnatch_BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
33582
33707
|
privilegedServices: PrivilegedServices.create({
|
|
33583
33708
|
manager: tryAsServiceId(0),
|
|
33584
33709
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
@@ -33618,51 +33743,10 @@ const serviceDataCodec = descriptors_codec.dictionary(descriptors_codec.u32.asOp
|
|
|
33618
33743
|
|
|
33619
33744
|
|
|
33620
33745
|
|
|
33621
|
-
;// CONCATENATED MODULE: ./packages/jam/state/not-yet-accumulated.ts
|
|
33622
33746
|
|
|
33623
33747
|
|
|
33624
33748
|
|
|
33625
33749
|
|
|
33626
|
-
|
|
33627
|
-
|
|
33628
|
-
/**
|
|
33629
|
-
* Ready (i.e. available and/or audited) but not-yet-accumulated work-reports.
|
|
33630
|
-
*
|
|
33631
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/165300165400
|
|
33632
|
-
*/
|
|
33633
|
-
class NotYetAccumulatedReport extends WithDebug {
|
|
33634
|
-
report;
|
|
33635
|
-
dependencies;
|
|
33636
|
-
static Codec = descriptors_codec.Class(NotYetAccumulatedReport, {
|
|
33637
|
-
report: WorkReport.Codec,
|
|
33638
|
-
dependencies: codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
33639
|
-
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
33640
|
-
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
33641
|
-
minLength: 0,
|
|
33642
|
-
}),
|
|
33643
|
-
});
|
|
33644
|
-
static create({ report, dependencies }) {
|
|
33645
|
-
return new NotYetAccumulatedReport(report, dependencies);
|
|
33646
|
-
}
|
|
33647
|
-
constructor(
|
|
33648
|
-
/**
|
|
33649
|
-
* Each of these were made available at most one epoch ago
|
|
33650
|
-
* but have or had unfulfilled dependencies.
|
|
33651
|
-
*/
|
|
33652
|
-
report,
|
|
33653
|
-
/**
|
|
33654
|
-
* Alongside the work-report itself, we retain its un-accumulated
|
|
33655
|
-
* dependencies, a set of work-package hashes.
|
|
33656
|
-
*
|
|
33657
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/165800165800
|
|
33658
|
-
*/
|
|
33659
|
-
dependencies) {
|
|
33660
|
-
super();
|
|
33661
|
-
this.report = report;
|
|
33662
|
-
this.dependencies = dependencies;
|
|
33663
|
-
}
|
|
33664
|
-
}
|
|
33665
|
-
|
|
33666
33750
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialize.ts
|
|
33667
33751
|
|
|
33668
33752
|
|
|
@@ -33675,26 +33759,19 @@ class NotYetAccumulatedReport extends WithDebug {
|
|
|
33675
33759
|
|
|
33676
33760
|
|
|
33677
33761
|
|
|
33678
|
-
|
|
33679
|
-
|
|
33680
|
-
|
|
33681
33762
|
/** Serialization for particular state entries. */
|
|
33682
|
-
var
|
|
33763
|
+
var serialize_serialize;
|
|
33683
33764
|
(function (serialize) {
|
|
33684
33765
|
/** C(1): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b15013b1501?v=0.6.7 */
|
|
33685
33766
|
serialize.authPools = {
|
|
33686
33767
|
key: stateKeys.index(StateKeyIdx.Alpha),
|
|
33687
|
-
Codec:
|
|
33688
|
-
minLength: 0,
|
|
33689
|
-
maxLength: MAX_AUTH_POOL_SIZE,
|
|
33690
|
-
typicalLength: MAX_AUTH_POOL_SIZE,
|
|
33691
|
-
})),
|
|
33768
|
+
Codec: authPoolsCodec,
|
|
33692
33769
|
extract: (s) => s.authPools,
|
|
33693
33770
|
};
|
|
33694
33771
|
/** C(2): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b31013b3101?v=0.6.7 */
|
|
33695
33772
|
serialize.authQueues = {
|
|
33696
33773
|
key: stateKeys.index(StateKeyIdx.Phi),
|
|
33697
|
-
Codec:
|
|
33774
|
+
Codec: authQueuesCodec,
|
|
33698
33775
|
extract: (s) => s.authQueues,
|
|
33699
33776
|
};
|
|
33700
33777
|
/**
|
|
@@ -33703,7 +33780,7 @@ var serialize;
|
|
|
33703
33780
|
*/
|
|
33704
33781
|
serialize.recentBlocks = {
|
|
33705
33782
|
key: stateKeys.index(StateKeyIdx.Beta),
|
|
33706
|
-
Codec:
|
|
33783
|
+
Codec: RecentBlocks.Codec,
|
|
33707
33784
|
extract: (s) => s.recentBlocks,
|
|
33708
33785
|
};
|
|
33709
33786
|
/** C(4): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b63013b6301?v=0.6.7 */
|
|
@@ -33732,25 +33809,25 @@ var serialize;
|
|
|
33732
33809
|
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
33733
33810
|
serialize.designatedValidators = {
|
|
33734
33811
|
key: stateKeys.index(StateKeyIdx.Iota),
|
|
33735
|
-
Codec:
|
|
33812
|
+
Codec: validatorsDataCodec,
|
|
33736
33813
|
extract: (s) => s.designatedValidatorData,
|
|
33737
33814
|
};
|
|
33738
33815
|
/** C(8): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b0d023b0d02?v=0.6.7 */
|
|
33739
33816
|
serialize.currentValidators = {
|
|
33740
33817
|
key: stateKeys.index(StateKeyIdx.Kappa),
|
|
33741
|
-
Codec:
|
|
33818
|
+
Codec: validatorsDataCodec,
|
|
33742
33819
|
extract: (s) => s.currentValidatorData,
|
|
33743
33820
|
};
|
|
33744
33821
|
/** C(9): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b1a023b1a02?v=0.6.7 */
|
|
33745
33822
|
serialize.previousValidators = {
|
|
33746
33823
|
key: stateKeys.index(StateKeyIdx.Lambda),
|
|
33747
|
-
Codec:
|
|
33824
|
+
Codec: validatorsDataCodec,
|
|
33748
33825
|
extract: (s) => s.previousValidatorData,
|
|
33749
33826
|
};
|
|
33750
33827
|
/** C(10): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b27023b2702?v=0.6.7 */
|
|
33751
33828
|
serialize.availabilityAssignment = {
|
|
33752
33829
|
key: stateKeys.index(StateKeyIdx.Rho),
|
|
33753
|
-
Codec:
|
|
33830
|
+
Codec: availabilityAssignmentsCodec,
|
|
33754
33831
|
extract: (s) => s.availabilityAssignment,
|
|
33755
33832
|
};
|
|
33756
33833
|
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
@@ -33774,13 +33851,13 @@ var serialize;
|
|
|
33774
33851
|
/** C(14): https://graypaper.fluffylabs.dev/#/1c979cb/3bf0023bf002?v=0.7.1 */
|
|
33775
33852
|
serialize.accumulationQueue = {
|
|
33776
33853
|
key: stateKeys.index(StateKeyIdx.Omega),
|
|
33777
|
-
Codec:
|
|
33854
|
+
Codec: accumulationQueueCodec,
|
|
33778
33855
|
extract: (s) => s.accumulationQueue,
|
|
33779
33856
|
};
|
|
33780
33857
|
/** C(15): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b96023b9602?v=0.6.7 */
|
|
33781
33858
|
serialize.recentlyAccumulated = {
|
|
33782
33859
|
key: stateKeys.index(StateKeyIdx.Xi),
|
|
33783
|
-
Codec:
|
|
33860
|
+
Codec: recentlyAccumulatedCodec,
|
|
33784
33861
|
extract: (s) => s.recentlyAccumulated,
|
|
33785
33862
|
};
|
|
33786
33863
|
/** C(16): https://graypaper.fluffylabs.dev/#/38c4e62/3b46033b4603?v=0.7.0 */
|
|
@@ -33809,9 +33886,9 @@ var serialize;
|
|
|
33809
33886
|
/** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
|
|
33810
33887
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
33811
33888
|
key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
|
|
33812
|
-
Codec:
|
|
33889
|
+
Codec: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.u32)),
|
|
33813
33890
|
});
|
|
33814
|
-
})(
|
|
33891
|
+
})(serialize_serialize || (serialize_serialize = {}));
|
|
33815
33892
|
/**
|
|
33816
33893
|
* Just dump the entire terminal blob as-is.
|
|
33817
33894
|
*
|
|
@@ -33821,6 +33898,87 @@ var serialize;
|
|
|
33821
33898
|
*/
|
|
33822
33899
|
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()));
|
|
33823
33900
|
|
|
33901
|
+
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state-view.ts
|
|
33902
|
+
|
|
33903
|
+
|
|
33904
|
+
class SerializedStateView {
|
|
33905
|
+
spec;
|
|
33906
|
+
backend;
|
|
33907
|
+
recentlyUsedServices;
|
|
33908
|
+
viewCache;
|
|
33909
|
+
constructor(spec, backend,
|
|
33910
|
+
/** Best-effort list of recently active services. */
|
|
33911
|
+
recentlyUsedServices, viewCache) {
|
|
33912
|
+
this.spec = spec;
|
|
33913
|
+
this.backend = backend;
|
|
33914
|
+
this.recentlyUsedServices = recentlyUsedServices;
|
|
33915
|
+
this.viewCache = viewCache;
|
|
33916
|
+
}
|
|
33917
|
+
retrieveView({ key, Codec }, description) {
|
|
33918
|
+
const cached = this.viewCache.get(key);
|
|
33919
|
+
if (cached !== undefined) {
|
|
33920
|
+
return cached;
|
|
33921
|
+
}
|
|
33922
|
+
const bytes = this.backend.get(key);
|
|
33923
|
+
if (bytes === null) {
|
|
33924
|
+
throw new Error(`Required state entry for ${description} is missing!. Accessing view of key: ${key}`);
|
|
33925
|
+
}
|
|
33926
|
+
// NOTE [ToDr] we are not using `Decoder.decodeObject` here because
|
|
33927
|
+
// it needs to get to the end of the data (skip), yet that's expensive.
|
|
33928
|
+
// we assume that the state data is correct and coherent anyway, so
|
|
33929
|
+
// for performance reasons we simply create the view here.
|
|
33930
|
+
const d = decoder_Decoder.fromBytesBlob(bytes);
|
|
33931
|
+
d.attachContext(this.spec);
|
|
33932
|
+
const view = Codec.View.decode(d);
|
|
33933
|
+
this.viewCache.set(key, view);
|
|
33934
|
+
return view;
|
|
33935
|
+
}
|
|
33936
|
+
availabilityAssignmentView() {
|
|
33937
|
+
return this.retrieveView(serialize_serialize.availabilityAssignment, "availabilityAssignmentView");
|
|
33938
|
+
}
|
|
33939
|
+
designatedValidatorDataView() {
|
|
33940
|
+
return this.retrieveView(serialize_serialize.designatedValidators, "designatedValidatorsView");
|
|
33941
|
+
}
|
|
33942
|
+
currentValidatorDataView() {
|
|
33943
|
+
return this.retrieveView(serialize_serialize.currentValidators, "currentValidatorsView");
|
|
33944
|
+
}
|
|
33945
|
+
previousValidatorDataView() {
|
|
33946
|
+
return this.retrieveView(serialize_serialize.previousValidators, "previousValidatorsView");
|
|
33947
|
+
}
|
|
33948
|
+
authPoolsView() {
|
|
33949
|
+
return this.retrieveView(serialize_serialize.authPools, "authPoolsView");
|
|
33950
|
+
}
|
|
33951
|
+
authQueuesView() {
|
|
33952
|
+
return this.retrieveView(serialize_serialize.authQueues, "authQueuesView");
|
|
33953
|
+
}
|
|
33954
|
+
recentBlocksView() {
|
|
33955
|
+
return this.retrieveView(serialize_serialize.recentBlocks, "recentBlocksView");
|
|
33956
|
+
}
|
|
33957
|
+
statisticsView() {
|
|
33958
|
+
return this.retrieveView(serialize_serialize.statistics, "statisticsView");
|
|
33959
|
+
}
|
|
33960
|
+
accumulationQueueView() {
|
|
33961
|
+
return this.retrieveView(serialize_serialize.accumulationQueue, "accumulationQueueView");
|
|
33962
|
+
}
|
|
33963
|
+
recentlyAccumulatedView() {
|
|
33964
|
+
return this.retrieveView(serialize_serialize.recentlyAccumulated, "recentlyAccumulatedView");
|
|
33965
|
+
}
|
|
33966
|
+
safroleDataView() {
|
|
33967
|
+
return this.retrieveView(serialize_serialize.safrole, "safroleDataView");
|
|
33968
|
+
}
|
|
33969
|
+
getServiceInfoView(id) {
|
|
33970
|
+
const serviceData = serialize_serialize.serviceData(id);
|
|
33971
|
+
const bytes = this.backend.get(serviceData.key);
|
|
33972
|
+
if (bytes === null) {
|
|
33973
|
+
return null;
|
|
33974
|
+
}
|
|
33975
|
+
if (!this.recentlyUsedServices.includes(id)) {
|
|
33976
|
+
this.recentlyUsedServices.push(id);
|
|
33977
|
+
}
|
|
33978
|
+
return decoder_Decoder.decodeObject(serviceData.Codec.View, bytes, this.spec);
|
|
33979
|
+
}
|
|
33980
|
+
}
|
|
33981
|
+
|
|
33824
33982
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state.ts
|
|
33825
33983
|
|
|
33826
33984
|
|
|
@@ -33829,6 +33987,8 @@ const dumpCodec = Descriptor.new("Dump", { bytes: 64, isExact: false }, (e, v) =
|
|
|
33829
33987
|
|
|
33830
33988
|
|
|
33831
33989
|
|
|
33990
|
+
|
|
33991
|
+
|
|
33832
33992
|
/**
|
|
33833
33993
|
* State object which reads it's entries from some backend.
|
|
33834
33994
|
*
|
|
@@ -33841,7 +34001,7 @@ class serialized_state_SerializedState {
|
|
|
33841
34001
|
spec;
|
|
33842
34002
|
blake2b;
|
|
33843
34003
|
backend;
|
|
33844
|
-
|
|
34004
|
+
recentlyUsedServices;
|
|
33845
34005
|
/** Create a state-like object from collection of serialized entries. */
|
|
33846
34006
|
static fromStateEntries(spec, blake2b, state, recentServices = []) {
|
|
33847
34007
|
return new serialized_state_SerializedState(spec, blake2b, state, recentServices);
|
|
@@ -33850,106 +34010,120 @@ class serialized_state_SerializedState {
|
|
|
33850
34010
|
static new(spec, blake2b, db, recentServices = []) {
|
|
33851
34011
|
return new serialized_state_SerializedState(spec, blake2b, db, recentServices);
|
|
33852
34012
|
}
|
|
34013
|
+
dataCache = hash_dictionary_HashDictionary.new();
|
|
34014
|
+
viewCache = hash_dictionary_HashDictionary.new();
|
|
33853
34015
|
constructor(spec, blake2b, backend,
|
|
33854
34016
|
/** Best-effort list of recently active services. */
|
|
33855
|
-
|
|
34017
|
+
recentlyUsedServices) {
|
|
33856
34018
|
this.spec = spec;
|
|
33857
34019
|
this.blake2b = blake2b;
|
|
33858
34020
|
this.backend = backend;
|
|
33859
|
-
this.
|
|
34021
|
+
this.recentlyUsedServices = recentlyUsedServices;
|
|
33860
34022
|
}
|
|
33861
34023
|
/** Comparing the serialized states, just means comparing their backends. */
|
|
33862
34024
|
[TEST_COMPARE_USING]() {
|
|
33863
34025
|
return this.backend;
|
|
33864
34026
|
}
|
|
34027
|
+
/** Return a non-decoding version of the state. */
|
|
34028
|
+
view() {
|
|
34029
|
+
return new SerializedStateView(this.spec, this.backend, this.recentlyUsedServices, this.viewCache);
|
|
34030
|
+
}
|
|
33865
34031
|
// TODO [ToDr] Temporary method to update the state,
|
|
33866
34032
|
// without changing references.
|
|
33867
34033
|
updateBackend(newBackend) {
|
|
33868
34034
|
this.backend = newBackend;
|
|
34035
|
+
this.dataCache = hash_dictionary_HashDictionary.new();
|
|
34036
|
+
this.viewCache = hash_dictionary_HashDictionary.new();
|
|
33869
34037
|
}
|
|
33870
34038
|
recentServiceIds() {
|
|
33871
|
-
return this.
|
|
34039
|
+
return this.recentlyUsedServices;
|
|
33872
34040
|
}
|
|
33873
34041
|
getService(id) {
|
|
33874
|
-
const serviceData = this.retrieveOptional(
|
|
34042
|
+
const serviceData = this.retrieveOptional(serialize_serialize.serviceData(id));
|
|
33875
34043
|
if (serviceData === undefined) {
|
|
33876
34044
|
return null;
|
|
33877
34045
|
}
|
|
33878
|
-
if (!this.
|
|
33879
|
-
this.
|
|
34046
|
+
if (!this.recentlyUsedServices.includes(id)) {
|
|
34047
|
+
this.recentlyUsedServices.push(id);
|
|
33880
34048
|
}
|
|
33881
34049
|
return new SerializedService(this.blake2b, id, serviceData, (key) => this.retrieveOptional(key));
|
|
33882
34050
|
}
|
|
33883
|
-
retrieve(
|
|
33884
|
-
const
|
|
33885
|
-
if (
|
|
33886
|
-
throw new Error(`Required state entry for ${description} is missing!. Accessing key: ${key}`);
|
|
34051
|
+
retrieve(k, description) {
|
|
34052
|
+
const data = this.retrieveOptional(k);
|
|
34053
|
+
if (data === undefined) {
|
|
34054
|
+
throw new Error(`Required state entry for ${description} is missing!. Accessing key: ${k.key}`);
|
|
33887
34055
|
}
|
|
33888
|
-
return
|
|
34056
|
+
return data;
|
|
33889
34057
|
}
|
|
33890
34058
|
retrieveOptional({ key, Codec }) {
|
|
34059
|
+
const cached = this.dataCache.get(key);
|
|
34060
|
+
if (cached !== undefined) {
|
|
34061
|
+
return cached;
|
|
34062
|
+
}
|
|
33891
34063
|
const bytes = this.backend.get(key);
|
|
33892
34064
|
if (bytes === null) {
|
|
33893
34065
|
return undefined;
|
|
33894
34066
|
}
|
|
33895
|
-
|
|
34067
|
+
const data = decoder_Decoder.decodeObject(Codec, bytes, this.spec);
|
|
34068
|
+
this.dataCache.set(key, data);
|
|
34069
|
+
return data;
|
|
33896
34070
|
}
|
|
33897
34071
|
get availabilityAssignment() {
|
|
33898
|
-
return this.retrieve(
|
|
34072
|
+
return this.retrieve(serialize_serialize.availabilityAssignment, "availabilityAssignment");
|
|
33899
34073
|
}
|
|
33900
34074
|
get designatedValidatorData() {
|
|
33901
|
-
return this.retrieve(
|
|
34075
|
+
return this.retrieve(serialize_serialize.designatedValidators, "designatedValidatorData");
|
|
33902
34076
|
}
|
|
33903
34077
|
get nextValidatorData() {
|
|
33904
|
-
return this.retrieve(
|
|
34078
|
+
return this.retrieve(serialize_serialize.safrole, "safroleData.nextValidatorData").nextValidatorData;
|
|
33905
34079
|
}
|
|
33906
34080
|
get currentValidatorData() {
|
|
33907
|
-
return this.retrieve(
|
|
34081
|
+
return this.retrieve(serialize_serialize.currentValidators, "currentValidators");
|
|
33908
34082
|
}
|
|
33909
34083
|
get previousValidatorData() {
|
|
33910
|
-
return this.retrieve(
|
|
34084
|
+
return this.retrieve(serialize_serialize.previousValidators, "previousValidators");
|
|
33911
34085
|
}
|
|
33912
34086
|
get disputesRecords() {
|
|
33913
|
-
return this.retrieve(
|
|
34087
|
+
return this.retrieve(serialize_serialize.disputesRecords, "disputesRecords");
|
|
33914
34088
|
}
|
|
33915
34089
|
get timeslot() {
|
|
33916
|
-
return this.retrieve(
|
|
34090
|
+
return this.retrieve(serialize_serialize.timeslot, "timeslot");
|
|
33917
34091
|
}
|
|
33918
34092
|
get entropy() {
|
|
33919
|
-
return this.retrieve(
|
|
34093
|
+
return this.retrieve(serialize_serialize.entropy, "entropy");
|
|
33920
34094
|
}
|
|
33921
34095
|
get authPools() {
|
|
33922
|
-
return this.retrieve(
|
|
34096
|
+
return this.retrieve(serialize_serialize.authPools, "authPools");
|
|
33923
34097
|
}
|
|
33924
34098
|
get authQueues() {
|
|
33925
|
-
return this.retrieve(
|
|
34099
|
+
return this.retrieve(serialize_serialize.authQueues, "authQueues");
|
|
33926
34100
|
}
|
|
33927
34101
|
get recentBlocks() {
|
|
33928
|
-
return this.retrieve(
|
|
34102
|
+
return this.retrieve(serialize_serialize.recentBlocks, "recentBlocks");
|
|
33929
34103
|
}
|
|
33930
34104
|
get statistics() {
|
|
33931
|
-
return this.retrieve(
|
|
34105
|
+
return this.retrieve(serialize_serialize.statistics, "statistics");
|
|
33932
34106
|
}
|
|
33933
34107
|
get accumulationQueue() {
|
|
33934
|
-
return this.retrieve(
|
|
34108
|
+
return this.retrieve(serialize_serialize.accumulationQueue, "accumulationQueue");
|
|
33935
34109
|
}
|
|
33936
34110
|
get recentlyAccumulated() {
|
|
33937
|
-
return this.retrieve(
|
|
34111
|
+
return this.retrieve(serialize_serialize.recentlyAccumulated, "recentlyAccumulated");
|
|
33938
34112
|
}
|
|
33939
34113
|
get ticketsAccumulator() {
|
|
33940
|
-
return this.retrieve(
|
|
34114
|
+
return this.retrieve(serialize_serialize.safrole, "safroleData.ticketsAccumulator").ticketsAccumulator;
|
|
33941
34115
|
}
|
|
33942
34116
|
get sealingKeySeries() {
|
|
33943
|
-
return this.retrieve(
|
|
34117
|
+
return this.retrieve(serialize_serialize.safrole, "safrole.sealingKeySeries").sealingKeySeries;
|
|
33944
34118
|
}
|
|
33945
34119
|
get epochRoot() {
|
|
33946
|
-
return this.retrieve(
|
|
34120
|
+
return this.retrieve(serialize_serialize.safrole, "safrole.epochRoot").epochRoot;
|
|
33947
34121
|
}
|
|
33948
34122
|
get privilegedServices() {
|
|
33949
|
-
return this.retrieve(
|
|
34123
|
+
return this.retrieve(serialize_serialize.privilegedServices, "privilegedServices");
|
|
33950
34124
|
}
|
|
33951
34125
|
get accumulationOutputLog() {
|
|
33952
|
-
return this.retrieve(
|
|
34126
|
+
return this.retrieve(serialize_serialize.accumulationOutputLog, "accumulationOutputLog");
|
|
33953
34127
|
}
|
|
33954
34128
|
}
|
|
33955
34129
|
/** Service data representation on a serialized state. */
|
|
@@ -33978,9 +34152,9 @@ class SerializedService {
|
|
|
33978
34152
|
serviceIdAndKey.set(numbers_u32AsLeBytes(this.serviceId));
|
|
33979
34153
|
serviceIdAndKey.set(rawKey.raw, SERVICE_ID_BYTES);
|
|
33980
34154
|
const key = opaque_asOpaqueType(bytes_BytesBlob.blobFrom(this.blake2b.hashBytes(serviceIdAndKey).raw));
|
|
33981
|
-
return this.retrieveOptional(
|
|
34155
|
+
return this.retrieveOptional(serialize_serialize.serviceStorage(this.blake2b, this.serviceId, key)) ?? null;
|
|
33982
34156
|
}
|
|
33983
|
-
return this.retrieveOptional(
|
|
34157
|
+
return this.retrieveOptional(serialize_serialize.serviceStorage(this.blake2b, this.serviceId, rawKey)) ?? null;
|
|
33984
34158
|
}
|
|
33985
34159
|
/**
|
|
33986
34160
|
* Check if preimage is present in the DB.
|
|
@@ -33989,15 +34163,15 @@ class SerializedService {
|
|
|
33989
34163
|
*/
|
|
33990
34164
|
hasPreimage(hash) {
|
|
33991
34165
|
// TODO [ToDr] consider optimizing to avoid fetching the whole data.
|
|
33992
|
-
return this.retrieveOptional(
|
|
34166
|
+
return this.retrieveOptional(serialize_serialize.servicePreimages(this.blake2b, this.serviceId, hash)) !== undefined;
|
|
33993
34167
|
}
|
|
33994
34168
|
/** Retrieve preimage from the DB. */
|
|
33995
34169
|
getPreimage(hash) {
|
|
33996
|
-
return this.retrieveOptional(
|
|
34170
|
+
return this.retrieveOptional(serialize_serialize.servicePreimages(this.blake2b, this.serviceId, hash)) ?? null;
|
|
33997
34171
|
}
|
|
33998
34172
|
/** Retrieve preimage lookup history. */
|
|
33999
34173
|
getLookupHistory(hash, len) {
|
|
34000
|
-
const rawSlots = this.retrieveOptional(
|
|
34174
|
+
const rawSlots = this.retrieveOptional(serialize_serialize.serviceLookupHistory(this.blake2b, this.serviceId, hash, len));
|
|
34001
34175
|
if (rawSlots === undefined) {
|
|
34002
34176
|
return null;
|
|
34003
34177
|
}
|
|
@@ -34686,7 +34860,7 @@ function* serializeStateUpdate(spec, blake2b, update) {
|
|
|
34686
34860
|
function* serializeRemovedServices(servicesRemoved) {
|
|
34687
34861
|
for (const serviceId of servicesRemoved ?? []) {
|
|
34688
34862
|
// TODO [ToDr] what about all data associated with a service?
|
|
34689
|
-
const codec =
|
|
34863
|
+
const codec = serialize_serialize.serviceData(serviceId);
|
|
34690
34864
|
yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
34691
34865
|
}
|
|
34692
34866
|
}
|
|
@@ -34695,13 +34869,13 @@ function* serializeStorage(storage, blake2b) {
|
|
|
34695
34869
|
switch (action.kind) {
|
|
34696
34870
|
case UpdateStorageKind.Set: {
|
|
34697
34871
|
const key = action.storage.key;
|
|
34698
|
-
const codec =
|
|
34872
|
+
const codec = serialize_serialize.serviceStorage(blake2b, serviceId, key);
|
|
34699
34873
|
yield [StateEntryUpdateAction.Insert, codec.key, action.storage.value];
|
|
34700
34874
|
break;
|
|
34701
34875
|
}
|
|
34702
34876
|
case UpdateStorageKind.Remove: {
|
|
34703
34877
|
const key = action.key;
|
|
34704
|
-
const codec =
|
|
34878
|
+
const codec = serialize_serialize.serviceStorage(blake2b, serviceId, key);
|
|
34705
34879
|
yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
34706
34880
|
break;
|
|
34707
34881
|
}
|
|
@@ -34715,10 +34889,10 @@ function* serializePreimages(preimages, encode, blake2b) {
|
|
|
34715
34889
|
switch (action.kind) {
|
|
34716
34890
|
case UpdatePreimageKind.Provide: {
|
|
34717
34891
|
const { hash, blob } = action.preimage;
|
|
34718
|
-
const codec =
|
|
34892
|
+
const codec = serialize_serialize.servicePreimages(blake2b, serviceId, hash);
|
|
34719
34893
|
yield [StateEntryUpdateAction.Insert, codec.key, blob];
|
|
34720
34894
|
if (action.slot !== null) {
|
|
34721
|
-
const codec2 =
|
|
34895
|
+
const codec2 = serialize_serialize.serviceLookupHistory(blake2b, serviceId, hash, numbers_tryAsU32(blob.length));
|
|
34722
34896
|
yield [
|
|
34723
34897
|
StateEntryUpdateAction.Insert,
|
|
34724
34898
|
codec2.key,
|
|
@@ -34729,15 +34903,15 @@ function* serializePreimages(preimages, encode, blake2b) {
|
|
|
34729
34903
|
}
|
|
34730
34904
|
case UpdatePreimageKind.UpdateOrAdd: {
|
|
34731
34905
|
const { hash, length, slots } = action.item;
|
|
34732
|
-
const codec =
|
|
34906
|
+
const codec = serialize_serialize.serviceLookupHistory(blake2b, serviceId, hash, length);
|
|
34733
34907
|
yield [StateEntryUpdateAction.Insert, codec.key, encode(codec.Codec, slots)];
|
|
34734
34908
|
break;
|
|
34735
34909
|
}
|
|
34736
34910
|
case UpdatePreimageKind.Remove: {
|
|
34737
34911
|
const { hash, length } = action;
|
|
34738
|
-
const codec =
|
|
34912
|
+
const codec = serialize_serialize.servicePreimages(blake2b, serviceId, hash);
|
|
34739
34913
|
yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
34740
|
-
const codec2 =
|
|
34914
|
+
const codec2 = serialize_serialize.serviceLookupHistory(blake2b, serviceId, hash, length);
|
|
34741
34915
|
yield [StateEntryUpdateAction.Remove, codec2.key, EMPTY_BLOB];
|
|
34742
34916
|
break;
|
|
34743
34917
|
}
|
|
@@ -34749,12 +34923,12 @@ function* serializePreimages(preimages, encode, blake2b) {
|
|
|
34749
34923
|
function* serializeServiceUpdates(servicesUpdates, encode, blake2b) {
|
|
34750
34924
|
for (const { action, serviceId } of servicesUpdates ?? []) {
|
|
34751
34925
|
// new service being created or updated
|
|
34752
|
-
const codec =
|
|
34926
|
+
const codec = serialize_serialize.serviceData(serviceId);
|
|
34753
34927
|
yield [StateEntryUpdateAction.Insert, codec.key, encode(codec.Codec, action.account)];
|
|
34754
34928
|
// additional lookup history update
|
|
34755
34929
|
if (action.kind === UpdateServiceKind.Create && action.lookupHistory !== null) {
|
|
34756
34930
|
const { lookupHistory } = action;
|
|
34757
|
-
const codec2 =
|
|
34931
|
+
const codec2 = serialize_serialize.serviceLookupHistory(blake2b, serviceId, lookupHistory.hash, lookupHistory.length);
|
|
34758
34932
|
yield [StateEntryUpdateAction.Insert, codec2.key, encode(codec2.Codec, lookupHistory.slots)];
|
|
34759
34933
|
}
|
|
34760
34934
|
}
|
|
@@ -34764,53 +34938,53 @@ function* serializeBasicKeys(spec, update) {
|
|
|
34764
34938
|
return [StateEntryUpdateAction.Insert, codec.key, encoder_Encoder.encodeObject(codec.Codec, val, spec)];
|
|
34765
34939
|
}
|
|
34766
34940
|
if (update.authPools !== undefined) {
|
|
34767
|
-
yield doSerialize(update.authPools,
|
|
34941
|
+
yield doSerialize(update.authPools, serialize_serialize.authPools); // C(1)
|
|
34768
34942
|
}
|
|
34769
34943
|
if (update.authQueues !== undefined) {
|
|
34770
|
-
yield doSerialize(update.authQueues,
|
|
34944
|
+
yield doSerialize(update.authQueues, serialize_serialize.authQueues); // C(2)
|
|
34771
34945
|
}
|
|
34772
34946
|
if (update.recentBlocks !== undefined) {
|
|
34773
|
-
yield doSerialize(update.recentBlocks,
|
|
34947
|
+
yield doSerialize(update.recentBlocks, serialize_serialize.recentBlocks); // C(3)
|
|
34774
34948
|
}
|
|
34775
34949
|
const safroleData = getSafroleData(update.nextValidatorData, update.epochRoot, update.sealingKeySeries, update.ticketsAccumulator);
|
|
34776
34950
|
if (safroleData !== undefined) {
|
|
34777
|
-
yield doSerialize(safroleData,
|
|
34951
|
+
yield doSerialize(safroleData, serialize_serialize.safrole); // C(4)
|
|
34778
34952
|
}
|
|
34779
34953
|
if (update.disputesRecords !== undefined) {
|
|
34780
|
-
yield doSerialize(update.disputesRecords,
|
|
34954
|
+
yield doSerialize(update.disputesRecords, serialize_serialize.disputesRecords); // C(5)
|
|
34781
34955
|
}
|
|
34782
34956
|
if (update.entropy !== undefined) {
|
|
34783
|
-
yield doSerialize(update.entropy,
|
|
34957
|
+
yield doSerialize(update.entropy, serialize_serialize.entropy); // C(6)
|
|
34784
34958
|
}
|
|
34785
34959
|
if (update.designatedValidatorData !== undefined) {
|
|
34786
|
-
yield doSerialize(update.designatedValidatorData,
|
|
34960
|
+
yield doSerialize(update.designatedValidatorData, serialize_serialize.designatedValidators); // C(7)
|
|
34787
34961
|
}
|
|
34788
34962
|
if (update.currentValidatorData !== undefined) {
|
|
34789
|
-
yield doSerialize(update.currentValidatorData,
|
|
34963
|
+
yield doSerialize(update.currentValidatorData, serialize_serialize.currentValidators); // C(8)
|
|
34790
34964
|
}
|
|
34791
34965
|
if (update.previousValidatorData !== undefined) {
|
|
34792
|
-
yield doSerialize(update.previousValidatorData,
|
|
34966
|
+
yield doSerialize(update.previousValidatorData, serialize_serialize.previousValidators); // C(9)
|
|
34793
34967
|
}
|
|
34794
34968
|
if (update.availabilityAssignment !== undefined) {
|
|
34795
|
-
yield doSerialize(update.availabilityAssignment,
|
|
34969
|
+
yield doSerialize(update.availabilityAssignment, serialize_serialize.availabilityAssignment); // C(10)
|
|
34796
34970
|
}
|
|
34797
34971
|
if (update.timeslot !== undefined) {
|
|
34798
|
-
yield doSerialize(update.timeslot,
|
|
34972
|
+
yield doSerialize(update.timeslot, serialize_serialize.timeslot); // C(11)
|
|
34799
34973
|
}
|
|
34800
34974
|
if (update.privilegedServices !== undefined) {
|
|
34801
|
-
yield doSerialize(update.privilegedServices,
|
|
34975
|
+
yield doSerialize(update.privilegedServices, serialize_serialize.privilegedServices); // C(12)
|
|
34802
34976
|
}
|
|
34803
34977
|
if (update.statistics !== undefined) {
|
|
34804
|
-
yield doSerialize(update.statistics,
|
|
34978
|
+
yield doSerialize(update.statistics, serialize_serialize.statistics); // C(13)
|
|
34805
34979
|
}
|
|
34806
34980
|
if (update.accumulationQueue !== undefined) {
|
|
34807
|
-
yield doSerialize(update.accumulationQueue,
|
|
34981
|
+
yield doSerialize(update.accumulationQueue, serialize_serialize.accumulationQueue); // C(14)
|
|
34808
34982
|
}
|
|
34809
34983
|
if (update.recentlyAccumulated !== undefined) {
|
|
34810
|
-
yield doSerialize(update.recentlyAccumulated,
|
|
34984
|
+
yield doSerialize(update.recentlyAccumulated, serialize_serialize.recentlyAccumulated); // C(15)
|
|
34811
34985
|
}
|
|
34812
34986
|
if (update.accumulationOutputLog !== undefined) {
|
|
34813
|
-
yield doSerialize(update.accumulationOutputLog,
|
|
34987
|
+
yield doSerialize(update.accumulationOutputLog, serialize_serialize.accumulationOutputLog); // C(16)
|
|
34814
34988
|
}
|
|
34815
34989
|
}
|
|
34816
34990
|
function getSafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator) {
|
|
@@ -34923,41 +35097,41 @@ function convertInMemoryStateToDictionary(spec, blake2b, state) {
|
|
|
34923
35097
|
function doSerialize(codec) {
|
|
34924
35098
|
serialized.set(codec.key, encoder_Encoder.encodeObject(codec.Codec, codec.extract(state), spec));
|
|
34925
35099
|
}
|
|
34926
|
-
doSerialize(
|
|
34927
|
-
doSerialize(
|
|
34928
|
-
doSerialize(
|
|
34929
|
-
doSerialize(
|
|
34930
|
-
doSerialize(
|
|
34931
|
-
doSerialize(
|
|
34932
|
-
doSerialize(
|
|
34933
|
-
doSerialize(
|
|
34934
|
-
doSerialize(
|
|
34935
|
-
doSerialize(
|
|
34936
|
-
doSerialize(
|
|
34937
|
-
doSerialize(
|
|
34938
|
-
doSerialize(
|
|
34939
|
-
doSerialize(
|
|
34940
|
-
doSerialize(
|
|
34941
|
-
doSerialize(
|
|
35100
|
+
doSerialize(serialize_serialize.authPools); // C(1)
|
|
35101
|
+
doSerialize(serialize_serialize.authQueues); // C(2)
|
|
35102
|
+
doSerialize(serialize_serialize.recentBlocks); // C(3)
|
|
35103
|
+
doSerialize(serialize_serialize.safrole); // C(4)
|
|
35104
|
+
doSerialize(serialize_serialize.disputesRecords); // C(5)
|
|
35105
|
+
doSerialize(serialize_serialize.entropy); // C(6)
|
|
35106
|
+
doSerialize(serialize_serialize.designatedValidators); // C(7)
|
|
35107
|
+
doSerialize(serialize_serialize.currentValidators); // C(8)
|
|
35108
|
+
doSerialize(serialize_serialize.previousValidators); // C(9)
|
|
35109
|
+
doSerialize(serialize_serialize.availabilityAssignment); // C(10)
|
|
35110
|
+
doSerialize(serialize_serialize.timeslot); // C(11)
|
|
35111
|
+
doSerialize(serialize_serialize.privilegedServices); // C(12)
|
|
35112
|
+
doSerialize(serialize_serialize.statistics); // C(13)
|
|
35113
|
+
doSerialize(serialize_serialize.accumulationQueue); // C(14)
|
|
35114
|
+
doSerialize(serialize_serialize.recentlyAccumulated); // C(15)
|
|
35115
|
+
doSerialize(serialize_serialize.accumulationOutputLog); // C(16)
|
|
34942
35116
|
// services
|
|
34943
35117
|
for (const [serviceId, service] of state.services.entries()) {
|
|
34944
35118
|
// data
|
|
34945
|
-
const { key, Codec } =
|
|
35119
|
+
const { key, Codec } = serialize_serialize.serviceData(serviceId);
|
|
34946
35120
|
serialized.set(key, encoder_Encoder.encodeObject(Codec, service.getInfo()));
|
|
34947
35121
|
// preimages
|
|
34948
35122
|
for (const preimage of service.data.preimages.values()) {
|
|
34949
|
-
const { key, Codec } =
|
|
35123
|
+
const { key, Codec } = serialize_serialize.servicePreimages(blake2b, serviceId, preimage.hash);
|
|
34950
35124
|
serialized.set(key, encoder_Encoder.encodeObject(Codec, preimage.blob));
|
|
34951
35125
|
}
|
|
34952
35126
|
// storage
|
|
34953
35127
|
for (const storage of service.data.storage.values()) {
|
|
34954
|
-
const { key, Codec } =
|
|
35128
|
+
const { key, Codec } = serialize_serialize.serviceStorage(blake2b, serviceId, storage.key);
|
|
34955
35129
|
serialized.set(key, encoder_Encoder.encodeObject(Codec, storage.value));
|
|
34956
35130
|
}
|
|
34957
35131
|
// lookup history
|
|
34958
35132
|
for (const lookupHistoryList of service.data.lookupHistory.values()) {
|
|
34959
35133
|
for (const lookupHistory of lookupHistoryList) {
|
|
34960
|
-
const { key, Codec } =
|
|
35134
|
+
const { key, Codec } = serialize_serialize.serviceLookupHistory(blake2b, serviceId, lookupHistory.hash, lookupHistory.length);
|
|
34961
35135
|
serialized.set(key, encoder_Encoder.encodeObject(Codec, lookupHistory.slots.slice()));
|
|
34962
35136
|
}
|
|
34963
35137
|
}
|
|
@@ -35007,6 +35181,7 @@ function loadState(spec, blake2b, entries) {
|
|
|
35007
35181
|
|
|
35008
35182
|
|
|
35009
35183
|
|
|
35184
|
+
|
|
35010
35185
|
;// CONCATENATED MODULE: ./packages/jam/database/leaf-db.ts
|
|
35011
35186
|
|
|
35012
35187
|
|
|
@@ -35165,7 +35340,7 @@ const codecMap = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH
|
|
|
35165
35340
|
const lookupHistoryItemCodec = descriptors_codec.object({
|
|
35166
35341
|
hash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
35167
35342
|
length: descriptors_codec.u32,
|
|
35168
|
-
slots:
|
|
35343
|
+
slots: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.u32.asOpaque())).convert(seeThrough, tryAsLookupHistorySlots),
|
|
35169
35344
|
}, "LookupHistoryItem", ({ hash, length, slots }) => new LookupHistoryItem(hash, length, slots));
|
|
35170
35345
|
const lookupHistoryEntryCodec = descriptors_codec.object({
|
|
35171
35346
|
key: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
@@ -35208,7 +35383,11 @@ class ServiceWithCodec extends InMemoryService {
|
|
|
35208
35383
|
return new ServiceWithCodec(serviceId, data);
|
|
35209
35384
|
}
|
|
35210
35385
|
}
|
|
35211
|
-
const in_memory_state_codec_inMemoryStateCodec =
|
|
35386
|
+
const in_memory_state_codec_inMemoryStateCodec = (spec) => codec.Class(class State extends InMemoryState {
|
|
35387
|
+
static create(data) {
|
|
35388
|
+
return InMemoryState.new(spec, data);
|
|
35389
|
+
}
|
|
35390
|
+
}, {
|
|
35212
35391
|
// alpha
|
|
35213
35392
|
authPools: serialize.authPools.Codec,
|
|
35214
35393
|
// phi
|
|
@@ -35218,11 +35397,11 @@ const in_memory_state_codec_inMemoryStateCodec = descriptors_codec.Class(InMemor
|
|
|
35218
35397
|
// gamma_k
|
|
35219
35398
|
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
35220
35399
|
// gamma_z
|
|
35221
|
-
epochRoot:
|
|
35400
|
+
epochRoot: codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
35222
35401
|
// gamma_s
|
|
35223
35402
|
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
35224
35403
|
// gamma_a
|
|
35225
|
-
ticketsAccumulator: readonlyArray(
|
|
35404
|
+
ticketsAccumulator: readonlyArray(codec.sequenceVarLen(Ticket.Codec)).convert((x) => x, asKnownSize),
|
|
35226
35405
|
// psi
|
|
35227
35406
|
disputesRecords: serialize.disputesRecords.Codec,
|
|
35228
35407
|
// eta
|
|
@@ -35248,7 +35427,7 @@ const in_memory_state_codec_inMemoryStateCodec = descriptors_codec.Class(InMemor
|
|
|
35248
35427
|
// theta
|
|
35249
35428
|
accumulationOutputLog: serialize.accumulationOutputLog.Codec,
|
|
35250
35429
|
// delta
|
|
35251
|
-
services:
|
|
35430
|
+
services: codec.dictionary(codec.u32.asOpaque(), ServiceWithCodec.Codec, {
|
|
35252
35431
|
sortKeys: (a, b) => a - b,
|
|
35253
35432
|
}),
|
|
35254
35433
|
});
|
|
@@ -35295,7 +35474,7 @@ class InMemoryStates {
|
|
|
35295
35474
|
}
|
|
35296
35475
|
/** Insert a full state into the database. */
|
|
35297
35476
|
async insertState(headerHash, state) {
|
|
35298
|
-
const encoded = Encoder.encodeObject(inMemoryStateCodec, state, this.spec);
|
|
35477
|
+
const encoded = Encoder.encodeObject(inMemoryStateCodec(this.spec), state, this.spec);
|
|
35299
35478
|
this.db.set(headerHash, encoded);
|
|
35300
35479
|
return Result.ok(OK);
|
|
35301
35480
|
}
|
|
@@ -35304,7 +35483,7 @@ class InMemoryStates {
|
|
|
35304
35483
|
if (encodedState === undefined) {
|
|
35305
35484
|
return null;
|
|
35306
35485
|
}
|
|
35307
|
-
return Decoder.decodeObject(inMemoryStateCodec, encodedState, this.spec);
|
|
35486
|
+
return Decoder.decodeObject(inMemoryStateCodec(this.spec), encodedState, this.spec);
|
|
35308
35487
|
}
|
|
35309
35488
|
}
|
|
35310
35489
|
|
|
@@ -35530,14 +35709,14 @@ async function initializeDatabase(spec, blake2b, genesisHeaderHash, rootDb, conf
|
|
|
35530
35709
|
const genesisHeader = decoder_Decoder.decodeObject(Header.Codec, config.genesisHeader, spec);
|
|
35531
35710
|
const genesisExtrinsic = emptyBlock().extrinsic;
|
|
35532
35711
|
const genesisBlock = Block.create({ header: genesisHeader, extrinsic: genesisExtrinsic });
|
|
35533
|
-
const blockView =
|
|
35712
|
+
const blockView = reencodeAsView(Block.Codec, genesisBlock, spec);
|
|
35534
35713
|
common_logger.log `🧬 Writing genesis block #${genesisHeader.timeSlotIndex}: ${genesisHeaderHash}`;
|
|
35535
35714
|
const { genesisStateSerialized, genesisStateRootHash } = loadGenesisState(spec, blake2b, config.genesisState);
|
|
35536
35715
|
// write to db
|
|
35537
35716
|
await blocks.insertBlock(new WithHash(genesisHeaderHash, blockView));
|
|
35538
35717
|
// insert fake blocks for ancestry data
|
|
35539
35718
|
for (const [hash, slot] of ancestry) {
|
|
35540
|
-
await blocks.insertBlock(new WithHash(hash,
|
|
35719
|
+
await blocks.insertBlock(new WithHash(hash, reencodeAsView(Block.Codec, emptyBlock(slot), spec)));
|
|
35541
35720
|
}
|
|
35542
35721
|
await states.insertState(genesisHeaderHash, genesisStateSerialized);
|
|
35543
35722
|
await blocks.setPostStateRoot(genesisHeaderHash, genesisStateRootHash);
|
|
@@ -35556,9 +35735,6 @@ function loadGenesisState(spec, blake2b, data) {
|
|
|
35556
35735
|
genesisStateRootHash,
|
|
35557
35736
|
};
|
|
35558
35737
|
}
|
|
35559
|
-
function blockAsView(block, spec) {
|
|
35560
|
-
return decoder_Decoder.decodeObject(Block.Codec.View, encoder_Encoder.encodeObject(Block.Codec, block, spec), spec);
|
|
35561
|
-
}
|
|
35562
35738
|
|
|
35563
35739
|
;// CONCATENATED MODULE: external "node:path"
|
|
35564
35740
|
const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
|
|
@@ -36748,21 +36924,21 @@ class TransitionHasher {
|
|
|
36748
36924
|
*/
|
|
36749
36925
|
extrinsic(extrinsicView) {
|
|
36750
36926
|
// https://graypaper.fluffylabs.dev/#/cc517d7/0cfb000cfb00?v=0.6.5
|
|
36751
|
-
const
|
|
36927
|
+
const guaranteesCount = numbers_tryAsU32(extrinsicView.guarantees.view().length);
|
|
36928
|
+
const countEncoded = encoder_Encoder.encodeObject(descriptors_codec.varU32, guaranteesCount);
|
|
36929
|
+
const guaranteesBlobs = extrinsicView.guarantees
|
|
36752
36930
|
.view()
|
|
36753
36931
|
.map((g) => g.view())
|
|
36754
|
-
.
|
|
36932
|
+
.reduce((aggregated, guarantee) => {
|
|
36755
36933
|
const reportHash = this.blake2b.hashBytes(guarantee.report.encoded()).asOpaque();
|
|
36756
|
-
|
|
36757
|
-
|
|
36758
|
-
|
|
36759
|
-
|
|
36760
|
-
|
|
36761
|
-
});
|
|
36762
|
-
const guaranteeBlob = encoder_Encoder.encodeObject(descriptors_codec.sequenceVarLen(dumpCodec), guarantees, this.context);
|
|
36934
|
+
aggregated.push(reportHash.raw);
|
|
36935
|
+
aggregated.push(guarantee.slot.encoded().raw);
|
|
36936
|
+
aggregated.push(guarantee.credentials.encoded().raw);
|
|
36937
|
+
return aggregated;
|
|
36938
|
+
}, [countEncoded.raw]);
|
|
36763
36939
|
const et = this.blake2b.hashBytes(extrinsicView.tickets.encoded()).asOpaque();
|
|
36764
36940
|
const ep = this.blake2b.hashBytes(extrinsicView.preimages.encoded()).asOpaque();
|
|
36765
|
-
const eg = this.blake2b.
|
|
36941
|
+
const eg = this.blake2b.hashBlobs(guaranteesBlobs).asOpaque();
|
|
36766
36942
|
const ea = this.blake2b.hashBytes(extrinsicView.assurances.encoded()).asOpaque();
|
|
36767
36943
|
const ed = this.blake2b.hashBytes(extrinsicView.disputes.encoded()).asOpaque();
|
|
36768
36944
|
const encoded = bytes_BytesBlob.blobFromParts([et.raw, ep.raw, eg.raw, ea.raw, ed.raw]);
|
|
@@ -41378,7 +41554,7 @@ async function getRingCommitmentNoCache(bandersnatch, keys) {
|
|
|
41378
41554
|
if (commitmentResult[RESULT_INDEX] === ResultValues.Error) {
|
|
41379
41555
|
return result_Result.error(null);
|
|
41380
41556
|
}
|
|
41381
|
-
return result_Result.ok(bytes_Bytes.fromBlob(commitmentResult.subarray(1),
|
|
41557
|
+
return result_Result.ok(bytes_Bytes.fromBlob(commitmentResult.subarray(1), bandersnatch_BANDERSNATCH_RING_ROOT_BYTES).asOpaque());
|
|
41382
41558
|
}
|
|
41383
41559
|
// One byte for result discriminator (`ResultValues`) and the rest is entropy hash.
|
|
41384
41560
|
const TICKET_RESULT_LENGTH = 1 + hash_HASH_SIZE;
|
|
@@ -41532,7 +41708,7 @@ class Safrole {
|
|
|
41532
41708
|
* https://graypaper.fluffylabs.dev/#/5f542d7/0ea2000ea200
|
|
41533
41709
|
*/
|
|
41534
41710
|
if (isOffender) {
|
|
41535
|
-
return
|
|
41711
|
+
return validator_data_ValidatorData.create({
|
|
41536
41712
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
41537
41713
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
41538
41714
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
@@ -41610,13 +41786,13 @@ class Safrole {
|
|
|
41610
41786
|
if (this.isNextEpoch(timeslot) &&
|
|
41611
41787
|
m >= this.chainSpec.contestLength &&
|
|
41612
41788
|
this.state.ticketsAccumulator.length === this.chainSpec.epochLength) {
|
|
41613
|
-
return
|
|
41789
|
+
return safrole_data_SafroleSealingKeysData.tickets(this.outsideInSequencer(this.state.ticketsAccumulator).tickets);
|
|
41614
41790
|
}
|
|
41615
41791
|
if (this.isSameEpoch(timeslot)) {
|
|
41616
41792
|
return this.state.sealingKeySeries;
|
|
41617
41793
|
}
|
|
41618
41794
|
// TODO [MaSi]: the result of fallback sequencer should be cached
|
|
41619
|
-
return
|
|
41795
|
+
return safrole_data_SafroleSealingKeysData.keys(this.fallbackKeySequencer(newEntropy, newValidators));
|
|
41620
41796
|
}
|
|
41621
41797
|
/**
|
|
41622
41798
|
* Returns epoch markers if the epoch is changed and null otherwise
|
|
@@ -41866,47 +42042,46 @@ class SafroleSeal {
|
|
|
41866
42042
|
}
|
|
41867
42043
|
async verifySeal(headerView, state) {
|
|
41868
42044
|
// we use transitioned keys already
|
|
41869
|
-
const validators = state.currentValidatorData;
|
|
41870
42045
|
const validatorIndex = headerView.bandersnatchBlockAuthorIndex.materialize();
|
|
41871
|
-
const
|
|
41872
|
-
if (
|
|
42046
|
+
const authorKeys = state.currentValidatorData.at(validatorIndex);
|
|
42047
|
+
if (authorKeys === undefined) {
|
|
41873
42048
|
return result_Result.error(SafroleSealError.InvalidValidatorIndex);
|
|
41874
42049
|
}
|
|
41875
42050
|
const timeSlot = headerView.timeSlotIndex.materialize();
|
|
41876
42051
|
const sealingKeys = state.sealingKeySeries;
|
|
41877
42052
|
const entropy = state.currentEntropy;
|
|
41878
42053
|
if (sealingKeys.kind === SafroleSealingKeysKind.Tickets) {
|
|
41879
|
-
return await this.verifySealWithTicket(sealingKeys.tickets, timeSlot, entropy,
|
|
42054
|
+
return await this.verifySealWithTicket(sealingKeys.tickets, timeSlot, entropy, authorKeys, headerView);
|
|
41880
42055
|
}
|
|
41881
|
-
return await this.verifySealWithKeys(sealingKeys.keys,
|
|
42056
|
+
return await this.verifySealWithKeys(sealingKeys.keys, timeSlot, entropy, authorKeys, headerView);
|
|
41882
42057
|
}
|
|
41883
42058
|
/** Regular (non-fallback) mode of Safrole. */
|
|
41884
|
-
async verifySealWithTicket(tickets, timeSlot, entropy,
|
|
42059
|
+
async verifySealWithTicket(tickets, timeSlot, entropy, validatorData, headerView) {
|
|
41885
42060
|
const index = timeSlot % tickets.length;
|
|
41886
|
-
const
|
|
41887
|
-
const payload = bytes_BytesBlob.blobFromParts(JAM_TICKET_SEAL, entropy.raw, new Uint8Array([attempt]));
|
|
42061
|
+
const ticket = tickets.at(index);
|
|
42062
|
+
const payload = bytes_BytesBlob.blobFromParts(JAM_TICKET_SEAL, entropy.raw, new Uint8Array([ticket?.attempt ?? 0]));
|
|
41888
42063
|
// verify seal correctness
|
|
41889
|
-
const authorKey =
|
|
42064
|
+
const authorKey = validatorData.bandersnatch;
|
|
41890
42065
|
const result = await bandersnatch_vrf.verifySeal(await this.bandersnatch, authorKey ?? BANDERSNATCH_ZERO_KEY, headerView.seal.materialize(), payload, encodeUnsealedHeader(headerView));
|
|
41891
42066
|
if (result.isError) {
|
|
41892
42067
|
return result_Result.error(SafroleSealError.IncorrectSeal);
|
|
41893
42068
|
}
|
|
41894
|
-
if (!id.isEqualTo(result.ok)) {
|
|
42069
|
+
if (ticket === undefined || !ticket.id.isEqualTo(result.ok)) {
|
|
41895
42070
|
return result_Result.error(SafroleSealError.InvalidTicket);
|
|
41896
42071
|
}
|
|
41897
42072
|
return result_Result.ok(result.ok);
|
|
41898
42073
|
}
|
|
41899
42074
|
/** Fallback mode of Safrole. */
|
|
41900
|
-
async verifySealWithKeys(keys,
|
|
42075
|
+
async verifySealWithKeys(keys, timeSlot, entropy, authorKey, headerView) {
|
|
41901
42076
|
const index = timeSlot % keys.length;
|
|
41902
|
-
const sealingKey = keys
|
|
41903
|
-
|
|
42077
|
+
const sealingKey = keys.at(index);
|
|
42078
|
+
const authorBandersnatchKey = authorKey.bandersnatch;
|
|
42079
|
+
if (sealingKey === undefined || !sealingKey.isEqualTo(authorBandersnatchKey)) {
|
|
41904
42080
|
return result_Result.error(SafroleSealError.InvalidValidator, `Invalid Validator. Expected: ${sealingKey}, got: ${authorKey.bandersnatch}`);
|
|
41905
42081
|
}
|
|
41906
42082
|
// verify seal correctness
|
|
41907
42083
|
const payload = bytes_BytesBlob.blobFromParts(JAM_FALLBACK_SEAL, entropy.raw);
|
|
41908
|
-
const
|
|
41909
|
-
const result = await bandersnatch_vrf.verifySeal(await this.bandersnatch, blockAuthorKey ?? BANDERSNATCH_ZERO_KEY, headerView.seal.materialize(), payload, encodeUnsealedHeader(headerView));
|
|
42084
|
+
const result = await bandersnatch_vrf.verifySeal(await this.bandersnatch, authorBandersnatchKey, headerView.seal.materialize(), payload, encodeUnsealedHeader(headerView));
|
|
41910
42085
|
if (result.isError) {
|
|
41911
42086
|
return result_Result.error(SafroleSealError.IncorrectSeal);
|
|
41912
42087
|
}
|
|
@@ -48103,7 +48278,7 @@ class Assign {
|
|
|
48103
48278
|
// NOTE: Here we know the core index is valid
|
|
48104
48279
|
const coreIndex = tryAsCoreIndex(Number(maybeCoreIndex));
|
|
48105
48280
|
const decoder = decoder_Decoder.fromBlob(res);
|
|
48106
|
-
const authQueue = decoder.sequenceFixLen(descriptors_codec.bytes(hash_HASH_SIZE), AUTHORIZATION_QUEUE_SIZE);
|
|
48281
|
+
const authQueue = decoder.sequenceFixLen(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE);
|
|
48107
48282
|
const fixedSizeAuthQueue = FixedSizeArray.new(authQueue, AUTHORIZATION_QUEUE_SIZE);
|
|
48108
48283
|
const result = this.partialState.updateAuthorizationQueue(coreIndex, fixedSizeAuthQueue, assigners);
|
|
48109
48284
|
if (result.isOk) {
|
|
@@ -48299,7 +48474,7 @@ class Checkpoint {
|
|
|
48299
48474
|
|
|
48300
48475
|
|
|
48301
48476
|
const designate_IN_OUT_REG = 7;
|
|
48302
|
-
const VALIDATOR_DATA_BYTES = tryAsExactBytes(
|
|
48477
|
+
const VALIDATOR_DATA_BYTES = tryAsExactBytes(validator_data_ValidatorData.Codec.sizeHint);
|
|
48303
48478
|
/**
|
|
48304
48479
|
* Designate a new set of validator keys.
|
|
48305
48480
|
*
|
|
@@ -48328,7 +48503,7 @@ class Designate {
|
|
|
48328
48503
|
return PvmExecution.Panic;
|
|
48329
48504
|
}
|
|
48330
48505
|
const decoder = decoder_Decoder.fromBlob(res);
|
|
48331
|
-
const validatorsData = decoder.sequenceFixLen(
|
|
48506
|
+
const validatorsData = decoder.sequenceFixLen(validator_data_ValidatorData.Codec, this.chainSpec.validatorsCount);
|
|
48332
48507
|
const result = this.partialState.updateValidatorsData(tryAsPerValidator(validatorsData, this.chainSpec));
|
|
48333
48508
|
if (result.isError) {
|
|
48334
48509
|
logger_logger.trace `DESIGNATE([${validatorsData[0]}, ${validatorsData[1]}, ...]) <- HUH`;
|
|
@@ -49984,9 +50159,10 @@ class Accumulate {
|
|
|
49984
50159
|
const recentlyAccumulated = tryAsPerEpochBlock(newRecentlyAccumulated, this.chainSpec);
|
|
49985
50160
|
const accumulationQueue = this.state.accumulationQueue.slice();
|
|
49986
50161
|
accumulationQueue[phaseIndex] = pruneQueue(toAccumulateLater, accumulatedSet);
|
|
50162
|
+
const timeslot = this.state.timeslot;
|
|
49987
50163
|
for (let i = 1; i < epochLength; i++) {
|
|
49988
50164
|
const queueIndex = (phaseIndex + epochLength - i) % epochLength;
|
|
49989
|
-
if (i < slot -
|
|
50165
|
+
if (i < slot - timeslot) {
|
|
49990
50166
|
accumulationQueue[queueIndex] = [];
|
|
49991
50167
|
}
|
|
49992
50168
|
else {
|
|
@@ -50198,7 +50374,6 @@ class DeferredTransfers {
|
|
|
50198
50374
|
|
|
50199
50375
|
|
|
50200
50376
|
|
|
50201
|
-
|
|
50202
50377
|
/**
|
|
50203
50378
|
* Maintain a list of available authorizations per core.
|
|
50204
50379
|
*
|
|
@@ -50227,11 +50402,12 @@ class Authorization {
|
|
|
50227
50402
|
*/
|
|
50228
50403
|
transition(input) {
|
|
50229
50404
|
const authPoolsUpdate = this.state.authPools.slice();
|
|
50405
|
+
const authQueues = this.state.authQueues;
|
|
50230
50406
|
// we transition authorizations for each core.
|
|
50231
50407
|
for (let coreIndex = tryAsCoreIndex(0); coreIndex < this.chainSpec.coresCount; coreIndex++) {
|
|
50232
50408
|
let pool = authPoolsUpdate[coreIndex].slice();
|
|
50233
50409
|
// the queue is only read (we should most likely use `ArrayView` here).
|
|
50234
|
-
const queue =
|
|
50410
|
+
const queue = authQueues[coreIndex];
|
|
50235
50411
|
// if there were any used hashes - remove them
|
|
50236
50412
|
const usedHashes = input.used.get(coreIndex);
|
|
50237
50413
|
if (usedHashes !== undefined) {
|
|
@@ -50405,14 +50581,18 @@ class RecentHistory {
|
|
|
50405
50581
|
* https://graypaper.fluffylabs.dev/#/1c979cb/0f55020f5502?v=0.7.1
|
|
50406
50582
|
*/
|
|
50407
50583
|
partialTransition(input) {
|
|
50408
|
-
const
|
|
50584
|
+
const stateBlocks = this.state.recentBlocks;
|
|
50585
|
+
const recentBlocks = stateBlocks.blocks.slice();
|
|
50409
50586
|
const lastState = recentBlocks.length > 0 ? recentBlocks[recentBlocks.length - 1] : null;
|
|
50410
50587
|
// update the posterior root of previous state.
|
|
50411
50588
|
if (lastState !== null) {
|
|
50412
50589
|
lastState.postStateRoot = input.priorStateRoot;
|
|
50413
50590
|
}
|
|
50414
50591
|
return {
|
|
50415
|
-
recentBlocks:
|
|
50592
|
+
recentBlocks: RecentBlocks.create({
|
|
50593
|
+
blocks: sized_array_asKnownSize(recentBlocks),
|
|
50594
|
+
accumulationLog: stateBlocks.accumulationLog,
|
|
50595
|
+
}), // β_H†
|
|
50416
50596
|
};
|
|
50417
50597
|
}
|
|
50418
50598
|
/**
|
|
@@ -50424,8 +50604,8 @@ class RecentHistory {
|
|
|
50424
50604
|
transition(input) {
|
|
50425
50605
|
const recentBlocks = input.partial.recentBlocks.blocks.slice();
|
|
50426
50606
|
// `β′_B`
|
|
50427
|
-
const mmr = this.state.recentBlocks.
|
|
50428
|
-
? MerkleMountainRange.fromPeaks(this.hasher, this.state.recentBlocks.
|
|
50607
|
+
const mmr = this.state.recentBlocks.accumulationLog !== null
|
|
50608
|
+
? MerkleMountainRange.fromPeaks(this.hasher, this.state.recentBlocks.accumulationLog)
|
|
50429
50609
|
: MerkleMountainRange.empty(this.hasher);
|
|
50430
50610
|
// append the accumulation root
|
|
50431
50611
|
mmr.append(input.accumulateRoot);
|
|
@@ -50443,7 +50623,7 @@ class RecentHistory {
|
|
|
50443
50623
|
}
|
|
50444
50624
|
// write back to the state.
|
|
50445
50625
|
return {
|
|
50446
|
-
recentBlocks:
|
|
50626
|
+
recentBlocks: RecentBlocks.create(RecentBlocks.create({
|
|
50447
50627
|
blocks: sized_array_asKnownSize(recentBlocks),
|
|
50448
50628
|
accumulationLog: peaks,
|
|
50449
50629
|
})),
|
|
@@ -50655,7 +50835,6 @@ function verifyReportsBasic(input) {
|
|
|
50655
50835
|
|
|
50656
50836
|
|
|
50657
50837
|
|
|
50658
|
-
|
|
50659
50838
|
const verify_contextual_logger = Logger.new(import.meta.filename, "stf:reports");
|
|
50660
50839
|
/** https://graypaper.fluffylabs.dev/#/7e6ff6a/15eb0115eb01?v=0.6.7 */
|
|
50661
50840
|
function verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge) {
|
|
@@ -50768,7 +50947,7 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
|
|
|
50768
50947
|
return result_Result.error(ReportsError.BadStateRoot, `Anchor state root mismatch. Got: ${context.stateRoot}, expected: ${recentBlock.postStateRoot}.`);
|
|
50769
50948
|
}
|
|
50770
50949
|
// check beefy root
|
|
50771
|
-
const beefyRoot =
|
|
50950
|
+
const beefyRoot = recentBlock.accumulationResult;
|
|
50772
50951
|
if (!beefyRoot.isEqualTo(context.beefyRoot)) {
|
|
50773
50952
|
return result_Result.error(ReportsError.BadBeefyMmrRoot, `Invalid BEEFY super peak hash. Got: ${context.beefyRoot}, expected: ${beefyRoot}. Anchor: ${recentBlock.headerHash}`);
|
|
50774
50953
|
}
|
|
@@ -51010,8 +51189,9 @@ function verifyPostSignatureChecks(input, availabilityAssignment, authPools, ser
|
|
|
51010
51189
|
* https://graypaper.fluffylabs.dev/#/5f542d7/15eb0015ed00
|
|
51011
51190
|
*/
|
|
51012
51191
|
const authorizerHash = report.authorizerHash;
|
|
51013
|
-
const authorizerPool = authPools
|
|
51014
|
-
|
|
51192
|
+
const authorizerPool = authPools.get(coreIndex);
|
|
51193
|
+
const pool = authorizerPool?.materialize() ?? [];
|
|
51194
|
+
if (pool.find((hash) => hash.isEqualTo(authorizerHash)) === undefined) {
|
|
51015
51195
|
return result_Result.error(ReportsError.CoreUnauthorized, `Authorizer hash not found in the pool of core ${coreIndex}: ${authorizerHash}`);
|
|
51016
51196
|
}
|
|
51017
51197
|
/**
|
|
@@ -51141,7 +51321,8 @@ class Reports {
|
|
|
51141
51321
|
return verifyCredentials(input.guarantees, workReportHashes, input.slot, (headerTimeSlot, guaranteeTimeSlot) => this.getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, input.newEntropy));
|
|
51142
51322
|
}
|
|
51143
51323
|
verifyPostSignatureChecks(input, assurancesAvailAssignment) {
|
|
51144
|
-
|
|
51324
|
+
const authPoolsView = this.state.view().authPoolsView();
|
|
51325
|
+
return verifyPostSignatureChecks(input, assurancesAvailAssignment, authPoolsView, (id) => this.state.getService(id));
|
|
51145
51326
|
}
|
|
51146
51327
|
verifyContextualValidity(input) {
|
|
51147
51328
|
return verifyContextualValidity(input, this.state, this.headerChain, this.chainSpec.maxLookupAnchorAge);
|