@typeberry/convert 0.2.0-b6e3410 → 0.2.0-c3df163
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1014 -828
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -6319,6 +6319,9 @@ class ObjectView {
|
|
|
6319
6319
|
toString() {
|
|
6320
6320
|
return `View<${this.materializedConstructor.name}>(cache: ${this.cache.size})`;
|
|
6321
6321
|
}
|
|
6322
|
+
[TEST_COMPARE_USING]() {
|
|
6323
|
+
return this.materialize();
|
|
6324
|
+
}
|
|
6322
6325
|
}
|
|
6323
6326
|
/**
|
|
6324
6327
|
* A lazy-evaluated decoder of a sequence.
|
|
@@ -6613,7 +6616,15 @@ var descriptors_codec;
|
|
|
6613
6616
|
/** Custom encoding / decoding logic. */
|
|
6614
6617
|
codec.custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
|
|
6615
6618
|
/** Choose a descriptor depending on the encoding/decoding context. */
|
|
6616
|
-
codec.select = ({ name, sizeHint, }, chooser) =>
|
|
6619
|
+
codec.select = ({ name, sizeHint, }, chooser) => {
|
|
6620
|
+
const Self = chooser(null);
|
|
6621
|
+
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)
|
|
6622
|
+
? codec.select({
|
|
6623
|
+
name: Self.View.name,
|
|
6624
|
+
sizeHint: Self.View.sizeHint,
|
|
6625
|
+
}, (ctx) => chooser(ctx).View)
|
|
6626
|
+
: Self.View);
|
|
6627
|
+
};
|
|
6617
6628
|
/**
|
|
6618
6629
|
* A descriptor for a more complex POJO.
|
|
6619
6630
|
*
|
|
@@ -10052,6 +10063,19 @@ function block_emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
|
10052
10063
|
});
|
|
10053
10064
|
}
|
|
10054
10065
|
|
|
10066
|
+
;// CONCATENATED MODULE: ./packages/jam/block/utils.ts
|
|
10067
|
+
|
|
10068
|
+
/**
|
|
10069
|
+
* Take an input data and re-encode that data as view.
|
|
10070
|
+
*
|
|
10071
|
+
* NOTE: this function should NEVER be used in any production code,
|
|
10072
|
+
* it's only a test helper.
|
|
10073
|
+
*/
|
|
10074
|
+
function reencodeAsView(codec, object, chainSpec) {
|
|
10075
|
+
const encoded = encoder_Encoder.encodeObject(codec, object, chainSpec);
|
|
10076
|
+
return decoder_Decoder.decodeObject(codec.View, encoded, chainSpec);
|
|
10077
|
+
}
|
|
10078
|
+
|
|
10055
10079
|
;// CONCATENATED MODULE: ./packages/jam/block/index.ts
|
|
10056
10080
|
|
|
10057
10081
|
|
|
@@ -10070,6 +10094,7 @@ function block_emptyBlock(slot = tryAsTimeSlot(0)) {
|
|
|
10070
10094
|
|
|
10071
10095
|
|
|
10072
10096
|
|
|
10097
|
+
|
|
10073
10098
|
;// CONCATENATED MODULE: ./packages/core/json-parser/parse.ts
|
|
10074
10099
|
const NO_KEY = Symbol("no key");
|
|
10075
10100
|
/** Given already parsed JSON, parse & validate it further to match the expected `jsonDescription` type. */
|
|
@@ -11438,10 +11463,129 @@ function accumulation_output_accumulationOutputComparator(a, b) {
|
|
|
11438
11463
|
return Ordering.Equal;
|
|
11439
11464
|
}
|
|
11440
11465
|
|
|
11466
|
+
;// CONCATENATED MODULE: ./packages/jam/block/gp-constants.ts
|
|
11467
|
+
|
|
11468
|
+
|
|
11469
|
+
/**
|
|
11470
|
+
* This file lists all of the constants defined in the GrayPaper appendix.
|
|
11471
|
+
*
|
|
11472
|
+
* NOTE: Avoid using the constants directly, prefer "named" constants defined
|
|
11473
|
+
* in a semantical proximity to where they are used.
|
|
11474
|
+
*
|
|
11475
|
+
* NOTE: This file will most likely be removed in the future. The constants
|
|
11476
|
+
* here are only temporarily for convenience. When we figure out better names
|
|
11477
|
+
* and places for these this file will be eradicated.
|
|
11478
|
+
*
|
|
11479
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/442300442300?v=0.7.2
|
|
11480
|
+
*/
|
|
11481
|
+
/** `G_I`: The gas allocated to invoke a work-package’s Is-Authorized logic. */
|
|
11482
|
+
const gp_constants_G_I = 50_000_000;
|
|
11483
|
+
/** `I`: Maximum number of work items in a package. */
|
|
11484
|
+
const I = (/* unused pure expression or super */ null && (MAX_NUMBER_OF_WORK_ITEMS));
|
|
11485
|
+
/** `O`: Maximum number of items in the authorizations pool. */
|
|
11486
|
+
const gp_constants_O = 8;
|
|
11487
|
+
/** `Q`: The number of items in the authorizations queue. */
|
|
11488
|
+
const gp_constants_Q = 80;
|
|
11489
|
+
/** `S`: The maximum number of entries in the accumulation queue. */
|
|
11490
|
+
const S = 1024;
|
|
11491
|
+
/** `T`: The maximum number of extrinsics in a work-package. */
|
|
11492
|
+
const gp_constants_T = 128;
|
|
11493
|
+
/** `W_A`: The maximum size of is-authorized code in octets. */
|
|
11494
|
+
const gp_constants_W_A = 64_000;
|
|
11495
|
+
/** `W_B`: The maximum size of the concatenated variable-size blobs, extrinsics and imported segments of a work-package, in octets */
|
|
11496
|
+
const gp_constants_W_B = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_2) ? 13_791_360 : 13_794_305;
|
|
11497
|
+
/** `W_C`: The maximum size of service code in octets. */
|
|
11498
|
+
const gp_constants_W_C = 4_000_000;
|
|
11499
|
+
/** `W_M`: The maximum number of imports in a work-package. */
|
|
11500
|
+
const gp_constants_W_M = 3_072;
|
|
11501
|
+
/** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
|
|
11502
|
+
const gp_constants_W_R = 49_152;
|
|
11503
|
+
/** `W_T`: The size of a transfer memo in octets. */
|
|
11504
|
+
const gp_constants_W_T = 128;
|
|
11505
|
+
/** `W_M`: The maximum number of exports in a work-package. */
|
|
11506
|
+
const gp_constants_W_X = 3_072;
|
|
11507
|
+
// TODO [ToDr] Not sure where these should live yet :(
|
|
11508
|
+
/**
|
|
11509
|
+
* `S`: The minimum public service index.
|
|
11510
|
+
* Services of indices below these may only be created by the Registrar.
|
|
11511
|
+
*
|
|
11512
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/447a00447a00?v=0.7.2
|
|
11513
|
+
*/
|
|
11514
|
+
const gp_constants_MIN_PUBLIC_SERVICE_INDEX = (/* unused pure expression or super */ null && (2 ** 16));
|
|
11515
|
+
/**
|
|
11516
|
+
* `J`: The maximum sum of dependency items in a work-report.
|
|
11517
|
+
*
|
|
11518
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/416a00416a00?v=0.6.2
|
|
11519
|
+
*/
|
|
11520
|
+
const gp_constants_MAX_REPORT_DEPENDENCIES = 8;
|
|
11521
|
+
|
|
11522
|
+
;// CONCATENATED MODULE: ./packages/jam/state/accumulation-queue.ts
|
|
11523
|
+
|
|
11524
|
+
|
|
11525
|
+
|
|
11526
|
+
|
|
11527
|
+
|
|
11528
|
+
|
|
11529
|
+
|
|
11530
|
+
/**
|
|
11531
|
+
* Ready (i.e. available and/or audited) but not-yet-accumulated work-reports.
|
|
11532
|
+
*
|
|
11533
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/165300165400
|
|
11534
|
+
*/
|
|
11535
|
+
class accumulation_queue_NotYetAccumulatedReport extends WithDebug {
|
|
11536
|
+
report;
|
|
11537
|
+
dependencies;
|
|
11538
|
+
static Codec = descriptors_codec.Class(accumulation_queue_NotYetAccumulatedReport, {
|
|
11539
|
+
report: work_report_WorkReport.Codec,
|
|
11540
|
+
dependencies: codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
11541
|
+
typicalLength: gp_constants_MAX_REPORT_DEPENDENCIES / 2,
|
|
11542
|
+
maxLength: gp_constants_MAX_REPORT_DEPENDENCIES,
|
|
11543
|
+
minLength: 0,
|
|
11544
|
+
}),
|
|
11545
|
+
});
|
|
11546
|
+
static create({ report, dependencies }) {
|
|
11547
|
+
return new accumulation_queue_NotYetAccumulatedReport(report, dependencies);
|
|
11548
|
+
}
|
|
11549
|
+
constructor(
|
|
11550
|
+
/**
|
|
11551
|
+
* Each of these were made available at most one epoch ago
|
|
11552
|
+
* but have or had unfulfilled dependencies.
|
|
11553
|
+
*/
|
|
11554
|
+
report,
|
|
11555
|
+
/**
|
|
11556
|
+
* Alongside the work-report itself, we retain its un-accumulated
|
|
11557
|
+
* dependencies, a set of work-package hashes.
|
|
11558
|
+
*
|
|
11559
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/165800165800
|
|
11560
|
+
*/
|
|
11561
|
+
dependencies) {
|
|
11562
|
+
super();
|
|
11563
|
+
this.report = report;
|
|
11564
|
+
this.dependencies = dependencies;
|
|
11565
|
+
}
|
|
11566
|
+
}
|
|
11567
|
+
const accumulationQueueCodec = codecPerEpochBlock(readonlyArray(descriptors_codec.sequenceVarLen(accumulation_queue_NotYetAccumulatedReport.Codec)));
|
|
11568
|
+
|
|
11569
|
+
;// CONCATENATED MODULE: ./packages/jam/state/common.ts
|
|
11570
|
+
|
|
11571
|
+
|
|
11572
|
+
/** Check if given array has correct length before casting to the opaque type. */
|
|
11573
|
+
function common_tryAsPerCore(array, spec) {
|
|
11574
|
+
debug_check `
|
|
11575
|
+
${array.length === spec.coresCount}
|
|
11576
|
+
Invalid per-core array length. Expected ${spec.coresCount}, got: ${array.length}
|
|
11577
|
+
`;
|
|
11578
|
+
return opaque_asOpaqueType(array);
|
|
11579
|
+
}
|
|
11580
|
+
const codecPerCore = (val) => codecWithContext((context) => {
|
|
11581
|
+
return codecKnownSizeArray(val, { fixedLength: context.coresCount });
|
|
11582
|
+
});
|
|
11583
|
+
|
|
11441
11584
|
;// CONCATENATED MODULE: ./packages/jam/state/assurances.ts
|
|
11442
11585
|
|
|
11443
11586
|
|
|
11444
11587
|
|
|
11588
|
+
|
|
11445
11589
|
/**
|
|
11446
11590
|
* Assignment of particular work report to a core.
|
|
11447
11591
|
*
|
|
@@ -11470,21 +11614,24 @@ class assurances_AvailabilityAssignment extends WithDebug {
|
|
|
11470
11614
|
this.timeout = timeout;
|
|
11471
11615
|
}
|
|
11472
11616
|
}
|
|
11617
|
+
const availabilityAssignmentsCodec = codecPerCore(descriptors_codec.optional(assurances_AvailabilityAssignment.Codec));
|
|
11473
11618
|
|
|
11474
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
11619
|
+
;// CONCATENATED MODULE: ./packages/jam/state/auth.ts
|
|
11475
11620
|
|
|
11476
11621
|
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11622
|
+
|
|
11623
|
+
|
|
11624
|
+
|
|
11625
|
+
/** `O`: Maximal authorization pool size. */
|
|
11626
|
+
const auth_MAX_AUTH_POOL_SIZE = gp_constants_O;
|
|
11627
|
+
/** `Q`: Size of the authorization queue. */
|
|
11628
|
+
const auth_AUTHORIZATION_QUEUE_SIZE = gp_constants_Q;
|
|
11629
|
+
const authPoolsCodec = codecPerCore(codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
11630
|
+
minLength: 0,
|
|
11631
|
+
maxLength: auth_MAX_AUTH_POOL_SIZE,
|
|
11632
|
+
typicalLength: auth_MAX_AUTH_POOL_SIZE,
|
|
11633
|
+
}));
|
|
11634
|
+
const authQueuesCodec = codecPerCore(codecFixedSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), auth_AUTHORIZATION_QUEUE_SIZE));
|
|
11488
11635
|
|
|
11489
11636
|
;// CONCATENATED MODULE: ./packages/jam/state/disputes.ts
|
|
11490
11637
|
|
|
@@ -11552,65 +11699,6 @@ function disputes_hashComparator(a, b) {
|
|
|
11552
11699
|
return a.compare(b);
|
|
11553
11700
|
}
|
|
11554
11701
|
|
|
11555
|
-
;// CONCATENATED MODULE: ./packages/jam/block/gp-constants.ts
|
|
11556
|
-
|
|
11557
|
-
/**
|
|
11558
|
-
* This file lists all of the constants defined in the GrayPaper appendix.
|
|
11559
|
-
*
|
|
11560
|
-
* NOTE: Avoid using the constants directly, prefer "named" constants defined
|
|
11561
|
-
* in a semantical proximity to where they are used.
|
|
11562
|
-
*
|
|
11563
|
-
* NOTE: This file will most likely be removed in the future. The constants
|
|
11564
|
-
* here are only temporarily for convenience. When we figure out better names
|
|
11565
|
-
* and places for these this file will be eradicated.
|
|
11566
|
-
*
|
|
11567
|
-
* https://graypaper.fluffylabs.dev/#/579bd12/413000413000
|
|
11568
|
-
*/
|
|
11569
|
-
/** `G_I`: The gas allocated to invoke a work-package’s Is-Authorized logic. */
|
|
11570
|
-
const gp_constants_G_I = 50_000_000;
|
|
11571
|
-
/** `I`: Maximum number of work items in a package. */
|
|
11572
|
-
const I = (/* unused pure expression or super */ null && (MAX_NUMBER_OF_WORK_ITEMS));
|
|
11573
|
-
/** `O`: Maximum number of items in the authorizations pool. */
|
|
11574
|
-
const gp_constants_O = 8;
|
|
11575
|
-
/** `Q`: The number of items in the authorizations queue. */
|
|
11576
|
-
const gp_constants_Q = 80;
|
|
11577
|
-
/** `S`: The maximum number of entries in the accumulation queue. */
|
|
11578
|
-
const S = 1024;
|
|
11579
|
-
/** `T`: The maximum number of extrinsics in a work-package. */
|
|
11580
|
-
const gp_constants_T = 128;
|
|
11581
|
-
/** `W_A`: The maximum size of is-authorized code in octets. */
|
|
11582
|
-
const gp_constants_W_A = 64_000;
|
|
11583
|
-
/** `W_B`: The maximum size of an encoded work-package with extrinsic data and imports. */
|
|
11584
|
-
const gp_constants_W_B = 13_794_305;
|
|
11585
|
-
/** `W_C`: The maximum size of service code in octets. */
|
|
11586
|
-
const gp_constants_W_C = 4_000_000;
|
|
11587
|
-
/** `W_M`: The maximum number of imports in a work-package. */
|
|
11588
|
-
const gp_constants_W_M = 3_072;
|
|
11589
|
-
/** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
|
|
11590
|
-
const gp_constants_W_R = 49_152;
|
|
11591
|
-
/** `W_T`: The size of a transfer memo in octets. */
|
|
11592
|
-
const gp_constants_W_T = 128;
|
|
11593
|
-
/** `W_M`: The maximum number of exports in a work-package. */
|
|
11594
|
-
const gp_constants_W_X = 3_072;
|
|
11595
|
-
// TODO [ToDr] Not sure where these should live yet :(
|
|
11596
|
-
/**
|
|
11597
|
-
* `S`: The minimum public service index.
|
|
11598
|
-
* Services of indices below these may only be created by the Registrar.
|
|
11599
|
-
*
|
|
11600
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/447a00447a00?v=0.7.2
|
|
11601
|
-
*/
|
|
11602
|
-
const gp_constants_MIN_PUBLIC_SERVICE_INDEX = (/* unused pure expression or super */ null && (2 ** 16));
|
|
11603
|
-
/**
|
|
11604
|
-
* `J`: The maximum sum of dependency items in a work-report.
|
|
11605
|
-
*
|
|
11606
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/416a00416a00?v=0.6.2
|
|
11607
|
-
*/
|
|
11608
|
-
const gp_constants_MAX_REPORT_DEPENDENCIES = 8;
|
|
11609
|
-
/** `Q`: Size of the authorization queue. */
|
|
11610
|
-
const gp_constants_AUTHORIZATION_QUEUE_SIZE = gp_constants_Q;
|
|
11611
|
-
/** `O`: Maximal authorization pool size. */
|
|
11612
|
-
const gp_constants_MAX_AUTH_POOL_SIZE = gp_constants_O;
|
|
11613
|
-
|
|
11614
11702
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/ops/math-consts.ts
|
|
11615
11703
|
const math_consts_MAX_VALUE = 4294967295;
|
|
11616
11704
|
const math_consts_MAX_VALUE_U64 = (/* unused pure expression or super */ null && (2n ** 63n));
|
|
@@ -11618,7 +11706,7 @@ const math_consts_MIN_VALUE = (/* unused pure expression or super */ null && (-(
|
|
|
11618
11706
|
const math_consts_MAX_SHIFT_U32 = 32;
|
|
11619
11707
|
const math_consts_MAX_SHIFT_U64 = 64n;
|
|
11620
11708
|
|
|
11621
|
-
;// CONCATENATED MODULE: ./packages/jam/state/
|
|
11709
|
+
;// CONCATENATED MODULE: ./packages/jam/state/recent-blocks.ts
|
|
11622
11710
|
|
|
11623
11711
|
|
|
11624
11712
|
|
|
@@ -11626,35 +11714,279 @@ const math_consts_MAX_SHIFT_U64 = 64n;
|
|
|
11626
11714
|
|
|
11627
11715
|
|
|
11628
11716
|
/**
|
|
11629
|
-
* `
|
|
11630
|
-
*
|
|
11631
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
11632
|
-
*/
|
|
11633
|
-
const service_BASE_SERVICE_BALANCE = 100n;
|
|
11634
|
-
/**
|
|
11635
|
-
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
11717
|
+
* `H = 8`: The size of recent history, in blocks.
|
|
11636
11718
|
*
|
|
11637
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
11719
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/416300416500
|
|
11638
11720
|
*/
|
|
11639
|
-
const
|
|
11721
|
+
const recent_blocks_MAX_RECENT_HISTORY = 8;
|
|
11722
|
+
/** Recent history of a single block. */
|
|
11723
|
+
class recent_blocks_BlockState extends WithDebug {
|
|
11724
|
+
headerHash;
|
|
11725
|
+
accumulationResult;
|
|
11726
|
+
postStateRoot;
|
|
11727
|
+
reported;
|
|
11728
|
+
static Codec = descriptors_codec.Class(recent_blocks_BlockState, {
|
|
11729
|
+
headerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
11730
|
+
accumulationResult: descriptors_codec.bytes(hash_HASH_SIZE),
|
|
11731
|
+
postStateRoot: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
11732
|
+
reported: codecHashDictionary(refine_context_WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
11733
|
+
});
|
|
11734
|
+
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
11735
|
+
return new recent_blocks_BlockState(headerHash, accumulationResult, postStateRoot, reported);
|
|
11736
|
+
}
|
|
11737
|
+
constructor(
|
|
11738
|
+
/** Header hash. */
|
|
11739
|
+
headerHash,
|
|
11740
|
+
/** Merkle mountain belt of accumulation result. */
|
|
11741
|
+
accumulationResult,
|
|
11742
|
+
/** Posterior state root filled in with a 1-block delay. */
|
|
11743
|
+
postStateRoot,
|
|
11744
|
+
/** Reported work packages (no more than number of cores). */
|
|
11745
|
+
reported) {
|
|
11746
|
+
super();
|
|
11747
|
+
this.headerHash = headerHash;
|
|
11748
|
+
this.accumulationResult = accumulationResult;
|
|
11749
|
+
this.postStateRoot = postStateRoot;
|
|
11750
|
+
this.reported = reported;
|
|
11751
|
+
}
|
|
11752
|
+
}
|
|
11640
11753
|
/**
|
|
11641
|
-
*
|
|
11754
|
+
* Recent history of blocks.
|
|
11642
11755
|
*
|
|
11643
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/
|
|
11756
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fc9010fc901?v=0.6.7
|
|
11644
11757
|
*/
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
},
|
|
11657
|
-
|
|
11758
|
+
class recent_blocks_RecentBlocks extends WithDebug {
|
|
11759
|
+
blocks;
|
|
11760
|
+
accumulationLog;
|
|
11761
|
+
static Codec = descriptors_codec.Class(recent_blocks_RecentBlocks, {
|
|
11762
|
+
blocks: codecKnownSizeArray(recent_blocks_BlockState.Codec, {
|
|
11763
|
+
minLength: 0,
|
|
11764
|
+
maxLength: recent_blocks_MAX_RECENT_HISTORY,
|
|
11765
|
+
typicalLength: recent_blocks_MAX_RECENT_HISTORY,
|
|
11766
|
+
}),
|
|
11767
|
+
accumulationLog: descriptors_codec.object({
|
|
11768
|
+
peaks: readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.optional(descriptors_codec.bytes(hash_HASH_SIZE)))),
|
|
11769
|
+
}),
|
|
11770
|
+
});
|
|
11771
|
+
static empty() {
|
|
11772
|
+
return new recent_blocks_RecentBlocks(sized_array_asKnownSize([]), {
|
|
11773
|
+
peaks: [],
|
|
11774
|
+
});
|
|
11775
|
+
}
|
|
11776
|
+
static create(a) {
|
|
11777
|
+
return new recent_blocks_RecentBlocks(a.blocks, a.accumulationLog);
|
|
11778
|
+
}
|
|
11779
|
+
constructor(
|
|
11780
|
+
/**
|
|
11781
|
+
* Most recent blocks.
|
|
11782
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fea010fea01?v=0.6.7
|
|
11783
|
+
*/
|
|
11784
|
+
blocks,
|
|
11785
|
+
/**
|
|
11786
|
+
* Accumulation output log.
|
|
11787
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0f02020f0202?v=0.6.7
|
|
11788
|
+
*/
|
|
11789
|
+
accumulationLog) {
|
|
11790
|
+
super();
|
|
11791
|
+
this.blocks = blocks;
|
|
11792
|
+
this.accumulationLog = accumulationLog;
|
|
11793
|
+
}
|
|
11794
|
+
}
|
|
11795
|
+
|
|
11796
|
+
;// CONCATENATED MODULE: ./packages/jam/state/recently-accumulated.ts
|
|
11797
|
+
|
|
11798
|
+
|
|
11799
|
+
|
|
11800
|
+
|
|
11801
|
+
const recentlyAccumulatedCodec = codecPerEpochBlock(descriptors_codec.sequenceVarLen(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque()).convert((x) => Array.from(x), (x) => hash_set_HashSet.from(x)));
|
|
11802
|
+
|
|
11803
|
+
;// CONCATENATED MODULE: ./packages/jam/state/validator-data.ts
|
|
11804
|
+
|
|
11805
|
+
|
|
11806
|
+
|
|
11807
|
+
|
|
11808
|
+
/**
|
|
11809
|
+
* Fixed size of validator metadata.
|
|
11810
|
+
*
|
|
11811
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/0d55010d5501
|
|
11812
|
+
*/
|
|
11813
|
+
const VALIDATOR_META_BYTES = 128;
|
|
11814
|
+
/**
|
|
11815
|
+
* Details about validators' identity.
|
|
11816
|
+
*
|
|
11817
|
+
* https://graypaper.fluffylabs.dev/#/5f542d7/0d4b010d4c01
|
|
11818
|
+
*/
|
|
11819
|
+
class validator_data_ValidatorData extends WithDebug {
|
|
11820
|
+
bandersnatch;
|
|
11821
|
+
ed25519;
|
|
11822
|
+
bls;
|
|
11823
|
+
metadata;
|
|
11824
|
+
static Codec = descriptors_codec.Class(validator_data_ValidatorData, {
|
|
11825
|
+
bandersnatch: descriptors_codec.bytes(bandersnatch_BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
11826
|
+
ed25519: descriptors_codec.bytes(ed25519_ED25519_KEY_BYTES).asOpaque(),
|
|
11827
|
+
bls: descriptors_codec.bytes(bandersnatch_BLS_KEY_BYTES).asOpaque(),
|
|
11828
|
+
metadata: descriptors_codec.bytes(VALIDATOR_META_BYTES),
|
|
11829
|
+
});
|
|
11830
|
+
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
11831
|
+
return new validator_data_ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
11832
|
+
}
|
|
11833
|
+
constructor(
|
|
11834
|
+
/** Bandersnatch public key. */
|
|
11835
|
+
bandersnatch,
|
|
11836
|
+
/** ED25519 key data. */
|
|
11837
|
+
ed25519,
|
|
11838
|
+
/** BLS public key. */
|
|
11839
|
+
bls,
|
|
11840
|
+
/** Validator-defined additional metdata. */
|
|
11841
|
+
metadata) {
|
|
11842
|
+
super();
|
|
11843
|
+
this.bandersnatch = bandersnatch;
|
|
11844
|
+
this.ed25519 = ed25519;
|
|
11845
|
+
this.bls = bls;
|
|
11846
|
+
this.metadata = metadata;
|
|
11847
|
+
}
|
|
11848
|
+
}
|
|
11849
|
+
const validatorsDataCodec = codecPerValidator(validator_data_ValidatorData.Codec);
|
|
11850
|
+
|
|
11851
|
+
;// CONCATENATED MODULE: ./packages/jam/state/safrole-data.ts
|
|
11852
|
+
|
|
11853
|
+
|
|
11854
|
+
|
|
11855
|
+
|
|
11856
|
+
|
|
11857
|
+
|
|
11858
|
+
|
|
11859
|
+
|
|
11860
|
+
|
|
11861
|
+
|
|
11862
|
+
|
|
11863
|
+
var safrole_data_SafroleSealingKeysKind;
|
|
11864
|
+
(function (SafroleSealingKeysKind) {
|
|
11865
|
+
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
11866
|
+
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
11867
|
+
})(safrole_data_SafroleSealingKeysKind || (safrole_data_SafroleSealingKeysKind = {}));
|
|
11868
|
+
const codecBandersnatchKey = descriptors_codec.bytes(bandersnatch_BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
11869
|
+
class safrole_data_SafroleSealingKeysData extends WithDebug {
|
|
11870
|
+
kind;
|
|
11871
|
+
keys;
|
|
11872
|
+
tickets;
|
|
11873
|
+
static Codec = codecWithContext((context) => {
|
|
11874
|
+
return descriptors_codec.custom({
|
|
11875
|
+
name: "SafroleSealingKeys",
|
|
11876
|
+
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
11877
|
+
}, (e, x) => {
|
|
11878
|
+
e.varU32(numbers_tryAsU32(x.kind));
|
|
11879
|
+
if (x.kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
11880
|
+
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
11881
|
+
}
|
|
11882
|
+
else {
|
|
11883
|
+
e.sequenceFixLen(Ticket.Codec, x.tickets);
|
|
11884
|
+
}
|
|
11885
|
+
}, (d) => {
|
|
11886
|
+
const epochLength = context.epochLength;
|
|
11887
|
+
const kind = d.varU32();
|
|
11888
|
+
if (kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
11889
|
+
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
11890
|
+
return safrole_data_SafroleSealingKeysData.keys(common_tryAsPerEpochBlock(keys, context));
|
|
11891
|
+
}
|
|
11892
|
+
if (kind === safrole_data_SafroleSealingKeysKind.Tickets) {
|
|
11893
|
+
const tickets = d.sequenceFixLen(Ticket.Codec, epochLength);
|
|
11894
|
+
return safrole_data_SafroleSealingKeysData.tickets(common_tryAsPerEpochBlock(tickets, context));
|
|
11895
|
+
}
|
|
11896
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
11897
|
+
}, (s) => {
|
|
11898
|
+
const kind = s.decoder.varU32();
|
|
11899
|
+
if (kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
11900
|
+
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
11901
|
+
return;
|
|
11902
|
+
}
|
|
11903
|
+
if (kind === safrole_data_SafroleSealingKeysKind.Tickets) {
|
|
11904
|
+
s.sequenceFixLen(Ticket.Codec, context.epochLength);
|
|
11905
|
+
return;
|
|
11906
|
+
}
|
|
11907
|
+
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
11908
|
+
});
|
|
11909
|
+
});
|
|
11910
|
+
static keys(keys) {
|
|
11911
|
+
return new safrole_data_SafroleSealingKeysData(safrole_data_SafroleSealingKeysKind.Keys, keys, undefined);
|
|
11912
|
+
}
|
|
11913
|
+
static tickets(tickets) {
|
|
11914
|
+
return new safrole_data_SafroleSealingKeysData(safrole_data_SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
11915
|
+
}
|
|
11916
|
+
constructor(kind, keys, tickets) {
|
|
11917
|
+
super();
|
|
11918
|
+
this.kind = kind;
|
|
11919
|
+
this.keys = keys;
|
|
11920
|
+
this.tickets = tickets;
|
|
11921
|
+
}
|
|
11922
|
+
}
|
|
11923
|
+
class safrole_data_SafroleData {
|
|
11924
|
+
nextValidatorData;
|
|
11925
|
+
epochRoot;
|
|
11926
|
+
sealingKeySeries;
|
|
11927
|
+
ticketsAccumulator;
|
|
11928
|
+
static Codec = descriptors_codec.Class(safrole_data_SafroleData, {
|
|
11929
|
+
nextValidatorData: codecPerValidator(validator_data_ValidatorData.Codec),
|
|
11930
|
+
epochRoot: descriptors_codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
11931
|
+
sealingKeySeries: safrole_data_SafroleSealingKeysData.Codec,
|
|
11932
|
+
ticketsAccumulator: readonlyArray(descriptors_codec.sequenceVarLen(Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
11933
|
+
});
|
|
11934
|
+
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
11935
|
+
return new safrole_data_SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
11936
|
+
}
|
|
11937
|
+
constructor(
|
|
11938
|
+
/** gamma_k */
|
|
11939
|
+
nextValidatorData,
|
|
11940
|
+
/** gamma_z */
|
|
11941
|
+
epochRoot,
|
|
11942
|
+
/** gamma_s */
|
|
11943
|
+
sealingKeySeries,
|
|
11944
|
+
/** gamma_a */
|
|
11945
|
+
ticketsAccumulator) {
|
|
11946
|
+
this.nextValidatorData = nextValidatorData;
|
|
11947
|
+
this.epochRoot = epochRoot;
|
|
11948
|
+
this.sealingKeySeries = sealingKeySeries;
|
|
11949
|
+
this.ticketsAccumulator = ticketsAccumulator;
|
|
11950
|
+
}
|
|
11951
|
+
}
|
|
11952
|
+
|
|
11953
|
+
;// CONCATENATED MODULE: ./packages/jam/state/service.ts
|
|
11954
|
+
|
|
11955
|
+
|
|
11956
|
+
|
|
11957
|
+
|
|
11958
|
+
|
|
11959
|
+
|
|
11960
|
+
/**
|
|
11961
|
+
* `B_S`: The basic minimum balance which all services require.
|
|
11962
|
+
*
|
|
11963
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445800445800?v=0.6.7
|
|
11964
|
+
*/
|
|
11965
|
+
const service_BASE_SERVICE_BALANCE = 100n;
|
|
11966
|
+
/**
|
|
11967
|
+
* `B_I`: The additional minimum balance required per item of elective service state.
|
|
11968
|
+
*
|
|
11969
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445000445000?v=0.6.7
|
|
11970
|
+
*/
|
|
11971
|
+
const service_ELECTIVE_ITEM_BALANCE = 10n;
|
|
11972
|
+
/**
|
|
11973
|
+
* `B_L`: The additional minimum balance required per octet of elective service state.
|
|
11974
|
+
*
|
|
11975
|
+
* https://graypaper.fluffylabs.dev/#/7e6ff6a/445400445400?v=0.6.7
|
|
11976
|
+
*/
|
|
11977
|
+
const service_ELECTIVE_BYTE_BALANCE = 1n;
|
|
11978
|
+
const zeroSizeHint = {
|
|
11979
|
+
bytes: 0,
|
|
11980
|
+
isExact: true,
|
|
11981
|
+
};
|
|
11982
|
+
/** 0-byte read, return given default value */
|
|
11983
|
+
const ignoreValueWithDefault = (defaultValue) => Descriptor.new("ignoreValue", zeroSizeHint, (_e, _v) => { }, (_d) => defaultValue, (_s) => { });
|
|
11984
|
+
/** Encode and decode object with leading version number. */
|
|
11985
|
+
const codecWithVersion = (val) => Descriptor.new("withVersion", {
|
|
11986
|
+
bytes: val.sizeHint.bytes + 8,
|
|
11987
|
+
isExact: false,
|
|
11988
|
+
}, (e, v) => {
|
|
11989
|
+
e.varU64(0n);
|
|
11658
11990
|
val.encode(e, v);
|
|
11659
11991
|
}, (d) => {
|
|
11660
11992
|
const version = d.varU64();
|
|
@@ -11808,522 +12140,6 @@ class service_LookupHistoryItem {
|
|
|
11808
12140
|
}
|
|
11809
12141
|
}
|
|
11810
12142
|
|
|
11811
|
-
;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
|
|
11812
|
-
|
|
11813
|
-
|
|
11814
|
-
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
-
/** Dictionary entry of services that auto-accumulate every block. */
|
|
11818
|
-
class privileged_services_AutoAccumulate {
|
|
11819
|
-
service;
|
|
11820
|
-
gasLimit;
|
|
11821
|
-
static Codec = descriptors_codec.Class(privileged_services_AutoAccumulate, {
|
|
11822
|
-
service: descriptors_codec.u32.asOpaque(),
|
|
11823
|
-
gasLimit: descriptors_codec.u64.asOpaque(),
|
|
11824
|
-
});
|
|
11825
|
-
static create({ service, gasLimit }) {
|
|
11826
|
-
return new privileged_services_AutoAccumulate(service, gasLimit);
|
|
11827
|
-
}
|
|
11828
|
-
constructor(
|
|
11829
|
-
/** Service id that auto-accumulates. */
|
|
11830
|
-
service,
|
|
11831
|
-
/** Gas limit for auto-accumulation. */
|
|
11832
|
-
gasLimit) {
|
|
11833
|
-
this.service = service;
|
|
11834
|
-
this.gasLimit = gasLimit;
|
|
11835
|
-
}
|
|
11836
|
-
}
|
|
11837
|
-
/**
|
|
11838
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
11839
|
-
*/
|
|
11840
|
-
class privileged_services_PrivilegedServices {
|
|
11841
|
-
manager;
|
|
11842
|
-
delegator;
|
|
11843
|
-
registrar;
|
|
11844
|
-
assigners;
|
|
11845
|
-
autoAccumulateServices;
|
|
11846
|
-
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
11847
|
-
static Codec = descriptors_codec.Class(privileged_services_PrivilegedServices, {
|
|
11848
|
-
manager: descriptors_codec.u32.asOpaque(),
|
|
11849
|
-
assigners: codecPerCore(descriptors_codec.u32.asOpaque()),
|
|
11850
|
-
delegator: descriptors_codec.u32.asOpaque(),
|
|
11851
|
-
registrar: compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1)
|
|
11852
|
-
? descriptors_codec.u32.asOpaque()
|
|
11853
|
-
: ignoreValueWithDefault(common_tryAsServiceId(2 ** 32 - 1)),
|
|
11854
|
-
autoAccumulateServices: readonlyArray(descriptors_codec.sequenceVarLen(privileged_services_AutoAccumulate.Codec)),
|
|
11855
|
-
});
|
|
11856
|
-
static create(a) {
|
|
11857
|
-
return new privileged_services_PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
11858
|
-
}
|
|
11859
|
-
constructor(
|
|
11860
|
-
/**
|
|
11861
|
-
* `χ_M`: Manages alteration of χ from block to block,
|
|
11862
|
-
* as well as bestow services with storage deposit credits.
|
|
11863
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111502111902?v=0.7.2
|
|
11864
|
-
*/
|
|
11865
|
-
manager,
|
|
11866
|
-
/** `χ_V`: Managers validator keys. */
|
|
11867
|
-
delegator,
|
|
11868
|
-
/**
|
|
11869
|
-
* `χ_R`: Manages the creation of services in protected range.
|
|
11870
|
-
*
|
|
11871
|
-
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111b02111d02?v=0.7.2
|
|
11872
|
-
*/
|
|
11873
|
-
registrar,
|
|
11874
|
-
/** `χ_A`: Manages authorization queue one for each core. */
|
|
11875
|
-
assigners,
|
|
11876
|
-
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
11877
|
-
autoAccumulateServices) {
|
|
11878
|
-
this.manager = manager;
|
|
11879
|
-
this.delegator = delegator;
|
|
11880
|
-
this.registrar = registrar;
|
|
11881
|
-
this.assigners = assigners;
|
|
11882
|
-
this.autoAccumulateServices = autoAccumulateServices;
|
|
11883
|
-
}
|
|
11884
|
-
}
|
|
11885
|
-
|
|
11886
|
-
;// CONCATENATED MODULE: ./packages/jam/state/recent-blocks.ts
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
/**
|
|
11894
|
-
* `H = 8`: The size of recent history, in blocks.
|
|
11895
|
-
*
|
|
11896
|
-
* https://graypaper.fluffylabs.dev/#/579bd12/416300416500
|
|
11897
|
-
*/
|
|
11898
|
-
const recent_blocks_MAX_RECENT_HISTORY = 8;
|
|
11899
|
-
/** Recent history of a single block. */
|
|
11900
|
-
class recent_blocks_BlockState extends WithDebug {
|
|
11901
|
-
headerHash;
|
|
11902
|
-
accumulationResult;
|
|
11903
|
-
postStateRoot;
|
|
11904
|
-
reported;
|
|
11905
|
-
static Codec = descriptors_codec.Class(recent_blocks_BlockState, {
|
|
11906
|
-
headerHash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
11907
|
-
accumulationResult: descriptors_codec.bytes(hash_HASH_SIZE),
|
|
11908
|
-
postStateRoot: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
|
|
11909
|
-
reported: codecHashDictionary(refine_context_WorkPackageInfo.Codec, (x) => x.workPackageHash),
|
|
11910
|
-
});
|
|
11911
|
-
static create({ headerHash, accumulationResult, postStateRoot, reported }) {
|
|
11912
|
-
return new recent_blocks_BlockState(headerHash, accumulationResult, postStateRoot, reported);
|
|
11913
|
-
}
|
|
11914
|
-
constructor(
|
|
11915
|
-
/** Header hash. */
|
|
11916
|
-
headerHash,
|
|
11917
|
-
/** Merkle mountain belt of accumulation result. */
|
|
11918
|
-
accumulationResult,
|
|
11919
|
-
/** Posterior state root filled in with a 1-block delay. */
|
|
11920
|
-
postStateRoot,
|
|
11921
|
-
/** Reported work packages (no more than number of cores). */
|
|
11922
|
-
reported) {
|
|
11923
|
-
super();
|
|
11924
|
-
this.headerHash = headerHash;
|
|
11925
|
-
this.accumulationResult = accumulationResult;
|
|
11926
|
-
this.postStateRoot = postStateRoot;
|
|
11927
|
-
this.reported = reported;
|
|
11928
|
-
}
|
|
11929
|
-
}
|
|
11930
|
-
class recent_blocks_RecentBlocks extends WithDebug {
|
|
11931
|
-
blocks;
|
|
11932
|
-
accumulationLog;
|
|
11933
|
-
static Codec = descriptors_codec.Class(recent_blocks_RecentBlocks, {
|
|
11934
|
-
blocks: codecKnownSizeArray(recent_blocks_BlockState.Codec, {
|
|
11935
|
-
minLength: 0,
|
|
11936
|
-
maxLength: recent_blocks_MAX_RECENT_HISTORY,
|
|
11937
|
-
typicalLength: recent_blocks_MAX_RECENT_HISTORY,
|
|
11938
|
-
}),
|
|
11939
|
-
accumulationLog: descriptors_codec.object({
|
|
11940
|
-
peaks: readonlyArray(descriptors_codec.sequenceVarLen(descriptors_codec.optional(descriptors_codec.bytes(hash_HASH_SIZE)))),
|
|
11941
|
-
}),
|
|
11942
|
-
});
|
|
11943
|
-
static create(a) {
|
|
11944
|
-
return new recent_blocks_RecentBlocks(a.blocks, a.accumulationLog);
|
|
11945
|
-
}
|
|
11946
|
-
constructor(
|
|
11947
|
-
/**
|
|
11948
|
-
* Most recent blocks.
|
|
11949
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fea010fea01?v=0.6.7
|
|
11950
|
-
*/
|
|
11951
|
-
blocks,
|
|
11952
|
-
/**
|
|
11953
|
-
* Accumulation output log.
|
|
11954
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0f02020f0202?v=0.6.7
|
|
11955
|
-
*/
|
|
11956
|
-
accumulationLog) {
|
|
11957
|
-
super();
|
|
11958
|
-
this.blocks = blocks;
|
|
11959
|
-
this.accumulationLog = accumulationLog;
|
|
11960
|
-
}
|
|
11961
|
-
}
|
|
11962
|
-
/**
|
|
11963
|
-
* Recent history of blocks.
|
|
11964
|
-
*
|
|
11965
|
-
* https://graypaper.fluffylabs.dev/#/7e6ff6a/0fc9010fc901?v=0.6.7
|
|
11966
|
-
*/
|
|
11967
|
-
class recent_blocks_RecentBlocksHistory extends WithDebug {
|
|
11968
|
-
current;
|
|
11969
|
-
static Codec = Descriptor.new("RecentBlocksHistory", recent_blocks_RecentBlocks.Codec.sizeHint, (encoder, value) => recent_blocks_RecentBlocks.Codec.encode(encoder, value.asCurrent()), (decoder) => {
|
|
11970
|
-
const recentBlocks = recent_blocks_RecentBlocks.Codec.decode(decoder);
|
|
11971
|
-
return recent_blocks_RecentBlocksHistory.create(recentBlocks);
|
|
11972
|
-
}, (skip) => {
|
|
11973
|
-
return recent_blocks_RecentBlocks.Codec.skip(skip);
|
|
11974
|
-
});
|
|
11975
|
-
static create(recentBlocks) {
|
|
11976
|
-
return new recent_blocks_RecentBlocksHistory(recentBlocks);
|
|
11977
|
-
}
|
|
11978
|
-
static empty() {
|
|
11979
|
-
return recent_blocks_RecentBlocksHistory.create(recent_blocks_RecentBlocks.create({
|
|
11980
|
-
blocks: sized_array_asKnownSize([]),
|
|
11981
|
-
accumulationLog: { peaks: [] },
|
|
11982
|
-
}));
|
|
11983
|
-
}
|
|
11984
|
-
/**
|
|
11985
|
-
* Returns the block's BEEFY super peak.
|
|
11986
|
-
*/
|
|
11987
|
-
static accumulationResult(block) {
|
|
11988
|
-
return block.accumulationResult;
|
|
11989
|
-
}
|
|
11990
|
-
constructor(current) {
|
|
11991
|
-
super();
|
|
11992
|
-
this.current = current;
|
|
11993
|
-
}
|
|
11994
|
-
/** History of recent blocks with maximum size of `MAX_RECENT_HISTORY` */
|
|
11995
|
-
get blocks() {
|
|
11996
|
-
if (this.current !== null) {
|
|
11997
|
-
return this.current.blocks;
|
|
11998
|
-
}
|
|
11999
|
-
throw new Error("RecentBlocksHistory is in invalid state");
|
|
12000
|
-
}
|
|
12001
|
-
asCurrent() {
|
|
12002
|
-
if (this.current === null) {
|
|
12003
|
-
throw new Error("Cannot access current RecentBlocks format");
|
|
12004
|
-
}
|
|
12005
|
-
return this.current;
|
|
12006
|
-
}
|
|
12007
|
-
updateBlocks(blocks) {
|
|
12008
|
-
if (this.current !== null) {
|
|
12009
|
-
return recent_blocks_RecentBlocksHistory.create(recent_blocks_RecentBlocks.create({
|
|
12010
|
-
...this.current,
|
|
12011
|
-
blocks: opaque_asOpaqueType(blocks),
|
|
12012
|
-
}));
|
|
12013
|
-
}
|
|
12014
|
-
throw new Error("RecentBlocksHistory is in invalid state. Cannot be updated!");
|
|
12015
|
-
}
|
|
12016
|
-
}
|
|
12017
|
-
|
|
12018
|
-
;// CONCATENATED MODULE: ./packages/jam/state/validator-data.ts
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
/**
|
|
12023
|
-
* Fixed size of validator metadata.
|
|
12024
|
-
*
|
|
12025
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/0d55010d5501
|
|
12026
|
-
*/
|
|
12027
|
-
const VALIDATOR_META_BYTES = 128;
|
|
12028
|
-
/**
|
|
12029
|
-
* Details about validators' identity.
|
|
12030
|
-
*
|
|
12031
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/0d4b010d4c01
|
|
12032
|
-
*/
|
|
12033
|
-
class validator_data_ValidatorData extends WithDebug {
|
|
12034
|
-
bandersnatch;
|
|
12035
|
-
ed25519;
|
|
12036
|
-
bls;
|
|
12037
|
-
metadata;
|
|
12038
|
-
static Codec = descriptors_codec.Class(validator_data_ValidatorData, {
|
|
12039
|
-
bandersnatch: descriptors_codec.bytes(bandersnatch_BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
12040
|
-
ed25519: descriptors_codec.bytes(ed25519_ED25519_KEY_BYTES).asOpaque(),
|
|
12041
|
-
bls: descriptors_codec.bytes(bandersnatch_BLS_KEY_BYTES).asOpaque(),
|
|
12042
|
-
metadata: descriptors_codec.bytes(VALIDATOR_META_BYTES),
|
|
12043
|
-
});
|
|
12044
|
-
static create({ ed25519, bandersnatch, bls, metadata }) {
|
|
12045
|
-
return new validator_data_ValidatorData(bandersnatch, ed25519, bls, metadata);
|
|
12046
|
-
}
|
|
12047
|
-
constructor(
|
|
12048
|
-
/** Bandersnatch public key. */
|
|
12049
|
-
bandersnatch,
|
|
12050
|
-
/** ED25519 key data. */
|
|
12051
|
-
ed25519,
|
|
12052
|
-
/** BLS public key. */
|
|
12053
|
-
bls,
|
|
12054
|
-
/** Validator-defined additional metdata. */
|
|
12055
|
-
metadata) {
|
|
12056
|
-
super();
|
|
12057
|
-
this.bandersnatch = bandersnatch;
|
|
12058
|
-
this.ed25519 = ed25519;
|
|
12059
|
-
this.bls = bls;
|
|
12060
|
-
this.metadata = metadata;
|
|
12061
|
-
}
|
|
12062
|
-
}
|
|
12063
|
-
|
|
12064
|
-
;// CONCATENATED MODULE: ./packages/jam/state/safrole-data.ts
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
var safrole_data_SafroleSealingKeysKind;
|
|
12077
|
-
(function (SafroleSealingKeysKind) {
|
|
12078
|
-
SafroleSealingKeysKind[SafroleSealingKeysKind["Tickets"] = 0] = "Tickets";
|
|
12079
|
-
SafroleSealingKeysKind[SafroleSealingKeysKind["Keys"] = 1] = "Keys";
|
|
12080
|
-
})(safrole_data_SafroleSealingKeysKind || (safrole_data_SafroleSealingKeysKind = {}));
|
|
12081
|
-
const codecBandersnatchKey = descriptors_codec.bytes(bandersnatch_BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
12082
|
-
class safrole_data_SafroleSealingKeysData extends WithDebug {
|
|
12083
|
-
kind;
|
|
12084
|
-
keys;
|
|
12085
|
-
tickets;
|
|
12086
|
-
static Codec = codecWithContext((context) => {
|
|
12087
|
-
return descriptors_codec.custom({
|
|
12088
|
-
name: "SafroleSealingKeys",
|
|
12089
|
-
sizeHint: { bytes: 1 + hash_HASH_SIZE * context.epochLength, isExact: false },
|
|
12090
|
-
}, (e, x) => {
|
|
12091
|
-
e.varU32(numbers_tryAsU32(x.kind));
|
|
12092
|
-
if (x.kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
12093
|
-
e.sequenceFixLen(codecBandersnatchKey, x.keys);
|
|
12094
|
-
}
|
|
12095
|
-
else {
|
|
12096
|
-
e.sequenceFixLen(Ticket.Codec, x.tickets);
|
|
12097
|
-
}
|
|
12098
|
-
}, (d) => {
|
|
12099
|
-
const epochLength = context.epochLength;
|
|
12100
|
-
const kind = d.varU32();
|
|
12101
|
-
if (kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
12102
|
-
const keys = d.sequenceFixLen(codecBandersnatchKey, epochLength);
|
|
12103
|
-
return safrole_data_SafroleSealingKeysData.keys(common_tryAsPerEpochBlock(keys, context));
|
|
12104
|
-
}
|
|
12105
|
-
if (kind === safrole_data_SafroleSealingKeysKind.Tickets) {
|
|
12106
|
-
const tickets = d.sequenceFixLen(Ticket.Codec, epochLength);
|
|
12107
|
-
return safrole_data_SafroleSealingKeysData.tickets(common_tryAsPerEpochBlock(tickets, context));
|
|
12108
|
-
}
|
|
12109
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
12110
|
-
}, (s) => {
|
|
12111
|
-
const kind = s.decoder.varU32();
|
|
12112
|
-
if (kind === safrole_data_SafroleSealingKeysKind.Keys) {
|
|
12113
|
-
s.sequenceFixLen(codecBandersnatchKey, context.epochLength);
|
|
12114
|
-
return;
|
|
12115
|
-
}
|
|
12116
|
-
if (kind === safrole_data_SafroleSealingKeysKind.Tickets) {
|
|
12117
|
-
s.sequenceFixLen(Ticket.Codec, context.epochLength);
|
|
12118
|
-
return;
|
|
12119
|
-
}
|
|
12120
|
-
throw new Error(`Unexpected safrole sealing keys kind: ${kind}`);
|
|
12121
|
-
});
|
|
12122
|
-
});
|
|
12123
|
-
static keys(keys) {
|
|
12124
|
-
return new safrole_data_SafroleSealingKeysData(safrole_data_SafroleSealingKeysKind.Keys, keys, undefined);
|
|
12125
|
-
}
|
|
12126
|
-
static tickets(tickets) {
|
|
12127
|
-
return new safrole_data_SafroleSealingKeysData(safrole_data_SafroleSealingKeysKind.Tickets, undefined, tickets);
|
|
12128
|
-
}
|
|
12129
|
-
constructor(kind, keys, tickets) {
|
|
12130
|
-
super();
|
|
12131
|
-
this.kind = kind;
|
|
12132
|
-
this.keys = keys;
|
|
12133
|
-
this.tickets = tickets;
|
|
12134
|
-
}
|
|
12135
|
-
}
|
|
12136
|
-
class safrole_data_SafroleData {
|
|
12137
|
-
nextValidatorData;
|
|
12138
|
-
epochRoot;
|
|
12139
|
-
sealingKeySeries;
|
|
12140
|
-
ticketsAccumulator;
|
|
12141
|
-
static Codec = descriptors_codec.Class(safrole_data_SafroleData, {
|
|
12142
|
-
nextValidatorData: codecPerValidator(validator_data_ValidatorData.Codec),
|
|
12143
|
-
epochRoot: descriptors_codec.bytes(BANDERSNATCH_RING_ROOT_BYTES).asOpaque(),
|
|
12144
|
-
sealingKeySeries: safrole_data_SafroleSealingKeysData.Codec,
|
|
12145
|
-
ticketsAccumulator: readonlyArray(descriptors_codec.sequenceVarLen(Ticket.Codec)).convert(seeThrough, sized_array_asKnownSize),
|
|
12146
|
-
});
|
|
12147
|
-
static create({ nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator }) {
|
|
12148
|
-
return new safrole_data_SafroleData(nextValidatorData, epochRoot, sealingKeySeries, ticketsAccumulator);
|
|
12149
|
-
}
|
|
12150
|
-
constructor(
|
|
12151
|
-
/** gamma_k */
|
|
12152
|
-
nextValidatorData,
|
|
12153
|
-
/** gamma_z */
|
|
12154
|
-
epochRoot,
|
|
12155
|
-
/** gamma_s */
|
|
12156
|
-
sealingKeySeries,
|
|
12157
|
-
/** gamma_a */
|
|
12158
|
-
ticketsAccumulator) {
|
|
12159
|
-
this.nextValidatorData = nextValidatorData;
|
|
12160
|
-
this.epochRoot = epochRoot;
|
|
12161
|
-
this.sealingKeySeries = sealingKeySeries;
|
|
12162
|
-
this.ticketsAccumulator = ticketsAccumulator;
|
|
12163
|
-
}
|
|
12164
|
-
}
|
|
12165
|
-
|
|
12166
|
-
;// CONCATENATED MODULE: ./packages/jam/state/state.ts
|
|
12167
|
-
/**
|
|
12168
|
-
* In addition to the entropy accumulator η_0, we retain
|
|
12169
|
-
* three additional historical values of the accumulator at
|
|
12170
|
-
* the point of each of the three most recently ended epochs,
|
|
12171
|
-
* η_1, η_2 and η_3. The second-oldest of these η2 is utilized to
|
|
12172
|
-
* help ensure future entropy is unbiased (see equation 6.29)
|
|
12173
|
-
* and seed the fallback seal-key generation function with
|
|
12174
|
-
* randomness (see equation 6.24). The oldest is used to re-
|
|
12175
|
-
* generate this randomness when verifying the seal above
|
|
12176
|
-
* (see equations 6.16 and 6.15).
|
|
12177
|
-
*
|
|
12178
|
-
* https://graypaper.fluffylabs.dev/#/579bd12/0ef5010ef501
|
|
12179
|
-
*/
|
|
12180
|
-
const ENTROPY_ENTRIES = 4;
|
|
12181
|
-
|
|
12182
|
-
;// CONCATENATED MODULE: ./packages/jam/state/state-update.ts
|
|
12183
|
-
|
|
12184
|
-
|
|
12185
|
-
var state_update_UpdatePreimageKind;
|
|
12186
|
-
(function (UpdatePreimageKind) {
|
|
12187
|
-
/** Insert new preimage and optionally update it's lookup history. */
|
|
12188
|
-
UpdatePreimageKind[UpdatePreimageKind["Provide"] = 0] = "Provide";
|
|
12189
|
-
/** Remove a preimage and it's lookup history. */
|
|
12190
|
-
UpdatePreimageKind[UpdatePreimageKind["Remove"] = 1] = "Remove";
|
|
12191
|
-
/** update or add lookup history for preimage hash/len to given value. */
|
|
12192
|
-
UpdatePreimageKind[UpdatePreimageKind["UpdateOrAdd"] = 2] = "UpdateOrAdd";
|
|
12193
|
-
})(state_update_UpdatePreimageKind || (state_update_UpdatePreimageKind = {}));
|
|
12194
|
-
/**
|
|
12195
|
-
* A preimage update.
|
|
12196
|
-
*
|
|
12197
|
-
* Can be one of the following cases:
|
|
12198
|
-
* 1. Provide a new preimage blob and set the lookup history to available at `slot`.
|
|
12199
|
-
* 2. Remove (expunge) a preimage and it's lookup history.
|
|
12200
|
-
* 3. Update `LookupHistory` with given value.
|
|
12201
|
-
*/
|
|
12202
|
-
class state_update_UpdatePreimage {
|
|
12203
|
-
serviceId;
|
|
12204
|
-
action;
|
|
12205
|
-
constructor(serviceId, action) {
|
|
12206
|
-
this.serviceId = serviceId;
|
|
12207
|
-
this.action = action;
|
|
12208
|
-
}
|
|
12209
|
-
/** A preimage is provided. We should update the lookuphistory and add the preimage to db. */
|
|
12210
|
-
static provide({ serviceId, preimage, slot, }) {
|
|
12211
|
-
return new state_update_UpdatePreimage(serviceId, {
|
|
12212
|
-
kind: state_update_UpdatePreimageKind.Provide,
|
|
12213
|
-
preimage,
|
|
12214
|
-
slot,
|
|
12215
|
-
});
|
|
12216
|
-
}
|
|
12217
|
-
/** The preimage should be removed completely from the database. */
|
|
12218
|
-
static remove({ serviceId, hash, length }) {
|
|
12219
|
-
return new state_update_UpdatePreimage(serviceId, {
|
|
12220
|
-
kind: state_update_UpdatePreimageKind.Remove,
|
|
12221
|
-
hash,
|
|
12222
|
-
length,
|
|
12223
|
-
});
|
|
12224
|
-
}
|
|
12225
|
-
/** Update the lookup history of some preimage or add a new one (request). */
|
|
12226
|
-
static updateOrAdd({ serviceId, lookupHistory }) {
|
|
12227
|
-
return new state_update_UpdatePreimage(serviceId, {
|
|
12228
|
-
kind: state_update_UpdatePreimageKind.UpdateOrAdd,
|
|
12229
|
-
item: lookupHistory,
|
|
12230
|
-
});
|
|
12231
|
-
}
|
|
12232
|
-
get hash() {
|
|
12233
|
-
switch (this.action.kind) {
|
|
12234
|
-
case state_update_UpdatePreimageKind.Provide:
|
|
12235
|
-
return this.action.preimage.hash;
|
|
12236
|
-
case state_update_UpdatePreimageKind.Remove:
|
|
12237
|
-
return this.action.hash;
|
|
12238
|
-
case state_update_UpdatePreimageKind.UpdateOrAdd:
|
|
12239
|
-
return this.action.item.hash;
|
|
12240
|
-
}
|
|
12241
|
-
throw assertNever(this.action);
|
|
12242
|
-
}
|
|
12243
|
-
get length() {
|
|
12244
|
-
switch (this.action.kind) {
|
|
12245
|
-
case state_update_UpdatePreimageKind.Provide:
|
|
12246
|
-
return tryAsU32(this.action.preimage.blob.length);
|
|
12247
|
-
case state_update_UpdatePreimageKind.Remove:
|
|
12248
|
-
return this.action.length;
|
|
12249
|
-
case state_update_UpdatePreimageKind.UpdateOrAdd:
|
|
12250
|
-
return this.action.item.length;
|
|
12251
|
-
}
|
|
12252
|
-
throw assertNever(this.action);
|
|
12253
|
-
}
|
|
12254
|
-
}
|
|
12255
|
-
/** The type of service update. */
|
|
12256
|
-
var state_update_UpdateServiceKind;
|
|
12257
|
-
(function (UpdateServiceKind) {
|
|
12258
|
-
/** Just update the `ServiceAccountInfo`. */
|
|
12259
|
-
UpdateServiceKind[UpdateServiceKind["Update"] = 0] = "Update";
|
|
12260
|
-
/** Create a new `Service` instance. */
|
|
12261
|
-
UpdateServiceKind[UpdateServiceKind["Create"] = 1] = "Create";
|
|
12262
|
-
})(state_update_UpdateServiceKind || (state_update_UpdateServiceKind = {}));
|
|
12263
|
-
/**
|
|
12264
|
-
* Update service info of a particular `ServiceId` or create a new one.
|
|
12265
|
-
*/
|
|
12266
|
-
class state_update_UpdateService {
|
|
12267
|
-
serviceId;
|
|
12268
|
-
action;
|
|
12269
|
-
constructor(serviceId, action) {
|
|
12270
|
-
this.serviceId = serviceId;
|
|
12271
|
-
this.action = action;
|
|
12272
|
-
}
|
|
12273
|
-
static update({ serviceId, serviceInfo }) {
|
|
12274
|
-
return new state_update_UpdateService(serviceId, {
|
|
12275
|
-
kind: state_update_UpdateServiceKind.Update,
|
|
12276
|
-
account: serviceInfo,
|
|
12277
|
-
});
|
|
12278
|
-
}
|
|
12279
|
-
static create({ serviceId, serviceInfo, lookupHistory, }) {
|
|
12280
|
-
return new state_update_UpdateService(serviceId, {
|
|
12281
|
-
kind: state_update_UpdateServiceKind.Create,
|
|
12282
|
-
account: serviceInfo,
|
|
12283
|
-
lookupHistory,
|
|
12284
|
-
});
|
|
12285
|
-
}
|
|
12286
|
-
}
|
|
12287
|
-
/** Update service storage kind. */
|
|
12288
|
-
var state_update_UpdateStorageKind;
|
|
12289
|
-
(function (UpdateStorageKind) {
|
|
12290
|
-
/** Set a storage value. */
|
|
12291
|
-
UpdateStorageKind[UpdateStorageKind["Set"] = 0] = "Set";
|
|
12292
|
-
/** Remove a storage value. */
|
|
12293
|
-
UpdateStorageKind[UpdateStorageKind["Remove"] = 1] = "Remove";
|
|
12294
|
-
})(state_update_UpdateStorageKind || (state_update_UpdateStorageKind = {}));
|
|
12295
|
-
/**
|
|
12296
|
-
* Update service storage item.
|
|
12297
|
-
*
|
|
12298
|
-
* Can either create/modify an entry or remove it.
|
|
12299
|
-
*/
|
|
12300
|
-
class state_update_UpdateStorage {
|
|
12301
|
-
serviceId;
|
|
12302
|
-
action;
|
|
12303
|
-
constructor(serviceId, action) {
|
|
12304
|
-
this.serviceId = serviceId;
|
|
12305
|
-
this.action = action;
|
|
12306
|
-
}
|
|
12307
|
-
static set({ serviceId, storage }) {
|
|
12308
|
-
return new state_update_UpdateStorage(serviceId, { kind: state_update_UpdateStorageKind.Set, storage });
|
|
12309
|
-
}
|
|
12310
|
-
static remove({ serviceId, key }) {
|
|
12311
|
-
return new state_update_UpdateStorage(serviceId, { kind: state_update_UpdateStorageKind.Remove, key });
|
|
12312
|
-
}
|
|
12313
|
-
get key() {
|
|
12314
|
-
if (this.action.kind === state_update_UpdateStorageKind.Remove) {
|
|
12315
|
-
return this.action.key;
|
|
12316
|
-
}
|
|
12317
|
-
return this.action.storage.key;
|
|
12318
|
-
}
|
|
12319
|
-
get value() {
|
|
12320
|
-
if (this.action.kind === state_update_UpdateStorageKind.Remove) {
|
|
12321
|
-
return null;
|
|
12322
|
-
}
|
|
12323
|
-
return this.action.storage.value;
|
|
12324
|
-
}
|
|
12325
|
-
}
|
|
12326
|
-
|
|
12327
12143
|
;// CONCATENATED MODULE: ./packages/jam/state/statistics.ts
|
|
12328
12144
|
|
|
12329
12145
|
|
|
@@ -12526,73 +12342,377 @@ class statistics_ServiceStatistics {
|
|
|
12526
12342
|
static create(v) {
|
|
12527
12343
|
return new statistics_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);
|
|
12528
12344
|
}
|
|
12529
|
-
constructor(
|
|
12530
|
-
/** `p.0` */
|
|
12531
|
-
providedCount,
|
|
12532
|
-
/** `p.1` */
|
|
12533
|
-
providedSize,
|
|
12534
|
-
/** `r.0` */
|
|
12535
|
-
refinementCount,
|
|
12536
|
-
/** `r.1` */
|
|
12537
|
-
refinementGasUsed,
|
|
12538
|
-
/** `i` */
|
|
12539
|
-
imports,
|
|
12540
|
-
/** `e` */
|
|
12541
|
-
exports,
|
|
12542
|
-
/** `z` */
|
|
12543
|
-
extrinsicSize,
|
|
12544
|
-
/** `x` */
|
|
12545
|
-
extrinsicCount,
|
|
12546
|
-
/** `a.0` */
|
|
12547
|
-
accumulateCount,
|
|
12548
|
-
/** `a.1` */
|
|
12549
|
-
accumulateGasUsed,
|
|
12550
|
-
/** `t.0` @deprecated since 0.7.1 */
|
|
12551
|
-
onTransfersCount,
|
|
12552
|
-
/** `t.1` @deprecated since 0.7.1 */
|
|
12553
|
-
onTransfersGasUsed) {
|
|
12554
|
-
this.providedCount = providedCount;
|
|
12555
|
-
this.providedSize = providedSize;
|
|
12556
|
-
this.refinementCount = refinementCount;
|
|
12557
|
-
this.refinementGasUsed = refinementGasUsed;
|
|
12558
|
-
this.imports = imports;
|
|
12559
|
-
this.exports = exports;
|
|
12560
|
-
this.extrinsicSize = extrinsicSize;
|
|
12561
|
-
this.extrinsicCount = extrinsicCount;
|
|
12562
|
-
this.accumulateCount = accumulateCount;
|
|
12563
|
-
this.accumulateGasUsed = accumulateGasUsed;
|
|
12564
|
-
this.onTransfersCount = onTransfersCount;
|
|
12565
|
-
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
12345
|
+
constructor(
|
|
12346
|
+
/** `p.0` */
|
|
12347
|
+
providedCount,
|
|
12348
|
+
/** `p.1` */
|
|
12349
|
+
providedSize,
|
|
12350
|
+
/** `r.0` */
|
|
12351
|
+
refinementCount,
|
|
12352
|
+
/** `r.1` */
|
|
12353
|
+
refinementGasUsed,
|
|
12354
|
+
/** `i` */
|
|
12355
|
+
imports,
|
|
12356
|
+
/** `e` */
|
|
12357
|
+
exports,
|
|
12358
|
+
/** `z` */
|
|
12359
|
+
extrinsicSize,
|
|
12360
|
+
/** `x` */
|
|
12361
|
+
extrinsicCount,
|
|
12362
|
+
/** `a.0` */
|
|
12363
|
+
accumulateCount,
|
|
12364
|
+
/** `a.1` */
|
|
12365
|
+
accumulateGasUsed,
|
|
12366
|
+
/** `t.0` @deprecated since 0.7.1 */
|
|
12367
|
+
onTransfersCount,
|
|
12368
|
+
/** `t.1` @deprecated since 0.7.1 */
|
|
12369
|
+
onTransfersGasUsed) {
|
|
12370
|
+
this.providedCount = providedCount;
|
|
12371
|
+
this.providedSize = providedSize;
|
|
12372
|
+
this.refinementCount = refinementCount;
|
|
12373
|
+
this.refinementGasUsed = refinementGasUsed;
|
|
12374
|
+
this.imports = imports;
|
|
12375
|
+
this.exports = exports;
|
|
12376
|
+
this.extrinsicSize = extrinsicSize;
|
|
12377
|
+
this.extrinsicCount = extrinsicCount;
|
|
12378
|
+
this.accumulateCount = accumulateCount;
|
|
12379
|
+
this.accumulateGasUsed = accumulateGasUsed;
|
|
12380
|
+
this.onTransfersCount = onTransfersCount;
|
|
12381
|
+
this.onTransfersGasUsed = onTransfersGasUsed;
|
|
12382
|
+
}
|
|
12383
|
+
static empty() {
|
|
12384
|
+
const zero = numbers_tryAsU32(0);
|
|
12385
|
+
const zero16 = numbers_tryAsU16(0);
|
|
12386
|
+
const zeroGas = common_tryAsServiceGas(0);
|
|
12387
|
+
return new statistics_ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas, zero, zeroGas);
|
|
12388
|
+
}
|
|
12389
|
+
}
|
|
12390
|
+
/** `pi`: Statistics of each validator, cores statistics and services statistics. */
|
|
12391
|
+
class statistics_StatisticsData {
|
|
12392
|
+
current;
|
|
12393
|
+
previous;
|
|
12394
|
+
cores;
|
|
12395
|
+
services;
|
|
12396
|
+
static Codec = descriptors_codec.Class(statistics_StatisticsData, {
|
|
12397
|
+
current: codecPerValidator(statistics_ValidatorStatistics.Codec),
|
|
12398
|
+
previous: codecPerValidator(statistics_ValidatorStatistics.Codec),
|
|
12399
|
+
cores: codecPerCore(CoreStatistics.Codec),
|
|
12400
|
+
services: descriptors_codec.dictionary(codecServiceId, statistics_ServiceStatistics.Codec, {
|
|
12401
|
+
sortKeys: (a, b) => a - b,
|
|
12402
|
+
}),
|
|
12403
|
+
});
|
|
12404
|
+
static create(v) {
|
|
12405
|
+
return new statistics_StatisticsData(v.current, v.previous, v.cores, v.services);
|
|
12406
|
+
}
|
|
12407
|
+
constructor(current, previous, cores, services) {
|
|
12408
|
+
this.current = current;
|
|
12409
|
+
this.previous = previous;
|
|
12410
|
+
this.cores = cores;
|
|
12411
|
+
this.services = services;
|
|
12412
|
+
}
|
|
12413
|
+
}
|
|
12414
|
+
|
|
12415
|
+
;// CONCATENATED MODULE: ./packages/jam/state/in-memory-state-view.ts
|
|
12416
|
+
|
|
12417
|
+
|
|
12418
|
+
|
|
12419
|
+
|
|
12420
|
+
|
|
12421
|
+
|
|
12422
|
+
|
|
12423
|
+
|
|
12424
|
+
|
|
12425
|
+
|
|
12426
|
+
class InMemoryStateView {
|
|
12427
|
+
chainSpec;
|
|
12428
|
+
state;
|
|
12429
|
+
constructor(chainSpec, state) {
|
|
12430
|
+
this.chainSpec = chainSpec;
|
|
12431
|
+
this.state = state;
|
|
12432
|
+
}
|
|
12433
|
+
availabilityAssignmentView() {
|
|
12434
|
+
return reencodeAsView(availabilityAssignmentsCodec, this.state.availabilityAssignment, this.chainSpec);
|
|
12435
|
+
}
|
|
12436
|
+
designatedValidatorDataView() {
|
|
12437
|
+
return reencodeAsView(validatorsDataCodec, this.state.designatedValidatorData, this.chainSpec);
|
|
12438
|
+
}
|
|
12439
|
+
currentValidatorDataView() {
|
|
12440
|
+
return reencodeAsView(validatorsDataCodec, this.state.currentValidatorData, this.chainSpec);
|
|
12441
|
+
}
|
|
12442
|
+
previousValidatorDataView() {
|
|
12443
|
+
return reencodeAsView(validatorsDataCodec, this.state.previousValidatorData, this.chainSpec);
|
|
12444
|
+
}
|
|
12445
|
+
authPoolsView() {
|
|
12446
|
+
return reencodeAsView(authPoolsCodec, this.state.authPools, this.chainSpec);
|
|
12447
|
+
}
|
|
12448
|
+
authQueuesView() {
|
|
12449
|
+
return reencodeAsView(authQueuesCodec, this.state.authQueues, this.chainSpec);
|
|
12450
|
+
}
|
|
12451
|
+
recentBlocksView() {
|
|
12452
|
+
return reencodeAsView(recent_blocks_RecentBlocks.Codec, this.state.recentBlocks, this.chainSpec);
|
|
12453
|
+
}
|
|
12454
|
+
statisticsView() {
|
|
12455
|
+
return reencodeAsView(statistics_StatisticsData.Codec, this.state.statistics, this.chainSpec);
|
|
12456
|
+
}
|
|
12457
|
+
accumulationQueueView() {
|
|
12458
|
+
return reencodeAsView(accumulationQueueCodec, this.state.accumulationQueue, this.chainSpec);
|
|
12459
|
+
}
|
|
12460
|
+
recentlyAccumulatedView() {
|
|
12461
|
+
return reencodeAsView(recentlyAccumulatedCodec, this.state.recentlyAccumulated, this.chainSpec);
|
|
12462
|
+
}
|
|
12463
|
+
safroleDataView() {
|
|
12464
|
+
// TODO [ToDr] Consider exposting `safrole` from state
|
|
12465
|
+
// instead of individual fields
|
|
12466
|
+
const safrole = safrole_data_SafroleData.create({
|
|
12467
|
+
nextValidatorData: this.state.nextValidatorData,
|
|
12468
|
+
epochRoot: this.state.epochRoot,
|
|
12469
|
+
sealingKeySeries: this.state.sealingKeySeries,
|
|
12470
|
+
ticketsAccumulator: this.state.ticketsAccumulator,
|
|
12471
|
+
});
|
|
12472
|
+
return reencodeAsView(safrole_data_SafroleData.Codec, safrole, this.chainSpec);
|
|
12473
|
+
}
|
|
12474
|
+
getServiceInfoView(id) {
|
|
12475
|
+
const service = this.state.getService(id);
|
|
12476
|
+
if (service === null) {
|
|
12477
|
+
return null;
|
|
12478
|
+
}
|
|
12479
|
+
return reencodeAsView(service_ServiceAccountInfo.Codec, service.getInfo(), this.chainSpec);
|
|
12480
|
+
}
|
|
12481
|
+
}
|
|
12482
|
+
|
|
12483
|
+
;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
|
|
12484
|
+
|
|
12485
|
+
|
|
12486
|
+
|
|
12487
|
+
|
|
12488
|
+
|
|
12489
|
+
/** Dictionary entry of services that auto-accumulate every block. */
|
|
12490
|
+
class privileged_services_AutoAccumulate {
|
|
12491
|
+
service;
|
|
12492
|
+
gasLimit;
|
|
12493
|
+
static Codec = descriptors_codec.Class(privileged_services_AutoAccumulate, {
|
|
12494
|
+
service: descriptors_codec.u32.asOpaque(),
|
|
12495
|
+
gasLimit: descriptors_codec.u64.asOpaque(),
|
|
12496
|
+
});
|
|
12497
|
+
static create({ service, gasLimit }) {
|
|
12498
|
+
return new privileged_services_AutoAccumulate(service, gasLimit);
|
|
12499
|
+
}
|
|
12500
|
+
constructor(
|
|
12501
|
+
/** Service id that auto-accumulates. */
|
|
12502
|
+
service,
|
|
12503
|
+
/** Gas limit for auto-accumulation. */
|
|
12504
|
+
gasLimit) {
|
|
12505
|
+
this.service = service;
|
|
12506
|
+
this.gasLimit = gasLimit;
|
|
12507
|
+
}
|
|
12508
|
+
}
|
|
12509
|
+
/**
|
|
12510
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
12511
|
+
*/
|
|
12512
|
+
class privileged_services_PrivilegedServices {
|
|
12513
|
+
manager;
|
|
12514
|
+
delegator;
|
|
12515
|
+
registrar;
|
|
12516
|
+
assigners;
|
|
12517
|
+
autoAccumulateServices;
|
|
12518
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bbd023bcb02?v=0.7.2 */
|
|
12519
|
+
static Codec = descriptors_codec.Class(privileged_services_PrivilegedServices, {
|
|
12520
|
+
manager: descriptors_codec.u32.asOpaque(),
|
|
12521
|
+
assigners: codecPerCore(descriptors_codec.u32.asOpaque()),
|
|
12522
|
+
delegator: descriptors_codec.u32.asOpaque(),
|
|
12523
|
+
registrar: compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1)
|
|
12524
|
+
? descriptors_codec.u32.asOpaque()
|
|
12525
|
+
: ignoreValueWithDefault(common_tryAsServiceId(2 ** 32 - 1)),
|
|
12526
|
+
autoAccumulateServices: readonlyArray(descriptors_codec.sequenceVarLen(privileged_services_AutoAccumulate.Codec)),
|
|
12527
|
+
});
|
|
12528
|
+
static create(a) {
|
|
12529
|
+
return new privileged_services_PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
12530
|
+
}
|
|
12531
|
+
constructor(
|
|
12532
|
+
/**
|
|
12533
|
+
* `χ_M`: Manages alteration of χ from block to block,
|
|
12534
|
+
* as well as bestow services with storage deposit credits.
|
|
12535
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111502111902?v=0.7.2
|
|
12536
|
+
*/
|
|
12537
|
+
manager,
|
|
12538
|
+
/** `χ_V`: Managers validator keys. */
|
|
12539
|
+
delegator,
|
|
12540
|
+
/**
|
|
12541
|
+
* `χ_R`: Manages the creation of services in protected range.
|
|
12542
|
+
*
|
|
12543
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/111b02111d02?v=0.7.2
|
|
12544
|
+
*/
|
|
12545
|
+
registrar,
|
|
12546
|
+
/** `χ_A`: Manages authorization queue one for each core. */
|
|
12547
|
+
assigners,
|
|
12548
|
+
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
12549
|
+
autoAccumulateServices) {
|
|
12550
|
+
this.manager = manager;
|
|
12551
|
+
this.delegator = delegator;
|
|
12552
|
+
this.registrar = registrar;
|
|
12553
|
+
this.assigners = assigners;
|
|
12554
|
+
this.autoAccumulateServices = autoAccumulateServices;
|
|
12555
|
+
}
|
|
12556
|
+
}
|
|
12557
|
+
|
|
12558
|
+
;// CONCATENATED MODULE: ./packages/jam/state/state.ts
|
|
12559
|
+
/**
|
|
12560
|
+
* In addition to the entropy accumulator η_0, we retain
|
|
12561
|
+
* three additional historical values of the accumulator at
|
|
12562
|
+
* the point of each of the three most recently ended epochs,
|
|
12563
|
+
* η_1, η_2 and η_3. The second-oldest of these η2 is utilized to
|
|
12564
|
+
* help ensure future entropy is unbiased (see equation 6.29)
|
|
12565
|
+
* and seed the fallback seal-key generation function with
|
|
12566
|
+
* randomness (see equation 6.24). The oldest is used to re-
|
|
12567
|
+
* generate this randomness when verifying the seal above
|
|
12568
|
+
* (see equations 6.16 and 6.15).
|
|
12569
|
+
*
|
|
12570
|
+
* https://graypaper.fluffylabs.dev/#/579bd12/0ef5010ef501
|
|
12571
|
+
*/
|
|
12572
|
+
const ENTROPY_ENTRIES = 4;
|
|
12573
|
+
|
|
12574
|
+
;// CONCATENATED MODULE: ./packages/jam/state/state-update.ts
|
|
12575
|
+
|
|
12576
|
+
|
|
12577
|
+
var state_update_UpdatePreimageKind;
|
|
12578
|
+
(function (UpdatePreimageKind) {
|
|
12579
|
+
/** Insert new preimage and optionally update it's lookup history. */
|
|
12580
|
+
UpdatePreimageKind[UpdatePreimageKind["Provide"] = 0] = "Provide";
|
|
12581
|
+
/** Remove a preimage and it's lookup history. */
|
|
12582
|
+
UpdatePreimageKind[UpdatePreimageKind["Remove"] = 1] = "Remove";
|
|
12583
|
+
/** update or add lookup history for preimage hash/len to given value. */
|
|
12584
|
+
UpdatePreimageKind[UpdatePreimageKind["UpdateOrAdd"] = 2] = "UpdateOrAdd";
|
|
12585
|
+
})(state_update_UpdatePreimageKind || (state_update_UpdatePreimageKind = {}));
|
|
12586
|
+
/**
|
|
12587
|
+
* A preimage update.
|
|
12588
|
+
*
|
|
12589
|
+
* Can be one of the following cases:
|
|
12590
|
+
* 1. Provide a new preimage blob and set the lookup history to available at `slot`.
|
|
12591
|
+
* 2. Remove (expunge) a preimage and it's lookup history.
|
|
12592
|
+
* 3. Update `LookupHistory` with given value.
|
|
12593
|
+
*/
|
|
12594
|
+
class state_update_UpdatePreimage {
|
|
12595
|
+
serviceId;
|
|
12596
|
+
action;
|
|
12597
|
+
constructor(serviceId, action) {
|
|
12598
|
+
this.serviceId = serviceId;
|
|
12599
|
+
this.action = action;
|
|
12600
|
+
}
|
|
12601
|
+
/** A preimage is provided. We should update the lookuphistory and add the preimage to db. */
|
|
12602
|
+
static provide({ serviceId, preimage, slot, }) {
|
|
12603
|
+
return new state_update_UpdatePreimage(serviceId, {
|
|
12604
|
+
kind: state_update_UpdatePreimageKind.Provide,
|
|
12605
|
+
preimage,
|
|
12606
|
+
slot,
|
|
12607
|
+
});
|
|
12608
|
+
}
|
|
12609
|
+
/** The preimage should be removed completely from the database. */
|
|
12610
|
+
static remove({ serviceId, hash, length }) {
|
|
12611
|
+
return new state_update_UpdatePreimage(serviceId, {
|
|
12612
|
+
kind: state_update_UpdatePreimageKind.Remove,
|
|
12613
|
+
hash,
|
|
12614
|
+
length,
|
|
12615
|
+
});
|
|
12616
|
+
}
|
|
12617
|
+
/** Update the lookup history of some preimage or add a new one (request). */
|
|
12618
|
+
static updateOrAdd({ serviceId, lookupHistory }) {
|
|
12619
|
+
return new state_update_UpdatePreimage(serviceId, {
|
|
12620
|
+
kind: state_update_UpdatePreimageKind.UpdateOrAdd,
|
|
12621
|
+
item: lookupHistory,
|
|
12622
|
+
});
|
|
12623
|
+
}
|
|
12624
|
+
get hash() {
|
|
12625
|
+
switch (this.action.kind) {
|
|
12626
|
+
case state_update_UpdatePreimageKind.Provide:
|
|
12627
|
+
return this.action.preimage.hash;
|
|
12628
|
+
case state_update_UpdatePreimageKind.Remove:
|
|
12629
|
+
return this.action.hash;
|
|
12630
|
+
case state_update_UpdatePreimageKind.UpdateOrAdd:
|
|
12631
|
+
return this.action.item.hash;
|
|
12632
|
+
}
|
|
12633
|
+
throw assertNever(this.action);
|
|
12634
|
+
}
|
|
12635
|
+
get length() {
|
|
12636
|
+
switch (this.action.kind) {
|
|
12637
|
+
case state_update_UpdatePreimageKind.Provide:
|
|
12638
|
+
return tryAsU32(this.action.preimage.blob.length);
|
|
12639
|
+
case state_update_UpdatePreimageKind.Remove:
|
|
12640
|
+
return this.action.length;
|
|
12641
|
+
case state_update_UpdatePreimageKind.UpdateOrAdd:
|
|
12642
|
+
return this.action.item.length;
|
|
12643
|
+
}
|
|
12644
|
+
throw assertNever(this.action);
|
|
12566
12645
|
}
|
|
12567
|
-
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12571
|
-
|
|
12646
|
+
}
|
|
12647
|
+
/** The type of service update. */
|
|
12648
|
+
var state_update_UpdateServiceKind;
|
|
12649
|
+
(function (UpdateServiceKind) {
|
|
12650
|
+
/** Just update the `ServiceAccountInfo`. */
|
|
12651
|
+
UpdateServiceKind[UpdateServiceKind["Update"] = 0] = "Update";
|
|
12652
|
+
/** Create a new `Service` instance. */
|
|
12653
|
+
UpdateServiceKind[UpdateServiceKind["Create"] = 1] = "Create";
|
|
12654
|
+
})(state_update_UpdateServiceKind || (state_update_UpdateServiceKind = {}));
|
|
12655
|
+
/**
|
|
12656
|
+
* Update service info of a particular `ServiceId` or create a new one.
|
|
12657
|
+
*/
|
|
12658
|
+
class state_update_UpdateService {
|
|
12659
|
+
serviceId;
|
|
12660
|
+
action;
|
|
12661
|
+
constructor(serviceId, action) {
|
|
12662
|
+
this.serviceId = serviceId;
|
|
12663
|
+
this.action = action;
|
|
12664
|
+
}
|
|
12665
|
+
static update({ serviceId, serviceInfo }) {
|
|
12666
|
+
return new state_update_UpdateService(serviceId, {
|
|
12667
|
+
kind: state_update_UpdateServiceKind.Update,
|
|
12668
|
+
account: serviceInfo,
|
|
12669
|
+
});
|
|
12670
|
+
}
|
|
12671
|
+
static create({ serviceId, serviceInfo, lookupHistory, }) {
|
|
12672
|
+
return new state_update_UpdateService(serviceId, {
|
|
12673
|
+
kind: state_update_UpdateServiceKind.Create,
|
|
12674
|
+
account: serviceInfo,
|
|
12675
|
+
lookupHistory,
|
|
12676
|
+
});
|
|
12572
12677
|
}
|
|
12573
12678
|
}
|
|
12574
|
-
/**
|
|
12575
|
-
|
|
12576
|
-
|
|
12577
|
-
|
|
12578
|
-
|
|
12579
|
-
|
|
12580
|
-
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
|
|
12584
|
-
|
|
12585
|
-
|
|
12586
|
-
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
|
|
12679
|
+
/** Update service storage kind. */
|
|
12680
|
+
var state_update_UpdateStorageKind;
|
|
12681
|
+
(function (UpdateStorageKind) {
|
|
12682
|
+
/** Set a storage value. */
|
|
12683
|
+
UpdateStorageKind[UpdateStorageKind["Set"] = 0] = "Set";
|
|
12684
|
+
/** Remove a storage value. */
|
|
12685
|
+
UpdateStorageKind[UpdateStorageKind["Remove"] = 1] = "Remove";
|
|
12686
|
+
})(state_update_UpdateStorageKind || (state_update_UpdateStorageKind = {}));
|
|
12687
|
+
/**
|
|
12688
|
+
* Update service storage item.
|
|
12689
|
+
*
|
|
12690
|
+
* Can either create/modify an entry or remove it.
|
|
12691
|
+
*/
|
|
12692
|
+
class state_update_UpdateStorage {
|
|
12693
|
+
serviceId;
|
|
12694
|
+
action;
|
|
12695
|
+
constructor(serviceId, action) {
|
|
12696
|
+
this.serviceId = serviceId;
|
|
12697
|
+
this.action = action;
|
|
12590
12698
|
}
|
|
12591
|
-
|
|
12592
|
-
|
|
12593
|
-
|
|
12594
|
-
|
|
12595
|
-
|
|
12699
|
+
static set({ serviceId, storage }) {
|
|
12700
|
+
return new state_update_UpdateStorage(serviceId, { kind: state_update_UpdateStorageKind.Set, storage });
|
|
12701
|
+
}
|
|
12702
|
+
static remove({ serviceId, key }) {
|
|
12703
|
+
return new state_update_UpdateStorage(serviceId, { kind: state_update_UpdateStorageKind.Remove, key });
|
|
12704
|
+
}
|
|
12705
|
+
get key() {
|
|
12706
|
+
if (this.action.kind === state_update_UpdateStorageKind.Remove) {
|
|
12707
|
+
return this.action.key;
|
|
12708
|
+
}
|
|
12709
|
+
return this.action.storage.key;
|
|
12710
|
+
}
|
|
12711
|
+
get value() {
|
|
12712
|
+
if (this.action.kind === state_update_UpdateStorageKind.Remove) {
|
|
12713
|
+
return null;
|
|
12714
|
+
}
|
|
12715
|
+
return this.action.storage.value;
|
|
12596
12716
|
}
|
|
12597
12717
|
}
|
|
12598
12718
|
|
|
@@ -12617,6 +12737,7 @@ class statistics_StatisticsData {
|
|
|
12617
12737
|
|
|
12618
12738
|
|
|
12619
12739
|
|
|
12740
|
+
|
|
12620
12741
|
|
|
12621
12742
|
|
|
12622
12743
|
var in_memory_state_UpdateError;
|
|
@@ -12718,9 +12839,10 @@ class InMemoryService extends WithDebug {
|
|
|
12718
12839
|
* A special version of state, stored fully in-memory.
|
|
12719
12840
|
*/
|
|
12720
12841
|
class InMemoryState extends WithDebug {
|
|
12842
|
+
chainSpec;
|
|
12721
12843
|
/** Create a new `InMemoryState` by providing all required fields. */
|
|
12722
|
-
static
|
|
12723
|
-
return new InMemoryState(state);
|
|
12844
|
+
static new(chainSpec, state) {
|
|
12845
|
+
return new InMemoryState(chainSpec, state);
|
|
12724
12846
|
}
|
|
12725
12847
|
/**
|
|
12726
12848
|
* Create a new `InMemoryState` with a partial state override.
|
|
@@ -12736,7 +12858,7 @@ class InMemoryState extends WithDebug {
|
|
|
12736
12858
|
/**
|
|
12737
12859
|
* Create a new `InMemoryState` from some other state object.
|
|
12738
12860
|
*/
|
|
12739
|
-
static copyFrom(other, servicesData) {
|
|
12861
|
+
static copyFrom(chainSpec, other, servicesData) {
|
|
12740
12862
|
const services = new Map();
|
|
12741
12863
|
for (const [id, entries] of servicesData.entries()) {
|
|
12742
12864
|
const service = other.getService(id);
|
|
@@ -12746,7 +12868,7 @@ class InMemoryState extends WithDebug {
|
|
|
12746
12868
|
const inMemService = InMemoryService.copyFrom(service, entries);
|
|
12747
12869
|
services.set(id, inMemService);
|
|
12748
12870
|
}
|
|
12749
|
-
return InMemoryState.
|
|
12871
|
+
return InMemoryState.new(chainSpec, {
|
|
12750
12872
|
availabilityAssignment: other.availabilityAssignment,
|
|
12751
12873
|
accumulationQueue: other.accumulationQueue,
|
|
12752
12874
|
designatedValidatorData: other.designatedValidatorData,
|
|
@@ -12943,8 +13065,9 @@ class InMemoryState extends WithDebug {
|
|
|
12943
13065
|
getService(id) {
|
|
12944
13066
|
return this.services.get(id) ?? null;
|
|
12945
13067
|
}
|
|
12946
|
-
constructor(s) {
|
|
13068
|
+
constructor(chainSpec, s) {
|
|
12947
13069
|
super();
|
|
13070
|
+
this.chainSpec = chainSpec;
|
|
12948
13071
|
this.availabilityAssignment = s.availabilityAssignment;
|
|
12949
13072
|
this.designatedValidatorData = s.designatedValidatorData;
|
|
12950
13073
|
this.nextValidatorData = s.nextValidatorData;
|
|
@@ -12966,11 +13089,14 @@ class InMemoryState extends WithDebug {
|
|
|
12966
13089
|
this.accumulationOutputLog = s.accumulationOutputLog;
|
|
12967
13090
|
this.services = s.services;
|
|
12968
13091
|
}
|
|
13092
|
+
view() {
|
|
13093
|
+
return new InMemoryStateView(this.chainSpec, this);
|
|
13094
|
+
}
|
|
12969
13095
|
/**
|
|
12970
13096
|
* Create an empty and possibly incoherent `InMemoryState`.
|
|
12971
13097
|
*/
|
|
12972
13098
|
static empty(spec) {
|
|
12973
|
-
return new InMemoryState({
|
|
13099
|
+
return new InMemoryState(spec, {
|
|
12974
13100
|
availabilityAssignment: common_tryAsPerCore(Array.from({ length: spec.coresCount }, () => null), spec),
|
|
12975
13101
|
designatedValidatorData: common_tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => validator_data_ValidatorData.create({
|
|
12976
13102
|
bandersnatch: bytes_Bytes.zero(bandersnatch_BANDERSNATCH_KEY_BYTES).asOpaque(),
|
|
@@ -13005,8 +13131,8 @@ class InMemoryState extends WithDebug {
|
|
|
13005
13131
|
timeslot: common_tryAsTimeSlot(0),
|
|
13006
13132
|
entropy: sized_array_FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), ENTROPY_ENTRIES),
|
|
13007
13133
|
authPools: common_tryAsPerCore(Array.from({ length: spec.coresCount }, () => sized_array_asKnownSize([])), spec),
|
|
13008
|
-
authQueues: common_tryAsPerCore(Array.from({ length: spec.coresCount }, () => sized_array_FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(),
|
|
13009
|
-
recentBlocks:
|
|
13134
|
+
authQueues: common_tryAsPerCore(Array.from({ length: spec.coresCount }, () => sized_array_FixedSizeArray.fill(() => bytes_Bytes.zero(hash_HASH_SIZE).asOpaque(), auth_AUTHORIZATION_QUEUE_SIZE)), spec),
|
|
13135
|
+
recentBlocks: recent_blocks_RecentBlocks.empty(),
|
|
13010
13136
|
statistics: statistics_StatisticsData.create({
|
|
13011
13137
|
current: common_tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => statistics_ValidatorStatistics.empty()), spec),
|
|
13012
13138
|
previous: common_tryAsPerValidator(Array.from({ length: spec.validatorsCount }, () => statistics_ValidatorStatistics.empty()), spec),
|
|
@@ -13057,6 +13183,10 @@ const serviceDataCodec = descriptors_codec.dictionary(descriptors_codec.u32.asOp
|
|
|
13057
13183
|
|
|
13058
13184
|
|
|
13059
13185
|
|
|
13186
|
+
|
|
13187
|
+
|
|
13188
|
+
|
|
13189
|
+
|
|
13060
13190
|
;// CONCATENATED MODULE: ./packages/jam/state-json/accounts.ts
|
|
13061
13191
|
|
|
13062
13192
|
|
|
@@ -13228,51 +13358,6 @@ const accumulationOutput = json.object({
|
|
|
13228
13358
|
output: fromJson.bytes32(),
|
|
13229
13359
|
}, ({ serviceId, output }) => AccumulationOutput.create({ serviceId, output }));
|
|
13230
13360
|
|
|
13231
|
-
;// CONCATENATED MODULE: ./packages/jam/state/not-yet-accumulated.ts
|
|
13232
|
-
|
|
13233
|
-
|
|
13234
|
-
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
|
|
13238
|
-
/**
|
|
13239
|
-
* Ready (i.e. available and/or audited) but not-yet-accumulated work-reports.
|
|
13240
|
-
*
|
|
13241
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/165300165400
|
|
13242
|
-
*/
|
|
13243
|
-
class not_yet_accumulated_NotYetAccumulatedReport extends WithDebug {
|
|
13244
|
-
report;
|
|
13245
|
-
dependencies;
|
|
13246
|
-
static Codec = descriptors_codec.Class(not_yet_accumulated_NotYetAccumulatedReport, {
|
|
13247
|
-
report: work_report_WorkReport.Codec,
|
|
13248
|
-
dependencies: codecKnownSizeArray(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), {
|
|
13249
|
-
typicalLength: gp_constants_MAX_REPORT_DEPENDENCIES / 2,
|
|
13250
|
-
maxLength: gp_constants_MAX_REPORT_DEPENDENCIES,
|
|
13251
|
-
minLength: 0,
|
|
13252
|
-
}),
|
|
13253
|
-
});
|
|
13254
|
-
static create({ report, dependencies }) {
|
|
13255
|
-
return new not_yet_accumulated_NotYetAccumulatedReport(report, dependencies);
|
|
13256
|
-
}
|
|
13257
|
-
constructor(
|
|
13258
|
-
/**
|
|
13259
|
-
* Each of these were made available at most one epoch ago
|
|
13260
|
-
* but have or had unfulfilled dependencies.
|
|
13261
|
-
*/
|
|
13262
|
-
report,
|
|
13263
|
-
/**
|
|
13264
|
-
* Alongside the work-report itself, we retain its un-accumulated
|
|
13265
|
-
* dependencies, a set of work-package hashes.
|
|
13266
|
-
*
|
|
13267
|
-
* https://graypaper.fluffylabs.dev/#/5f542d7/165800165800
|
|
13268
|
-
*/
|
|
13269
|
-
dependencies) {
|
|
13270
|
-
super();
|
|
13271
|
-
this.report = report;
|
|
13272
|
-
this.dependencies = dependencies;
|
|
13273
|
-
}
|
|
13274
|
-
}
|
|
13275
|
-
|
|
13276
13361
|
;// CONCATENATED MODULE: ./packages/jam/state-json/not-yet-accumulated.ts
|
|
13277
13362
|
|
|
13278
13363
|
|
|
@@ -13280,7 +13365,7 @@ class not_yet_accumulated_NotYetAccumulatedReport extends WithDebug {
|
|
|
13280
13365
|
const notYetAccumulatedFromJson = json.object({
|
|
13281
13366
|
report: workReportFromJson,
|
|
13282
13367
|
dependencies: json.array(fromJson.bytes32()),
|
|
13283
|
-
}, ({ report, dependencies }) =>
|
|
13368
|
+
}, ({ report, dependencies }) => accumulation_queue_NotYetAccumulatedReport.create({ report, dependencies }));
|
|
13284
13369
|
|
|
13285
13370
|
;// CONCATENATED MODULE: ./packages/jam/state-json/recent-history.ts
|
|
13286
13371
|
|
|
@@ -13313,10 +13398,10 @@ const recentBlocksHistoryFromJson = json.object({
|
|
|
13313
13398
|
peaks: json.array(json.nullable(fromJson.bytes32())),
|
|
13314
13399
|
},
|
|
13315
13400
|
}, ({ history, mmr }) => {
|
|
13316
|
-
return
|
|
13401
|
+
return recent_blocks_RecentBlocks.create({
|
|
13317
13402
|
blocks: history,
|
|
13318
13403
|
accumulationLog: mmr,
|
|
13319
|
-
})
|
|
13404
|
+
});
|
|
13320
13405
|
});
|
|
13321
13406
|
|
|
13322
13407
|
;// CONCATENATED MODULE: ./packages/jam/state-json/safrole.ts
|
|
@@ -13514,7 +13599,6 @@ const validatorDataFromJson = json.object({
|
|
|
13514
13599
|
|
|
13515
13600
|
|
|
13516
13601
|
|
|
13517
|
-
|
|
13518
13602
|
const fullStateDumpFromJson = (spec) => json.object({
|
|
13519
13603
|
alpha: json.array(json.array(fromJson.bytes32())),
|
|
13520
13604
|
varphi: json.array(json.array(fromJson.bytes32())),
|
|
@@ -13551,20 +13635,20 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
13551
13635
|
if (compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_1) && chi.chi_r === undefined) {
|
|
13552
13636
|
throw new Error("Registrar is required in Privileges GP ^0.7.1");
|
|
13553
13637
|
}
|
|
13554
|
-
return InMemoryState.
|
|
13638
|
+
return InMemoryState.new(spec, {
|
|
13555
13639
|
authPools: common_tryAsPerCore(alpha.map((perCore) => {
|
|
13556
|
-
if (perCore.length >
|
|
13557
|
-
throw new Error(`AuthPools: expected less than ${
|
|
13640
|
+
if (perCore.length > auth_MAX_AUTH_POOL_SIZE) {
|
|
13641
|
+
throw new Error(`AuthPools: expected less than ${auth_MAX_AUTH_POOL_SIZE}, got ${perCore.length}`);
|
|
13558
13642
|
}
|
|
13559
13643
|
return sized_array_asKnownSize(perCore);
|
|
13560
13644
|
}), spec),
|
|
13561
13645
|
authQueues: common_tryAsPerCore(varphi.map((perCore) => {
|
|
13562
|
-
if (perCore.length !==
|
|
13563
|
-
throw new Error(`AuthQueues: expected ${
|
|
13646
|
+
if (perCore.length !== auth_AUTHORIZATION_QUEUE_SIZE) {
|
|
13647
|
+
throw new Error(`AuthQueues: expected ${auth_AUTHORIZATION_QUEUE_SIZE}, got: ${perCore.length}`);
|
|
13564
13648
|
}
|
|
13565
13649
|
return sized_array_asKnownSize(perCore);
|
|
13566
13650
|
}), spec),
|
|
13567
|
-
recentBlocks: beta ??
|
|
13651
|
+
recentBlocks: beta ?? recent_blocks_RecentBlocks.empty(),
|
|
13568
13652
|
nextValidatorData: gamma.gamma_k,
|
|
13569
13653
|
epochRoot: gamma.gamma_z,
|
|
13570
13654
|
sealingKeySeries: TicketsOrKeys.toSafroleSealingKeys(gamma.gamma_s, spec),
|
|
@@ -13778,26 +13862,19 @@ function legacyServiceNested(serviceId, hash) {
|
|
|
13778
13862
|
|
|
13779
13863
|
|
|
13780
13864
|
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
13865
|
/** Serialization for particular state entries. */
|
|
13785
13866
|
var serialize_serialize;
|
|
13786
13867
|
(function (serialize) {
|
|
13787
13868
|
/** C(1): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b15013b1501?v=0.6.7 */
|
|
13788
13869
|
serialize.authPools = {
|
|
13789
13870
|
key: stateKeys.index(StateKeyIdx.Alpha),
|
|
13790
|
-
Codec:
|
|
13791
|
-
minLength: 0,
|
|
13792
|
-
maxLength: gp_constants_MAX_AUTH_POOL_SIZE,
|
|
13793
|
-
typicalLength: gp_constants_MAX_AUTH_POOL_SIZE,
|
|
13794
|
-
})),
|
|
13871
|
+
Codec: authPoolsCodec,
|
|
13795
13872
|
extract: (s) => s.authPools,
|
|
13796
13873
|
};
|
|
13797
13874
|
/** C(2): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b31013b3101?v=0.6.7 */
|
|
13798
13875
|
serialize.authQueues = {
|
|
13799
13876
|
key: stateKeys.index(StateKeyIdx.Phi),
|
|
13800
|
-
Codec:
|
|
13877
|
+
Codec: authQueuesCodec,
|
|
13801
13878
|
extract: (s) => s.authQueues,
|
|
13802
13879
|
};
|
|
13803
13880
|
/**
|
|
@@ -13806,7 +13883,7 @@ var serialize_serialize;
|
|
|
13806
13883
|
*/
|
|
13807
13884
|
serialize.recentBlocks = {
|
|
13808
13885
|
key: stateKeys.index(StateKeyIdx.Beta),
|
|
13809
|
-
Codec:
|
|
13886
|
+
Codec: recent_blocks_RecentBlocks.Codec,
|
|
13810
13887
|
extract: (s) => s.recentBlocks,
|
|
13811
13888
|
};
|
|
13812
13889
|
/** C(4): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b63013b6301?v=0.6.7 */
|
|
@@ -13835,25 +13912,25 @@ var serialize_serialize;
|
|
|
13835
13912
|
/** C(7): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b00023b0002?v=0.6.7 */
|
|
13836
13913
|
serialize.designatedValidators = {
|
|
13837
13914
|
key: stateKeys.index(StateKeyIdx.Iota),
|
|
13838
|
-
Codec:
|
|
13915
|
+
Codec: validatorsDataCodec,
|
|
13839
13916
|
extract: (s) => s.designatedValidatorData,
|
|
13840
13917
|
};
|
|
13841
13918
|
/** C(8): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b0d023b0d02?v=0.6.7 */
|
|
13842
13919
|
serialize.currentValidators = {
|
|
13843
13920
|
key: stateKeys.index(StateKeyIdx.Kappa),
|
|
13844
|
-
Codec:
|
|
13921
|
+
Codec: validatorsDataCodec,
|
|
13845
13922
|
extract: (s) => s.currentValidatorData,
|
|
13846
13923
|
};
|
|
13847
13924
|
/** C(9): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b1a023b1a02?v=0.6.7 */
|
|
13848
13925
|
serialize.previousValidators = {
|
|
13849
13926
|
key: stateKeys.index(StateKeyIdx.Lambda),
|
|
13850
|
-
Codec:
|
|
13927
|
+
Codec: validatorsDataCodec,
|
|
13851
13928
|
extract: (s) => s.previousValidatorData,
|
|
13852
13929
|
};
|
|
13853
13930
|
/** C(10): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b27023b2702?v=0.6.7 */
|
|
13854
13931
|
serialize.availabilityAssignment = {
|
|
13855
13932
|
key: stateKeys.index(StateKeyIdx.Rho),
|
|
13856
|
-
Codec:
|
|
13933
|
+
Codec: availabilityAssignmentsCodec,
|
|
13857
13934
|
extract: (s) => s.availabilityAssignment,
|
|
13858
13935
|
};
|
|
13859
13936
|
/** C(11): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b3e023b3e02?v=0.6.7 */
|
|
@@ -13877,13 +13954,13 @@ var serialize_serialize;
|
|
|
13877
13954
|
/** C(14): https://graypaper.fluffylabs.dev/#/1c979cb/3bf0023bf002?v=0.7.1 */
|
|
13878
13955
|
serialize.accumulationQueue = {
|
|
13879
13956
|
key: stateKeys.index(StateKeyIdx.Omega),
|
|
13880
|
-
Codec:
|
|
13957
|
+
Codec: accumulationQueueCodec,
|
|
13881
13958
|
extract: (s) => s.accumulationQueue,
|
|
13882
13959
|
};
|
|
13883
13960
|
/** C(15): https://graypaper.fluffylabs.dev/#/7e6ff6a/3b96023b9602?v=0.6.7 */
|
|
13884
13961
|
serialize.recentlyAccumulated = {
|
|
13885
13962
|
key: stateKeys.index(StateKeyIdx.Xi),
|
|
13886
|
-
Codec:
|
|
13963
|
+
Codec: recentlyAccumulatedCodec,
|
|
13887
13964
|
extract: (s) => s.recentlyAccumulated,
|
|
13888
13965
|
};
|
|
13889
13966
|
/** C(16): https://graypaper.fluffylabs.dev/#/38c4e62/3b46033b4603?v=0.7.0 */
|
|
@@ -13902,12 +13979,12 @@ var serialize_serialize;
|
|
|
13902
13979
|
/** https://graypaper.fluffylabs.dev/#/85129da/384803384803?v=0.6.3 */
|
|
13903
13980
|
serialize.serviceStorage = (blake2b, serviceId, key) => ({
|
|
13904
13981
|
key: stateKeys.serviceStorage(blake2b, serviceId, key),
|
|
13905
|
-
Codec:
|
|
13982
|
+
Codec: dumpCodec,
|
|
13906
13983
|
});
|
|
13907
13984
|
/** https://graypaper.fluffylabs.dev/#/85129da/385b03385b03?v=0.6.3 */
|
|
13908
13985
|
serialize.servicePreimages = (blake2b, serviceId, hash) => ({
|
|
13909
13986
|
key: stateKeys.servicePreimage(blake2b, serviceId, hash),
|
|
13910
|
-
Codec:
|
|
13987
|
+
Codec: dumpCodec,
|
|
13911
13988
|
});
|
|
13912
13989
|
/** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
|
|
13913
13990
|
serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
|
|
@@ -13922,7 +13999,88 @@ var serialize_serialize;
|
|
|
13922
13999
|
* determine the boundary of the bytes, so it can only be used
|
|
13923
14000
|
* as the last element of the codec and can't be used in sequences!
|
|
13924
14001
|
*/
|
|
13925
|
-
const
|
|
14002
|
+
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()));
|
|
14003
|
+
|
|
14004
|
+
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state-view.ts
|
|
14005
|
+
|
|
14006
|
+
|
|
14007
|
+
class SerializedStateView {
|
|
14008
|
+
spec;
|
|
14009
|
+
backend;
|
|
14010
|
+
recentlyUsedServices;
|
|
14011
|
+
viewCache;
|
|
14012
|
+
constructor(spec, backend,
|
|
14013
|
+
/** Best-effort list of recently active services. */
|
|
14014
|
+
recentlyUsedServices, viewCache) {
|
|
14015
|
+
this.spec = spec;
|
|
14016
|
+
this.backend = backend;
|
|
14017
|
+
this.recentlyUsedServices = recentlyUsedServices;
|
|
14018
|
+
this.viewCache = viewCache;
|
|
14019
|
+
}
|
|
14020
|
+
retrieveView({ key, Codec }, description) {
|
|
14021
|
+
const cached = this.viewCache.get(key);
|
|
14022
|
+
if (cached !== undefined) {
|
|
14023
|
+
return cached;
|
|
14024
|
+
}
|
|
14025
|
+
const bytes = this.backend.get(key);
|
|
14026
|
+
if (bytes === null) {
|
|
14027
|
+
throw new Error(`Required state entry for ${description} is missing!. Accessing view of key: ${key}`);
|
|
14028
|
+
}
|
|
14029
|
+
// NOTE [ToDr] we are not using `Decoder.decodeObject` here because
|
|
14030
|
+
// it needs to get to the end of the data (skip), yet that's expensive.
|
|
14031
|
+
// we assume that the state data is correct and coherent anyway, so
|
|
14032
|
+
// for performance reasons we simply create the view here.
|
|
14033
|
+
const d = decoder_Decoder.fromBytesBlob(bytes);
|
|
14034
|
+
d.attachContext(this.spec);
|
|
14035
|
+
const view = Codec.View.decode(d);
|
|
14036
|
+
this.viewCache.set(key, view);
|
|
14037
|
+
return view;
|
|
14038
|
+
}
|
|
14039
|
+
availabilityAssignmentView() {
|
|
14040
|
+
return this.retrieveView(serialize_serialize.availabilityAssignment, "availabilityAssignmentView");
|
|
14041
|
+
}
|
|
14042
|
+
designatedValidatorDataView() {
|
|
14043
|
+
return this.retrieveView(serialize_serialize.designatedValidators, "designatedValidatorsView");
|
|
14044
|
+
}
|
|
14045
|
+
currentValidatorDataView() {
|
|
14046
|
+
return this.retrieveView(serialize_serialize.currentValidators, "currentValidatorsView");
|
|
14047
|
+
}
|
|
14048
|
+
previousValidatorDataView() {
|
|
14049
|
+
return this.retrieveView(serialize_serialize.previousValidators, "previousValidatorsView");
|
|
14050
|
+
}
|
|
14051
|
+
authPoolsView() {
|
|
14052
|
+
return this.retrieveView(serialize_serialize.authPools, "authPoolsView");
|
|
14053
|
+
}
|
|
14054
|
+
authQueuesView() {
|
|
14055
|
+
return this.retrieveView(serialize_serialize.authQueues, "authQueuesView");
|
|
14056
|
+
}
|
|
14057
|
+
recentBlocksView() {
|
|
14058
|
+
return this.retrieveView(serialize_serialize.recentBlocks, "recentBlocksView");
|
|
14059
|
+
}
|
|
14060
|
+
statisticsView() {
|
|
14061
|
+
return this.retrieveView(serialize_serialize.statistics, "statisticsView");
|
|
14062
|
+
}
|
|
14063
|
+
accumulationQueueView() {
|
|
14064
|
+
return this.retrieveView(serialize_serialize.accumulationQueue, "accumulationQueueView");
|
|
14065
|
+
}
|
|
14066
|
+
recentlyAccumulatedView() {
|
|
14067
|
+
return this.retrieveView(serialize_serialize.recentlyAccumulated, "recentlyAccumulatedView");
|
|
14068
|
+
}
|
|
14069
|
+
safroleDataView() {
|
|
14070
|
+
return this.retrieveView(serialize_serialize.safrole, "safroleDataView");
|
|
14071
|
+
}
|
|
14072
|
+
getServiceInfoView(id) {
|
|
14073
|
+
const serviceData = serialize_serialize.serviceData(id);
|
|
14074
|
+
const bytes = this.backend.get(serviceData.key);
|
|
14075
|
+
if (bytes === null) {
|
|
14076
|
+
return null;
|
|
14077
|
+
}
|
|
14078
|
+
if (!this.recentlyUsedServices.includes(id)) {
|
|
14079
|
+
this.recentlyUsedServices.push(id);
|
|
14080
|
+
}
|
|
14081
|
+
return decoder_Decoder.decodeObject(serviceData.Codec.View, bytes, this.spec);
|
|
14082
|
+
}
|
|
14083
|
+
}
|
|
13926
14084
|
|
|
13927
14085
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state.ts
|
|
13928
14086
|
|
|
@@ -13932,6 +14090,8 @@ const serialize_dumpCodec = Descriptor.new("Dump", { bytes: 64, isExact: false }
|
|
|
13932
14090
|
|
|
13933
14091
|
|
|
13934
14092
|
|
|
14093
|
+
|
|
14094
|
+
|
|
13935
14095
|
/**
|
|
13936
14096
|
* State object which reads it's entries from some backend.
|
|
13937
14097
|
*
|
|
@@ -13944,7 +14104,7 @@ class serialized_state_SerializedState {
|
|
|
13944
14104
|
spec;
|
|
13945
14105
|
blake2b;
|
|
13946
14106
|
backend;
|
|
13947
|
-
|
|
14107
|
+
recentlyUsedServices;
|
|
13948
14108
|
/** Create a state-like object from collection of serialized entries. */
|
|
13949
14109
|
static fromStateEntries(spec, blake2b, state, recentServices = []) {
|
|
13950
14110
|
return new serialized_state_SerializedState(spec, blake2b, state, recentServices);
|
|
@@ -13953,49 +14113,63 @@ class serialized_state_SerializedState {
|
|
|
13953
14113
|
static new(spec, blake2b, db, recentServices = []) {
|
|
13954
14114
|
return new serialized_state_SerializedState(spec, blake2b, db, recentServices);
|
|
13955
14115
|
}
|
|
14116
|
+
dataCache = hash_dictionary_HashDictionary.new();
|
|
14117
|
+
viewCache = hash_dictionary_HashDictionary.new();
|
|
13956
14118
|
constructor(spec, blake2b, backend,
|
|
13957
14119
|
/** Best-effort list of recently active services. */
|
|
13958
|
-
|
|
14120
|
+
recentlyUsedServices) {
|
|
13959
14121
|
this.spec = spec;
|
|
13960
14122
|
this.blake2b = blake2b;
|
|
13961
14123
|
this.backend = backend;
|
|
13962
|
-
this.
|
|
14124
|
+
this.recentlyUsedServices = recentlyUsedServices;
|
|
13963
14125
|
}
|
|
13964
14126
|
/** Comparing the serialized states, just means comparing their backends. */
|
|
13965
14127
|
[TEST_COMPARE_USING]() {
|
|
13966
14128
|
return this.backend;
|
|
13967
14129
|
}
|
|
14130
|
+
/** Return a non-decoding version of the state. */
|
|
14131
|
+
view() {
|
|
14132
|
+
return new SerializedStateView(this.spec, this.backend, this.recentlyUsedServices, this.viewCache);
|
|
14133
|
+
}
|
|
13968
14134
|
// TODO [ToDr] Temporary method to update the state,
|
|
13969
14135
|
// without changing references.
|
|
13970
14136
|
updateBackend(newBackend) {
|
|
13971
14137
|
this.backend = newBackend;
|
|
14138
|
+
this.dataCache = hash_dictionary_HashDictionary.new();
|
|
14139
|
+
this.viewCache = hash_dictionary_HashDictionary.new();
|
|
13972
14140
|
}
|
|
13973
14141
|
recentServiceIds() {
|
|
13974
|
-
return this.
|
|
14142
|
+
return this.recentlyUsedServices;
|
|
13975
14143
|
}
|
|
13976
14144
|
getService(id) {
|
|
13977
14145
|
const serviceData = this.retrieveOptional(serialize_serialize.serviceData(id));
|
|
13978
14146
|
if (serviceData === undefined) {
|
|
13979
14147
|
return null;
|
|
13980
14148
|
}
|
|
13981
|
-
if (!this.
|
|
13982
|
-
this.
|
|
14149
|
+
if (!this.recentlyUsedServices.includes(id)) {
|
|
14150
|
+
this.recentlyUsedServices.push(id);
|
|
13983
14151
|
}
|
|
13984
14152
|
return new SerializedService(this.blake2b, id, serviceData, (key) => this.retrieveOptional(key));
|
|
13985
14153
|
}
|
|
13986
|
-
retrieve(
|
|
13987
|
-
const
|
|
13988
|
-
if (
|
|
13989
|
-
throw new Error(`Required state entry for ${description} is missing!. Accessing key: ${key}`);
|
|
14154
|
+
retrieve(k, description) {
|
|
14155
|
+
const data = this.retrieveOptional(k);
|
|
14156
|
+
if (data === undefined) {
|
|
14157
|
+
throw new Error(`Required state entry for ${description} is missing!. Accessing key: ${k.key}`);
|
|
13990
14158
|
}
|
|
13991
|
-
return
|
|
14159
|
+
return data;
|
|
13992
14160
|
}
|
|
13993
14161
|
retrieveOptional({ key, Codec }) {
|
|
14162
|
+
const cached = this.dataCache.get(key);
|
|
14163
|
+
if (cached !== undefined) {
|
|
14164
|
+
return cached;
|
|
14165
|
+
}
|
|
13994
14166
|
const bytes = this.backend.get(key);
|
|
13995
14167
|
if (bytes === null) {
|
|
13996
14168
|
return undefined;
|
|
13997
14169
|
}
|
|
13998
|
-
|
|
14170
|
+
const data = decoder_Decoder.decodeObject(Codec, bytes, this.spec);
|
|
14171
|
+
this.dataCache.set(key, data);
|
|
14172
|
+
return data;
|
|
13999
14173
|
}
|
|
14000
14174
|
get availabilityAssignment() {
|
|
14001
14175
|
return this.retrieve(serialize_serialize.availabilityAssignment, "availabilityAssignment");
|
|
@@ -15110,6 +15284,7 @@ function loader_loadState(spec, blake2b, entries) {
|
|
|
15110
15284
|
|
|
15111
15285
|
|
|
15112
15286
|
|
|
15287
|
+
|
|
15113
15288
|
;// CONCATENATED MODULE: ./packages/jam/state-merkleization/in-memory-state-codec.ts
|
|
15114
15289
|
|
|
15115
15290
|
|
|
@@ -15214,7 +15389,11 @@ class ServiceWithCodec extends InMemoryService {
|
|
|
15214
15389
|
return new ServiceWithCodec(serviceId, data);
|
|
15215
15390
|
}
|
|
15216
15391
|
}
|
|
15217
|
-
const in_memory_state_codec_inMemoryStateCodec = descriptors_codec.Class(InMemoryState
|
|
15392
|
+
const in_memory_state_codec_inMemoryStateCodec = (spec) => descriptors_codec.Class(class State extends InMemoryState {
|
|
15393
|
+
static create(data) {
|
|
15394
|
+
return InMemoryState.new(spec, data);
|
|
15395
|
+
}
|
|
15396
|
+
}, {
|
|
15218
15397
|
// alpha
|
|
15219
15398
|
authPools: serialize_serialize.authPools.Codec,
|
|
15220
15399
|
// phi
|
|
@@ -15450,7 +15629,7 @@ class InMemoryStates {
|
|
|
15450
15629
|
}
|
|
15451
15630
|
/** Insert a full state into the database. */
|
|
15452
15631
|
async insertState(headerHash, state) {
|
|
15453
|
-
const encoded = Encoder.encodeObject(inMemoryStateCodec, state, this.spec);
|
|
15632
|
+
const encoded = Encoder.encodeObject(inMemoryStateCodec(this.spec), state, this.spec);
|
|
15454
15633
|
this.db.set(headerHash, encoded);
|
|
15455
15634
|
return Result.ok(OK);
|
|
15456
15635
|
}
|
|
@@ -15459,7 +15638,7 @@ class InMemoryStates {
|
|
|
15459
15638
|
if (encodedState === undefined) {
|
|
15460
15639
|
return null;
|
|
15461
15640
|
}
|
|
15462
|
-
return Decoder.decodeObject(inMemoryStateCodec, encodedState, this.spec);
|
|
15641
|
+
return Decoder.decodeObject(inMemoryStateCodec(this.spec), encodedState, this.spec);
|
|
15463
15642
|
}
|
|
15464
15643
|
}
|
|
15465
15644
|
|
|
@@ -15502,21 +15681,21 @@ class hasher_TransitionHasher {
|
|
|
15502
15681
|
*/
|
|
15503
15682
|
extrinsic(extrinsicView) {
|
|
15504
15683
|
// https://graypaper.fluffylabs.dev/#/cc517d7/0cfb000cfb00?v=0.6.5
|
|
15505
|
-
const
|
|
15684
|
+
const guaranteesCount = tryAsU32(extrinsicView.guarantees.view().length);
|
|
15685
|
+
const countEncoded = Encoder.encodeObject(codec.varU32, guaranteesCount);
|
|
15686
|
+
const guaranteesBlobs = extrinsicView.guarantees
|
|
15506
15687
|
.view()
|
|
15507
15688
|
.map((g) => g.view())
|
|
15508
|
-
.
|
|
15689
|
+
.reduce((aggregated, guarantee) => {
|
|
15509
15690
|
const reportHash = this.blake2b.hashBytes(guarantee.report.encoded()).asOpaque();
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
15513
|
-
|
|
15514
|
-
|
|
15515
|
-
});
|
|
15516
|
-
const guaranteeBlob = Encoder.encodeObject(codec.sequenceVarLen(dumpCodec), guarantees, this.context);
|
|
15691
|
+
aggregated.push(reportHash.raw);
|
|
15692
|
+
aggregated.push(guarantee.slot.encoded().raw);
|
|
15693
|
+
aggregated.push(guarantee.credentials.encoded().raw);
|
|
15694
|
+
return aggregated;
|
|
15695
|
+
}, [countEncoded.raw]);
|
|
15517
15696
|
const et = this.blake2b.hashBytes(extrinsicView.tickets.encoded()).asOpaque();
|
|
15518
15697
|
const ep = this.blake2b.hashBytes(extrinsicView.preimages.encoded()).asOpaque();
|
|
15519
|
-
const eg = this.blake2b.
|
|
15698
|
+
const eg = this.blake2b.hashBlobs(guaranteesBlobs).asOpaque();
|
|
15520
15699
|
const ea = this.blake2b.hashBytes(extrinsicView.assurances.encoded()).asOpaque();
|
|
15521
15700
|
const ed = this.blake2b.hashBytes(extrinsicView.disputes.encoded()).asOpaque();
|
|
15522
15701
|
const encoded = BytesBlob.blobFromParts([et.raw, ep.raw, eg.raw, ea.raw, ed.raw]);
|
|
@@ -16639,47 +16818,46 @@ class safrole_seal_SafroleSeal {
|
|
|
16639
16818
|
}
|
|
16640
16819
|
async verifySeal(headerView, state) {
|
|
16641
16820
|
// we use transitioned keys already
|
|
16642
|
-
const validators = state.currentValidatorData;
|
|
16643
16821
|
const validatorIndex = headerView.bandersnatchBlockAuthorIndex.materialize();
|
|
16644
|
-
const
|
|
16645
|
-
if (
|
|
16822
|
+
const authorKeys = state.currentValidatorData.at(validatorIndex);
|
|
16823
|
+
if (authorKeys === undefined) {
|
|
16646
16824
|
return Result.error(SafroleSealError.InvalidValidatorIndex);
|
|
16647
16825
|
}
|
|
16648
16826
|
const timeSlot = headerView.timeSlotIndex.materialize();
|
|
16649
16827
|
const sealingKeys = state.sealingKeySeries;
|
|
16650
16828
|
const entropy = state.currentEntropy;
|
|
16651
16829
|
if (sealingKeys.kind === SafroleSealingKeysKind.Tickets) {
|
|
16652
|
-
return await this.verifySealWithTicket(sealingKeys.tickets, timeSlot, entropy,
|
|
16830
|
+
return await this.verifySealWithTicket(sealingKeys.tickets, timeSlot, entropy, authorKeys, headerView);
|
|
16653
16831
|
}
|
|
16654
|
-
return await this.verifySealWithKeys(sealingKeys.keys,
|
|
16832
|
+
return await this.verifySealWithKeys(sealingKeys.keys, timeSlot, entropy, authorKeys, headerView);
|
|
16655
16833
|
}
|
|
16656
16834
|
/** Regular (non-fallback) mode of Safrole. */
|
|
16657
|
-
async verifySealWithTicket(tickets, timeSlot, entropy,
|
|
16835
|
+
async verifySealWithTicket(tickets, timeSlot, entropy, validatorData, headerView) {
|
|
16658
16836
|
const index = timeSlot % tickets.length;
|
|
16659
|
-
const
|
|
16660
|
-
const payload = BytesBlob.blobFromParts(JAM_TICKET_SEAL, entropy.raw, new Uint8Array([attempt]));
|
|
16837
|
+
const ticket = tickets.at(index);
|
|
16838
|
+
const payload = BytesBlob.blobFromParts(JAM_TICKET_SEAL, entropy.raw, new Uint8Array([ticket?.attempt ?? 0]));
|
|
16661
16839
|
// verify seal correctness
|
|
16662
|
-
const authorKey =
|
|
16840
|
+
const authorKey = validatorData.bandersnatch;
|
|
16663
16841
|
const result = await bandersnatchVrf.verifySeal(await this.bandersnatch, authorKey ?? BANDERSNATCH_ZERO_KEY, headerView.seal.materialize(), payload, encodeUnsealedHeader(headerView));
|
|
16664
16842
|
if (result.isError) {
|
|
16665
16843
|
return Result.error(SafroleSealError.IncorrectSeal);
|
|
16666
16844
|
}
|
|
16667
|
-
if (!id.isEqualTo(result.ok)) {
|
|
16845
|
+
if (ticket === undefined || !ticket.id.isEqualTo(result.ok)) {
|
|
16668
16846
|
return Result.error(SafroleSealError.InvalidTicket);
|
|
16669
16847
|
}
|
|
16670
16848
|
return Result.ok(result.ok);
|
|
16671
16849
|
}
|
|
16672
16850
|
/** Fallback mode of Safrole. */
|
|
16673
|
-
async verifySealWithKeys(keys,
|
|
16851
|
+
async verifySealWithKeys(keys, timeSlot, entropy, authorKey, headerView) {
|
|
16674
16852
|
const index = timeSlot % keys.length;
|
|
16675
|
-
const sealingKey = keys
|
|
16676
|
-
|
|
16853
|
+
const sealingKey = keys.at(index);
|
|
16854
|
+
const authorBandersnatchKey = authorKey.bandersnatch;
|
|
16855
|
+
if (sealingKey === undefined || !sealingKey.isEqualTo(authorBandersnatchKey)) {
|
|
16677
16856
|
return Result.error(SafroleSealError.InvalidValidator, `Invalid Validator. Expected: ${sealingKey}, got: ${authorKey.bandersnatch}`);
|
|
16678
16857
|
}
|
|
16679
16858
|
// verify seal correctness
|
|
16680
16859
|
const payload = BytesBlob.blobFromParts(JAM_FALLBACK_SEAL, entropy.raw);
|
|
16681
|
-
const
|
|
16682
|
-
const result = await bandersnatchVrf.verifySeal(await this.bandersnatch, blockAuthorKey ?? BANDERSNATCH_ZERO_KEY, headerView.seal.materialize(), payload, encodeUnsealedHeader(headerView));
|
|
16860
|
+
const result = await bandersnatchVrf.verifySeal(await this.bandersnatch, authorBandersnatchKey, headerView.seal.materialize(), payload, encodeUnsealedHeader(headerView));
|
|
16683
16861
|
if (result.isError) {
|
|
16684
16862
|
return Result.error(SafroleSealError.IncorrectSeal);
|
|
16685
16863
|
}
|
|
@@ -22291,9 +22469,6 @@ class host_call_memory_HostCallMemory {
|
|
|
22291
22469
|
}
|
|
22292
22470
|
return this.memory.loadInto(result, tryAsMemoryIndex(Number(startAddress)));
|
|
22293
22471
|
}
|
|
22294
|
-
getMemory() {
|
|
22295
|
-
return this.memory;
|
|
22296
|
-
}
|
|
22297
22472
|
}
|
|
22298
22473
|
|
|
22299
22474
|
;// CONCATENATED MODULE: ./packages/core/pvm-host-calls/host-call-registers.ts
|
|
@@ -22558,7 +22733,7 @@ class Assign {
|
|
|
22558
22733
|
const authorizationQueueStart = regs.get(8);
|
|
22559
22734
|
// a
|
|
22560
22735
|
const assigners = getServiceId(regs.get(9));
|
|
22561
|
-
const res = safe_alloc_uint8array_safeAllocUint8Array(hash_HASH_SIZE *
|
|
22736
|
+
const res = safe_alloc_uint8array_safeAllocUint8Array(hash_HASH_SIZE * auth_AUTHORIZATION_QUEUE_SIZE);
|
|
22562
22737
|
const memoryReadResult = memory.loadInto(res, authorizationQueueStart);
|
|
22563
22738
|
// error while reading the memory.
|
|
22564
22739
|
if (memoryReadResult.isError) {
|
|
@@ -22572,8 +22747,8 @@ class Assign {
|
|
|
22572
22747
|
// NOTE: Here we know the core index is valid
|
|
22573
22748
|
const coreIndex = common_tryAsCoreIndex(Number(maybeCoreIndex));
|
|
22574
22749
|
const decoder = decoder_Decoder.fromBlob(res);
|
|
22575
|
-
const authQueue = decoder.sequenceFixLen(descriptors_codec.bytes(hash_HASH_SIZE),
|
|
22576
|
-
const fixedSizeAuthQueue = sized_array_FixedSizeArray.new(authQueue,
|
|
22750
|
+
const authQueue = decoder.sequenceFixLen(descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(), auth_AUTHORIZATION_QUEUE_SIZE);
|
|
22751
|
+
const fixedSizeAuthQueue = sized_array_FixedSizeArray.new(authQueue, auth_AUTHORIZATION_QUEUE_SIZE);
|
|
22577
22752
|
const result = this.partialState.updateAuthorizationQueue(coreIndex, fixedSizeAuthQueue, assigners);
|
|
22578
22753
|
if (result.isOk) {
|
|
22579
22754
|
regs.set(IN_OUT_REG, results_HostCallResult.OK);
|
|
@@ -24184,7 +24359,7 @@ class accumulate_Accumulate {
|
|
|
24184
24359
|
}
|
|
24185
24360
|
const result = await this.pvmAccumulateInvocation(slot, serviceId, transfers, operands, gasCost, entropy, updatedState);
|
|
24186
24361
|
if (result.isError) {
|
|
24187
|
-
// https://graypaper.fluffylabs.dev/#/
|
|
24362
|
+
// https://graypaper.fluffylabs.dev/#/ab2cdbd/2fc9032fc903?v=0.7.2
|
|
24188
24363
|
accumulate_logger.log `Accumulation failed for ${serviceId}.`;
|
|
24189
24364
|
// even though accumulation failed, we still need to make sure that
|
|
24190
24365
|
// incoming transfers updated the balance, hence we pass state update here
|
|
@@ -24278,10 +24453,12 @@ class accumulate_Accumulate {
|
|
|
24278
24453
|
const { consumedGas, stateUpdate } = await this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), operands, accumulateData.getGasCost(serviceId), slot, entropy, currentState);
|
|
24279
24454
|
gasCost = tryAsServiceGas(gasCost + consumedGas);
|
|
24280
24455
|
// https://graypaper.fluffylabs.dev/#/ab2cdbd/193b05193b05?v=0.7.2
|
|
24281
|
-
|
|
24282
|
-
|
|
24283
|
-
|
|
24284
|
-
|
|
24456
|
+
const serviceStatistics = statistics.get(serviceId) ?? { count: tryAsU32(0), gasUsed: tryAsServiceGas(0) };
|
|
24457
|
+
const count = accumulateData.getReportsLength(serviceId);
|
|
24458
|
+
// [0.7.1]: do not update statistics, if the service only had incoming transfers
|
|
24459
|
+
if ((Compatibility.isLessThan(GpVersion.V0_7_2) && count > 0) ||
|
|
24460
|
+
(Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) && (count > 0 || consumedGas > 0n))) {
|
|
24461
|
+
serviceStatistics.count = tryAsU32(serviceStatistics.count + count);
|
|
24285
24462
|
serviceStatistics.gasUsed = tryAsServiceGas(serviceStatistics.gasUsed + consumedGas);
|
|
24286
24463
|
statistics.set(serviceId, serviceStatistics);
|
|
24287
24464
|
}
|
|
@@ -24319,9 +24496,10 @@ class accumulate_Accumulate {
|
|
|
24319
24496
|
const recentlyAccumulated = tryAsPerEpochBlock(newRecentlyAccumulated, this.chainSpec);
|
|
24320
24497
|
const accumulationQueue = this.state.accumulationQueue.slice();
|
|
24321
24498
|
accumulationQueue[phaseIndex] = pruneQueue(toAccumulateLater, accumulatedSet);
|
|
24499
|
+
const timeslot = this.state.timeslot;
|
|
24322
24500
|
for (let i = 1; i < epochLength; i++) {
|
|
24323
24501
|
const queueIndex = (phaseIndex + epochLength - i) % epochLength;
|
|
24324
|
-
if (i < slot -
|
|
24502
|
+
if (i < slot - timeslot) {
|
|
24325
24503
|
accumulationQueue[queueIndex] = [];
|
|
24326
24504
|
}
|
|
24327
24505
|
else {
|
|
@@ -24533,7 +24711,6 @@ class deferred_transfers_DeferredTransfers {
|
|
|
24533
24711
|
|
|
24534
24712
|
|
|
24535
24713
|
|
|
24536
|
-
|
|
24537
24714
|
/**
|
|
24538
24715
|
* Maintain a list of available authorizations per core.
|
|
24539
24716
|
*
|
|
@@ -24562,11 +24739,12 @@ class authorization_Authorization {
|
|
|
24562
24739
|
*/
|
|
24563
24740
|
transition(input) {
|
|
24564
24741
|
const authPoolsUpdate = this.state.authPools.slice();
|
|
24742
|
+
const authQueues = this.state.authQueues;
|
|
24565
24743
|
// we transition authorizations for each core.
|
|
24566
24744
|
for (let coreIndex = tryAsCoreIndex(0); coreIndex < this.chainSpec.coresCount; coreIndex++) {
|
|
24567
24745
|
let pool = authPoolsUpdate[coreIndex].slice();
|
|
24568
24746
|
// the queue is only read (we should most likely use `ArrayView` here).
|
|
24569
|
-
const queue =
|
|
24747
|
+
const queue = authQueues[coreIndex];
|
|
24570
24748
|
// if there were any used hashes - remove them
|
|
24571
24749
|
const usedHashes = input.used.get(coreIndex);
|
|
24572
24750
|
if (usedHashes !== undefined) {
|
|
@@ -24740,14 +24918,18 @@ class recent_history_RecentHistory {
|
|
|
24740
24918
|
* https://graypaper.fluffylabs.dev/#/1c979cb/0f55020f5502?v=0.7.1
|
|
24741
24919
|
*/
|
|
24742
24920
|
partialTransition(input) {
|
|
24743
|
-
const
|
|
24921
|
+
const stateBlocks = this.state.recentBlocks;
|
|
24922
|
+
const recentBlocks = stateBlocks.blocks.slice();
|
|
24744
24923
|
const lastState = recentBlocks.length > 0 ? recentBlocks[recentBlocks.length - 1] : null;
|
|
24745
24924
|
// update the posterior root of previous state.
|
|
24746
24925
|
if (lastState !== null) {
|
|
24747
24926
|
lastState.postStateRoot = input.priorStateRoot;
|
|
24748
24927
|
}
|
|
24749
24928
|
return {
|
|
24750
|
-
recentBlocks:
|
|
24929
|
+
recentBlocks: RecentBlocks.create({
|
|
24930
|
+
blocks: asKnownSize(recentBlocks),
|
|
24931
|
+
accumulationLog: stateBlocks.accumulationLog,
|
|
24932
|
+
}), // β_H†
|
|
24751
24933
|
};
|
|
24752
24934
|
}
|
|
24753
24935
|
/**
|
|
@@ -24759,8 +24941,8 @@ class recent_history_RecentHistory {
|
|
|
24759
24941
|
transition(input) {
|
|
24760
24942
|
const recentBlocks = input.partial.recentBlocks.blocks.slice();
|
|
24761
24943
|
// `β′_B`
|
|
24762
|
-
const mmr = this.state.recentBlocks.
|
|
24763
|
-
? MerkleMountainRange.fromPeaks(this.hasher, this.state.recentBlocks.
|
|
24944
|
+
const mmr = this.state.recentBlocks.accumulationLog !== null
|
|
24945
|
+
? MerkleMountainRange.fromPeaks(this.hasher, this.state.recentBlocks.accumulationLog)
|
|
24764
24946
|
: MerkleMountainRange.empty(this.hasher);
|
|
24765
24947
|
// append the accumulation root
|
|
24766
24948
|
mmr.append(input.accumulateRoot);
|
|
@@ -24778,7 +24960,7 @@ class recent_history_RecentHistory {
|
|
|
24778
24960
|
}
|
|
24779
24961
|
// write back to the state.
|
|
24780
24962
|
return {
|
|
24781
|
-
recentBlocks:
|
|
24963
|
+
recentBlocks: RecentBlocks.create(RecentBlocks.create({
|
|
24782
24964
|
blocks: asKnownSize(recentBlocks),
|
|
24783
24965
|
accumulationLog: peaks,
|
|
24784
24966
|
})),
|
|
@@ -24990,7 +25172,6 @@ function verify_basic_verifyReportsBasic(input) {
|
|
|
24990
25172
|
|
|
24991
25173
|
|
|
24992
25174
|
|
|
24993
|
-
|
|
24994
25175
|
const verify_contextual_logger = Logger.new(import.meta.filename, "stf:reports");
|
|
24995
25176
|
/** https://graypaper.fluffylabs.dev/#/7e6ff6a/15eb0115eb01?v=0.6.7 */
|
|
24996
25177
|
function verify_contextual_verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge) {
|
|
@@ -25103,7 +25284,7 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
|
|
|
25103
25284
|
return Result.error(ReportsError.BadStateRoot, `Anchor state root mismatch. Got: ${context.stateRoot}, expected: ${recentBlock.postStateRoot}.`);
|
|
25104
25285
|
}
|
|
25105
25286
|
// check beefy root
|
|
25106
|
-
const beefyRoot =
|
|
25287
|
+
const beefyRoot = recentBlock.accumulationResult;
|
|
25107
25288
|
if (!beefyRoot.isEqualTo(context.beefyRoot)) {
|
|
25108
25289
|
return Result.error(ReportsError.BadBeefyMmrRoot, `Invalid BEEFY super peak hash. Got: ${context.beefyRoot}, expected: ${beefyRoot}. Anchor: ${recentBlock.headerHash}`);
|
|
25109
25290
|
}
|
|
@@ -25345,8 +25526,9 @@ function verify_post_signature_verifyPostSignatureChecks(input, availabilityAssi
|
|
|
25345
25526
|
* https://graypaper.fluffylabs.dev/#/5f542d7/15eb0015ed00
|
|
25346
25527
|
*/
|
|
25347
25528
|
const authorizerHash = report.authorizerHash;
|
|
25348
|
-
const authorizerPool = authPools
|
|
25349
|
-
|
|
25529
|
+
const authorizerPool = authPools.get(coreIndex);
|
|
25530
|
+
const pool = authorizerPool?.materialize() ?? [];
|
|
25531
|
+
if (pool.find((hash) => hash.isEqualTo(authorizerHash)) === undefined) {
|
|
25350
25532
|
return Result.error(ReportsError.CoreUnauthorized, `Authorizer hash not found in the pool of core ${coreIndex}: ${authorizerHash}`);
|
|
25351
25533
|
}
|
|
25352
25534
|
/**
|
|
@@ -25476,7 +25658,8 @@ class reports_Reports {
|
|
|
25476
25658
|
return verifyCredentials(input.guarantees, workReportHashes, input.slot, (headerTimeSlot, guaranteeTimeSlot) => this.getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, input.newEntropy));
|
|
25477
25659
|
}
|
|
25478
25660
|
verifyPostSignatureChecks(input, assurancesAvailAssignment) {
|
|
25479
|
-
|
|
25661
|
+
const authPoolsView = this.state.view().authPoolsView();
|
|
25662
|
+
return verifyPostSignatureChecks(input, assurancesAvailAssignment, authPoolsView, (id) => this.state.getService(id));
|
|
25480
25663
|
}
|
|
25481
25664
|
verifyContextualValidity(input) {
|
|
25482
25665
|
return verifyContextualValidity(input, this.state, this.headerChain, this.chainSpec.maxLookupAnchorAge);
|
|
@@ -27038,18 +27221,20 @@ function dumpOutput(spec, data, type, outputFormat, args, withRelPath) {
|
|
|
27038
27221
|
if (type.encode === undefined) {
|
|
27039
27222
|
throw new Error(`${type.name} does not support encoding to JAM codec.`);
|
|
27040
27223
|
}
|
|
27041
|
-
const
|
|
27224
|
+
const encoder = typeof type.encode === "function" ? type.encode(spec) : type.encode;
|
|
27225
|
+
const encoded = encoder_Encoder.encodeObject(encoder, data, spec);
|
|
27042
27226
|
dump(`${encoded}`);
|
|
27043
27227
|
return;
|
|
27044
27228
|
}
|
|
27045
27229
|
case OutputFormat.Bin: {
|
|
27046
|
-
if (type.encode === undefined) {
|
|
27047
|
-
throw new Error(`${type.name} does not support encoding to JAM codec.`);
|
|
27048
|
-
}
|
|
27049
27230
|
if (destination === null) {
|
|
27050
27231
|
throw new Error(`${OutputFormat.Bin} requires destination file.`);
|
|
27051
27232
|
}
|
|
27052
|
-
|
|
27233
|
+
if (type.encode === undefined) {
|
|
27234
|
+
throw new Error(`${type.name} does not support encoding to JAM codec.`);
|
|
27235
|
+
}
|
|
27236
|
+
const encoder = typeof type.encode === "function" ? type.encode(spec) : type.encode;
|
|
27237
|
+
const encoded = encoder_Encoder.encodeObject(encoder, data, spec);
|
|
27053
27238
|
dump(encoded.raw);
|
|
27054
27239
|
return;
|
|
27055
27240
|
}
|
|
@@ -27156,7 +27341,8 @@ async function loadAndProcessDataFile(file, withRelPath, flavor, decodeType, pro
|
|
|
27156
27341
|
if (decodeType.decode === undefined) {
|
|
27157
27342
|
throw new Error(`${decodeType.name} does not support decoding from binary data.`);
|
|
27158
27343
|
}
|
|
27159
|
-
|
|
27344
|
+
const decoder = typeof decodeType.decode === "function" ? decodeType.decode(spec) : decodeType.decode;
|
|
27345
|
+
data = decoder_Decoder.decodeObject(decoder, input.data, spec);
|
|
27160
27346
|
}
|
|
27161
27347
|
else if (input.type === "json") {
|
|
27162
27348
|
if (decodeType.json === undefined) {
|