@typeberry/jam 0.2.0-e767e74 → 0.2.0
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 +867 -1046
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +904 -1088
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +800 -979
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +900 -1081
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-generator.mjs
CHANGED
|
@@ -4940,9 +4940,6 @@ class ObjectView {
|
|
|
4940
4940
|
toString() {
|
|
4941
4941
|
return `View<${this.materializedConstructor.name}>(cache: ${this.cache.size})`;
|
|
4942
4942
|
}
|
|
4943
|
-
[TEST_COMPARE_USING]() {
|
|
4944
|
-
return this.materialize();
|
|
4945
|
-
}
|
|
4946
4943
|
}
|
|
4947
4944
|
/**
|
|
4948
4945
|
* A lazy-evaluated decoder of a sequence.
|
|
@@ -5075,7 +5072,7 @@ const TYPICAL_DICTIONARY_LENGTH = 32;
|
|
|
5075
5072
|
* It's not true in a general case, but should be good enough for us.
|
|
5076
5073
|
*
|
|
5077
5074
|
*/
|
|
5078
|
-
function
|
|
5075
|
+
function readonlyArray(desc) {
|
|
5079
5076
|
return desc.convert((x) => {
|
|
5080
5077
|
debug_check `
|
|
5081
5078
|
${Array.isArray(x)}
|
|
@@ -5237,15 +5234,7 @@ var descriptors_codec;
|
|
|
5237
5234
|
/** Custom encoding / decoding logic. */
|
|
5238
5235
|
codec.custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
5239
5236
|
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
5240
|
-
codec.select = ({ name, sizeHint, }, chooser) =>
|
|
5241
|
-
const Self = chooser(null);
|
|
5242
|
-
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)
|
|
5243
|
-
? codec.select({
|
|
5244
|
-
name: Self.View.name,
|
|
5245
|
-
sizeHint: Self.View.sizeHint,
|
|
5246
|
-
}, (ctx) => chooser(ctx).View)
|
|
5247
|
-
: Self.View);
|
|
5248
|
-
};
|
|
5237
|
+
codec.select = ({ name, sizeHint, }, chooser) => 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), chooser(null).View);
|
|
5249
5238
|
/**
|
|
5250
5239
|
* A descriptor for a more complex POJO.
|
|
5251
5240
|
*
|
|
@@ -6067,7 +6056,7 @@ const BANDERSNATCH_KEY_BYTES = 32;
|
|
|
6067
6056
|
/** Bandersnatch VRF signature size */
|
|
6068
6057
|
const bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES = 96;
|
|
6069
6058
|
/** Bandersnatch ring commitment size */
|
|
6070
|
-
const
|
|
6059
|
+
const BANDERSNATCH_RING_ROOT_BYTES = 144;
|
|
6071
6060
|
/** Bandersnatch proof size */
|
|
6072
6061
|
const BANDERSNATCH_PROOF_BYTES = 784;
|
|
6073
6062
|
/** BLS public key size. */
|
|
@@ -7195,9 +7184,9 @@ function codecWithContext(chooser) {
|
|
|
7195
7184
|
/** Codec for a known-size array with length validation. */
|
|
7196
7185
|
const codecKnownSizeArray = (val, options, _id) => {
|
|
7197
7186
|
if ("fixedLength" in options) {
|
|
7198
|
-
return
|
|
7187
|
+
return readonlyArray(descriptors_codec.sequenceFixLen(val, options.fixedLength)).convert(seeThrough, sized_array_asKnownSize);
|
|
7199
7188
|
}
|
|
7200
|
-
return
|
|
7189
|
+
return readonlyArray(descriptors_codec.sequenceVarLen(val, options)).convert(seeThrough, sized_array_asKnownSize);
|
|
7201
7190
|
};
|
|
7202
7191
|
/** Codec for a fixed-size array with length validation. */
|
|
7203
7192
|
const codecFixedSizeArray = (val, len) => {
|
|
@@ -7334,7 +7323,7 @@ function tryAsPerValidator(array, spec) {
|
|
|
7334
7323
|
`;
|
|
7335
7324
|
return sized_array_asKnownSize(array);
|
|
7336
7325
|
}
|
|
7337
|
-
const
|
|
7326
|
+
const codecPerValidator = (val) => codecWithContext((context) => {
|
|
7338
7327
|
return codecKnownSizeArray(val, {
|
|
7339
7328
|
fixedLength: context.validatorsCount,
|
|
7340
7329
|
});
|
|
@@ -7461,7 +7450,7 @@ class Verdict extends WithDebug {
|
|
|
7461
7450
|
workReportHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
7462
7451
|
votesEpoch: descriptors_codec.u32.asOpaque(),
|
|
7463
7452
|
votes: codecWithContext((context) => {
|
|
7464
|
-
return
|
|
7453
|
+
return readonlyArray(descriptors_codec.sequenceFixLen(Judgement.Codec, context.validatorsSuperMajority)).convert(seeThrough, sized_array_asKnownSize);
|
|
7465
7454
|
}),
|
|
7466
7455
|
});
|
|
7467
7456
|
static create({ workReportHash, votesEpoch, votes }) {
|
|
@@ -8153,7 +8142,7 @@ const WorkReportCodec = descriptors_codec.Class(WorkReportNoCodec, {
|
|
|
8153
8142
|
authorizerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
8154
8143
|
authorizationGasUsed: descriptors_codec.varU64.asOpaque(),
|
|
8155
8144
|
authorizationOutput: descriptors_codec.blob,
|
|
8156
|
-
segmentRootLookup:
|
|
8145
|
+
segmentRootLookup: readonlyArray(descriptors_codec.sequenceVarLen(WorkPackageInfo.Codec)),
|
|
8157
8146
|
results: descriptors_codec.sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
8158
8147
|
});
|
|
8159
8148
|
const WorkReportCodecPre070 = descriptors_codec.Class(WorkReportNoCodec, {
|
|
@@ -8167,7 +8156,7 @@ const WorkReportCodecPre070 = descriptors_codec.Class(WorkReportNoCodec, {
|
|
|
8167
8156
|
}),
|
|
8168
8157
|
authorizerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
8169
8158
|
authorizationOutput: descriptors_codec.blob,
|
|
8170
|
-
segmentRootLookup:
|
|
8159
|
+
segmentRootLookup: readonlyArray(descriptors_codec.sequenceVarLen(WorkPackageInfo.Codec)),
|
|
8171
8160
|
results: descriptors_codec.sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
8172
8161
|
authorizationGasUsed: descriptors_codec.varU64.asOpaque(),
|
|
8173
8162
|
});
|
|
@@ -8285,16 +8274,16 @@ class SignedTicket extends WithDebug {
|
|
|
8285
8274
|
}
|
|
8286
8275
|
}
|
|
8287
8276
|
/** Anonymous? entry into the ticket contest. */
|
|
8288
|
-
class
|
|
8277
|
+
class Ticket extends WithDebug {
|
|
8289
8278
|
id;
|
|
8290
8279
|
attempt;
|
|
8291
|
-
static Codec = descriptors_codec.Class(
|
|
8280
|
+
static Codec = descriptors_codec.Class(Ticket, {
|
|
8292
8281
|
id: descriptors_codec.bytes(hash_HASH_SIZE),
|
|
8293
8282
|
// TODO [ToDr] we should verify that attempt is either 0|1|2.
|
|
8294
8283
|
attempt: descriptors_codec.u8.asOpaque(),
|
|
8295
8284
|
});
|
|
8296
8285
|
static create({ id, attempt }) {
|
|
8297
|
-
return new
|
|
8286
|
+
return new Ticket(id, attempt);
|
|
8298
8287
|
}
|
|
8299
8288
|
constructor(
|
|
8300
8289
|
/**
|
|
@@ -8363,7 +8352,7 @@ class ValidatorKeys extends WithDebug {
|
|
|
8363
8352
|
class TicketsMarker extends WithDebug {
|
|
8364
8353
|
tickets;
|
|
8365
8354
|
static Codec = descriptors_codec.Class(TicketsMarker, {
|
|
8366
|
-
tickets: codecPerEpochBlock(
|
|
8355
|
+
tickets: codecPerEpochBlock(Ticket.Codec),
|
|
8367
8356
|
});
|
|
8368
8357
|
static create({ tickets }) {
|
|
8369
8358
|
return new TicketsMarker(tickets);
|
|
@@ -8387,7 +8376,7 @@ class EpochMarker extends WithDebug {
|
|
|
8387
8376
|
static Codec = descriptors_codec.Class(EpochMarker, {
|
|
8388
8377
|
entropy: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
8389
8378
|
ticketsEntropy: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
8390
|
-
validators:
|
|
8379
|
+
validators: codecPerValidator(ValidatorKeys.Codec),
|
|
8391
8380
|
});
|
|
8392
8381
|
static create({ entropy, ticketsEntropy, validators }) {
|
|
8393
8382
|
return new EpochMarker(entropy, ticketsEntropy, validators);
|
|
@@ -8659,19 +8648,6 @@ function emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
|
8659
8648
|
});
|
|
8660
8649
|
}
|
|
8661
8650
|
|
|
8662
|
-
;// CONCATENATED MODULE: ./packages/jam/block/utils.ts
|
|
8663
|
-
|
|
8664
|
-
/**
|
|
8665
|
-
* Take an input data and re-encode that data as view.
|
|
8666
|
-
*
|
|
8667
|
-
* NOTE: this function should NEVER be used in any production code,
|
|
8668
|
-
* it's only a test helper.
|
|
8669
|
-
*/
|
|
8670
|
-
function reencodeAsView(codec, object, chainSpec) {
|
|
8671
|
-
const encoded = encoder_Encoder.encodeObject(codec, object, chainSpec);
|
|
8672
|
-
return decoder_Decoder.decodeObject(codec.View, encoded, chainSpec);
|
|
8673
|
-
}
|
|
8674
|
-
|
|
8675
8651
|
;// CONCATENATED MODULE: ./packages/jam/block/index.ts
|
|
8676
8652
|
|
|
8677
8653
|
|
|
@@ -8690,7 +8666,6 @@ function reencodeAsView(codec, object, chainSpec) {
|
|
|
8690
8666
|
|
|
8691
8667
|
|
|
8692
8668
|
|
|
8693
|
-
|
|
8694
8669
|
;// CONCATENATED MODULE: ./packages/jam/database-lmdb/blocks.ts
|
|
8695
8670
|
|
|
8696
8671
|
|
|
@@ -9042,128 +9017,10 @@ function accumulationOutputComparator(a, b) {
|
|
|
9042
9017
|
return Ordering.Equal;
|
|
9043
9018
|
}
|
|
9044
9019
|
|
|
9045
|
-
;// CONCATENATED MODULE: ./packages/jam/block/gp-constants.ts
|
|
9046
|
-
|
|
9047
|
-
/**
|
|
9048
|
-
* This file lists all of the constants defined in the GrayPaper appendix.
|
|
9049
|
-
*
|
|
9050
|
-
* NOTE: Avoid using the constants directly, prefer "named" constants defined
|
|
9051
|
-
* in a semantical proximity to where they are used.
|
|
9052
|
-
*
|
|
9053
|
-
* NOTE: This file will most likely be removed in the future. The constants
|
|
9054
|
-
* here are only temporarily for convenience. When we figure out better names
|
|
9055
|
-
* and places for these this file will be eradicated.
|
|
9056
|
-
*
|
|
9057
|
-
* https://graypaper.fluffylabs.dev/#/579bd12/413000413000
|
|
9058
|
-
*/
|
|
9059
|
-
/** `G_I`: The gas allocated to invoke a work-package’s Is-Authorized logic. */
|
|
9060
|
-
const G_I = 50_000_000;
|
|
9061
|
-
/** `I`: Maximum number of work items in a package. */
|
|
9062
|
-
const I = (/* unused pure expression or super */ null && (MAX_NUMBER_OF_WORK_ITEMS));
|
|
9063
|
-
/** `O`: Maximum number of items in the authorizations pool. */
|
|
9064
|
-
const O = 8;
|
|
9065
|
-
/** `Q`: The number of items in the authorizations queue. */
|
|
9066
|
-
const Q = 80;
|
|
9067
|
-
/** `S`: The maximum number of entries in the accumulation queue. */
|
|
9068
|
-
const S = 1024;
|
|
9069
|
-
/** `T`: The maximum number of extrinsics in a work-package. */
|
|
9070
|
-
const T = 128;
|
|
9071
|
-
/** `W_A`: The maximum size of is-authorized code in octets. */
|
|
9072
|
-
const W_A = 64_000;
|
|
9073
|
-
/** `W_B`: The maximum size of an encoded work-package with extrinsic data and imports. */
|
|
9074
|
-
const W_B = 13_794_305;
|
|
9075
|
-
/** `W_C`: The maximum size of service code in octets. */
|
|
9076
|
-
const W_C = 4_000_000;
|
|
9077
|
-
/** `W_M`: The maximum number of imports in a work-package. */
|
|
9078
|
-
const W_M = 3_072;
|
|
9079
|
-
/** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
|
|
9080
|
-
const W_R = 49_152;
|
|
9081
|
-
/** `W_T`: The size of a transfer memo in octets. */
|
|
9082
|
-
const W_T = 128;
|
|
9083
|
-
/** `W_M`: The maximum number of exports in a work-package. */
|
|
9084
|
-
const W_X = 3_072;
|
|
9085
|
-
// TODO [ToDr] Not sure where these should live yet :(
|
|
9086
|
-
/**
|
|
9087
|
-
* `S`: The minimum public service index.
|
|
9088
|
-
* Services of indices below these may only be created by the Registrar.
|
|
9089
|
-
*
|
|
9090
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/447a00447a00?v=0.7.2
|
|
9091
|
-
*/
|
|
9092
|
-
const MIN_PUBLIC_SERVICE_INDEX = (/* unused pure expression or super */ null && (2 ** 16));
|
|
9093
|
-
/**
|
|
9094
|
-
* `J`: The maximum sum of dependency items in a work-report.
|
|
9095
|
-
*
|
|
9096
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/416a00416a00?v=0.6.2
|
|
9097
|
-
*/
|
|
9098
|
-
const MAX_REPORT_DEPENDENCIES = 8;
|
|
9099
|
-
|
|
9100
|
-
;// CONCATENATED MODULE: ./packages/jam/state/accumulation-queue.ts
|
|
9101
|
-
|
|
9102
|
-
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
/**
|
|
9109
|
-
* Ready (i.e. available and/or audited) but not-yet-accumulated work-reports.
|
|
9110
|
-
*
|
|
9111
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/165300165400
|
|
9112
|
-
*/
|
|
9113
|
-
class NotYetAccumulatedReport extends WithDebug {
|
|
9114
|
-
report;
|
|
9115
|
-
dependencies;
|
|
9116
|
-
static Codec = descriptors_codec.Class(NotYetAccumulatedReport, {
|
|
9117
|
-
report: WorkReport.Codec,
|
|
9118
|
-
dependencies: codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
9119
|
-
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
9120
|
-
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
9121
|
-
minLength: 0,
|
|
9122
|
-
}),
|
|
9123
|
-
});
|
|
9124
|
-
static create({ report, dependencies }) {
|
|
9125
|
-
return new NotYetAccumulatedReport(report, dependencies);
|
|
9126
|
-
}
|
|
9127
|
-
constructor(
|
|
9128
|
-
/**
|
|
9129
|
-
* Each of these were made available at most one epoch ago
|
|
9130
|
-
* but have or had unfulfilled dependencies.
|
|
9131
|
-
*/
|
|
9132
|
-
report,
|
|
9133
|
-
/**
|
|
9134
|
-
* Alongside the work-report itself, we retain its un-accumulated
|
|
9135
|
-
* dependencies, a set of work-package hashes.
|
|
9136
|
-
*
|
|
9137
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/165800165800
|
|
9138
|
-
*/
|
|
9139
|
-
dependencies) {
|
|
9140
|
-
super();
|
|
9141
|
-
this.report = report;
|
|
9142
|
-
this.dependencies = dependencies;
|
|
9143
|
-
}
|
|
9144
|
-
}
|
|
9145
|
-
const accumulationQueueCodec = codecPerEpochBlock(descriptors_readonlyArray(descriptors_codec.sequenceVarLen(NotYetAccumulatedReport.Codec)));
|
|
9146
|
-
|
|
9147
|
-
;// CONCATENATED MODULE: ./packages/jam/state/common.ts
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
/** Check if given array has correct length before casting to the opaque type. */
|
|
9151
|
-
function tryAsPerCore(array, spec) {
|
|
9152
|
-
debug_check `
|
|
9153
|
-
${array.length === spec.coresCount}
|
|
9154
|
-
Invalid per-core array length. Expected ${spec.coresCount}, got: ${array.length}
|
|
9155
|
-
`;
|
|
9156
|
-
return opaque_asOpaqueType(array);
|
|
9157
|
-
}
|
|
9158
|
-
const codecPerCore = (val) => codecWithContext((context) => {
|
|
9159
|
-
return codecKnownSizeArray(val, { fixedLength: context.coresCount });
|
|
9160
|
-
});
|
|
9161
|
-
|
|
9162
9020
|
;// CONCATENATED MODULE: ./packages/jam/state/assurances.ts
|
|
9163
9021
|
|
|
9164
9022
|
|
|
9165
9023
|
|
|
9166
|
-
|
|
9167
9024
|
/**
|
|
9168
9025
|
* Assignment of particular work report to a core.
|
|
9169
9026
|
*
|
|
@@ -9192,30 +9049,27 @@ class AvailabilityAssignment extends WithDebug {
|
|
|
9192
9049
|
this.timeout = timeout;
|
|
9193
9050
|
}
|
|
9194
9051
|
}
|
|
9195
|
-
const availabilityAssignmentsCodec = codecPerCore(descriptors_codec.optional(AvailabilityAssignment.Codec));
|
|
9196
|
-
|
|
9197
|
-
;// CONCATENATED MODULE: ./packages/jam/state/auth.ts
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
9052
|
|
|
9053
|
+
;// CONCATENATED MODULE: ./packages/jam/state/common.ts
|
|
9201
9054
|
|
|
9202
9055
|
|
|
9203
|
-
/**
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9056
|
+
/** Check if given array has correct length before casting to the opaque type. */
|
|
9057
|
+
function tryAsPerCore(array, spec) {
|
|
9058
|
+
debug_check `
|
|
9059
|
+
${array.length === spec.coresCount}
|
|
9060
|
+
Invalid per-core array length. Expected ${spec.coresCount}, got: ${array.length}
|
|
9061
|
+
`;
|
|
9062
|
+
return opaque_asOpaqueType(array);
|
|
9063
|
+
}
|
|
9064
|
+
const codecPerCore = (val) => codecWithContext((context) => {
|
|
9065
|
+
return codecKnownSizeArray(val, { fixedLength: context.coresCount });
|
|
9066
|
+
});
|
|
9213
9067
|
|
|
9214
9068
|
;// CONCATENATED MODULE: ./packages/jam/state/disputes.ts
|
|
9215
9069
|
|
|
9216
9070
|
|
|
9217
9071
|
|
|
9218
|
-
const sortedSetCodec = () =>
|
|
9072
|
+
const sortedSetCodec = () => readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.bytes(hash_HASH_SIZE))).convert((input) => input.array, (output) => {
|
|
9219
9073
|
const typed = output.map((x) => x.asOpaque());
|
|
9220
9074
|
return SortedSet.fromSortedArray(hashComparator, typed);
|
|
9221
9075
|
});
|
|
@@ -9277,6 +9131,65 @@ function hashComparator(a, b) {
|
|
|
9277
9131
|
return a.compare(b);
|
|
9278
9132
|
}
|
|
9279
9133
|
|
|
9134
|
+
;// CONCATENATED MODULE: ./packages/jam/block/gp-constants.ts
|
|
9135
|
+
|
|
9136
|
+
/**
|
|
9137
|
+
* This file lists all of the constants defined in the GrayPaper appendix.
|
|
9138
|
+
*
|
|
9139
|
+
* NOTE: Avoid using the constants directly, prefer "named" constants defined
|
|
9140
|
+
* in a semantical proximity to where they are used.
|
|
9141
|
+
*
|
|
9142
|
+
* NOTE: This file will most likely be removed in the future. The constants
|
|
9143
|
+
* here are only temporarily for convenience. When we figure out better names
|
|
9144
|
+
* and places for these this file will be eradicated.
|
|
9145
|
+
*
|
|
9146
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/413000413000
|
|
9147
|
+
*/
|
|
9148
|
+
/** `G_I`: The gas allocated to invoke a work-package’s Is-Authorized logic. */
|
|
9149
|
+
const G_I = 50_000_000;
|
|
9150
|
+
/** `I`: Maximum number of work items in a package. */
|
|
9151
|
+
const I = (/* unused pure expression or super */ null && (MAX_NUMBER_OF_WORK_ITEMS));
|
|
9152
|
+
/** `O`: Maximum number of items in the authorizations pool. */
|
|
9153
|
+
const O = 8;
|
|
9154
|
+
/** `Q`: The number of items in the authorizations queue. */
|
|
9155
|
+
const Q = 80;
|
|
9156
|
+
/** `S`: The maximum number of entries in the accumulation queue. */
|
|
9157
|
+
const S = 1024;
|
|
9158
|
+
/** `T`: The maximum number of extrinsics in a work-package. */
|
|
9159
|
+
const T = 128;
|
|
9160
|
+
/** `W_A`: The maximum size of is-authorized code in octets. */
|
|
9161
|
+
const W_A = 64_000;
|
|
9162
|
+
/** `W_B`: The maximum size of an encoded work-package with extrinsic data and imports. */
|
|
9163
|
+
const W_B = 13_794_305;
|
|
9164
|
+
/** `W_C`: The maximum size of service code in octets. */
|
|
9165
|
+
const W_C = 4_000_000;
|
|
9166
|
+
/** `W_M`: The maximum number of imports in a work-package. */
|
|
9167
|
+
const W_M = 3_072;
|
|
9168
|
+
/** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
|
|
9169
|
+
const W_R = 49_152;
|
|
9170
|
+
/** `W_T`: The size of a transfer memo in octets. */
|
|
9171
|
+
const W_T = 128;
|
|
9172
|
+
/** `W_M`: The maximum number of exports in a work-package. */
|
|
9173
|
+
const W_X = 3_072;
|
|
9174
|
+
// TODO [ToDr] Not sure where these should live yet :(
|
|
9175
|
+
/**
|
|
9176
|
+
* `S`: The minimum public service index.
|
|
9177
|
+
* Services of indices below these may only be created by the Registrar.
|
|
9178
|
+
*
|
|
9179
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/447a00447a00?v=0.7.2
|
|
9180
|
+
*/
|
|
9181
|
+
const MIN_PUBLIC_SERVICE_INDEX = (/* unused pure expression or super */ null && (2 ** 16));
|
|
9182
|
+
/**
|
|
9183
|
+
* `J`: The maximum sum of dependency items in a work-report.
|
|
9184
|
+
*
|
|
9185
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/416a00416a00?v=0.6.2
|
|
9186
|
+
*/
|
|
9187
|
+
const MAX_REPORT_DEPENDENCIES = 8;
|
|
9188
|
+
/** `Q`: Size of the authorization queue. */
|
|
9189
|
+
const AUTHORIZATION_QUEUE_SIZE = Q;
|
|
9190
|
+
/** `O`: Maximal authorization pool size. */
|
|
9191
|
+
const MAX_AUTH_POOL_SIZE = O;
|
|
9192
|
+
|
|
9280
9193
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/ops/math-consts.ts
|
|
9281
9194
|
const MAX_VALUE = 4294967295;
|
|
9282
9195
|
const math_consts_MAX_VALUE_U64 = (/* unused pure expression or super */ null && (2n ** 63n));
|
|
@@ -9284,7 +9197,7 @@ const MIN_VALUE = (/* unused pure expression or super */ null && (-(2 ** 31)));
|
|
|
9284
9197
|
const MAX_SHIFT_U32 = 32;
|
|
9285
9198
|
const MAX_SHIFT_U64 = 64n;
|
|
9286
9199
|
|
|
9287
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
9200
|
+
;// CONCATENATED MODULE: ./packages/jam/state/service.ts
|
|
9288
9201
|
|
|
9289
9202
|
|
|
9290
9203
|
|
|
@@ -9292,259 +9205,15 @@ const MAX_SHIFT_U64 = 64n;
|
|
|
9292
9205
|
|
|
9293
9206
|
|
|
9294
9207
|
/**
|
|
9295
|
-
* `
|
|
9208
|
+
* `B_S`: The basic minimum balance which all services require.
|
|
9296
9209
|
*
|
|
9297
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
9210
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
9298
9211
|
*/
|
|
9299
|
-
const
|
|
9300
|
-
/** Recent history of a single block. */
|
|
9301
|
-
class BlockState extends WithDebug {
|
|
9302
|
-
headerHash;
|
|
9303
|
-
accumulationResult;
|
|
9304
|
-
postStateRoot;
|
|
9305
|
-
reported;
|
|
9306
|
-
static Codec = descriptors_codec.Class(BlockState, {
|
|
9307
|
-
headerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9308
|
-
accumulationResult: descriptors_codec.bytes(hash_HASH_SIZE),
|
|
9309
|
-
postStateRoot: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9310
|
-
reported: codecHashDictionary(WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
9311
|
-
});
|
|
9312
|
-
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
9313
|
-
return new BlockState(headerHash, accumulationResult, postStateRoot, reported);
|
|
9314
|
-
}
|
|
9315
|
-
constructor(
|
|
9316
|
-
/** Header hash. */
|
|
9317
|
-
headerHash,
|
|
9318
|
-
/** Merkle mountain belt of accumulation result. */
|
|
9319
|
-
accumulationResult,
|
|
9320
|
-
/** Posterior state root filled in with a 1-block delay. */
|
|
9321
|
-
postStateRoot,
|
|
9322
|
-
/** Reported work packages (no more than number of cores). */
|
|
9323
|
-
reported) {
|
|
9324
|
-
super();
|
|
9325
|
-
this.headerHash = headerHash;
|
|
9326
|
-
this.accumulationResult = accumulationResult;
|
|
9327
|
-
this.postStateRoot = postStateRoot;
|
|
9328
|
-
this.reported = reported;
|
|
9329
|
-
}
|
|
9330
|
-
}
|
|
9212
|
+
const BASE_SERVICE_BALANCE = 100n;
|
|
9331
9213
|
/**
|
|
9332
|
-
*
|
|
9214
|
+
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
9333
9215
|
*
|
|
9334
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/
|
|
9335
|
-
*/
|
|
9336
|
-
class RecentBlocks extends WithDebug {
|
|
9337
|
-
blocks;
|
|
9338
|
-
accumulationLog;
|
|
9339
|
-
static Codec = descriptors_codec.Class(RecentBlocks, {
|
|
9340
|
-
blocks: codecKnownSizeArray(BlockState.Codec, {
|
|
9341
|
-
minLength: 0,
|
|
9342
|
-
maxLength: MAX_RECENT_HISTORY,
|
|
9343
|
-
typicalLength: MAX_RECENT_HISTORY,
|
|
9344
|
-
}),
|
|
9345
|
-
accumulationLog: descriptors_codec.object({
|
|
9346
|
-
peaks: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.optional(descriptors_codec.bytes(hash_HASH_SIZE)))),
|
|
9347
|
-
}),
|
|
9348
|
-
});
|
|
9349
|
-
static empty() {
|
|
9350
|
-
return new RecentBlocks(sized_array_asKnownSize([]), {
|
|
9351
|
-
peaks: [],
|
|
9352
|
-
});
|
|
9353
|
-
}
|
|
9354
|
-
static create(a) {
|
|
9355
|
-
return new RecentBlocks(a.blocks, a.accumulationLog);
|
|
9356
|
-
}
|
|
9357
|
-
constructor(
|
|
9358
|
-
/**
|
|
9359
|
-
* Most recent blocks.
|
|
9360
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fea010fea01?v=0.6.7
|
|
9361
|
-
*/
|
|
9362
|
-
blocks,
|
|
9363
|
-
/**
|
|
9364
|
-
* Accumulation output log.
|
|
9365
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0f02020f0202?v=0.6.7
|
|
9366
|
-
*/
|
|
9367
|
-
accumulationLog) {
|
|
9368
|
-
super();
|
|
9369
|
-
this.blocks = blocks;
|
|
9370
|
-
this.accumulationLog = accumulationLog;
|
|
9371
|
-
}
|
|
9372
|
-
}
|
|
9373
|
-
|
|
9374
|
-
;// CONCATENATED MODULE: ./packages/jam/state/recently-accumulated.ts
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
const recentlyAccumulatedCodec = codecPerEpochBlock(descriptors_codec.sequenceVarLen(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x)));
|
|
9380
|
-
|
|
9381
|
-
;// CONCATENATED MODULE: ./packages/jam/state/validator-data.ts
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
/**
|
|
9387
|
-
* Fixed size of validator metadata.
|
|
9388
|
-
*
|
|
9389
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/0d55010d5501
|
|
9390
|
-
*/
|
|
9391
|
-
const VALIDATOR_META_BYTES = 128;
|
|
9392
|
-
/**
|
|
9393
|
-
* Details about validators' identity.
|
|
9394
|
-
*
|
|
9395
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/0d4b010d4c01
|
|
9396
|
-
*/
|
|
9397
|
-
class validator_data_ValidatorData extends WithDebug {
|
|
9398
|
-
bandersnatch;
|
|
9399
|
-
ed25519;
|
|
9400
|
-
bls;
|
|
9401
|
-
metadata;
|
|
9402
|
-
static Codec = descriptors_codec.Class(validator_data_ValidatorData, {
|
|
9403
|
-
bandersnatch: descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
9404
|
-
ed25519: descriptors_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
9405
|
-
bls: descriptors_codec.bytes(BLS_KEY_BYTES).asOpaque(),
|
|
9406
|
-
metadata: descriptors_codec.bytes(VALIDATOR_META_BYTES),
|
|
9407
|
-
});
|
|
9408
|
-
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
9409
|
-
return new validator_data_ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
9410
|
-
}
|
|
9411
|
-
constructor(
|
|
9412
|
-
/** Bandersnatch public key. */
|
|
9413
|
-
bandersnatch,
|
|
9414
|
-
/** ED25519 key data. */
|
|
9415
|
-
ed25519,
|
|
9416
|
-
/** BLS public key. */
|
|
9417
|
-
bls,
|
|
9418
|
-
/** Validator-defined additional metdata. */
|
|
9419
|
-
metadata) {
|
|
9420
|
-
super();
|
|
9421
|
-
this.bandersnatch = bandersnatch;
|
|
9422
|
-
this.ed25519 = ed25519;
|
|
9423
|
-
this.bls = bls;
|
|
9424
|
-
this.metadata = metadata;
|
|
9425
|
-
}
|
|
9426
|
-
}
|
|
9427
|
-
const validatorsDataCodec = common_codecPerValidator(validator_data_ValidatorData.Codec);
|
|
9428
|
-
|
|
9429
|
-
;// CONCATENATED MODULE: ./packages/jam/state/safrole-data.ts
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
var SafroleSealingKeysKind;
|
|
9442
|
-
(function (SafroleSealingKeysKind) {
|
|
9443
|
-
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
9444
|
-
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
9445
|
-
})(SafroleSealingKeysKind || (SafroleSealingKeysKind = {}));
|
|
9446
|
-
const codecBandersnatchKey = descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
9447
|
-
class safrole_data_SafroleSealingKeysData extends WithDebug {
|
|
9448
|
-
kind;
|
|
9449
|
-
keys;
|
|
9450
|
-
tickets;
|
|
9451
|
-
static Codec = codecWithContext((context) => {
|
|
9452
|
-
return descriptors_codec.custom({
|
|
9453
|
-
name: "SafroleSealingKeys",
|
|
9454
|
-
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
9455
|
-
}, (e, x) => {
|
|
9456
|
-
e.varU32(numbers_tryAsU32(x.kind));
|
|
9457
|
-
if (x.kind === SafroleSealingKeysKind.Keys) {
|
|
9458
|
-
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
9459
|
-
}
|
|
9460
|
-
else {
|
|
9461
|
-
e.sequenceFixLen(tickets_Ticket.Codec, x.tickets);
|
|
9462
|
-
}
|
|
9463
|
-
}, (d) => {
|
|
9464
|
-
const epochLength = context.epochLength;
|
|
9465
|
-
const kind = d.varU32();
|
|
9466
|
-
if (kind === SafroleSealingKeysKind.Keys) {
|
|
9467
|
-
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
9468
|
-
return safrole_data_SafroleSealingKeysData.keys(tryAsPerEpochBlock(keys, context));
|
|
9469
|
-
}
|
|
9470
|
-
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
9471
|
-
const tickets = d.sequenceFixLen(tickets_Ticket.Codec, epochLength);
|
|
9472
|
-
return safrole_data_SafroleSealingKeysData.tickets(tryAsPerEpochBlock(tickets, context));
|
|
9473
|
-
}
|
|
9474
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
9475
|
-
}, (s) => {
|
|
9476
|
-
const kind = s.decoder.varU32();
|
|
9477
|
-
if (kind === SafroleSealingKeysKind.Keys) {
|
|
9478
|
-
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
9479
|
-
return;
|
|
9480
|
-
}
|
|
9481
|
-
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
9482
|
-
s.sequenceFixLen(tickets_Ticket.Codec, context.epochLength);
|
|
9483
|
-
return;
|
|
9484
|
-
}
|
|
9485
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
9486
|
-
});
|
|
9487
|
-
});
|
|
9488
|
-
static keys(keys) {
|
|
9489
|
-
return new safrole_data_SafroleSealingKeysData(SafroleSealingKeysKind.Keys, keys, undefined);
|
|
9490
|
-
}
|
|
9491
|
-
static tickets(tickets) {
|
|
9492
|
-
return new safrole_data_SafroleSealingKeysData(SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
9493
|
-
}
|
|
9494
|
-
constructor(kind, keys, tickets) {
|
|
9495
|
-
super();
|
|
9496
|
-
this.kind = kind;
|
|
9497
|
-
this.keys = keys;
|
|
9498
|
-
this.tickets = tickets;
|
|
9499
|
-
}
|
|
9500
|
-
}
|
|
9501
|
-
class SafroleData {
|
|
9502
|
-
nextValidatorData;
|
|
9503
|
-
epochRoot;
|
|
9504
|
-
sealingKeySeries;
|
|
9505
|
-
ticketsAccumulator;
|
|
9506
|
-
static Codec = descriptors_codec.Class(SafroleData, {
|
|
9507
|
-
nextValidatorData: common_codecPerValidator(validator_data_ValidatorData.Codec),
|
|
9508
|
-
epochRoot: descriptors_codec.bytes(bandersnatch_BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
9509
|
-
sealingKeySeries: safrole_data_SafroleSealingKeysData.Codec,
|
|
9510
|
-
ticketsAccumulator: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(tickets_Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
9511
|
-
});
|
|
9512
|
-
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
9513
|
-
return new SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
9514
|
-
}
|
|
9515
|
-
constructor(
|
|
9516
|
-
/** gamma_k */
|
|
9517
|
-
nextValidatorData,
|
|
9518
|
-
/** gamma_z */
|
|
9519
|
-
epochRoot,
|
|
9520
|
-
/** gamma_s */
|
|
9521
|
-
sealingKeySeries,
|
|
9522
|
-
/** gamma_a */
|
|
9523
|
-
ticketsAccumulator) {
|
|
9524
|
-
this.nextValidatorData = nextValidatorData;
|
|
9525
|
-
this.epochRoot = epochRoot;
|
|
9526
|
-
this.sealingKeySeries = sealingKeySeries;
|
|
9527
|
-
this.ticketsAccumulator = ticketsAccumulator;
|
|
9528
|
-
}
|
|
9529
|
-
}
|
|
9530
|
-
|
|
9531
|
-
;// CONCATENATED MODULE: ./packages/jam/state/service.ts
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
/**
|
|
9539
|
-
* `B_S`: The basic minimum balance which all services require.
|
|
9540
|
-
*
|
|
9541
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
9542
|
-
*/
|
|
9543
|
-
const BASE_SERVICE_BALANCE = 100n;
|
|
9544
|
-
/**
|
|
9545
|
-
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
9546
|
-
*
|
|
9547
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445000445000?v=0.6.7
|
|
9216
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445000445000?v=0.6.7
|
|
9548
9217
|
*/
|
|
9549
9218
|
const ELECTIVE_ITEM_BALANCE = 10n;
|
|
9550
9219
|
/**
|
|
@@ -9718,418 +9387,358 @@ class service_LookupHistoryItem {
|
|
|
9718
9387
|
}
|
|
9719
9388
|
}
|
|
9720
9389
|
|
|
9721
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
9722
|
-
|
|
9390
|
+
;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
|
|
9723
9391
|
|
|
9724
9392
|
|
|
9725
9393
|
|
|
9726
9394
|
|
|
9727
9395
|
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
*/
|
|
9736
|
-
class ValidatorStatistics {
|
|
9737
|
-
blocks;
|
|
9738
|
-
tickets;
|
|
9739
|
-
preImages;
|
|
9740
|
-
preImagesSize;
|
|
9741
|
-
guarantees;
|
|
9742
|
-
assurances;
|
|
9743
|
-
static Codec = descriptors_codec.Class(ValidatorStatistics, {
|
|
9744
|
-
blocks: descriptors_codec.u32,
|
|
9745
|
-
tickets: descriptors_codec.u32,
|
|
9746
|
-
preImages: descriptors_codec.u32,
|
|
9747
|
-
preImagesSize: descriptors_codec.u32,
|
|
9748
|
-
guarantees: descriptors_codec.u32,
|
|
9749
|
-
assurances: descriptors_codec.u32,
|
|
9396
|
+
/** Dictionary entry of services that auto-accumulate every block. */
|
|
9397
|
+
class AutoAccumulate {
|
|
9398
|
+
service;
|
|
9399
|
+
gasLimit;
|
|
9400
|
+
static Codec = descriptors_codec.Class(AutoAccumulate, {
|
|
9401
|
+
service: descriptors_codec.u32.asOpaque(),
|
|
9402
|
+
gasLimit: descriptors_codec.u64.asOpaque(),
|
|
9750
9403
|
});
|
|
9751
|
-
static create({
|
|
9752
|
-
return new
|
|
9404
|
+
static create({ service, gasLimit }) {
|
|
9405
|
+
return new AutoAccumulate(service, gasLimit);
|
|
9753
9406
|
}
|
|
9754
9407
|
constructor(
|
|
9755
|
-
/**
|
|
9756
|
-
|
|
9757
|
-
/**
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
/** The total number of octets across all preimages introduced by the validator. */
|
|
9762
|
-
preImagesSize,
|
|
9763
|
-
/** The number of reports guaranteed by the validator. */
|
|
9764
|
-
guarantees,
|
|
9765
|
-
/** The number of availability assurances made by the validator. */
|
|
9766
|
-
assurances) {
|
|
9767
|
-
this.blocks = blocks;
|
|
9768
|
-
this.tickets = tickets;
|
|
9769
|
-
this.preImages = preImages;
|
|
9770
|
-
this.preImagesSize = preImagesSize;
|
|
9771
|
-
this.guarantees = guarantees;
|
|
9772
|
-
this.assurances = assurances;
|
|
9773
|
-
}
|
|
9774
|
-
static empty() {
|
|
9775
|
-
const zero = numbers_tryAsU32(0);
|
|
9776
|
-
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
9408
|
+
/** Service id that auto-accumulates. */
|
|
9409
|
+
service,
|
|
9410
|
+
/** Gas limit for auto-accumulation. */
|
|
9411
|
+
gasLimit) {
|
|
9412
|
+
this.service = service;
|
|
9413
|
+
this.gasLimit = gasLimit;
|
|
9777
9414
|
}
|
|
9778
9415
|
}
|
|
9779
|
-
const codecVarU16 = descriptors_codec.varU32.convert((i) => numbers_tryAsU32(i), (o) => numbers_tryAsU16(o));
|
|
9780
|
-
/** Encode/decode unsigned gas. */
|
|
9781
|
-
const codecVarGas = descriptors_codec.varU64.convert((g) => tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
9782
9416
|
/**
|
|
9783
|
-
*
|
|
9784
|
-
* Updated per block, based on incoming work reports (`w`).
|
|
9785
|
-
*
|
|
9786
|
-
* https://graypaper.fluffylabs.dev/#/68eaa1f/18f10318f103?v=0.6.4
|
|
9787
|
-
* https://github.com/gavofyork/graypaper/blob/9bffb08f3ea7b67832019176754df4fb36b9557d/text/statistics.tex#L65
|
|
9417
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
9788
9418
|
*/
|
|
9789
|
-
class
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
gasUsed: codecVarGas,
|
|
9808
|
-
})
|
|
9809
|
-
: descriptors_codec.Class(CoreStatistics, {
|
|
9810
|
-
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
9811
|
-
popularity: codecVarU16,
|
|
9812
|
-
imports: codecVarU16,
|
|
9813
|
-
exports: codecVarU16,
|
|
9814
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
9815
|
-
extrinsicCount: codecVarU16,
|
|
9816
|
-
bundleSize: descriptors_codec.varU32,
|
|
9817
|
-
gasUsed: codecVarGas,
|
|
9818
|
-
});
|
|
9819
|
-
static create(v) {
|
|
9820
|
-
return new CoreStatistics(v.dataAvailabilityLoad, v.popularity, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.bundleSize, v.gasUsed);
|
|
9419
|
+
class PrivilegedServices {
|
|
9420
|
+
manager;
|
|
9421
|
+
delegator;
|
|
9422
|
+
registrar;
|
|
9423
|
+
assigners;
|
|
9424
|
+
autoAccumulateServices;
|
|
9425
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
9426
|
+
static Codec = descriptors_codec.Class(PrivilegedServices, {
|
|
9427
|
+
manager: descriptors_codec.u32.asOpaque(),
|
|
9428
|
+
assigners: codecPerCore(descriptors_codec.u32.asOpaque()),
|
|
9429
|
+
delegator: descriptors_codec.u32.asOpaque(),
|
|
9430
|
+
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
9431
|
+
? descriptors_codec.u32.asOpaque()
|
|
9432
|
+
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
9433
|
+
autoAccumulateServices: readonlyArray(descriptors_codec.sequenceVarLen(AutoAccumulate.Codec)),
|
|
9434
|
+
});
|
|
9435
|
+
static create(a) {
|
|
9436
|
+
return new PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
9821
9437
|
}
|
|
9822
9438
|
constructor(
|
|
9823
|
-
/**
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
/**
|
|
9830
|
-
|
|
9831
|
-
/**
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
/**
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
this.
|
|
9842
|
-
this.
|
|
9843
|
-
this.
|
|
9844
|
-
this.
|
|
9845
|
-
this.
|
|
9846
|
-
this.gasUsed = gasUsed;
|
|
9847
|
-
}
|
|
9848
|
-
static empty() {
|
|
9849
|
-
const zero = numbers_tryAsU32(0);
|
|
9850
|
-
const zero16 = numbers_tryAsU16(0);
|
|
9851
|
-
const zeroGas = tryAsServiceGas(0);
|
|
9852
|
-
return new CoreStatistics(zero, zero16, zero16, zero16, zero, zero16, zero, zeroGas);
|
|
9439
|
+
/**
|
|
9440
|
+
* `χ_M`: Manages alteration of χ from block to block,
|
|
9441
|
+
* as well as bestow services with storage deposit credits.
|
|
9442
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111502111902?v=0.7.2
|
|
9443
|
+
*/
|
|
9444
|
+
manager,
|
|
9445
|
+
/** `χ_V`: Managers validator keys. */
|
|
9446
|
+
delegator,
|
|
9447
|
+
/**
|
|
9448
|
+
* `χ_R`: Manages the creation of services in protected range.
|
|
9449
|
+
*
|
|
9450
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111b02111d02?v=0.7.2
|
|
9451
|
+
*/
|
|
9452
|
+
registrar,
|
|
9453
|
+
/** `χ_A`: Manages authorization queue one for each core. */
|
|
9454
|
+
assigners,
|
|
9455
|
+
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
9456
|
+
autoAccumulateServices) {
|
|
9457
|
+
this.manager = manager;
|
|
9458
|
+
this.delegator = delegator;
|
|
9459
|
+
this.registrar = registrar;
|
|
9460
|
+
this.assigners = assigners;
|
|
9461
|
+
this.autoAccumulateServices = autoAccumulateServices;
|
|
9853
9462
|
}
|
|
9854
9463
|
}
|
|
9464
|
+
|
|
9465
|
+
;// CONCATENATED MODULE: ./packages/jam/state/recent-blocks.ts
|
|
9466
|
+
|
|
9467
|
+
|
|
9468
|
+
|
|
9469
|
+
|
|
9470
|
+
|
|
9471
|
+
|
|
9855
9472
|
/**
|
|
9856
|
-
*
|
|
9857
|
-
* Updated per block, based on available work reports (`W`).
|
|
9473
|
+
* `H = 8`: The size of recent history, in blocks.
|
|
9858
9474
|
*
|
|
9859
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
9475
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/416300416500
|
|
9860
9476
|
*/
|
|
9861
|
-
|
|
9862
|
-
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
onTransfersGasUsed;
|
|
9874
|
-
static Codec = Compatibility.selectIfGreaterOrEqual({
|
|
9875
|
-
fallback: descriptors_codec.Class(ServiceStatistics, {
|
|
9876
|
-
providedCount: codecVarU16,
|
|
9877
|
-
providedSize: descriptors_codec.varU32,
|
|
9878
|
-
refinementCount: descriptors_codec.varU32,
|
|
9879
|
-
refinementGasUsed: codecVarGas,
|
|
9880
|
-
imports: codecVarU16,
|
|
9881
|
-
exports: codecVarU16,
|
|
9882
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
9883
|
-
extrinsicCount: codecVarU16,
|
|
9884
|
-
accumulateCount: descriptors_codec.varU32,
|
|
9885
|
-
accumulateGasUsed: codecVarGas,
|
|
9886
|
-
onTransfersCount: descriptors_codec.varU32,
|
|
9887
|
-
onTransfersGasUsed: codecVarGas,
|
|
9888
|
-
}),
|
|
9889
|
-
versions: {
|
|
9890
|
-
[GpVersion.V0_7_0]: descriptors_codec.Class(ServiceStatistics, {
|
|
9891
|
-
providedCount: codecVarU16,
|
|
9892
|
-
providedSize: descriptors_codec.varU32,
|
|
9893
|
-
refinementCount: descriptors_codec.varU32,
|
|
9894
|
-
refinementGasUsed: codecVarGas,
|
|
9895
|
-
imports: codecVarU16,
|
|
9896
|
-
extrinsicCount: codecVarU16,
|
|
9897
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
9898
|
-
exports: codecVarU16,
|
|
9899
|
-
accumulateCount: descriptors_codec.varU32,
|
|
9900
|
-
accumulateGasUsed: codecVarGas,
|
|
9901
|
-
onTransfersCount: descriptors_codec.varU32,
|
|
9902
|
-
onTransfersGasUsed: codecVarGas,
|
|
9903
|
-
}),
|
|
9904
|
-
[GpVersion.V0_7_1]: descriptors_codec.Class(ServiceStatistics, {
|
|
9905
|
-
providedCount: codecVarU16,
|
|
9906
|
-
providedSize: descriptors_codec.varU32,
|
|
9907
|
-
refinementCount: descriptors_codec.varU32,
|
|
9908
|
-
refinementGasUsed: codecVarGas,
|
|
9909
|
-
imports: codecVarU16,
|
|
9910
|
-
extrinsicCount: codecVarU16,
|
|
9911
|
-
extrinsicSize: descriptors_codec.varU32,
|
|
9912
|
-
exports: codecVarU16,
|
|
9913
|
-
accumulateCount: descriptors_codec.varU32,
|
|
9914
|
-
accumulateGasUsed: codecVarGas,
|
|
9915
|
-
onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
|
|
9916
|
-
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
9917
|
-
}),
|
|
9918
|
-
},
|
|
9477
|
+
const MAX_RECENT_HISTORY = 8;
|
|
9478
|
+
/** Recent history of a single block. */
|
|
9479
|
+
class BlockState extends WithDebug {
|
|
9480
|
+
headerHash;
|
|
9481
|
+
accumulationResult;
|
|
9482
|
+
postStateRoot;
|
|
9483
|
+
reported;
|
|
9484
|
+
static Codec = descriptors_codec.Class(BlockState, {
|
|
9485
|
+
headerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9486
|
+
accumulationResult: descriptors_codec.bytes(hash_HASH_SIZE),
|
|
9487
|
+
postStateRoot: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
9488
|
+
reported: codecHashDictionary(WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
9919
9489
|
});
|
|
9920
|
-
static create(
|
|
9921
|
-
return new
|
|
9490
|
+
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
9491
|
+
return new BlockState(headerHash, accumulationResult, postStateRoot, reported);
|
|
9922
9492
|
}
|
|
9923
9493
|
constructor(
|
|
9924
|
-
/**
|
|
9925
|
-
|
|
9926
|
-
/**
|
|
9927
|
-
|
|
9928
|
-
/**
|
|
9929
|
-
|
|
9930
|
-
/**
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
extrinsicSize,
|
|
9938
|
-
/** `x` */
|
|
9939
|
-
extrinsicCount,
|
|
9940
|
-
/** `a.0` */
|
|
9941
|
-
accumulateCount,
|
|
9942
|
-
/** `a.1` */
|
|
9943
|
-
accumulateGasUsed,
|
|
9944
|
-
/** `t.0` @deprecated since 0.7.1 */
|
|
9945
|
-
onTransfersCount,
|
|
9946
|
-
/** `t.1` @deprecated since 0.7.1 */
|
|
9947
|
-
onTransfersGasUsed) {
|
|
9948
|
-
this.providedCount = providedCount;
|
|
9949
|
-
this.providedSize = providedSize;
|
|
9950
|
-
this.refinementCount = refinementCount;
|
|
9951
|
-
this.refinementGasUsed = refinementGasUsed;
|
|
9952
|
-
this.imports = imports;
|
|
9953
|
-
this.exports = exports;
|
|
9954
|
-
this.extrinsicSize = extrinsicSize;
|
|
9955
|
-
this.extrinsicCount = extrinsicCount;
|
|
9956
|
-
this.accumulateCount = accumulateCount;
|
|
9957
|
-
this.accumulateGasUsed = accumulateGasUsed;
|
|
9958
|
-
this.onTransfersCount = onTransfersCount;
|
|
9959
|
-
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
9494
|
+
/** Header hash. */
|
|
9495
|
+
headerHash,
|
|
9496
|
+
/** Merkle mountain belt of accumulation result. */
|
|
9497
|
+
accumulationResult,
|
|
9498
|
+
/** Posterior state root filled in with a 1-block delay. */
|
|
9499
|
+
postStateRoot,
|
|
9500
|
+
/** Reported work packages (no more than number of cores). */
|
|
9501
|
+
reported) {
|
|
9502
|
+
super();
|
|
9503
|
+
this.headerHash = headerHash;
|
|
9504
|
+
this.accumulationResult = accumulationResult;
|
|
9505
|
+
this.postStateRoot = postStateRoot;
|
|
9506
|
+
this.reported = reported;
|
|
9960
9507
|
}
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9508
|
+
}
|
|
9509
|
+
class RecentBlocks extends WithDebug {
|
|
9510
|
+
blocks;
|
|
9511
|
+
accumulationLog;
|
|
9512
|
+
static Codec = descriptors_codec.Class(RecentBlocks, {
|
|
9513
|
+
blocks: codecKnownSizeArray(BlockState.Codec, {
|
|
9514
|
+
minLength: 0,
|
|
9515
|
+
maxLength: MAX_RECENT_HISTORY,
|
|
9516
|
+
typicalLength: MAX_RECENT_HISTORY,
|
|
9517
|
+
}),
|
|
9518
|
+
accumulationLog: descriptors_codec.object({
|
|
9519
|
+
peaks: readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.optional(descriptors_codec.bytes(hash_HASH_SIZE)))),
|
|
9520
|
+
}),
|
|
9521
|
+
});
|
|
9522
|
+
static create(a) {
|
|
9523
|
+
return new RecentBlocks(a.blocks, a.accumulationLog);
|
|
9524
|
+
}
|
|
9525
|
+
constructor(
|
|
9526
|
+
/**
|
|
9527
|
+
* Most recent blocks.
|
|
9528
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fea010fea01?v=0.6.7
|
|
9529
|
+
*/
|
|
9530
|
+
blocks,
|
|
9531
|
+
/**
|
|
9532
|
+
* Accumulation output log.
|
|
9533
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0f02020f0202?v=0.6.7
|
|
9534
|
+
*/
|
|
9535
|
+
accumulationLog) {
|
|
9536
|
+
super();
|
|
9537
|
+
this.blocks = blocks;
|
|
9538
|
+
this.accumulationLog = accumulationLog;
|
|
9966
9539
|
}
|
|
9967
9540
|
}
|
|
9968
|
-
/**
|
|
9969
|
-
|
|
9541
|
+
/**
|
|
9542
|
+
* Recent history of blocks.
|
|
9543
|
+
*
|
|
9544
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fc9010fc901?v=0.6.7
|
|
9545
|
+
*/
|
|
9546
|
+
class RecentBlocksHistory extends WithDebug {
|
|
9970
9547
|
current;
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
previous: common_codecPerValidator(ValidatorStatistics.Codec),
|
|
9977
|
-
cores: codecPerCore(CoreStatistics.Codec),
|
|
9978
|
-
services: descriptors_codec.dictionary(codecServiceId, ServiceStatistics.Codec, {
|
|
9979
|
-
sortKeys: (a, b) => a - b,
|
|
9980
|
-
}),
|
|
9548
|
+
static Codec = Descriptor.new("RecentBlocksHistory", RecentBlocks.Codec.sizeHint, (encoder, value) => RecentBlocks.Codec.encode(encoder, value.asCurrent()), (decoder) => {
|
|
9549
|
+
const recentBlocks = RecentBlocks.Codec.decode(decoder);
|
|
9550
|
+
return RecentBlocksHistory.create(recentBlocks);
|
|
9551
|
+
}, (skip) => {
|
|
9552
|
+
return RecentBlocks.Codec.skip(skip);
|
|
9981
9553
|
});
|
|
9982
|
-
static create(
|
|
9983
|
-
return new
|
|
9554
|
+
static create(recentBlocks) {
|
|
9555
|
+
return new RecentBlocksHistory(recentBlocks);
|
|
9984
9556
|
}
|
|
9985
|
-
|
|
9557
|
+
static empty() {
|
|
9558
|
+
return RecentBlocksHistory.create(RecentBlocks.create({
|
|
9559
|
+
blocks: sized_array_asKnownSize([]),
|
|
9560
|
+
accumulationLog: { peaks: [] },
|
|
9561
|
+
}));
|
|
9562
|
+
}
|
|
9563
|
+
/**
|
|
9564
|
+
* Returns the block's BEEFY super peak.
|
|
9565
|
+
*/
|
|
9566
|
+
static accumulationResult(block) {
|
|
9567
|
+
return block.accumulationResult;
|
|
9568
|
+
}
|
|
9569
|
+
constructor(current) {
|
|
9570
|
+
super();
|
|
9986
9571
|
this.current = current;
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9572
|
+
}
|
|
9573
|
+
/** History of recent blocks with maximum size of `MAX_RECENT_HISTORY` */
|
|
9574
|
+
get blocks() {
|
|
9575
|
+
if (this.current !== null) {
|
|
9576
|
+
return this.current.blocks;
|
|
9577
|
+
}
|
|
9578
|
+
throw new Error("RecentBlocksHistory is in invalid state");
|
|
9579
|
+
}
|
|
9580
|
+
asCurrent() {
|
|
9581
|
+
if (this.current === null) {
|
|
9582
|
+
throw new Error("Cannot access current RecentBlocks format");
|
|
9583
|
+
}
|
|
9584
|
+
return this.current;
|
|
9585
|
+
}
|
|
9586
|
+
updateBlocks(blocks) {
|
|
9587
|
+
if (this.current !== null) {
|
|
9588
|
+
return RecentBlocksHistory.create(RecentBlocks.create({
|
|
9589
|
+
...this.current,
|
|
9590
|
+
blocks: opaque_asOpaqueType(blocks),
|
|
9591
|
+
}));
|
|
9592
|
+
}
|
|
9593
|
+
throw new Error("RecentBlocksHistory is in invalid state. Cannot be updated!");
|
|
9990
9594
|
}
|
|
9991
9595
|
}
|
|
9992
9596
|
|
|
9993
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
9597
|
+
;// CONCATENATED MODULE: ./packages/jam/state/validator-data.ts
|
|
9994
9598
|
|
|
9995
9599
|
|
|
9996
9600
|
|
|
9601
|
+
/**
|
|
9602
|
+
* Fixed size of validator metadata.
|
|
9603
|
+
*
|
|
9604
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/0d55010d5501
|
|
9605
|
+
*/
|
|
9606
|
+
const VALIDATOR_META_BYTES = 128;
|
|
9607
|
+
/**
|
|
9608
|
+
* Details about validators' identity.
|
|
9609
|
+
*
|
|
9610
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/0d4b010d4c01
|
|
9611
|
+
*/
|
|
9612
|
+
class ValidatorData extends WithDebug {
|
|
9613
|
+
bandersnatch;
|
|
9614
|
+
ed25519;
|
|
9615
|
+
bls;
|
|
9616
|
+
metadata;
|
|
9617
|
+
static Codec = descriptors_codec.Class(ValidatorData, {
|
|
9618
|
+
bandersnatch: descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
9619
|
+
ed25519: descriptors_codec.bytes(ED25519_KEY_BYTES).asOpaque(),
|
|
9620
|
+
bls: descriptors_codec.bytes(BLS_KEY_BYTES).asOpaque(),
|
|
9621
|
+
metadata: descriptors_codec.bytes(VALIDATOR_META_BYTES),
|
|
9622
|
+
});
|
|
9623
|
+
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
9624
|
+
return new ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
9625
|
+
}
|
|
9626
|
+
constructor(
|
|
9627
|
+
/** Bandersnatch public key. */
|
|
9628
|
+
bandersnatch,
|
|
9629
|
+
/** ED25519 key data. */
|
|
9630
|
+
ed25519,
|
|
9631
|
+
/** BLS public key. */
|
|
9632
|
+
bls,
|
|
9633
|
+
/** Validator-defined additional metdata. */
|
|
9634
|
+
metadata) {
|
|
9635
|
+
super();
|
|
9636
|
+
this.bandersnatch = bandersnatch;
|
|
9637
|
+
this.ed25519 = ed25519;
|
|
9638
|
+
this.bls = bls;
|
|
9639
|
+
this.metadata = metadata;
|
|
9640
|
+
}
|
|
9641
|
+
}
|
|
9997
9642
|
|
|
9643
|
+
;// CONCATENATED MODULE: ./packages/jam/state/safrole-data.ts
|
|
9998
9644
|
|
|
9999
9645
|
|
|
10000
9646
|
|
|
10001
9647
|
|
|
10002
9648
|
|
|
10003
9649
|
|
|
10004
|
-
class InMemoryStateView {
|
|
10005
|
-
chainSpec;
|
|
10006
|
-
state;
|
|
10007
|
-
constructor(chainSpec, state) {
|
|
10008
|
-
this.chainSpec = chainSpec;
|
|
10009
|
-
this.state = state;
|
|
10010
|
-
}
|
|
10011
|
-
availabilityAssignmentView() {
|
|
10012
|
-
return reencodeAsView(availabilityAssignmentsCodec, this.state.availabilityAssignment, this.chainSpec);
|
|
10013
|
-
}
|
|
10014
|
-
designatedValidatorDataView() {
|
|
10015
|
-
return reencodeAsView(validatorsDataCodec, this.state.designatedValidatorData, this.chainSpec);
|
|
10016
|
-
}
|
|
10017
|
-
currentValidatorDataView() {
|
|
10018
|
-
return reencodeAsView(validatorsDataCodec, this.state.currentValidatorData, this.chainSpec);
|
|
10019
|
-
}
|
|
10020
|
-
previousValidatorDataView() {
|
|
10021
|
-
return reencodeAsView(validatorsDataCodec, this.state.previousValidatorData, this.chainSpec);
|
|
10022
|
-
}
|
|
10023
|
-
authPoolsView() {
|
|
10024
|
-
return reencodeAsView(authPoolsCodec, this.state.authPools, this.chainSpec);
|
|
10025
|
-
}
|
|
10026
|
-
authQueuesView() {
|
|
10027
|
-
return reencodeAsView(authQueuesCodec, this.state.authQueues, this.chainSpec);
|
|
10028
|
-
}
|
|
10029
|
-
recentBlocksView() {
|
|
10030
|
-
return reencodeAsView(RecentBlocks.Codec, this.state.recentBlocks, this.chainSpec);
|
|
10031
|
-
}
|
|
10032
|
-
statisticsView() {
|
|
10033
|
-
return reencodeAsView(StatisticsData.Codec, this.state.statistics, this.chainSpec);
|
|
10034
|
-
}
|
|
10035
|
-
accumulationQueueView() {
|
|
10036
|
-
return reencodeAsView(accumulationQueueCodec, this.state.accumulationQueue, this.chainSpec);
|
|
10037
|
-
}
|
|
10038
|
-
recentlyAccumulatedView() {
|
|
10039
|
-
return reencodeAsView(recentlyAccumulatedCodec, this.state.recentlyAccumulated, this.chainSpec);
|
|
10040
|
-
}
|
|
10041
|
-
safroleDataView() {
|
|
10042
|
-
// TODO [ToDr] Consider exposting `safrole` from state
|
|
10043
|
-
// instead of individual fields
|
|
10044
|
-
const safrole = SafroleData.create({
|
|
10045
|
-
nextValidatorData: this.state.nextValidatorData,
|
|
10046
|
-
epochRoot: this.state.epochRoot,
|
|
10047
|
-
sealingKeySeries: this.state.sealingKeySeries,
|
|
10048
|
-
ticketsAccumulator: this.state.ticketsAccumulator,
|
|
10049
|
-
});
|
|
10050
|
-
return reencodeAsView(SafroleData.Codec, safrole, this.chainSpec);
|
|
10051
|
-
}
|
|
10052
|
-
getServiceInfoView(id) {
|
|
10053
|
-
const service = this.state.getService(id);
|
|
10054
|
-
if (service === null) {
|
|
10055
|
-
return null;
|
|
10056
|
-
}
|
|
10057
|
-
return reencodeAsView(ServiceAccountInfo.Codec, service.getInfo(), this.chainSpec);
|
|
10058
|
-
}
|
|
10059
|
-
}
|
|
10060
|
-
|
|
10061
|
-
;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
|
|
10062
9650
|
|
|
10063
9651
|
|
|
10064
9652
|
|
|
10065
9653
|
|
|
10066
9654
|
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
9655
|
+
var SafroleSealingKeysKind;
|
|
9656
|
+
(function (SafroleSealingKeysKind) {
|
|
9657
|
+
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
9658
|
+
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
9659
|
+
})(SafroleSealingKeysKind || (SafroleSealingKeysKind = {}));
|
|
9660
|
+
const codecBandersnatchKey = descriptors_codec.bytes(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
9661
|
+
class SafroleSealingKeysData extends WithDebug {
|
|
9662
|
+
kind;
|
|
9663
|
+
keys;
|
|
9664
|
+
tickets;
|
|
9665
|
+
static Codec = codecWithContext((context) => {
|
|
9666
|
+
return descriptors_codec.custom({
|
|
9667
|
+
name: "SafroleSealingKeys",
|
|
9668
|
+
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
9669
|
+
}, (e, x) => {
|
|
9670
|
+
e.varU32(numbers_tryAsU32(x.kind));
|
|
9671
|
+
if (x.kind === SafroleSealingKeysKind.Keys) {
|
|
9672
|
+
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
9673
|
+
}
|
|
9674
|
+
else {
|
|
9675
|
+
e.sequenceFixLen(Ticket.Codec, x.tickets);
|
|
9676
|
+
}
|
|
9677
|
+
}, (d) => {
|
|
9678
|
+
const epochLength = context.epochLength;
|
|
9679
|
+
const kind = d.varU32();
|
|
9680
|
+
if (kind === SafroleSealingKeysKind.Keys) {
|
|
9681
|
+
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
9682
|
+
return SafroleSealingKeysData.keys(tryAsPerEpochBlock(keys, context));
|
|
9683
|
+
}
|
|
9684
|
+
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
9685
|
+
const tickets = d.sequenceFixLen(Ticket.Codec, epochLength);
|
|
9686
|
+
return SafroleSealingKeysData.tickets(tryAsPerEpochBlock(tickets, context));
|
|
9687
|
+
}
|
|
9688
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
9689
|
+
}, (s) => {
|
|
9690
|
+
const kind = s.decoder.varU32();
|
|
9691
|
+
if (kind === SafroleSealingKeysKind.Keys) {
|
|
9692
|
+
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
9693
|
+
return;
|
|
9694
|
+
}
|
|
9695
|
+
if (kind === SafroleSealingKeysKind.Tickets) {
|
|
9696
|
+
s.sequenceFixLen(Ticket.Codec, context.epochLength);
|
|
9697
|
+
return;
|
|
9698
|
+
}
|
|
9699
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
9700
|
+
});
|
|
10074
9701
|
});
|
|
10075
|
-
static
|
|
10076
|
-
return new
|
|
9702
|
+
static keys(keys) {
|
|
9703
|
+
return new SafroleSealingKeysData(SafroleSealingKeysKind.Keys, keys, undefined);
|
|
10077
9704
|
}
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
this.
|
|
10084
|
-
this.
|
|
9705
|
+
static tickets(tickets) {
|
|
9706
|
+
return new SafroleSealingKeysData(SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
9707
|
+
}
|
|
9708
|
+
constructor(kind, keys, tickets) {
|
|
9709
|
+
super();
|
|
9710
|
+
this.kind = kind;
|
|
9711
|
+
this.keys = keys;
|
|
9712
|
+
this.tickets = tickets;
|
|
10085
9713
|
}
|
|
10086
9714
|
}
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
static Codec = descriptors_codec.Class(PrivilegedServices, {
|
|
10098
|
-
manager: descriptors_codec.u32.asOpaque(),
|
|
10099
|
-
assigners: codecPerCore(descriptors_codec.u32.asOpaque()),
|
|
10100
|
-
delegator: descriptors_codec.u32.asOpaque(),
|
|
10101
|
-
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
10102
|
-
? descriptors_codec.u32.asOpaque()
|
|
10103
|
-
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
10104
|
-
autoAccumulateServices: descriptors_readonlyArray(descriptors_codec.sequenceVarLen(AutoAccumulate.Codec)),
|
|
9715
|
+
class SafroleData {
|
|
9716
|
+
nextValidatorData;
|
|
9717
|
+
epochRoot;
|
|
9718
|
+
sealingKeySeries;
|
|
9719
|
+
ticketsAccumulator;
|
|
9720
|
+
static Codec = descriptors_codec.Class(SafroleData, {
|
|
9721
|
+
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
9722
|
+
epochRoot: descriptors_codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
9723
|
+
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
9724
|
+
ticketsAccumulator: readonlyArray(descriptors_codec.sequenceVarLen(Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
10105
9725
|
});
|
|
10106
|
-
static create(
|
|
10107
|
-
return new
|
|
9726
|
+
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
9727
|
+
return new SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
10108
9728
|
}
|
|
10109
9729
|
constructor(
|
|
10110
|
-
/**
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
/**
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
*/
|
|
10123
|
-
registrar,
|
|
10124
|
-
/** `χ_A`: Manages authorization queue one for each core. */
|
|
10125
|
-
assigners,
|
|
10126
|
-
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
10127
|
-
autoAccumulateServices) {
|
|
10128
|
-
this.manager = manager;
|
|
10129
|
-
this.delegator = delegator;
|
|
10130
|
-
this.registrar = registrar;
|
|
10131
|
-
this.assigners = assigners;
|
|
10132
|
-
this.autoAccumulateServices = autoAccumulateServices;
|
|
9730
|
+
/** gamma_k */
|
|
9731
|
+
nextValidatorData,
|
|
9732
|
+
/** gamma_z */
|
|
9733
|
+
epochRoot,
|
|
9734
|
+
/** gamma_s */
|
|
9735
|
+
sealingKeySeries,
|
|
9736
|
+
/** gamma_a */
|
|
9737
|
+
ticketsAccumulator) {
|
|
9738
|
+
this.nextValidatorData = nextValidatorData;
|
|
9739
|
+
this.epochRoot = epochRoot;
|
|
9740
|
+
this.sealingKeySeries = sealingKeySeries;
|
|
9741
|
+
this.ticketsAccumulator = ticketsAccumulator;
|
|
10133
9742
|
}
|
|
10134
9743
|
}
|
|
10135
9744
|
|
|
@@ -10254,43 +9863,315 @@ class UpdateService {
|
|
|
10254
9863
|
});
|
|
10255
9864
|
}
|
|
10256
9865
|
}
|
|
10257
|
-
/** Update service storage kind. */
|
|
10258
|
-
var UpdateStorageKind;
|
|
10259
|
-
(function (UpdateStorageKind) {
|
|
10260
|
-
/** Set a storage value. */
|
|
10261
|
-
UpdateStorageKind[UpdateStorageKind["Set"] = 0] = "Set";
|
|
10262
|
-
/** Remove a storage value. */
|
|
10263
|
-
UpdateStorageKind[UpdateStorageKind["Remove"] = 1] = "Remove";
|
|
10264
|
-
})(UpdateStorageKind || (UpdateStorageKind = {}));
|
|
9866
|
+
/** Update service storage kind. */
|
|
9867
|
+
var UpdateStorageKind;
|
|
9868
|
+
(function (UpdateStorageKind) {
|
|
9869
|
+
/** Set a storage value. */
|
|
9870
|
+
UpdateStorageKind[UpdateStorageKind["Set"] = 0] = "Set";
|
|
9871
|
+
/** Remove a storage value. */
|
|
9872
|
+
UpdateStorageKind[UpdateStorageKind["Remove"] = 1] = "Remove";
|
|
9873
|
+
})(UpdateStorageKind || (UpdateStorageKind = {}));
|
|
9874
|
+
/**
|
|
9875
|
+
* Update service storage item.
|
|
9876
|
+
*
|
|
9877
|
+
* Can either create/modify an entry or remove it.
|
|
9878
|
+
*/
|
|
9879
|
+
class UpdateStorage {
|
|
9880
|
+
serviceId;
|
|
9881
|
+
action;
|
|
9882
|
+
constructor(serviceId, action) {
|
|
9883
|
+
this.serviceId = serviceId;
|
|
9884
|
+
this.action = action;
|
|
9885
|
+
}
|
|
9886
|
+
static set({ serviceId, storage }) {
|
|
9887
|
+
return new UpdateStorage(serviceId, { kind: UpdateStorageKind.Set, storage });
|
|
9888
|
+
}
|
|
9889
|
+
static remove({ serviceId, key }) {
|
|
9890
|
+
return new UpdateStorage(serviceId, { kind: UpdateStorageKind.Remove, key });
|
|
9891
|
+
}
|
|
9892
|
+
get key() {
|
|
9893
|
+
if (this.action.kind === UpdateStorageKind.Remove) {
|
|
9894
|
+
return this.action.key;
|
|
9895
|
+
}
|
|
9896
|
+
return this.action.storage.key;
|
|
9897
|
+
}
|
|
9898
|
+
get value() {
|
|
9899
|
+
if (this.action.kind === UpdateStorageKind.Remove) {
|
|
9900
|
+
return null;
|
|
9901
|
+
}
|
|
9902
|
+
return this.action.storage.value;
|
|
9903
|
+
}
|
|
9904
|
+
}
|
|
9905
|
+
|
|
9906
|
+
;// CONCATENATED MODULE: ./packages/jam/state/statistics.ts
|
|
9907
|
+
|
|
9908
|
+
|
|
9909
|
+
|
|
9910
|
+
|
|
9911
|
+
|
|
9912
|
+
|
|
9913
|
+
const codecServiceId = Compatibility.isSuite(TestSuite.W3F_DAVXY) || Compatibility.isSuite(TestSuite.JAMDUNA, GpVersion.V0_6_7)
|
|
9914
|
+
? descriptors_codec.u32.asOpaque()
|
|
9915
|
+
: descriptors_codec.varU32.convert((s) => numbers_tryAsU32(s), (i) => tryAsServiceId(i));
|
|
9916
|
+
/**
|
|
9917
|
+
* Activity Record of a single validator.
|
|
9918
|
+
*
|
|
9919
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/183701183701
|
|
9920
|
+
*/
|
|
9921
|
+
class ValidatorStatistics {
|
|
9922
|
+
blocks;
|
|
9923
|
+
tickets;
|
|
9924
|
+
preImages;
|
|
9925
|
+
preImagesSize;
|
|
9926
|
+
guarantees;
|
|
9927
|
+
assurances;
|
|
9928
|
+
static Codec = descriptors_codec.Class(ValidatorStatistics, {
|
|
9929
|
+
blocks: descriptors_codec.u32,
|
|
9930
|
+
tickets: descriptors_codec.u32,
|
|
9931
|
+
preImages: descriptors_codec.u32,
|
|
9932
|
+
preImagesSize: descriptors_codec.u32,
|
|
9933
|
+
guarantees: descriptors_codec.u32,
|
|
9934
|
+
assurances: descriptors_codec.u32,
|
|
9935
|
+
});
|
|
9936
|
+
static create({ blocks, tickets, preImages, preImagesSize, guarantees, assurances, }) {
|
|
9937
|
+
return new ValidatorStatistics(blocks, tickets, preImages, preImagesSize, guarantees, assurances);
|
|
9938
|
+
}
|
|
9939
|
+
constructor(
|
|
9940
|
+
/** The number of blocks produced by the validator. */
|
|
9941
|
+
blocks,
|
|
9942
|
+
/** The number of tickets introduced by the validator. */
|
|
9943
|
+
tickets,
|
|
9944
|
+
/** The number of preimages introduced by the validator. */
|
|
9945
|
+
preImages,
|
|
9946
|
+
/** The total number of octets across all preimages introduced by the validator. */
|
|
9947
|
+
preImagesSize,
|
|
9948
|
+
/** The number of reports guaranteed by the validator. */
|
|
9949
|
+
guarantees,
|
|
9950
|
+
/** The number of availability assurances made by the validator. */
|
|
9951
|
+
assurances) {
|
|
9952
|
+
this.blocks = blocks;
|
|
9953
|
+
this.tickets = tickets;
|
|
9954
|
+
this.preImages = preImages;
|
|
9955
|
+
this.preImagesSize = preImagesSize;
|
|
9956
|
+
this.guarantees = guarantees;
|
|
9957
|
+
this.assurances = assurances;
|
|
9958
|
+
}
|
|
9959
|
+
static empty() {
|
|
9960
|
+
const zero = numbers_tryAsU32(0);
|
|
9961
|
+
return new ValidatorStatistics(zero, zero, zero, zero, zero, zero);
|
|
9962
|
+
}
|
|
9963
|
+
}
|
|
9964
|
+
const codecVarU16 = descriptors_codec.varU32.convert((i) => numbers_tryAsU32(i), (o) => numbers_tryAsU16(o));
|
|
9965
|
+
/** Encode/decode unsigned gas. */
|
|
9966
|
+
const codecVarGas = descriptors_codec.varU64.convert((g) => tryAsU64(g), (i) => tryAsServiceGas(i));
|
|
9967
|
+
/**
|
|
9968
|
+
* Single core statistics.
|
|
9969
|
+
* Updated per block, based on incoming work reports (`w`).
|
|
9970
|
+
*
|
|
9971
|
+
* https://graypaper.fluffylabs.dev/#/68eaa1f/18f10318f103?v=0.6.4
|
|
9972
|
+
* https://github.com/gavofyork/graypaper/blob/9bffb08f3ea7b67832019176754df4fb36b9557d/text/statistics.tex#L65
|
|
9973
|
+
*/
|
|
9974
|
+
class CoreStatistics {
|
|
9975
|
+
dataAvailabilityLoad;
|
|
9976
|
+
popularity;
|
|
9977
|
+
imports;
|
|
9978
|
+
exports;
|
|
9979
|
+
extrinsicSize;
|
|
9980
|
+
extrinsicCount;
|
|
9981
|
+
bundleSize;
|
|
9982
|
+
gasUsed;
|
|
9983
|
+
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
9984
|
+
? descriptors_codec.Class(CoreStatistics, {
|
|
9985
|
+
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
9986
|
+
popularity: codecVarU16,
|
|
9987
|
+
imports: codecVarU16,
|
|
9988
|
+
extrinsicCount: codecVarU16,
|
|
9989
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
9990
|
+
exports: codecVarU16,
|
|
9991
|
+
bundleSize: descriptors_codec.varU32,
|
|
9992
|
+
gasUsed: codecVarGas,
|
|
9993
|
+
})
|
|
9994
|
+
: descriptors_codec.Class(CoreStatistics, {
|
|
9995
|
+
dataAvailabilityLoad: descriptors_codec.varU32,
|
|
9996
|
+
popularity: codecVarU16,
|
|
9997
|
+
imports: codecVarU16,
|
|
9998
|
+
exports: codecVarU16,
|
|
9999
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
10000
|
+
extrinsicCount: codecVarU16,
|
|
10001
|
+
bundleSize: descriptors_codec.varU32,
|
|
10002
|
+
gasUsed: codecVarGas,
|
|
10003
|
+
});
|
|
10004
|
+
static create(v) {
|
|
10005
|
+
return new CoreStatistics(v.dataAvailabilityLoad, v.popularity, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.bundleSize, v.gasUsed);
|
|
10006
|
+
}
|
|
10007
|
+
constructor(
|
|
10008
|
+
/** `d` */
|
|
10009
|
+
dataAvailabilityLoad,
|
|
10010
|
+
/** `p` */
|
|
10011
|
+
popularity,
|
|
10012
|
+
/** `i` */
|
|
10013
|
+
imports,
|
|
10014
|
+
/** `e` */
|
|
10015
|
+
exports,
|
|
10016
|
+
/** `z` */
|
|
10017
|
+
extrinsicSize,
|
|
10018
|
+
/** `x` */
|
|
10019
|
+
extrinsicCount,
|
|
10020
|
+
/** `b` */
|
|
10021
|
+
bundleSize,
|
|
10022
|
+
/** `u` */
|
|
10023
|
+
gasUsed) {
|
|
10024
|
+
this.dataAvailabilityLoad = dataAvailabilityLoad;
|
|
10025
|
+
this.popularity = popularity;
|
|
10026
|
+
this.imports = imports;
|
|
10027
|
+
this.exports = exports;
|
|
10028
|
+
this.extrinsicSize = extrinsicSize;
|
|
10029
|
+
this.extrinsicCount = extrinsicCount;
|
|
10030
|
+
this.bundleSize = bundleSize;
|
|
10031
|
+
this.gasUsed = gasUsed;
|
|
10032
|
+
}
|
|
10033
|
+
static empty() {
|
|
10034
|
+
const zero = numbers_tryAsU32(0);
|
|
10035
|
+
const zero16 = numbers_tryAsU16(0);
|
|
10036
|
+
const zeroGas = tryAsServiceGas(0);
|
|
10037
|
+
return new CoreStatistics(zero, zero16, zero16, zero16, zero, zero16, zero, zeroGas);
|
|
10038
|
+
}
|
|
10039
|
+
}
|
|
10265
10040
|
/**
|
|
10266
|
-
*
|
|
10041
|
+
* Service statistics.
|
|
10042
|
+
* Updated per block, based on available work reports (`W`).
|
|
10267
10043
|
*
|
|
10268
|
-
*
|
|
10044
|
+
* https://graypaper.fluffylabs.dev/#/1c979cb/199802199802?v=0.7.1
|
|
10269
10045
|
*/
|
|
10270
|
-
class
|
|
10271
|
-
|
|
10272
|
-
|
|
10273
|
-
|
|
10274
|
-
|
|
10275
|
-
|
|
10046
|
+
class ServiceStatistics {
|
|
10047
|
+
providedCount;
|
|
10048
|
+
providedSize;
|
|
10049
|
+
refinementCount;
|
|
10050
|
+
refinementGasUsed;
|
|
10051
|
+
imports;
|
|
10052
|
+
exports;
|
|
10053
|
+
extrinsicSize;
|
|
10054
|
+
extrinsicCount;
|
|
10055
|
+
accumulateCount;
|
|
10056
|
+
accumulateGasUsed;
|
|
10057
|
+
onTransfersCount;
|
|
10058
|
+
onTransfersGasUsed;
|
|
10059
|
+
static Codec = Compatibility.selectIfGreaterOrEqual({
|
|
10060
|
+
fallback: descriptors_codec.Class(ServiceStatistics, {
|
|
10061
|
+
providedCount: codecVarU16,
|
|
10062
|
+
providedSize: descriptors_codec.varU32,
|
|
10063
|
+
refinementCount: descriptors_codec.varU32,
|
|
10064
|
+
refinementGasUsed: codecVarGas,
|
|
10065
|
+
imports: codecVarU16,
|
|
10066
|
+
exports: codecVarU16,
|
|
10067
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
10068
|
+
extrinsicCount: codecVarU16,
|
|
10069
|
+
accumulateCount: descriptors_codec.varU32,
|
|
10070
|
+
accumulateGasUsed: codecVarGas,
|
|
10071
|
+
onTransfersCount: descriptors_codec.varU32,
|
|
10072
|
+
onTransfersGasUsed: codecVarGas,
|
|
10073
|
+
}),
|
|
10074
|
+
versions: {
|
|
10075
|
+
[GpVersion.V0_7_0]: descriptors_codec.Class(ServiceStatistics, {
|
|
10076
|
+
providedCount: codecVarU16,
|
|
10077
|
+
providedSize: descriptors_codec.varU32,
|
|
10078
|
+
refinementCount: descriptors_codec.varU32,
|
|
10079
|
+
refinementGasUsed: codecVarGas,
|
|
10080
|
+
imports: codecVarU16,
|
|
10081
|
+
extrinsicCount: codecVarU16,
|
|
10082
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
10083
|
+
exports: codecVarU16,
|
|
10084
|
+
accumulateCount: descriptors_codec.varU32,
|
|
10085
|
+
accumulateGasUsed: codecVarGas,
|
|
10086
|
+
onTransfersCount: descriptors_codec.varU32,
|
|
10087
|
+
onTransfersGasUsed: codecVarGas,
|
|
10088
|
+
}),
|
|
10089
|
+
[GpVersion.V0_7_1]: descriptors_codec.Class(ServiceStatistics, {
|
|
10090
|
+
providedCount: codecVarU16,
|
|
10091
|
+
providedSize: descriptors_codec.varU32,
|
|
10092
|
+
refinementCount: descriptors_codec.varU32,
|
|
10093
|
+
refinementGasUsed: codecVarGas,
|
|
10094
|
+
imports: codecVarU16,
|
|
10095
|
+
extrinsicCount: codecVarU16,
|
|
10096
|
+
extrinsicSize: descriptors_codec.varU32,
|
|
10097
|
+
exports: codecVarU16,
|
|
10098
|
+
accumulateCount: descriptors_codec.varU32,
|
|
10099
|
+
accumulateGasUsed: codecVarGas,
|
|
10100
|
+
onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
|
|
10101
|
+
onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
|
|
10102
|
+
}),
|
|
10103
|
+
},
|
|
10104
|
+
});
|
|
10105
|
+
static create(v) {
|
|
10106
|
+
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);
|
|
10276
10107
|
}
|
|
10277
|
-
|
|
10278
|
-
|
|
10108
|
+
constructor(
|
|
10109
|
+
/** `p.0` */
|
|
10110
|
+
providedCount,
|
|
10111
|
+
/** `p.1` */
|
|
10112
|
+
providedSize,
|
|
10113
|
+
/** `r.0` */
|
|
10114
|
+
refinementCount,
|
|
10115
|
+
/** `r.1` */
|
|
10116
|
+
refinementGasUsed,
|
|
10117
|
+
/** `i` */
|
|
10118
|
+
imports,
|
|
10119
|
+
/** `e` */
|
|
10120
|
+
exports,
|
|
10121
|
+
/** `z` */
|
|
10122
|
+
extrinsicSize,
|
|
10123
|
+
/** `x` */
|
|
10124
|
+
extrinsicCount,
|
|
10125
|
+
/** `a.0` */
|
|
10126
|
+
accumulateCount,
|
|
10127
|
+
/** `a.1` */
|
|
10128
|
+
accumulateGasUsed,
|
|
10129
|
+
/** `t.0` @deprecated since 0.7.1 */
|
|
10130
|
+
onTransfersCount,
|
|
10131
|
+
/** `t.1` @deprecated since 0.7.1 */
|
|
10132
|
+
onTransfersGasUsed) {
|
|
10133
|
+
this.providedCount = providedCount;
|
|
10134
|
+
this.providedSize = providedSize;
|
|
10135
|
+
this.refinementCount = refinementCount;
|
|
10136
|
+
this.refinementGasUsed = refinementGasUsed;
|
|
10137
|
+
this.imports = imports;
|
|
10138
|
+
this.exports = exports;
|
|
10139
|
+
this.extrinsicSize = extrinsicSize;
|
|
10140
|
+
this.extrinsicCount = extrinsicCount;
|
|
10141
|
+
this.accumulateCount = accumulateCount;
|
|
10142
|
+
this.accumulateGasUsed = accumulateGasUsed;
|
|
10143
|
+
this.onTransfersCount = onTransfersCount;
|
|
10144
|
+
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
10279
10145
|
}
|
|
10280
|
-
static
|
|
10281
|
-
|
|
10146
|
+
static empty() {
|
|
10147
|
+
const zero = numbers_tryAsU32(0);
|
|
10148
|
+
const zero16 = numbers_tryAsU16(0);
|
|
10149
|
+
const zeroGas = tryAsServiceGas(0);
|
|
10150
|
+
return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas, zero, zeroGas);
|
|
10282
10151
|
}
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10152
|
+
}
|
|
10153
|
+
/** `pi`: Statistics of each validator, cores statistics and services statistics. */
|
|
10154
|
+
class StatisticsData {
|
|
10155
|
+
current;
|
|
10156
|
+
previous;
|
|
10157
|
+
cores;
|
|
10158
|
+
services;
|
|
10159
|
+
static Codec = descriptors_codec.Class(StatisticsData, {
|
|
10160
|
+
current: codecPerValidator(ValidatorStatistics.Codec),
|
|
10161
|
+
previous: codecPerValidator(ValidatorStatistics.Codec),
|
|
10162
|
+
cores: codecPerCore(CoreStatistics.Codec),
|
|
10163
|
+
services: descriptors_codec.dictionary(codecServiceId, ServiceStatistics.Codec, {
|
|
10164
|
+
sortKeys: (a, b) => a - b,
|
|
10165
|
+
}),
|
|
10166
|
+
});
|
|
10167
|
+
static create(v) {
|
|
10168
|
+
return new StatisticsData(v.current, v.previous, v.cores, v.services);
|
|
10288
10169
|
}
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10293
|
-
|
|
10170
|
+
constructor(current, previous, cores, services) {
|
|
10171
|
+
this.current = current;
|
|
10172
|
+
this.previous = previous;
|
|
10173
|
+
this.cores = cores;
|
|
10174
|
+
this.services = services;
|
|
10294
10175
|
}
|
|
10295
10176
|
}
|
|
10296
10177
|
|
|
@@ -10315,7 +10196,6 @@ class UpdateStorage {
|
|
|
10315
10196
|
|
|
10316
10197
|
|
|
10317
10198
|
|
|
10318
|
-
|
|
10319
10199
|
|
|
10320
10200
|
|
|
10321
10201
|
var in_memory_state_UpdateError;
|
|
@@ -10416,11 +10296,10 @@ class InMemoryService extends WithDebug {
|
|
|
10416
10296
|
/**
|
|
10417
10297
|
* A special version of state, stored fully in-memory.
|
|
10418
10298
|
*/
|
|
10419
|
-
class
|
|
10420
|
-
chainSpec;
|
|
10299
|
+
class InMemoryState extends WithDebug {
|
|
10421
10300
|
/** Create a new `InMemoryState` by providing all required fields. */
|
|
10422
|
-
static
|
|
10423
|
-
return new
|
|
10301
|
+
static create(state) {
|
|
10302
|
+
return new InMemoryState(state);
|
|
10424
10303
|
}
|
|
10425
10304
|
/**
|
|
10426
10305
|
* Create a new `InMemoryState` with a partial state override.
|
|
@@ -10429,14 +10308,14 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
10429
10308
|
* not-necessarily coherent values.
|
|
10430
10309
|
*/
|
|
10431
10310
|
static partial(spec, partial) {
|
|
10432
|
-
const state =
|
|
10311
|
+
const state = InMemoryState.empty(spec);
|
|
10433
10312
|
Object.assign(state, partial);
|
|
10434
10313
|
return state;
|
|
10435
10314
|
}
|
|
10436
10315
|
/**
|
|
10437
10316
|
* Create a new `InMemoryState` from some other state object.
|
|
10438
10317
|
*/
|
|
10439
|
-
static copyFrom(
|
|
10318
|
+
static copyFrom(other, servicesData) {
|
|
10440
10319
|
const services = new Map();
|
|
10441
10320
|
for (const [id, entries] of servicesData.entries()) {
|
|
10442
10321
|
const service = other.getService(id);
|
|
@@ -10446,7 +10325,7 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
10446
10325
|
const inMemService = InMemoryService.copyFrom(service, entries);
|
|
10447
10326
|
services.set(id, inMemService);
|
|
10448
10327
|
}
|
|
10449
|
-
return
|
|
10328
|
+
return InMemoryState.create({
|
|
10450
10329
|
availabilityAssignment: other.availabilityAssignment,
|
|
10451
10330
|
accumulationQueue: other.accumulationQueue,
|
|
10452
10331
|
designatedValidatorData: other.designatedValidatorData,
|
|
@@ -10643,9 +10522,8 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
10643
10522
|
getService(id) {
|
|
10644
10523
|
return this.services.get(id) ?? null;
|
|
10645
10524
|
}
|
|
10646
|
-
constructor(
|
|
10525
|
+
constructor(s) {
|
|
10647
10526
|
super();
|
|
10648
|
-
this.chainSpec = chainSpec;
|
|
10649
10527
|
this.availabilityAssignment = s.availabilityAssignment;
|
|
10650
10528
|
this.designatedValidatorData = s.designatedValidatorData;
|
|
10651
10529
|
this.nextValidatorData = s.nextValidatorData;
|
|
@@ -10667,34 +10545,31 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
10667
10545
|
this.accumulationOutputLog = s.accumulationOutputLog;
|
|
10668
10546
|
this.services = s.services;
|
|
10669
10547
|
}
|
|
10670
|
-
view() {
|
|
10671
|
-
return new InMemoryStateView(this.chainSpec, this);
|
|
10672
|
-
}
|
|
10673
10548
|
/**
|
|
10674
10549
|
* Create an empty and possibly incoherent `InMemoryState`.
|
|
10675
10550
|
*/
|
|
10676
10551
|
static empty(spec) {
|
|
10677
|
-
return new
|
|
10552
|
+
return new InMemoryState({
|
|
10678
10553
|
availabilityAssignment: tryAsPerCore(Array.from({ length: spec.coresCount }, () => null), spec),
|
|
10679
|
-
designatedValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
10554
|
+
designatedValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorData.create({
|
|
10680
10555
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
10681
10556
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
10682
10557
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
10683
10558
|
metadata: bytes_Bytes.zero(VALIDATOR_META_BYTES).asOpaque(),
|
|
10684
10559
|
})), spec),
|
|
10685
|
-
nextValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
10560
|
+
nextValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorData.create({
|
|
10686
10561
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
10687
10562
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
10688
10563
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
10689
10564
|
metadata: bytes_Bytes.zero(VALIDATOR_META_BYTES).asOpaque(),
|
|
10690
10565
|
})), spec),
|
|
10691
|
-
currentValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
10566
|
+
currentValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorData.create({
|
|
10692
10567
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
10693
10568
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
10694
10569
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
10695
10570
|
metadata: bytes_Bytes.zero(VALIDATOR_META_BYTES).asOpaque(),
|
|
10696
10571
|
})), spec),
|
|
10697
|
-
previousValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () =>
|
|
10572
|
+
previousValidatorData: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorData.create({
|
|
10698
10573
|
bandersnatch: bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
10699
10574
|
bls: bytes_Bytes.zero(BLS_KEY_BYTES).asOpaque(),
|
|
10700
10575
|
ed25519: bytes_Bytes.zero(ED25519_KEY_BYTES).asOpaque(),
|
|
@@ -10710,7 +10585,7 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
10710
10585
|
entropy: FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
10711
10586
|
authPools: tryAsPerCore(Array.from({ length: spec.coresCount }, () => sized_array_asKnownSize([])), spec),
|
|
10712
10587
|
authQueues: tryAsPerCore(Array.from({ length: spec.coresCount }, () => FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE)), spec),
|
|
10713
|
-
recentBlocks:
|
|
10588
|
+
recentBlocks: RecentBlocksHistory.empty(),
|
|
10714
10589
|
statistics: StatisticsData.create({
|
|
10715
10590
|
current: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorStatistics.empty()), spec),
|
|
10716
10591
|
previous: tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => ValidatorStatistics.empty()), spec),
|
|
@@ -10720,8 +10595,8 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
10720
10595
|
accumulationQueue: tryAsPerEpochBlock(Array.from({ length: spec.epochLength }, () => []), spec),
|
|
10721
10596
|
recentlyAccumulated: tryAsPerEpochBlock(Array.from({ length: spec.epochLength }, () => HashSet.new()), spec),
|
|
10722
10597
|
ticketsAccumulator: sized_array_asKnownSize([]),
|
|
10723
|
-
sealingKeySeries:
|
|
10724
|
-
epochRoot: bytes_Bytes.zero(
|
|
10598
|
+
sealingKeySeries: SafroleSealingKeysData.keys(tryAsPerEpochBlock(Array.from({ length: spec.epochLength }, () => bytes_Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque()), spec)),
|
|
10599
|
+
epochRoot: bytes_Bytes.zero(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
10725
10600
|
privilegedServices: PrivilegedServices.create({
|
|
10726
10601
|
manager: tryAsServiceId(0),
|
|
10727
10602
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
@@ -10761,9 +10636,50 @@ const serviceDataCodec = descriptors_codec.dictionary(descriptors_codec.u32.asOp
|
|
|
10761
10636
|
|
|
10762
10637
|
|
|
10763
10638
|
|
|
10639
|
+
;// CONCATENATED MODULE: ./packages/jam/state/not-yet-accumulated.ts
|
|
10640
|
+
|
|
10641
|
+
|
|
10642
|
+
|
|
10764
10643
|
|
|
10765
10644
|
|
|
10766
10645
|
|
|
10646
|
+
/**
|
|
10647
|
+
* Ready (i.e. available and/or audited) but not-yet-accumulated work-reports.
|
|
10648
|
+
*
|
|
10649
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/165300165400
|
|
10650
|
+
*/
|
|
10651
|
+
class NotYetAccumulatedReport extends WithDebug {
|
|
10652
|
+
report;
|
|
10653
|
+
dependencies;
|
|
10654
|
+
static Codec = descriptors_codec.Class(NotYetAccumulatedReport, {
|
|
10655
|
+
report: WorkReport.Codec,
|
|
10656
|
+
dependencies: codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
10657
|
+
typicalLength: MAX_REPORT_DEPENDENCIES / 2,
|
|
10658
|
+
maxLength: MAX_REPORT_DEPENDENCIES,
|
|
10659
|
+
minLength: 0,
|
|
10660
|
+
}),
|
|
10661
|
+
});
|
|
10662
|
+
static create({ report, dependencies }) {
|
|
10663
|
+
return new NotYetAccumulatedReport(report, dependencies);
|
|
10664
|
+
}
|
|
10665
|
+
constructor(
|
|
10666
|
+
/**
|
|
10667
|
+
* Each of these were made available at most one epoch ago
|
|
10668
|
+
* but have or had unfulfilled dependencies.
|
|
10669
|
+
*/
|
|
10670
|
+
report,
|
|
10671
|
+
/**
|
|
10672
|
+
* Alongside the work-report itself, we retain its un-accumulated
|
|
10673
|
+
* dependencies, a set of work-package hashes.
|
|
10674
|
+
*
|
|
10675
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/165800165800
|
|
10676
|
+
*/
|
|
10677
|
+
dependencies) {
|
|
10678
|
+
super();
|
|
10679
|
+
this.report = report;
|
|
10680
|
+
this.dependencies = dependencies;
|
|
10681
|
+
}
|
|
10682
|
+
}
|
|
10767
10683
|
|
|
10768
10684
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialize.ts
|
|
10769
10685
|
|
|
@@ -10777,19 +10693,26 @@ const serviceDataCodec = descriptors_codec.dictionary(descriptors_codec.u32.asOp
|
|
|
10777
10693
|
|
|
10778
10694
|
|
|
10779
10695
|
|
|
10696
|
+
|
|
10697
|
+
|
|
10698
|
+
|
|
10780
10699
|
/** Serialization for particular state entries. */
|
|
10781
|
-
var
|
|
10700
|
+
var serialize;
|
|
10782
10701
|
(function (serialize) {
|
|
10783
10702
|
/** C(1): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b15013b1501?v=0.6.7 */
|
|
10784
10703
|
serialize.authPools = {
|
|
10785
10704
|
key: stateKeys.index(StateKeyIdx.Alpha),
|
|
10786
|
-
Codec:
|
|
10705
|
+
Codec: codecPerCore(codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
10706
|
+
minLength: 0,
|
|
10707
|
+
maxLength: MAX_AUTH_POOL_SIZE,
|
|
10708
|
+
typicalLength: MAX_AUTH_POOL_SIZE,
|
|
10709
|
+
})),
|
|
10787
10710
|
extract: (s) => s.authPools,
|
|
10788
10711
|
};
|
|
10789
10712
|
/** C(2): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b31013b3101?v=0.6.7 */
|
|
10790
10713
|
serialize.authQueues = {
|
|
10791
10714
|
key: stateKeys.index(StateKeyIdx.Phi),
|
|
10792
|
-
Codec:
|
|
10715
|
+
Codec: codecPerCore(codecFixedSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), AUTHORIZATION_QUEUE_SIZE)),
|
|
10793
10716
|
extract: (s) => s.authQueues,
|
|
10794
10717
|
};
|
|
10795
10718
|
/**
|
|
@@ -10798,7 +10721,7 @@ var serialize_serialize;
|
|
|
10798
10721
|
*/
|
|
10799
10722
|
serialize.recentBlocks = {
|
|
10800
10723
|
key: stateKeys.index(StateKeyIdx.Beta),
|
|
10801
|
-
Codec:
|
|
10724
|
+
Codec: RecentBlocksHistory.Codec,
|
|
10802
10725
|
extract: (s) => s.recentBlocks,
|
|
10803
10726
|
};
|
|
10804
10727
|
/** C(4): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b63013b6301?v=0.6.7 */
|
|
@@ -10827,25 +10750,25 @@ var serialize_serialize;
|
|
|
10827
10750
|
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
10828
10751
|
serialize.designatedValidators = {
|
|
10829
10752
|
key: stateKeys.index(StateKeyIdx.Iota),
|
|
10830
|
-
Codec:
|
|
10753
|
+
Codec: codecPerValidator(ValidatorData.Codec),
|
|
10831
10754
|
extract: (s) => s.designatedValidatorData,
|
|
10832
10755
|
};
|
|
10833
10756
|
/** C(8): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b0d023b0d02?v=0.6.7 */
|
|
10834
10757
|
serialize.currentValidators = {
|
|
10835
10758
|
key: stateKeys.index(StateKeyIdx.Kappa),
|
|
10836
|
-
Codec:
|
|
10759
|
+
Codec: codecPerValidator(ValidatorData.Codec),
|
|
10837
10760
|
extract: (s) => s.currentValidatorData,
|
|
10838
10761
|
};
|
|
10839
10762
|
/** C(9): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b1a023b1a02?v=0.6.7 */
|
|
10840
10763
|
serialize.previousValidators = {
|
|
10841
10764
|
key: stateKeys.index(StateKeyIdx.Lambda),
|
|
10842
|
-
Codec:
|
|
10765
|
+
Codec: codecPerValidator(ValidatorData.Codec),
|
|
10843
10766
|
extract: (s) => s.previousValidatorData,
|
|
10844
10767
|
};
|
|
10845
10768
|
/** C(10): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b27023b2702?v=0.6.7 */
|
|
10846
10769
|
serialize.availabilityAssignment = {
|
|
10847
10770
|
key: stateKeys.index(StateKeyIdx.Rho),
|
|
10848
|
-
Codec:
|
|
10771
|
+
Codec: codecPerCore(descriptors_codec.optional(AvailabilityAssignment.Codec)),
|
|
10849
10772
|
extract: (s) => s.availabilityAssignment,
|
|
10850
10773
|
};
|
|
10851
10774
|
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
@@ -10869,13 +10792,13 @@ var serialize_serialize;
|
|
|
10869
10792
|
/** C(14): https://graypaper.fluffylabs.dev/#/1c979cb/3bf0023bf002?v=0.7.1 */
|
|
10870
10793
|
serialize.accumulationQueue = {
|
|
10871
10794
|
key: stateKeys.index(StateKeyIdx.Omega),
|
|
10872
|
-
Codec:
|
|
10795
|
+
Codec: codecPerEpochBlock(readonlyArray(descriptors_codec.sequenceVarLen(NotYetAccumulatedReport.Codec))),
|
|
10873
10796
|
extract: (s) => s.accumulationQueue,
|
|
10874
10797
|
};
|
|
10875
10798
|
/** C(15): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b96023b9602?v=0.6.7 */
|
|
10876
10799
|
serialize.recentlyAccumulated = {
|
|
10877
10800
|
key: stateKeys.index(StateKeyIdx.Xi),
|
|
10878
|
-
Codec:
|
|
10801
|
+
Codec: codecPerEpochBlock(descriptors_codec.sequenceVarLen(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => HashSet.from(x))),
|
|
10879
10802
|
extract: (s) => s.recentlyAccumulated,
|
|
10880
10803
|
};
|
|
10881
10804
|
/** C(16): https://graypaper.fluffylabs.dev/#/38c4e62/3b46033b4603?v=0.7.0 */
|
|
@@ -10904,9 +10827,9 @@ var serialize_serialize;
|
|
|
10904
10827
|
/** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
|
|
10905
10828
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
10906
10829
|
key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
|
|
10907
|
-
Codec:
|
|
10830
|
+
Codec: readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.u32)),
|
|
10908
10831
|
});
|
|
10909
|
-
})(
|
|
10832
|
+
})(serialize || (serialize = {}));
|
|
10910
10833
|
/**
|
|
10911
10834
|
* Just dump the entire terminal blob as-is.
|
|
10912
10835
|
*
|
|
@@ -10916,87 +10839,6 @@ var serialize_serialize;
|
|
|
10916
10839
|
*/
|
|
10917
10840
|
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()));
|
|
10918
10841
|
|
|
10919
|
-
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state-view.ts
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
class SerializedStateView {
|
|
10923
|
-
spec;
|
|
10924
|
-
backend;
|
|
10925
|
-
recentlyUsedServices;
|
|
10926
|
-
viewCache;
|
|
10927
|
-
constructor(spec, backend,
|
|
10928
|
-
/** Best-effort list of recently active services. */
|
|
10929
|
-
recentlyUsedServices, viewCache) {
|
|
10930
|
-
this.spec = spec;
|
|
10931
|
-
this.backend = backend;
|
|
10932
|
-
this.recentlyUsedServices = recentlyUsedServices;
|
|
10933
|
-
this.viewCache = viewCache;
|
|
10934
|
-
}
|
|
10935
|
-
retrieveView({ key, Codec }, description) {
|
|
10936
|
-
const cached = this.viewCache.get(key);
|
|
10937
|
-
if (cached !== undefined) {
|
|
10938
|
-
return cached;
|
|
10939
|
-
}
|
|
10940
|
-
const bytes = this.backend.get(key);
|
|
10941
|
-
if (bytes === null) {
|
|
10942
|
-
throw new Error(`Required state entry for ${description} is missing!. Accessing view of key: ${key}`);
|
|
10943
|
-
}
|
|
10944
|
-
// NOTE [ToDr] we are not using `Decoder.decodeObject` here because
|
|
10945
|
-
// it needs to get to the end of the data (skip), yet that's expensive.
|
|
10946
|
-
// we assume that the state data is correct and coherent anyway, so
|
|
10947
|
-
// for performance reasons we simply create the view here.
|
|
10948
|
-
const d = decoder_Decoder.fromBytesBlob(bytes);
|
|
10949
|
-
d.attachContext(this.spec);
|
|
10950
|
-
const view = Codec.View.decode(d);
|
|
10951
|
-
this.viewCache.set(key, view);
|
|
10952
|
-
return view;
|
|
10953
|
-
}
|
|
10954
|
-
availabilityAssignmentView() {
|
|
10955
|
-
return this.retrieveView(serialize_serialize.availabilityAssignment, "availabilityAssignmentView");
|
|
10956
|
-
}
|
|
10957
|
-
designatedValidatorDataView() {
|
|
10958
|
-
return this.retrieveView(serialize_serialize.designatedValidators, "designatedValidatorsView");
|
|
10959
|
-
}
|
|
10960
|
-
currentValidatorDataView() {
|
|
10961
|
-
return this.retrieveView(serialize_serialize.currentValidators, "currentValidatorsView");
|
|
10962
|
-
}
|
|
10963
|
-
previousValidatorDataView() {
|
|
10964
|
-
return this.retrieveView(serialize_serialize.previousValidators, "previousValidatorsView");
|
|
10965
|
-
}
|
|
10966
|
-
authPoolsView() {
|
|
10967
|
-
return this.retrieveView(serialize_serialize.authPools, "authPoolsView");
|
|
10968
|
-
}
|
|
10969
|
-
authQueuesView() {
|
|
10970
|
-
return this.retrieveView(serialize_serialize.authQueues, "authQueuesView");
|
|
10971
|
-
}
|
|
10972
|
-
recentBlocksView() {
|
|
10973
|
-
return this.retrieveView(serialize_serialize.recentBlocks, "recentBlocksView");
|
|
10974
|
-
}
|
|
10975
|
-
statisticsView() {
|
|
10976
|
-
return this.retrieveView(serialize_serialize.statistics, "statisticsView");
|
|
10977
|
-
}
|
|
10978
|
-
accumulationQueueView() {
|
|
10979
|
-
return this.retrieveView(serialize_serialize.accumulationQueue, "accumulationQueueView");
|
|
10980
|
-
}
|
|
10981
|
-
recentlyAccumulatedView() {
|
|
10982
|
-
return this.retrieveView(serialize_serialize.recentlyAccumulated, "recentlyAccumulatedView");
|
|
10983
|
-
}
|
|
10984
|
-
safroleDataView() {
|
|
10985
|
-
return this.retrieveView(serialize_serialize.safrole, "safroleDataView");
|
|
10986
|
-
}
|
|
10987
|
-
getServiceInfoView(id) {
|
|
10988
|
-
const serviceData = serialize_serialize.serviceData(id);
|
|
10989
|
-
const bytes = this.backend.get(serviceData.key);
|
|
10990
|
-
if (bytes === null) {
|
|
10991
|
-
return null;
|
|
10992
|
-
}
|
|
10993
|
-
if (!this.recentlyUsedServices.includes(id)) {
|
|
10994
|
-
this.recentlyUsedServices.push(id);
|
|
10995
|
-
}
|
|
10996
|
-
return decoder_Decoder.decodeObject(serviceData.Codec.View, bytes, this.spec);
|
|
10997
|
-
}
|
|
10998
|
-
}
|
|
10999
|
-
|
|
11000
10842
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state.ts
|
|
11001
10843
|
|
|
11002
10844
|
|
|
@@ -11005,8 +10847,6 @@ class SerializedStateView {
|
|
|
11005
10847
|
|
|
11006
10848
|
|
|
11007
10849
|
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
10850
|
/**
|
|
11011
10851
|
* State object which reads it's entries from some backend.
|
|
11012
10852
|
*
|
|
@@ -11019,7 +10859,7 @@ class serialized_state_SerializedState {
|
|
|
11019
10859
|
spec;
|
|
11020
10860
|
blake2b;
|
|
11021
10861
|
backend;
|
|
11022
|
-
|
|
10862
|
+
_recentServiceIds;
|
|
11023
10863
|
/** Create a state-like object from collection of serialized entries. */
|
|
11024
10864
|
static fromStateEntries(spec, blake2b, state, recentServices = []) {
|
|
11025
10865
|
return new serialized_state_SerializedState(spec, blake2b, state, recentServices);
|
|
@@ -11028,120 +10868,106 @@ class serialized_state_SerializedState {
|
|
|
11028
10868
|
static new(spec, blake2b, db, recentServices = []) {
|
|
11029
10869
|
return new serialized_state_SerializedState(spec, blake2b, db, recentServices);
|
|
11030
10870
|
}
|
|
11031
|
-
dataCache = hash_dictionary_HashDictionary.new();
|
|
11032
|
-
viewCache = hash_dictionary_HashDictionary.new();
|
|
11033
10871
|
constructor(spec, blake2b, backend,
|
|
11034
10872
|
/** Best-effort list of recently active services. */
|
|
11035
|
-
|
|
10873
|
+
_recentServiceIds) {
|
|
11036
10874
|
this.spec = spec;
|
|
11037
10875
|
this.blake2b = blake2b;
|
|
11038
10876
|
this.backend = backend;
|
|
11039
|
-
this.
|
|
10877
|
+
this._recentServiceIds = _recentServiceIds;
|
|
11040
10878
|
}
|
|
11041
10879
|
/** Comparing the serialized states, just means comparing their backends. */
|
|
11042
10880
|
[TEST_COMPARE_USING]() {
|
|
11043
10881
|
return this.backend;
|
|
11044
10882
|
}
|
|
11045
|
-
/** Return a non-decoding version of the state. */
|
|
11046
|
-
view() {
|
|
11047
|
-
return new SerializedStateView(this.spec, this.backend, this.recentlyUsedServices, this.viewCache);
|
|
11048
|
-
}
|
|
11049
10883
|
// TODO [ToDr] Temporary method to update the state,
|
|
11050
10884
|
// without changing references.
|
|
11051
10885
|
updateBackend(newBackend) {
|
|
11052
10886
|
this.backend = newBackend;
|
|
11053
|
-
this.dataCache = hash_dictionary_HashDictionary.new();
|
|
11054
|
-
this.viewCache = hash_dictionary_HashDictionary.new();
|
|
11055
10887
|
}
|
|
11056
10888
|
recentServiceIds() {
|
|
11057
|
-
return this.
|
|
10889
|
+
return this._recentServiceIds;
|
|
11058
10890
|
}
|
|
11059
10891
|
getService(id) {
|
|
11060
|
-
const serviceData = this.retrieveOptional(
|
|
10892
|
+
const serviceData = this.retrieveOptional(serialize.serviceData(id));
|
|
11061
10893
|
if (serviceData === undefined) {
|
|
11062
10894
|
return null;
|
|
11063
10895
|
}
|
|
11064
|
-
if (!this.
|
|
11065
|
-
this.
|
|
10896
|
+
if (!this._recentServiceIds.includes(id)) {
|
|
10897
|
+
this._recentServiceIds.push(id);
|
|
11066
10898
|
}
|
|
11067
10899
|
return new SerializedService(this.blake2b, id, serviceData, (key) => this.retrieveOptional(key));
|
|
11068
10900
|
}
|
|
11069
|
-
retrieve(
|
|
11070
|
-
const
|
|
11071
|
-
if (
|
|
11072
|
-
throw new Error(`Required state entry for ${description} is missing!. Accessing key: ${
|
|
10901
|
+
retrieve({ key, Codec }, description) {
|
|
10902
|
+
const bytes = this.backend.get(key);
|
|
10903
|
+
if (bytes === null) {
|
|
10904
|
+
throw new Error(`Required state entry for ${description} is missing!. Accessing key: ${key}`);
|
|
11073
10905
|
}
|
|
11074
|
-
return
|
|
10906
|
+
return decoder_Decoder.decodeObject(Codec, bytes, this.spec);
|
|
11075
10907
|
}
|
|
11076
10908
|
retrieveOptional({ key, Codec }) {
|
|
11077
|
-
const cached = this.dataCache.get(key);
|
|
11078
|
-
if (cached !== undefined) {
|
|
11079
|
-
return cached;
|
|
11080
|
-
}
|
|
11081
10909
|
const bytes = this.backend.get(key);
|
|
11082
10910
|
if (bytes === null) {
|
|
11083
10911
|
return undefined;
|
|
11084
10912
|
}
|
|
11085
|
-
|
|
11086
|
-
this.dataCache.set(key, data);
|
|
11087
|
-
return data;
|
|
10913
|
+
return decoder_Decoder.decodeObject(Codec, bytes, this.spec);
|
|
11088
10914
|
}
|
|
11089
10915
|
get availabilityAssignment() {
|
|
11090
|
-
return this.retrieve(
|
|
10916
|
+
return this.retrieve(serialize.availabilityAssignment, "availabilityAssignment");
|
|
11091
10917
|
}
|
|
11092
10918
|
get designatedValidatorData() {
|
|
11093
|
-
return this.retrieve(
|
|
10919
|
+
return this.retrieve(serialize.designatedValidators, "designatedValidatorData");
|
|
11094
10920
|
}
|
|
11095
10921
|
get nextValidatorData() {
|
|
11096
|
-
return this.retrieve(
|
|
10922
|
+
return this.retrieve(serialize.safrole, "safroleData.nextValidatorData").nextValidatorData;
|
|
11097
10923
|
}
|
|
11098
10924
|
get currentValidatorData() {
|
|
11099
|
-
return this.retrieve(
|
|
10925
|
+
return this.retrieve(serialize.currentValidators, "currentValidators");
|
|
11100
10926
|
}
|
|
11101
10927
|
get previousValidatorData() {
|
|
11102
|
-
return this.retrieve(
|
|
10928
|
+
return this.retrieve(serialize.previousValidators, "previousValidators");
|
|
11103
10929
|
}
|
|
11104
10930
|
get disputesRecords() {
|
|
11105
|
-
return this.retrieve(
|
|
10931
|
+
return this.retrieve(serialize.disputesRecords, "disputesRecords");
|
|
11106
10932
|
}
|
|
11107
10933
|
get timeslot() {
|
|
11108
|
-
return this.retrieve(
|
|
10934
|
+
return this.retrieve(serialize.timeslot, "timeslot");
|
|
11109
10935
|
}
|
|
11110
10936
|
get entropy() {
|
|
11111
|
-
return this.retrieve(
|
|
10937
|
+
return this.retrieve(serialize.entropy, "entropy");
|
|
11112
10938
|
}
|
|
11113
10939
|
get authPools() {
|
|
11114
|
-
return this.retrieve(
|
|
10940
|
+
return this.retrieve(serialize.authPools, "authPools");
|
|
11115
10941
|
}
|
|
11116
10942
|
get authQueues() {
|
|
11117
|
-
return this.retrieve(
|
|
10943
|
+
return this.retrieve(serialize.authQueues, "authQueues");
|
|
11118
10944
|
}
|
|
11119
10945
|
get recentBlocks() {
|
|
11120
|
-
return this.retrieve(
|
|
10946
|
+
return this.retrieve(serialize.recentBlocks, "recentBlocks");
|
|
11121
10947
|
}
|
|
11122
10948
|
get statistics() {
|
|
11123
|
-
return this.retrieve(
|
|
10949
|
+
return this.retrieve(serialize.statistics, "statistics");
|
|
11124
10950
|
}
|
|
11125
10951
|
get accumulationQueue() {
|
|
11126
|
-
return this.retrieve(
|
|
10952
|
+
return this.retrieve(serialize.accumulationQueue, "accumulationQueue");
|
|
11127
10953
|
}
|
|
11128
10954
|
get recentlyAccumulated() {
|
|
11129
|
-
return this.retrieve(
|
|
10955
|
+
return this.retrieve(serialize.recentlyAccumulated, "recentlyAccumulated");
|
|
11130
10956
|
}
|
|
11131
10957
|
get ticketsAccumulator() {
|
|
11132
|
-
return this.retrieve(
|
|
10958
|
+
return this.retrieve(serialize.safrole, "safroleData.ticketsAccumulator").ticketsAccumulator;
|
|
11133
10959
|
}
|
|
11134
10960
|
get sealingKeySeries() {
|
|
11135
|
-
return this.retrieve(
|
|
10961
|
+
return this.retrieve(serialize.safrole, "safrole.sealingKeySeries").sealingKeySeries;
|
|
11136
10962
|
}
|
|
11137
10963
|
get epochRoot() {
|
|
11138
|
-
return this.retrieve(
|
|
10964
|
+
return this.retrieve(serialize.safrole, "safrole.epochRoot").epochRoot;
|
|
11139
10965
|
}
|
|
11140
10966
|
get privilegedServices() {
|
|
11141
|
-
return this.retrieve(
|
|
10967
|
+
return this.retrieve(serialize.privilegedServices, "privilegedServices");
|
|
11142
10968
|
}
|
|
11143
10969
|
get accumulationOutputLog() {
|
|
11144
|
-
return this.retrieve(
|
|
10970
|
+
return this.retrieve(serialize.accumulationOutputLog, "accumulationOutputLog");
|
|
11145
10971
|
}
|
|
11146
10972
|
}
|
|
11147
10973
|
/** Service data representation on a serialized state. */
|
|
@@ -11170,9 +10996,9 @@ class SerializedService {
|
|
|
11170
10996
|
serviceIdAndKey.set(numbers_u32AsLeBytes(this.serviceId));
|
|
11171
10997
|
serviceIdAndKey.set(rawKey.raw, SERVICE_ID_BYTES);
|
|
11172
10998
|
const key = opaque_asOpaqueType(bytes_BytesBlob.blobFrom(this.blake2b.hashBytes(serviceIdAndKey).raw));
|
|
11173
|
-
return this.retrieveOptional(
|
|
10999
|
+
return this.retrieveOptional(serialize.serviceStorage(this.blake2b, this.serviceId, key)) ?? null;
|
|
11174
11000
|
}
|
|
11175
|
-
return this.retrieveOptional(
|
|
11001
|
+
return this.retrieveOptional(serialize.serviceStorage(this.blake2b, this.serviceId, rawKey)) ?? null;
|
|
11176
11002
|
}
|
|
11177
11003
|
/**
|
|
11178
11004
|
* Check if preimage is present in the DB.
|
|
@@ -11181,15 +11007,15 @@ class SerializedService {
|
|
|
11181
11007
|
*/
|
|
11182
11008
|
hasPreimage(hash) {
|
|
11183
11009
|
// TODO [ToDr] consider optimizing to avoid fetching the whole data.
|
|
11184
|
-
return this.retrieveOptional(
|
|
11010
|
+
return this.retrieveOptional(serialize.servicePreimages(this.blake2b, this.serviceId, hash)) !== undefined;
|
|
11185
11011
|
}
|
|
11186
11012
|
/** Retrieve preimage from the DB. */
|
|
11187
11013
|
getPreimage(hash) {
|
|
11188
|
-
return this.retrieveOptional(
|
|
11014
|
+
return this.retrieveOptional(serialize.servicePreimages(this.blake2b, this.serviceId, hash)) ?? null;
|
|
11189
11015
|
}
|
|
11190
11016
|
/** Retrieve preimage lookup history. */
|
|
11191
11017
|
getLookupHistory(hash, len) {
|
|
11192
|
-
const rawSlots = this.retrieveOptional(
|
|
11018
|
+
const rawSlots = this.retrieveOptional(serialize.serviceLookupHistory(this.blake2b, this.serviceId, hash, len));
|
|
11193
11019
|
if (rawSlots === undefined) {
|
|
11194
11020
|
return null;
|
|
11195
11021
|
}
|
|
@@ -11878,7 +11704,7 @@ function* serializeStateUpdate(spec, blake2b, update) {
|
|
|
11878
11704
|
function* serializeRemovedServices(servicesRemoved) {
|
|
11879
11705
|
for (const serviceId of servicesRemoved ?? []) {
|
|
11880
11706
|
// TODO [ToDr] what about all data associated with a service?
|
|
11881
|
-
const codec =
|
|
11707
|
+
const codec = serialize.serviceData(serviceId);
|
|
11882
11708
|
yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
11883
11709
|
}
|
|
11884
11710
|
}
|
|
@@ -11887,13 +11713,13 @@ function* serializeStorage(storage, blake2b) {
|
|
|
11887
11713
|
switch (action.kind) {
|
|
11888
11714
|
case UpdateStorageKind.Set: {
|
|
11889
11715
|
const key = action.storage.key;
|
|
11890
|
-
const codec =
|
|
11716
|
+
const codec = serialize.serviceStorage(blake2b, serviceId, key);
|
|
11891
11717
|
yield [StateEntryUpdateAction.Insert, codec.key, action.storage.value];
|
|
11892
11718
|
break;
|
|
11893
11719
|
}
|
|
11894
11720
|
case UpdateStorageKind.Remove: {
|
|
11895
11721
|
const key = action.key;
|
|
11896
|
-
const codec =
|
|
11722
|
+
const codec = serialize.serviceStorage(blake2b, serviceId, key);
|
|
11897
11723
|
yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
11898
11724
|
break;
|
|
11899
11725
|
}
|
|
@@ -11907,10 +11733,10 @@ function* serializePreimages(preimages, encode, blake2b) {
|
|
|
11907
11733
|
switch (action.kind) {
|
|
11908
11734
|
case UpdatePreimageKind.Provide: {
|
|
11909
11735
|
const { hash, blob } = action.preimage;
|
|
11910
|
-
const codec =
|
|
11736
|
+
const codec = serialize.servicePreimages(blake2b, serviceId, hash);
|
|
11911
11737
|
yield [StateEntryUpdateAction.Insert, codec.key, blob];
|
|
11912
11738
|
if (action.slot !== null) {
|
|
11913
|
-
const codec2 =
|
|
11739
|
+
const codec2 = serialize.serviceLookupHistory(blake2b, serviceId, hash, numbers_tryAsU32(blob.length));
|
|
11914
11740
|
yield [
|
|
11915
11741
|
StateEntryUpdateAction.Insert,
|
|
11916
11742
|
codec2.key,
|
|
@@ -11921,15 +11747,15 @@ function* serializePreimages(preimages, encode, blake2b) {
|
|
|
11921
11747
|
}
|
|
11922
11748
|
case UpdatePreimageKind.UpdateOrAdd: {
|
|
11923
11749
|
const { hash, length, slots } = action.item;
|
|
11924
|
-
const codec =
|
|
11750
|
+
const codec = serialize.serviceLookupHistory(blake2b, serviceId, hash, length);
|
|
11925
11751
|
yield [StateEntryUpdateAction.Insert, codec.key, encode(codec.Codec, slots)];
|
|
11926
11752
|
break;
|
|
11927
11753
|
}
|
|
11928
11754
|
case UpdatePreimageKind.Remove: {
|
|
11929
11755
|
const { hash, length } = action;
|
|
11930
|
-
const codec =
|
|
11756
|
+
const codec = serialize.servicePreimages(blake2b, serviceId, hash);
|
|
11931
11757
|
yield [StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
11932
|
-
const codec2 =
|
|
11758
|
+
const codec2 = serialize.serviceLookupHistory(blake2b, serviceId, hash, length);
|
|
11933
11759
|
yield [StateEntryUpdateAction.Remove, codec2.key, EMPTY_BLOB];
|
|
11934
11760
|
break;
|
|
11935
11761
|
}
|
|
@@ -11941,12 +11767,12 @@ function* serializePreimages(preimages, encode, blake2b) {
|
|
|
11941
11767
|
function* serializeServiceUpdates(servicesUpdates, encode, blake2b) {
|
|
11942
11768
|
for (const { action, serviceId } of servicesUpdates ?? []) {
|
|
11943
11769
|
// new service being created or updated
|
|
11944
|
-
const codec =
|
|
11770
|
+
const codec = serialize.serviceData(serviceId);
|
|
11945
11771
|
yield [StateEntryUpdateAction.Insert, codec.key, encode(codec.Codec, action.account)];
|
|
11946
11772
|
// additional lookup history update
|
|
11947
11773
|
if (action.kind === UpdateServiceKind.Create && action.lookupHistory !== null) {
|
|
11948
11774
|
const { lookupHistory } = action;
|
|
11949
|
-
const codec2 =
|
|
11775
|
+
const codec2 = serialize.serviceLookupHistory(blake2b, serviceId, lookupHistory.hash, lookupHistory.length);
|
|
11950
11776
|
yield [StateEntryUpdateAction.Insert, codec2.key, encode(codec2.Codec, lookupHistory.slots)];
|
|
11951
11777
|
}
|
|
11952
11778
|
}
|
|
@@ -11956,53 +11782,53 @@ function* serializeBasicKeys(spec, update) {
|
|
|
11956
11782
|
return [StateEntryUpdateAction.Insert, codec.key, encoder_Encoder.encodeObject(codec.Codec, val, spec)];
|
|
11957
11783
|
}
|
|
11958
11784
|
if (update.authPools !== undefined) {
|
|
11959
|
-
yield doSerialize(update.authPools,
|
|
11785
|
+
yield doSerialize(update.authPools, serialize.authPools); // C(1)
|
|
11960
11786
|
}
|
|
11961
11787
|
if (update.authQueues !== undefined) {
|
|
11962
|
-
yield doSerialize(update.authQueues,
|
|
11788
|
+
yield doSerialize(update.authQueues, serialize.authQueues); // C(2)
|
|
11963
11789
|
}
|
|
11964
11790
|
if (update.recentBlocks !== undefined) {
|
|
11965
|
-
yield doSerialize(update.recentBlocks,
|
|
11791
|
+
yield doSerialize(update.recentBlocks, serialize.recentBlocks); // C(3)
|
|
11966
11792
|
}
|
|
11967
11793
|
const safroleData = getSafroleData(update.nextValidatorData, update.epochRoot, update.sealingKeySeries, update.ticketsAccumulator);
|
|
11968
11794
|
if (safroleData !== undefined) {
|
|
11969
|
-
yield doSerialize(safroleData,
|
|
11795
|
+
yield doSerialize(safroleData, serialize.safrole); // C(4)
|
|
11970
11796
|
}
|
|
11971
11797
|
if (update.disputesRecords !== undefined) {
|
|
11972
|
-
yield doSerialize(update.disputesRecords,
|
|
11798
|
+
yield doSerialize(update.disputesRecords, serialize.disputesRecords); // C(5)
|
|
11973
11799
|
}
|
|
11974
11800
|
if (update.entropy !== undefined) {
|
|
11975
|
-
yield doSerialize(update.entropy,
|
|
11801
|
+
yield doSerialize(update.entropy, serialize.entropy); // C(6)
|
|
11976
11802
|
}
|
|
11977
11803
|
if (update.designatedValidatorData !== undefined) {
|
|
11978
|
-
yield doSerialize(update.designatedValidatorData,
|
|
11804
|
+
yield doSerialize(update.designatedValidatorData, serialize.designatedValidators); // C(7)
|
|
11979
11805
|
}
|
|
11980
11806
|
if (update.currentValidatorData !== undefined) {
|
|
11981
|
-
yield doSerialize(update.currentValidatorData,
|
|
11807
|
+
yield doSerialize(update.currentValidatorData, serialize.currentValidators); // C(8)
|
|
11982
11808
|
}
|
|
11983
11809
|
if (update.previousValidatorData !== undefined) {
|
|
11984
|
-
yield doSerialize(update.previousValidatorData,
|
|
11810
|
+
yield doSerialize(update.previousValidatorData, serialize.previousValidators); // C(9)
|
|
11985
11811
|
}
|
|
11986
11812
|
if (update.availabilityAssignment !== undefined) {
|
|
11987
|
-
yield doSerialize(update.availabilityAssignment,
|
|
11813
|
+
yield doSerialize(update.availabilityAssignment, serialize.availabilityAssignment); // C(10)
|
|
11988
11814
|
}
|
|
11989
11815
|
if (update.timeslot !== undefined) {
|
|
11990
|
-
yield doSerialize(update.timeslot,
|
|
11816
|
+
yield doSerialize(update.timeslot, serialize.timeslot); // C(11)
|
|
11991
11817
|
}
|
|
11992
11818
|
if (update.privilegedServices !== undefined) {
|
|
11993
|
-
yield doSerialize(update.privilegedServices,
|
|
11819
|
+
yield doSerialize(update.privilegedServices, serialize.privilegedServices); // C(12)
|
|
11994
11820
|
}
|
|
11995
11821
|
if (update.statistics !== undefined) {
|
|
11996
|
-
yield doSerialize(update.statistics,
|
|
11822
|
+
yield doSerialize(update.statistics, serialize.statistics); // C(13)
|
|
11997
11823
|
}
|
|
11998
11824
|
if (update.accumulationQueue !== undefined) {
|
|
11999
|
-
yield doSerialize(update.accumulationQueue,
|
|
11825
|
+
yield doSerialize(update.accumulationQueue, serialize.accumulationQueue); // C(14)
|
|
12000
11826
|
}
|
|
12001
11827
|
if (update.recentlyAccumulated !== undefined) {
|
|
12002
|
-
yield doSerialize(update.recentlyAccumulated,
|
|
11828
|
+
yield doSerialize(update.recentlyAccumulated, serialize.recentlyAccumulated); // C(15)
|
|
12003
11829
|
}
|
|
12004
11830
|
if (update.accumulationOutputLog !== undefined) {
|
|
12005
|
-
yield doSerialize(update.accumulationOutputLog,
|
|
11831
|
+
yield doSerialize(update.accumulationOutputLog, serialize.accumulationOutputLog); // C(16)
|
|
12006
11832
|
}
|
|
12007
11833
|
}
|
|
12008
11834
|
function getSafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator) {
|
|
@@ -12115,41 +11941,41 @@ function convertInMemoryStateToDictionary(spec, blake2b, state) {
|
|
|
12115
11941
|
function doSerialize(codec) {
|
|
12116
11942
|
serialized.set(codec.key, encoder_Encoder.encodeObject(codec.Codec, codec.extract(state), spec));
|
|
12117
11943
|
}
|
|
12118
|
-
doSerialize(
|
|
12119
|
-
doSerialize(
|
|
12120
|
-
doSerialize(
|
|
12121
|
-
doSerialize(
|
|
12122
|
-
doSerialize(
|
|
12123
|
-
doSerialize(
|
|
12124
|
-
doSerialize(
|
|
12125
|
-
doSerialize(
|
|
12126
|
-
doSerialize(
|
|
12127
|
-
doSerialize(
|
|
12128
|
-
doSerialize(
|
|
12129
|
-
doSerialize(
|
|
12130
|
-
doSerialize(
|
|
12131
|
-
doSerialize(
|
|
12132
|
-
doSerialize(
|
|
12133
|
-
doSerialize(
|
|
11944
|
+
doSerialize(serialize.authPools); // C(1)
|
|
11945
|
+
doSerialize(serialize.authQueues); // C(2)
|
|
11946
|
+
doSerialize(serialize.recentBlocks); // C(3)
|
|
11947
|
+
doSerialize(serialize.safrole); // C(4)
|
|
11948
|
+
doSerialize(serialize.disputesRecords); // C(5)
|
|
11949
|
+
doSerialize(serialize.entropy); // C(6)
|
|
11950
|
+
doSerialize(serialize.designatedValidators); // C(7)
|
|
11951
|
+
doSerialize(serialize.currentValidators); // C(8)
|
|
11952
|
+
doSerialize(serialize.previousValidators); // C(9)
|
|
11953
|
+
doSerialize(serialize.availabilityAssignment); // C(10)
|
|
11954
|
+
doSerialize(serialize.timeslot); // C(11)
|
|
11955
|
+
doSerialize(serialize.privilegedServices); // C(12)
|
|
11956
|
+
doSerialize(serialize.statistics); // C(13)
|
|
11957
|
+
doSerialize(serialize.accumulationQueue); // C(14)
|
|
11958
|
+
doSerialize(serialize.recentlyAccumulated); // C(15)
|
|
11959
|
+
doSerialize(serialize.accumulationOutputLog); // C(16)
|
|
12134
11960
|
// services
|
|
12135
11961
|
for (const [serviceId, service] of state.services.entries()) {
|
|
12136
11962
|
// data
|
|
12137
|
-
const { key, Codec } =
|
|
11963
|
+
const { key, Codec } = serialize.serviceData(serviceId);
|
|
12138
11964
|
serialized.set(key, encoder_Encoder.encodeObject(Codec, service.getInfo()));
|
|
12139
11965
|
// preimages
|
|
12140
11966
|
for (const preimage of service.data.preimages.values()) {
|
|
12141
|
-
const { key, Codec } =
|
|
11967
|
+
const { key, Codec } = serialize.servicePreimages(blake2b, serviceId, preimage.hash);
|
|
12142
11968
|
serialized.set(key, encoder_Encoder.encodeObject(Codec, preimage.blob));
|
|
12143
11969
|
}
|
|
12144
11970
|
// storage
|
|
12145
11971
|
for (const storage of service.data.storage.values()) {
|
|
12146
|
-
const { key, Codec } =
|
|
11972
|
+
const { key, Codec } = serialize.serviceStorage(blake2b, serviceId, storage.key);
|
|
12147
11973
|
serialized.set(key, encoder_Encoder.encodeObject(Codec, storage.value));
|
|
12148
11974
|
}
|
|
12149
11975
|
// lookup history
|
|
12150
11976
|
for (const lookupHistoryList of service.data.lookupHistory.values()) {
|
|
12151
11977
|
for (const lookupHistory of lookupHistoryList) {
|
|
12152
|
-
const { key, Codec } =
|
|
11978
|
+
const { key, Codec } = serialize.serviceLookupHistory(blake2b, serviceId, lookupHistory.hash, lookupHistory.length);
|
|
12153
11979
|
serialized.set(key, encoder_Encoder.encodeObject(Codec, lookupHistory.slots.slice()));
|
|
12154
11980
|
}
|
|
12155
11981
|
}
|
|
@@ -12199,7 +12025,6 @@ function loadState(spec, blake2b, entries) {
|
|
|
12199
12025
|
|
|
12200
12026
|
|
|
12201
12027
|
|
|
12202
|
-
|
|
12203
12028
|
;// CONCATENATED MODULE: ./packages/jam/database/leaf-db.ts
|
|
12204
12029
|
|
|
12205
12030
|
|
|
@@ -12358,7 +12183,7 @@ const codecMap = (value, extractKey, { typicalLength = TYPICAL_DICTIONARY_LENGTH
|
|
|
12358
12183
|
const lookupHistoryItemCodec = descriptors_codec.object({
|
|
12359
12184
|
hash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
12360
12185
|
length: descriptors_codec.u32,
|
|
12361
|
-
slots:
|
|
12186
|
+
slots: readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.u32.asOpaque())).convert(seeThrough, tryAsLookupHistorySlots),
|
|
12362
12187
|
}, "LookupHistoryItem", ({ hash, length, slots }) => new service_LookupHistoryItem(hash, length, slots));
|
|
12363
12188
|
const lookupHistoryEntryCodec = descriptors_codec.object({
|
|
12364
12189
|
key: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
@@ -12401,11 +12226,7 @@ class ServiceWithCodec extends InMemoryService {
|
|
|
12401
12226
|
return new ServiceWithCodec(serviceId, data);
|
|
12402
12227
|
}
|
|
12403
12228
|
}
|
|
12404
|
-
const in_memory_state_codec_inMemoryStateCodec =
|
|
12405
|
-
static create(data) {
|
|
12406
|
-
return InMemoryState.new(spec, data);
|
|
12407
|
-
}
|
|
12408
|
-
}, {
|
|
12229
|
+
const in_memory_state_codec_inMemoryStateCodec = descriptors_codec.Class(InMemoryState, {
|
|
12409
12230
|
// alpha
|
|
12410
12231
|
authPools: serialize.authPools.Codec,
|
|
12411
12232
|
// phi
|
|
@@ -12415,11 +12236,11 @@ const in_memory_state_codec_inMemoryStateCodec = (spec) => codec.Class(class Sta
|
|
|
12415
12236
|
// gamma_k
|
|
12416
12237
|
nextValidatorData: codecPerValidator(ValidatorData.Codec),
|
|
12417
12238
|
// gamma_z
|
|
12418
|
-
epochRoot:
|
|
12239
|
+
epochRoot: descriptors_codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
12419
12240
|
// gamma_s
|
|
12420
12241
|
sealingKeySeries: SafroleSealingKeysData.Codec,
|
|
12421
12242
|
// gamma_a
|
|
12422
|
-
ticketsAccumulator: readonlyArray(
|
|
12243
|
+
ticketsAccumulator: readonlyArray(descriptors_codec.sequenceVarLen(Ticket.Codec)).convert((x) => x, sized_array_asKnownSize),
|
|
12423
12244
|
// psi
|
|
12424
12245
|
disputesRecords: serialize.disputesRecords.Codec,
|
|
12425
12246
|
// eta
|
|
@@ -12445,7 +12266,7 @@ const in_memory_state_codec_inMemoryStateCodec = (spec) => codec.Class(class Sta
|
|
|
12445
12266
|
// theta
|
|
12446
12267
|
accumulationOutputLog: serialize.accumulationOutputLog.Codec,
|
|
12447
12268
|
// delta
|
|
12448
|
-
services:
|
|
12269
|
+
services: descriptors_codec.dictionary(descriptors_codec.u32.asOpaque(), ServiceWithCodec.Codec, {
|
|
12449
12270
|
sortKeys: (a, b) => a - b,
|
|
12450
12271
|
}),
|
|
12451
12272
|
});
|
|
@@ -12492,7 +12313,7 @@ class InMemoryStates {
|
|
|
12492
12313
|
}
|
|
12493
12314
|
/** Insert a full state into the database. */
|
|
12494
12315
|
async insertState(headerHash, state) {
|
|
12495
|
-
const encoded = Encoder.encodeObject(inMemoryStateCodec
|
|
12316
|
+
const encoded = Encoder.encodeObject(inMemoryStateCodec, state, this.spec);
|
|
12496
12317
|
this.db.set(headerHash, encoded);
|
|
12497
12318
|
return Result.ok(OK);
|
|
12498
12319
|
}
|
|
@@ -12501,7 +12322,7 @@ class InMemoryStates {
|
|
|
12501
12322
|
if (encodedState === undefined) {
|
|
12502
12323
|
return null;
|
|
12503
12324
|
}
|
|
12504
|
-
return Decoder.decodeObject(inMemoryStateCodec
|
|
12325
|
+
return Decoder.decodeObject(inMemoryStateCodec, encodedState, this.spec);
|
|
12505
12326
|
}
|
|
12506
12327
|
}
|
|
12507
12328
|
|
|
@@ -13688,21 +13509,21 @@ class TransitionHasher {
|
|
|
13688
13509
|
*/
|
|
13689
13510
|
extrinsic(extrinsicView) {
|
|
13690
13511
|
// https://graypaper.fluffylabs.dev/#/cc517d7/0cfb000cfb00?v=0.6.5
|
|
13691
|
-
const
|
|
13692
|
-
const countEncoded = encoder_Encoder.encodeObject(descriptors_codec.varU32, guaranteesCount);
|
|
13693
|
-
const guaranteesBlobs = extrinsicView.guarantees
|
|
13512
|
+
const guarantees = extrinsicView.guarantees
|
|
13694
13513
|
.view()
|
|
13695
13514
|
.map((g) => g.view())
|
|
13696
|
-
.
|
|
13515
|
+
.map((guarantee) => {
|
|
13697
13516
|
const reportHash = this.blake2b.hashBytes(guarantee.report.encoded()).asOpaque();
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13517
|
+
return bytes_BytesBlob.blobFromParts([
|
|
13518
|
+
reportHash.raw,
|
|
13519
|
+
guarantee.slot.encoded().raw,
|
|
13520
|
+
guarantee.credentials.encoded().raw,
|
|
13521
|
+
]);
|
|
13522
|
+
});
|
|
13523
|
+
const guaranteeBlob = encoder_Encoder.encodeObject(descriptors_codec.sequenceVarLen(dumpCodec), guarantees, this.context);
|
|
13703
13524
|
const et = this.blake2b.hashBytes(extrinsicView.tickets.encoded()).asOpaque();
|
|
13704
13525
|
const ep = this.blake2b.hashBytes(extrinsicView.preimages.encoded()).asOpaque();
|
|
13705
|
-
const eg = this.blake2b.
|
|
13526
|
+
const eg = this.blake2b.hashBytes(guaranteeBlob).asOpaque();
|
|
13706
13527
|
const ea = this.blake2b.hashBytes(extrinsicView.assurances.encoded()).asOpaque();
|
|
13707
13528
|
const ed = this.blake2b.hashBytes(extrinsicView.disputes.encoded()).asOpaque();
|
|
13708
13529
|
const encoded = bytes_BytesBlob.blobFromParts([et.raw, ep.raw, eg.raw, ea.raw, ed.raw]);
|