@typeberry/convert 0.5.0-2a69cc5 → 0.5.0-8992448
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/README.md +0 -1
- package/index.js +78 -199
- package/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -4254,7 +4254,6 @@ const env = typeof process === "undefined" ? {} : process.env;
|
|
|
4254
4254
|
|
|
4255
4255
|
var GpVersion;
|
|
4256
4256
|
(function (GpVersion) {
|
|
4257
|
-
GpVersion["V0_6_7"] = "0.6.7";
|
|
4258
4257
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
4259
4258
|
GpVersion["V0_7_1"] = "0.7.1";
|
|
4260
4259
|
GpVersion["V0_7_2"] = "0.7.2";
|
|
@@ -4262,9 +4261,9 @@ var GpVersion;
|
|
|
4262
4261
|
var TestSuite;
|
|
4263
4262
|
(function (TestSuite) {
|
|
4264
4263
|
TestSuite["W3F_DAVXY"] = "w3f-davxy";
|
|
4265
|
-
TestSuite["JAMDUNA"] = "jamduna";
|
|
4266
4264
|
})(TestSuite || (TestSuite = {}));
|
|
4267
|
-
|
|
4265
|
+
// NOTE: Also acts as a supported versions
|
|
4266
|
+
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
4268
4267
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
4269
4268
|
const DEFAULT_VERSION = GpVersion.V0_7_2;
|
|
4270
4269
|
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
@@ -9574,7 +9573,7 @@ function workItemExtrinsicsCodec(workItems) {
|
|
|
9574
9573
|
/**
|
|
9575
9574
|
* Work Item which is a part of some work package.
|
|
9576
9575
|
*
|
|
9577
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
9576
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/1a86001a9100?v=0.7.2
|
|
9578
9577
|
*/
|
|
9579
9578
|
class work_item_WorkItem extends WithDebug {
|
|
9580
9579
|
service;
|
|
@@ -9585,35 +9584,20 @@ class work_item_WorkItem extends WithDebug {
|
|
|
9585
9584
|
importSegments;
|
|
9586
9585
|
extrinsic;
|
|
9587
9586
|
exportCount;
|
|
9588
|
-
static Codec =
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
})
|
|
9603
|
-
: Class(work_item_WorkItem, {
|
|
9604
|
-
service: u32.asOpaque(),
|
|
9605
|
-
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9606
|
-
payload: blob,
|
|
9607
|
-
refineGasLimit: u64.asOpaque(),
|
|
9608
|
-
accumulateGasLimit: u64.asOpaque(),
|
|
9609
|
-
importSegments: codecKnownSizeArray(ImportSpec.Codec, {
|
|
9610
|
-
minLength: 0,
|
|
9611
|
-
maxLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9612
|
-
typicalLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9613
|
-
}),
|
|
9614
|
-
extrinsic: sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
9615
|
-
exportCount: u16,
|
|
9616
|
-
});
|
|
9587
|
+
static Codec = Class(work_item_WorkItem, {
|
|
9588
|
+
service: u32.asOpaque(),
|
|
9589
|
+
codeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9590
|
+
refineGasLimit: u64.asOpaque(),
|
|
9591
|
+
accumulateGasLimit: u64.asOpaque(),
|
|
9592
|
+
exportCount: u16,
|
|
9593
|
+
payload: blob,
|
|
9594
|
+
importSegments: codecKnownSizeArray(ImportSpec.Codec, {
|
|
9595
|
+
minLength: 0,
|
|
9596
|
+
maxLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9597
|
+
typicalLength: MAX_NUMBER_OF_SEGMENTS,
|
|
9598
|
+
}),
|
|
9599
|
+
extrinsic: sequenceVarLen(WorkItemExtrinsicSpec.Codec),
|
|
9600
|
+
});
|
|
9617
9601
|
static create({ service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount, }) {
|
|
9618
9602
|
return new work_item_WorkItem(service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount);
|
|
9619
9603
|
}
|
|
@@ -9685,23 +9669,14 @@ class work_package_WorkPackage extends WithDebug {
|
|
|
9685
9669
|
parametrization;
|
|
9686
9670
|
context;
|
|
9687
9671
|
items;
|
|
9688
|
-
static Codec =
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
})
|
|
9697
|
-
: Class(work_package_WorkPackage, {
|
|
9698
|
-
authorization: blob,
|
|
9699
|
-
authCodeHost: u32.asOpaque(),
|
|
9700
|
-
authCodeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9701
|
-
parametrization: blob,
|
|
9702
|
-
context: RefineContext.Codec,
|
|
9703
|
-
items: sequenceVarLen(work_item_WorkItem.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
9704
|
-
});
|
|
9672
|
+
static Codec = Class(work_package_WorkPackage, {
|
|
9673
|
+
authCodeHost: u32.asOpaque(),
|
|
9674
|
+
authCodeHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9675
|
+
context: RefineContext.Codec,
|
|
9676
|
+
authorization: blob,
|
|
9677
|
+
parametrization: blob,
|
|
9678
|
+
items: sequenceVarLen(work_item_WorkItem.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
9679
|
+
});
|
|
9705
9680
|
static create({ authorization, authCodeHost, authCodeHash, parametrization, context, items, }) {
|
|
9706
9681
|
return new work_package_WorkPackage(authorization, authCodeHost, authCodeHash, parametrization, context, items);
|
|
9707
9682
|
}
|
|
@@ -9951,9 +9926,9 @@ class WorkPackageSpec extends WithDebug {
|
|
|
9951
9926
|
/**
|
|
9952
9927
|
* A report of execution of some work package.
|
|
9953
9928
|
*
|
|
9954
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
9929
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/13bb0113c301?v=0.7.2
|
|
9955
9930
|
*/
|
|
9956
|
-
class
|
|
9931
|
+
class WorkReport extends WithDebug {
|
|
9957
9932
|
workPackageSpec;
|
|
9958
9933
|
context;
|
|
9959
9934
|
coreIndex;
|
|
@@ -9962,17 +9937,32 @@ class WorkReportNoCodec extends WithDebug {
|
|
|
9962
9937
|
segmentRootLookup;
|
|
9963
9938
|
results;
|
|
9964
9939
|
authorizationGasUsed;
|
|
9940
|
+
static Codec = Class(WorkReport, {
|
|
9941
|
+
workPackageSpec: WorkPackageSpec.Codec,
|
|
9942
|
+
context: RefineContext.Codec,
|
|
9943
|
+
coreIndex: varU32.convert((o) => numbers_tryAsU32(o), (i) => {
|
|
9944
|
+
if (!isU16(i)) {
|
|
9945
|
+
throw new Error(`Core index exceeds U16: ${i}`);
|
|
9946
|
+
}
|
|
9947
|
+
return tryAsCoreIndex(i);
|
|
9948
|
+
}),
|
|
9949
|
+
authorizerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
9950
|
+
authorizationGasUsed: varU64.asOpaque(),
|
|
9951
|
+
authorizationOutput: blob,
|
|
9952
|
+
segmentRootLookup: readonlyArray(sequenceVarLen(WorkPackageInfo.Codec)),
|
|
9953
|
+
results: sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
9954
|
+
});
|
|
9965
9955
|
static create({ workPackageSpec, context, coreIndex, authorizerHash, authorizationOutput, segmentRootLookup, results, authorizationGasUsed, }) {
|
|
9966
|
-
return new
|
|
9956
|
+
return new WorkReport(workPackageSpec, context, coreIndex, authorizerHash, authorizationOutput, segmentRootLookup, results, authorizationGasUsed);
|
|
9967
9957
|
}
|
|
9968
9958
|
constructor(
|
|
9969
9959
|
/** `s`: Work package specification. */
|
|
9970
9960
|
workPackageSpec,
|
|
9971
|
-
/** `
|
|
9961
|
+
/** `c`: Refinement context. */
|
|
9972
9962
|
context,
|
|
9973
|
-
/**
|
|
9963
|
+
/** *`c`*: Core index on which the work is done. */
|
|
9974
9964
|
coreIndex,
|
|
9975
|
-
/**
|
|
9965
|
+
/** *`a`*: Hash of the authorizer. */
|
|
9976
9966
|
authorizerHash,
|
|
9977
9967
|
/** `o`: Authorization output. */
|
|
9978
9968
|
authorizationOutput,
|
|
@@ -9983,7 +9973,7 @@ class WorkReportNoCodec extends WithDebug {
|
|
|
9983
9973
|
segmentRootLookup,
|
|
9984
9974
|
/** `r`: The results of evaluation of each of the items in the work package. */
|
|
9985
9975
|
results,
|
|
9986
|
-
/**
|
|
9976
|
+
/** *`g`*: Gas used during authorization. */
|
|
9987
9977
|
authorizationGasUsed) {
|
|
9988
9978
|
super();
|
|
9989
9979
|
this.workPackageSpec = workPackageSpec;
|
|
@@ -9996,41 +9986,6 @@ class WorkReportNoCodec extends WithDebug {
|
|
|
9996
9986
|
this.authorizationGasUsed = authorizationGasUsed;
|
|
9997
9987
|
}
|
|
9998
9988
|
}
|
|
9999
|
-
const WorkReportCodec = Class(WorkReportNoCodec, {
|
|
10000
|
-
workPackageSpec: WorkPackageSpec.Codec,
|
|
10001
|
-
context: RefineContext.Codec,
|
|
10002
|
-
coreIndex: varU32.convert((o) => numbers_tryAsU32(o), (i) => {
|
|
10003
|
-
if (!isU16(i)) {
|
|
10004
|
-
throw new Error(`Core index exceeds U16: ${i}`);
|
|
10005
|
-
}
|
|
10006
|
-
return tryAsCoreIndex(i);
|
|
10007
|
-
}),
|
|
10008
|
-
authorizerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10009
|
-
authorizationGasUsed: varU64.asOpaque(),
|
|
10010
|
-
authorizationOutput: blob,
|
|
10011
|
-
segmentRootLookup: readonlyArray(sequenceVarLen(WorkPackageInfo.Codec)),
|
|
10012
|
-
results: sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
10013
|
-
});
|
|
10014
|
-
const WorkReportCodecPre070 = Class(WorkReportNoCodec, {
|
|
10015
|
-
workPackageSpec: WorkPackageSpec.Codec,
|
|
10016
|
-
context: RefineContext.Codec,
|
|
10017
|
-
coreIndex: varU32.convert((o) => numbers_tryAsU32(o), (i) => {
|
|
10018
|
-
if (!isU16(i)) {
|
|
10019
|
-
throw new Error(`Core index exceeds U16: ${i}`);
|
|
10020
|
-
}
|
|
10021
|
-
return tryAsCoreIndex(i);
|
|
10022
|
-
}),
|
|
10023
|
-
authorizerHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10024
|
-
authorizationOutput: blob,
|
|
10025
|
-
segmentRootLookup: readonlyArray(sequenceVarLen(WorkPackageInfo.Codec)),
|
|
10026
|
-
results: sequenceVarLen(WorkResult.Codec).convert((x) => x, (items) => FixedSizeArray.new(items, tryAsWorkItemsCount(items.length))),
|
|
10027
|
-
authorizationGasUsed: varU64.asOpaque(),
|
|
10028
|
-
});
|
|
10029
|
-
class WorkReport extends WorkReportNoCodec {
|
|
10030
|
-
static Codec = Compatibility.isGreaterOrEqual(GpVersion.V0_7_0)
|
|
10031
|
-
? WorkReportCodec
|
|
10032
|
-
: WorkReportCodecPre070;
|
|
10033
|
-
}
|
|
10034
9989
|
|
|
10035
9990
|
;// CONCATENATED MODULE: ./packages/jam/block/guarantees.ts
|
|
10036
9991
|
|
|
@@ -10272,41 +10227,24 @@ const encodeUnsealedHeader = (view) => {
|
|
|
10272
10227
|
const encodedUnsealedLen = encodedFullHeader.length - BANDERSNATCH_VRF_SIGNATURE_BYTES;
|
|
10273
10228
|
return BytesBlob.blobFrom(encodedFullHeader.subarray(0, encodedUnsealedLen));
|
|
10274
10229
|
};
|
|
10275
|
-
/**
|
|
10276
|
-
* Codec descriptor with pre 0.7.0 encoding order
|
|
10277
|
-
*/
|
|
10278
|
-
const legacyDescriptor = {
|
|
10279
|
-
parentHeaderHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10280
|
-
priorStateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10281
|
-
extrinsicHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10282
|
-
timeSlotIndex: u32.asOpaque(),
|
|
10283
|
-
epochMarker: optional(EpochMarker.Codec),
|
|
10284
|
-
ticketsMarker: optional(TicketsMarker.Codec),
|
|
10285
|
-
offendersMarker: sequenceVarLen(bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
10286
|
-
bandersnatchBlockAuthorIndex: u16.asOpaque(),
|
|
10287
|
-
entropySource: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10288
|
-
seal: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10289
|
-
};
|
|
10290
10230
|
/**
|
|
10291
10231
|
* The header of the JAM block.
|
|
10292
10232
|
*
|
|
10293
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
10233
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/0c66000c7200?v=0.7.2
|
|
10294
10234
|
*/
|
|
10295
10235
|
class header_Header extends WithDebug {
|
|
10296
|
-
static Codec = Class(header_Header,
|
|
10297
|
-
|
|
10298
|
-
:
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
seal: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10309
|
-
});
|
|
10236
|
+
static Codec = Class(header_Header, {
|
|
10237
|
+
parentHeaderHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10238
|
+
priorStateRoot: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10239
|
+
extrinsicHash: bytes(hash_HASH_SIZE).asOpaque(),
|
|
10240
|
+
timeSlotIndex: u32.asOpaque(),
|
|
10241
|
+
epochMarker: optional(EpochMarker.Codec),
|
|
10242
|
+
ticketsMarker: optional(TicketsMarker.Codec),
|
|
10243
|
+
bandersnatchBlockAuthorIndex: u16.asOpaque(),
|
|
10244
|
+
entropySource: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10245
|
+
offendersMarker: sequenceVarLen(bytes(ED25519_KEY_BYTES).asOpaque()),
|
|
10246
|
+
seal: bytes(bandersnatch_BANDERSNATCH_VRF_SIGNATURE_BYTES).asOpaque(),
|
|
10247
|
+
});
|
|
10310
10248
|
static create(h) {
|
|
10311
10249
|
return Object.assign(header_Header.empty(), h);
|
|
10312
10250
|
}
|
|
@@ -12729,9 +12667,6 @@ class LookupHistoryItem {
|
|
|
12729
12667
|
|
|
12730
12668
|
|
|
12731
12669
|
|
|
12732
|
-
const codecServiceId = Compatibility.isSuite(TestSuite.W3F_DAVXY) || Compatibility.isSuite(TestSuite.JAMDUNA, GpVersion.V0_6_7)
|
|
12733
|
-
? u32.asOpaque()
|
|
12734
|
-
: varU32.convert((s) => numbers_tryAsU32(s), (i) => tryAsServiceId(i));
|
|
12735
12670
|
/**
|
|
12736
12671
|
* Activity Record of a single validator.
|
|
12737
12672
|
*
|
|
@@ -12787,7 +12722,7 @@ const codecVarGas = varU64.convert((g) => numbers_tryAsU64(g), (i) => tryAsServi
|
|
|
12787
12722
|
* Single core statistics.
|
|
12788
12723
|
* Updated per block, based on incoming work reports (`w`).
|
|
12789
12724
|
*
|
|
12790
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
12725
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/197902197902?v=0.7.2
|
|
12791
12726
|
* https://github.com/gavofyork/graypaper/blob/9bffb08f3ea7b67832019176754df4fb36b9557d/text/statistics.tex#L65
|
|
12792
12727
|
*/
|
|
12793
12728
|
class CoreStatistics {
|
|
@@ -12799,27 +12734,16 @@ class CoreStatistics {
|
|
|
12799
12734
|
extrinsicCount;
|
|
12800
12735
|
bundleSize;
|
|
12801
12736
|
gasUsed;
|
|
12802
|
-
static Codec =
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
})
|
|
12813
|
-
: Class(CoreStatistics, {
|
|
12814
|
-
dataAvailabilityLoad: varU32,
|
|
12815
|
-
popularity: codecVarU16,
|
|
12816
|
-
imports: codecVarU16,
|
|
12817
|
-
exports: codecVarU16,
|
|
12818
|
-
extrinsicSize: varU32,
|
|
12819
|
-
extrinsicCount: codecVarU16,
|
|
12820
|
-
bundleSize: varU32,
|
|
12821
|
-
gasUsed: codecVarGas,
|
|
12822
|
-
});
|
|
12737
|
+
static Codec = Class(CoreStatistics, {
|
|
12738
|
+
dataAvailabilityLoad: varU32,
|
|
12739
|
+
popularity: codecVarU16,
|
|
12740
|
+
imports: codecVarU16,
|
|
12741
|
+
extrinsicCount: codecVarU16,
|
|
12742
|
+
extrinsicSize: varU32,
|
|
12743
|
+
exports: codecVarU16,
|
|
12744
|
+
bundleSize: varU32,
|
|
12745
|
+
gasUsed: codecVarGas,
|
|
12746
|
+
});
|
|
12823
12747
|
static create(v) {
|
|
12824
12748
|
return new CoreStatistics(v.dataAvailabilityLoad, v.popularity, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.bundleSize, v.gasUsed);
|
|
12825
12749
|
}
|
|
@@ -12860,7 +12784,7 @@ class CoreStatistics {
|
|
|
12860
12784
|
* Service statistics.
|
|
12861
12785
|
* Updated per block, based on available work reports (`W`).
|
|
12862
12786
|
*
|
|
12863
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
12787
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/19e20219e202?v=0.7.2
|
|
12864
12788
|
*/
|
|
12865
12789
|
class ServiceStatistics {
|
|
12866
12790
|
providedCount;
|
|
@@ -12882,29 +12806,15 @@ class ServiceStatistics {
|
|
|
12882
12806
|
refinementCount: varU32,
|
|
12883
12807
|
refinementGasUsed: codecVarGas,
|
|
12884
12808
|
imports: codecVarU16,
|
|
12885
|
-
exports: codecVarU16,
|
|
12886
|
-
extrinsicSize: varU32,
|
|
12887
12809
|
extrinsicCount: codecVarU16,
|
|
12810
|
+
extrinsicSize: varU32,
|
|
12811
|
+
exports: codecVarU16,
|
|
12888
12812
|
accumulateCount: varU32,
|
|
12889
12813
|
accumulateGasUsed: codecVarGas,
|
|
12890
12814
|
onTransfersCount: varU32,
|
|
12891
12815
|
onTransfersGasUsed: codecVarGas,
|
|
12892
12816
|
}),
|
|
12893
12817
|
versions: {
|
|
12894
|
-
[GpVersion.V0_7_0]: Class(ServiceStatistics, {
|
|
12895
|
-
providedCount: codecVarU16,
|
|
12896
|
-
providedSize: varU32,
|
|
12897
|
-
refinementCount: varU32,
|
|
12898
|
-
refinementGasUsed: codecVarGas,
|
|
12899
|
-
imports: codecVarU16,
|
|
12900
|
-
extrinsicCount: codecVarU16,
|
|
12901
|
-
extrinsicSize: varU32,
|
|
12902
|
-
exports: codecVarU16,
|
|
12903
|
-
accumulateCount: varU32,
|
|
12904
|
-
accumulateGasUsed: codecVarGas,
|
|
12905
|
-
onTransfersCount: varU32,
|
|
12906
|
-
onTransfersGasUsed: codecVarGas,
|
|
12907
|
-
}),
|
|
12908
12818
|
[GpVersion.V0_7_1]: Class(ServiceStatistics, {
|
|
12909
12819
|
providedCount: codecVarU16,
|
|
12910
12820
|
providedSize: varU32,
|
|
@@ -12979,7 +12889,7 @@ class StatisticsData {
|
|
|
12979
12889
|
current: codecPerValidator(ValidatorStatistics.Codec),
|
|
12980
12890
|
previous: codecPerValidator(ValidatorStatistics.Codec),
|
|
12981
12891
|
cores: codecPerCore(CoreStatistics.Codec),
|
|
12982
|
-
services: dictionary(
|
|
12892
|
+
services: dictionary(u32.asOpaque(), ServiceStatistics.Codec, {
|
|
12983
12893
|
sortKeys: (a, b) => a - b,
|
|
12984
12894
|
}),
|
|
12985
12895
|
});
|
|
@@ -14320,8 +14230,6 @@ function binaryMerkleization(input, hasher) {
|
|
|
14320
14230
|
|
|
14321
14231
|
|
|
14322
14232
|
|
|
14323
|
-
|
|
14324
|
-
const U32_BYTES = 4;
|
|
14325
14233
|
/** Numeric mapping for state entries. */
|
|
14326
14234
|
var StateKeyIdx;
|
|
14327
14235
|
(function (StateKeyIdx) {
|
|
@@ -14384,35 +14292,16 @@ var stateKeys;
|
|
|
14384
14292
|
stateKeys.serviceInfo = serviceInfo;
|
|
14385
14293
|
/** https://graypaper.fluffylabs.dev/#/1c979cb/3bba033bba03?v=0.7.1 */
|
|
14386
14294
|
function serviceStorage(blake2b, serviceId, key) {
|
|
14387
|
-
if (Compatibility.isLessThan(GpVersion.V0_6_7)) {
|
|
14388
|
-
const out = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
14389
|
-
out.raw.set(numbers_u32AsLeBytes(numbers_tryAsU32(2 ** 32 - 1)), 0);
|
|
14390
|
-
out.raw.set(key.raw.subarray(0, hash_HASH_SIZE - U32_BYTES), U32_BYTES);
|
|
14391
|
-
return legacyServiceNested(serviceId, out);
|
|
14392
|
-
}
|
|
14393
14295
|
return serviceNested(blake2b, serviceId, numbers_tryAsU32(2 ** 32 - 1), key);
|
|
14394
14296
|
}
|
|
14395
14297
|
stateKeys.serviceStorage = serviceStorage;
|
|
14396
14298
|
/** https://graypaper.fluffylabs.dev/#/1c979cb/3bd7033bd703?v=0.7.1 */
|
|
14397
14299
|
function servicePreimage(blake2b, serviceId, hash) {
|
|
14398
|
-
if (Compatibility.isLessThan(GpVersion.V0_6_7)) {
|
|
14399
|
-
const out = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
14400
|
-
out.raw.set(numbers_u32AsLeBytes(numbers_tryAsU32(2 ** 32 - 2)), 0);
|
|
14401
|
-
out.raw.set(hash.raw.subarray(1, hash_HASH_SIZE - U32_BYTES + 1), U32_BYTES);
|
|
14402
|
-
return legacyServiceNested(serviceId, out);
|
|
14403
|
-
}
|
|
14404
14300
|
return serviceNested(blake2b, serviceId, numbers_tryAsU32(2 ** 32 - 2), hash);
|
|
14405
14301
|
}
|
|
14406
14302
|
stateKeys.servicePreimage = servicePreimage;
|
|
14407
14303
|
/** https://graypaper.fluffylabs.dev/#/1c979cb/3b0a043b0a04?v=0.7.1 */
|
|
14408
14304
|
function serviceLookupHistory(blake2b, serviceId, hash, preimageLength) {
|
|
14409
|
-
if (Compatibility.isLessThan(GpVersion.V0_6_7)) {
|
|
14410
|
-
const doubleHash = blake2b.hashBytes(hash);
|
|
14411
|
-
const out = bytes_Bytes.zero(hash_HASH_SIZE);
|
|
14412
|
-
out.raw.set(numbers_u32AsLeBytes(preimageLength), 0);
|
|
14413
|
-
out.raw.set(doubleHash.raw.subarray(2, hash_HASH_SIZE - U32_BYTES + 2), U32_BYTES);
|
|
14414
|
-
return legacyServiceNested(serviceId, out);
|
|
14415
|
-
}
|
|
14416
14305
|
return serviceNested(blake2b, serviceId, preimageLength, hash);
|
|
14417
14306
|
}
|
|
14418
14307
|
stateKeys.serviceLookupHistory = serviceLookupHistory;
|
|
@@ -14436,16 +14325,16 @@ var stateKeys;
|
|
|
14436
14325
|
})(stateKeys || (stateKeys = {}));
|
|
14437
14326
|
/** https://graypaper.fluffylabs.dev/#/85129da/380101380101?v=0.6.3 */
|
|
14438
14327
|
function legacyServiceNested(serviceId, hash) {
|
|
14439
|
-
const key =
|
|
14328
|
+
const key = Bytes.zero(HASH_SIZE);
|
|
14440
14329
|
let i = 0;
|
|
14441
|
-
for (const byte of
|
|
14330
|
+
for (const byte of u32AsLeBytes(serviceId)) {
|
|
14442
14331
|
key.raw[i] = byte;
|
|
14443
14332
|
key.raw[i + 1] = hash.raw[i / 2];
|
|
14444
14333
|
i += 2;
|
|
14445
14334
|
}
|
|
14446
14335
|
// no need to floor, since we know it's divisible (adding +2 every iteration).
|
|
14447
14336
|
const middle = i / 2;
|
|
14448
|
-
key.raw.set(hash.raw.subarray(middle,
|
|
14337
|
+
key.raw.set(hash.raw.subarray(middle, HASH_SIZE - middle), i);
|
|
14449
14338
|
return key.asOpaque();
|
|
14450
14339
|
}
|
|
14451
14340
|
|
|
@@ -14689,8 +14578,6 @@ class SerializedStateView {
|
|
|
14689
14578
|
|
|
14690
14579
|
|
|
14691
14580
|
|
|
14692
|
-
|
|
14693
|
-
|
|
14694
14581
|
/**
|
|
14695
14582
|
* State object which reads it's entries from some backend.
|
|
14696
14583
|
*
|
|
@@ -14848,14 +14735,6 @@ class SerializedService {
|
|
|
14848
14735
|
}
|
|
14849
14736
|
/** Retrieve a storage item. */
|
|
14850
14737
|
getStorage(rawKey) {
|
|
14851
|
-
if (Compatibility.isLessThan(GpVersion.V0_6_7)) {
|
|
14852
|
-
const SERVICE_ID_BYTES = 4;
|
|
14853
|
-
const serviceIdAndKey = safe_alloc_uint8array_safeAllocUint8Array(SERVICE_ID_BYTES + rawKey.length);
|
|
14854
|
-
serviceIdAndKey.set(numbers_u32AsLeBytes(this.serviceId));
|
|
14855
|
-
serviceIdAndKey.set(rawKey.raw, SERVICE_ID_BYTES);
|
|
14856
|
-
const key = opaque_asOpaqueType(bytes_BytesBlob.blobFrom(this.blake2b.hashBytes(serviceIdAndKey).raw));
|
|
14857
|
-
return this.retrieveOptional(serialize_serialize.serviceStorage(this.blake2b, this.serviceId, key)) ?? null;
|
|
14858
|
-
}
|
|
14859
14738
|
return this.retrieveOptional(serialize_serialize.serviceStorage(this.blake2b, this.serviceId, rawKey)) ?? null;
|
|
14860
14739
|
}
|
|
14861
14740
|
/**
|