@typeberry/lib 0.5.0-d7595f1 → 0.5.1-f5e8f92

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.
Files changed (4) hide show
  1. package/index.cjs +191 -176
  2. package/index.d.ts +42 -21
  3. package/index.js +191 -176
  4. package/package.json +1 -1
package/index.cjs CHANGED
@@ -1584,7 +1584,7 @@ function addSizeHints(a, b) {
1584
1584
  };
1585
1585
  }
1586
1586
  const DEFAULT_START_LENGTH = 512; // 512B
1587
- const MAX_LENGTH$1 = 10 * 1024 * 1024; // 10MB
1587
+ const MAX_LENGTH$1 = 20 * 1024 * 1024; // 20MB
1588
1588
  /**
1589
1589
  * JAM encoder.
1590
1590
  */
@@ -1937,7 +1937,7 @@ class Encoder {
1937
1937
  if (options.silent) {
1938
1938
  return;
1939
1939
  }
1940
- throw new Error(`The encoded size would reach the maximum of ${MAX_LENGTH$1}.`);
1940
+ throw new Error(`The encoded size (${newLength}) would reach the maximum of ${MAX_LENGTH$1}.`);
1941
1941
  }
1942
1942
  if (newLength > this.destination.length) {
1943
1943
  // we can try to resize the underlying buffer
@@ -6778,7 +6778,7 @@ class Credential extends WithDebug {
6778
6778
  /**
6779
6779
  * Tuple of work-report, a credential and it's corresponding timeslot.
6780
6780
  *
6781
- * https://graypaper.fluffylabs.dev/#/579bd12/147102149102
6781
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/15df00150301?v=0.7.2
6782
6782
  */
6783
6783
  class ReportGuarantee extends WithDebug {
6784
6784
  report;
@@ -6806,7 +6806,7 @@ class ReportGuarantee extends WithDebug {
6806
6806
  * validator index and a signature.
6807
6807
  * Credentials must be ordered by their validator index.
6808
6808
  *
6809
- * https://graypaper.fluffylabs.dev/#/579bd12/14b90214bb02
6809
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/152b01152d01?v=0.7.2
6810
6810
  */
6811
6811
  credentials) {
6812
6812
  super();
@@ -7581,8 +7581,9 @@ const workExecResultFromJson = json.object({
7581
7581
  panic: json.optional(json.fromAny(() => null)),
7582
7582
  bad_code: json.optional(json.fromAny(() => null)),
7583
7583
  code_oversize: json.optional(json.fromAny(() => null)),
7584
+ output_oversize: json.optional(json.fromAny(() => null)),
7584
7585
  }, (val) => {
7585
- const { ok, out_of_gas, panic, bad_code, code_oversize } = val;
7586
+ const { ok, out_of_gas, panic, bad_code, code_oversize, output_oversize } = val;
7586
7587
  if (ok !== undefined) {
7587
7588
  return new WorkExecResult(tryAsU32(WorkExecResultKind.ok), ok);
7588
7589
  }
@@ -7598,6 +7599,9 @@ const workExecResultFromJson = json.object({
7598
7599
  if (code_oversize === null) {
7599
7600
  return new WorkExecResult(tryAsU32(WorkExecResultKind.codeOversize));
7600
7601
  }
7602
+ if (output_oversize === null) {
7603
+ return new WorkExecResult(tryAsU32(WorkExecResultKind.digestTooBig));
7604
+ }
7601
7605
  throw new Error("Invalid WorkExecResult");
7602
7606
  });
7603
7607
  const workRefineLoadFromJson = json.object({
@@ -7862,14 +7866,14 @@ var chain_spec$1 = {
7862
7866
  ff000000000000000000000000000000000000000000000000000000000000: "00d1b097b4410b3a63446d7c57d093972a9744fcd2d74f4a5e2ec163610e6d6327ffffffffffffffff0a000000000000000a000000000000003418020000000000ffffffffffffffff04000000000000000000000000000000"
7863
7867
  }
7864
7868
  };
7865
- var database_base_path$1 = "./database";
7869
+ var database_base_path = "./database";
7866
7870
  var defaultConfig = {
7867
7871
  $schema: $schema$1,
7868
7872
  version: version$2,
7869
7873
  flavor: flavor$1,
7870
7874
  authorship: authorship$1,
7871
7875
  chain_spec: chain_spec$1,
7872
- database_base_path: database_base_path$1
7876
+ database_base_path: database_base_path
7873
7877
  };
7874
7878
 
7875
7879
  var $schema = "https://fluffylabs.dev/typeberry/schemas/config-v1.schema.json";
@@ -7907,14 +7911,12 @@ var chain_spec = {
7907
7911
  ff000000000000000000000000000000000000000000000000000000000000: "00d1b097b4410b3a63446d7c57d093972a9744fcd2d74f4a5e2ec163610e6d6327ffffffffffffffff0a000000000000000a000000000000003418020000000000ffffffffffffffff04000000000000000000000000000000"
7908
7912
  }
7909
7913
  };
7910
- var database_base_path = "./database";
7911
7914
  var devConfig = {
7912
7915
  $schema: $schema,
7913
7916
  version: version$1,
7914
7917
  flavor: flavor,
7915
7918
  authorship: authorship,
7916
- chain_spec: chain_spec,
7917
- database_base_path: database_base_path
7919
+ chain_spec: chain_spec
7918
7920
  };
7919
7921
 
7920
7922
  const configs = {
@@ -8707,8 +8709,6 @@ const W_B = Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) ? 13_791_360 : 13_7
8707
8709
  const W_C = 4_000_000;
8708
8710
  /** `W_M`: The maximum number of imports in a work-package. */
8709
8711
  const W_M = 3_072;
8710
- /** `W_R`: The maximum total size of all output blobs in a work-report, in octets. */
8711
- const W_R = 49_152;
8712
8712
  /** `W_T`: The size of a transfer memo in octets. */
8713
8713
  const W_T = 128;
8714
8714
  /** `W_M`: The maximum number of exports in a work-package. */
@@ -20474,6 +20474,103 @@ function signingPayload$1(blake2b, anchor, blob) {
20474
20474
  return BytesBlob.blobFromParts(JAM_AVAILABLE, blake2b.hashBytes(BytesBlob.blobFromParts(anchor.raw, blob.raw)).raw);
20475
20475
  }
20476
20476
 
20477
+ /** Error that may happen during reports processing. */
20478
+ var ReportsError;
20479
+ (function (ReportsError) {
20480
+ /** Core index is greater than the number of available cores. */
20481
+ ReportsError[ReportsError["BadCoreIndex"] = 0] = "BadCoreIndex";
20482
+ /** The report slot is greater than the current block slot. */
20483
+ ReportsError[ReportsError["FutureReportSlot"] = 1] = "FutureReportSlot";
20484
+ /** Report is too old to be considered. */
20485
+ ReportsError[ReportsError["ReportEpochBeforeLast"] = 2] = "ReportEpochBeforeLast";
20486
+ /** Not enough credentials for the guarantee. */
20487
+ ReportsError[ReportsError["InsufficientGuarantees"] = 3] = "InsufficientGuarantees";
20488
+ /** Guarantees are not ordered by the core index. */
20489
+ ReportsError[ReportsError["OutOfOrderGuarantee"] = 4] = "OutOfOrderGuarantee";
20490
+ /** Credentials of guarantors are not sorted or unique. */
20491
+ ReportsError[ReportsError["NotSortedOrUniqueGuarantors"] = 5] = "NotSortedOrUniqueGuarantors";
20492
+ /** Validator in credentials is assigned to a different core. */
20493
+ ReportsError[ReportsError["WrongAssignment"] = 6] = "WrongAssignment";
20494
+ /** There is a report pending availability on that core already. */
20495
+ ReportsError[ReportsError["CoreEngaged"] = 7] = "CoreEngaged";
20496
+ /** Anchor block is not found in recent blocks. */
20497
+ ReportsError[ReportsError["AnchorNotRecent"] = 8] = "AnchorNotRecent";
20498
+ /** Service not foubd. */
20499
+ ReportsError[ReportsError["BadServiceId"] = 9] = "BadServiceId";
20500
+ /** Service code hash does not match the current one. */
20501
+ ReportsError[ReportsError["BadCodeHash"] = 10] = "BadCodeHash";
20502
+ /** Pre-requisite work package is missing in either recent blocks or lookup extrinsic. */
20503
+ ReportsError[ReportsError["DependencyMissing"] = 11] = "DependencyMissing";
20504
+ /** Results for the same package are in more than one report. */
20505
+ ReportsError[ReportsError["DuplicatePackage"] = 12] = "DuplicatePackage";
20506
+ /** Anchor block declared state root does not match the one we have in recent blocks. */
20507
+ ReportsError[ReportsError["BadStateRoot"] = 13] = "BadStateRoot";
20508
+ /** BEEFY super hash mmr mismatch. */
20509
+ ReportsError[ReportsError["BadBeefyMmrRoot"] = 14] = "BadBeefyMmrRoot";
20510
+ /** The authorization hash is not found in the authorization pool. */
20511
+ ReportsError[ReportsError["CoreUnauthorized"] = 15] = "CoreUnauthorized";
20512
+ /** Validator index is greater than the number of validators. */
20513
+ ReportsError[ReportsError["BadValidatorIndex"] = 16] = "BadValidatorIndex";
20514
+ /** Total gas of work report is too high. */
20515
+ ReportsError[ReportsError["WorkReportGasTooHigh"] = 17] = "WorkReportGasTooHigh";
20516
+ /** Work item has is smaller than required minimal accumulation gas of a service. */
20517
+ ReportsError[ReportsError["ServiceItemGasTooLow"] = 18] = "ServiceItemGasTooLow";
20518
+ /** The report has too many dependencies (prerequisites and/or segment-root lookups). */
20519
+ ReportsError[ReportsError["TooManyDependencies"] = 19] = "TooManyDependencies";
20520
+ /** Segment root lookup block has invalid time slot or is not found in the header chain. */
20521
+ ReportsError[ReportsError["SegmentRootLookupInvalid"] = 20] = "SegmentRootLookupInvalid";
20522
+ /** Signature in credentials is invalid. */
20523
+ ReportsError[ReportsError["BadSignature"] = 21] = "BadSignature";
20524
+ /** Size of authorizer output and all work-item successful output blobs is too big. */
20525
+ ReportsError[ReportsError["WorkReportTooBig"] = 22] = "WorkReportTooBig";
20526
+ /** Contains guarantee from validator that is proven to be an offender. */
20527
+ ReportsError[ReportsError["BannedValidator"] = 23] = "BannedValidator";
20528
+ })(ReportsError || (ReportsError = {}));
20529
+
20530
+ /**
20531
+ * `W_R = 48 * 2**10`: The maximum total size of all output blobs in a work-report, in octets.
20532
+ *
20533
+ * https://graypaper.fluffylabs.dev/#/5f542d7/41a60041aa00?v=0.6.2
20534
+ */
20535
+ const MAX_WORK_REPORT_SIZE_BYTES = 48 * 2 ** 10;
20536
+ function verifyReportsBasic(input) {
20537
+ for (const guarantee of input) {
20538
+ const reportView = guarantee.view().report.view();
20539
+ /**
20540
+ * We limit the sum of the number of items in the
20541
+ * segment-root lookup dictionary and the number of
20542
+ * prerequisites to J = 8:
20543
+ *
20544
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/13fd0113ff01?v=0.7.2
20545
+ */
20546
+ const noOfPrerequisites = reportView.context.view().prerequisites.view().length;
20547
+ const noOfSegmentRootLookups = reportView.segmentRootLookup.view().length;
20548
+ if (noOfPrerequisites + noOfSegmentRootLookups > MAX_REPORT_DEPENDENCIES) {
20549
+ return Result$1.error(ReportsError.TooManyDependencies, () => `Report at ${reportView.coreIndex.materialize()} has too many dependencies. Got ${noOfPrerequisites} + ${noOfSegmentRootLookups}, max: ${MAX_REPORT_DEPENDENCIES}`);
20550
+ }
20551
+ /**
20552
+ * In order to ensure fair use of a block’s extrinsic space,
20553
+ * work-reports are limited in the maximum total size of the
20554
+ * successful output blobs together with the authorizer output
20555
+ * blob, effectively limiting their overall size:
20556
+ *
20557
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/14a80014ab00?v=0.7.2
20558
+ */
20559
+ // adding is safe here, since the total-encoded size of the report
20560
+ // is limited as well. Even though we just have a view, the size
20561
+ // should have been verified earlier.
20562
+ const authOutputSize = reportView.authorizationOutput.view().length;
20563
+ let totalOutputsSize = 0;
20564
+ for (const item of reportView.results.view()) {
20565
+ totalOutputsSize += item.view().result.view().okBlob?.raw.length ?? 0;
20566
+ }
20567
+ if (authOutputSize + totalOutputsSize > MAX_WORK_REPORT_SIZE_BYTES) {
20568
+ return Result$1.error(ReportsError.WorkReportTooBig, () => `Work report at ${reportView.coreIndex.materialize()} too big. Got ${authOutputSize} + ${totalOutputsSize}, max: ${MAX_WORK_REPORT_SIZE_BYTES}`);
20569
+ }
20570
+ }
20571
+ return Result$1.ok(OK);
20572
+ }
20573
+
20477
20574
  var TransferOperandKind;
20478
20575
  (function (TransferOperandKind) {
20479
20576
  TransferOperandKind[TransferOperandKind["OPERAND"] = 0] = "OPERAND";
@@ -20585,7 +20682,7 @@ function getEncodedConstants(chainSpec) {
20585
20682
  W_E: tryAsU32(chainSpec.erasureCodedPieceSize),
20586
20683
  W_M: tryAsU32(W_M),
20587
20684
  W_P: tryAsU32(chainSpec.numberECPiecesPerSegment),
20588
- W_R: tryAsU32(W_R),
20685
+ W_R: tryAsU32(MAX_WORK_REPORT_SIZE_BYTES),
20589
20686
  W_T: tryAsU32(W_T),
20590
20687
  W_X: tryAsU32(W_X),
20591
20688
  Y: tryAsU32(chainSpec.contestLength),
@@ -21322,12 +21419,15 @@ class Accumulate {
21322
21419
  chainSpec;
21323
21420
  blake2b;
21324
21421
  state;
21325
- pvm;
21326
- constructor(chainSpec, blake2b, state, pvm) {
21422
+ options;
21423
+ constructor(chainSpec, blake2b, state, options) {
21327
21424
  this.chainSpec = chainSpec;
21328
21425
  this.blake2b = blake2b;
21329
21426
  this.state = state;
21330
- this.pvm = pvm;
21427
+ this.options = options;
21428
+ if (options.accumulateSequentially === true) {
21429
+ logger$5.warn `⚠️ Parallel accumulation is disabled. Running in sequential mode.`;
21430
+ }
21331
21431
  }
21332
21432
  /**
21333
21433
  * Returns an index that determines how many WorkReports can be processed before exceeding a given gasLimit.
@@ -21379,7 +21479,7 @@ class Accumulate {
21379
21479
  serviceExternalities: partialState,
21380
21480
  fetchExternalities,
21381
21481
  };
21382
- const executor = await PvmExecutor.createAccumulateExecutor(serviceId, code, externalities, this.chainSpec, this.pvm);
21482
+ const executor = await PvmExecutor.createAccumulateExecutor(serviceId, code, externalities, this.chainSpec, this.options.pvm);
21383
21483
  const invocationArgs = Encoder.encodeObject(ARGS_CODEC$1, {
21384
21484
  slot,
21385
21485
  serviceId,
@@ -21596,6 +21696,9 @@ class Accumulate {
21596
21696
  ];
21597
21697
  return resultEntry;
21598
21698
  });
21699
+ if (this.options.accumulateSequentially === true) {
21700
+ await promise;
21701
+ }
21599
21702
  resultPromises[serviceIndex] = promise;
21600
21703
  }
21601
21704
  return Promise.all(resultPromises).then((results) => new Map(results));
@@ -21904,7 +22007,7 @@ class BlockVerifier {
21904
22007
  }
21905
22008
  }
21906
22009
  // Check if extrinsic is valid.
21907
- // https://graypaper.fluffylabs.dev/#/cc517d7/0cba000cba00?v=0.6.5
22010
+ // https://graypaper.fluffylabs.dev/#/ab2cdbd/0cba000cba00?v=0.7.2
21908
22011
  const extrinsicHash = headerView.extrinsicHash.materialize();
21909
22012
  const extrinsicMerkleCommitment = this.hasher.extrinsic(block.extrinsic.view());
21910
22013
  if (!extrinsicHash.isEqualTo(extrinsicMerkleCommitment.hash)) {
@@ -23230,59 +23333,6 @@ class RecentHistory {
23230
23333
  }
23231
23334
  }
23232
23335
 
23233
- /** Error that may happen during reports processing. */
23234
- var ReportsError;
23235
- (function (ReportsError) {
23236
- /** Core index is greater than the number of available cores. */
23237
- ReportsError[ReportsError["BadCoreIndex"] = 0] = "BadCoreIndex";
23238
- /** The report slot is greater than the current block slot. */
23239
- ReportsError[ReportsError["FutureReportSlot"] = 1] = "FutureReportSlot";
23240
- /** Report is too old to be considered. */
23241
- ReportsError[ReportsError["ReportEpochBeforeLast"] = 2] = "ReportEpochBeforeLast";
23242
- /** Not enough credentials for the guarantee. */
23243
- ReportsError[ReportsError["InsufficientGuarantees"] = 3] = "InsufficientGuarantees";
23244
- /** Guarantees are not ordered by the core index. */
23245
- ReportsError[ReportsError["OutOfOrderGuarantee"] = 4] = "OutOfOrderGuarantee";
23246
- /** Credentials of guarantors are not sorted or unique. */
23247
- ReportsError[ReportsError["NotSortedOrUniqueGuarantors"] = 5] = "NotSortedOrUniqueGuarantors";
23248
- /** Validator in credentials is assigned to a different core. */
23249
- ReportsError[ReportsError["WrongAssignment"] = 6] = "WrongAssignment";
23250
- /** There is a report pending availability on that core already. */
23251
- ReportsError[ReportsError["CoreEngaged"] = 7] = "CoreEngaged";
23252
- /** Anchor block is not found in recent blocks. */
23253
- ReportsError[ReportsError["AnchorNotRecent"] = 8] = "AnchorNotRecent";
23254
- /** Service not foubd. */
23255
- ReportsError[ReportsError["BadServiceId"] = 9] = "BadServiceId";
23256
- /** Service code hash does not match the current one. */
23257
- ReportsError[ReportsError["BadCodeHash"] = 10] = "BadCodeHash";
23258
- /** Pre-requisite work package is missing in either recent blocks or lookup extrinsic. */
23259
- ReportsError[ReportsError["DependencyMissing"] = 11] = "DependencyMissing";
23260
- /** Results for the same package are in more than one report. */
23261
- ReportsError[ReportsError["DuplicatePackage"] = 12] = "DuplicatePackage";
23262
- /** Anchor block declared state root does not match the one we have in recent blocks. */
23263
- ReportsError[ReportsError["BadStateRoot"] = 13] = "BadStateRoot";
23264
- /** BEEFY super hash mmr mismatch. */
23265
- ReportsError[ReportsError["BadBeefyMmrRoot"] = 14] = "BadBeefyMmrRoot";
23266
- /** The authorization hash is not found in the authorization pool. */
23267
- ReportsError[ReportsError["CoreUnauthorized"] = 15] = "CoreUnauthorized";
23268
- /** Validator index is greater than the number of validators. */
23269
- ReportsError[ReportsError["BadValidatorIndex"] = 16] = "BadValidatorIndex";
23270
- /** Total gas of work report is too high. */
23271
- ReportsError[ReportsError["WorkReportGasTooHigh"] = 17] = "WorkReportGasTooHigh";
23272
- /** Work item has is smaller than required minimal accumulation gas of a service. */
23273
- ReportsError[ReportsError["ServiceItemGasTooLow"] = 18] = "ServiceItemGasTooLow";
23274
- /** The report has too many dependencies (prerequisites and/or segment-root lookups). */
23275
- ReportsError[ReportsError["TooManyDependencies"] = 19] = "TooManyDependencies";
23276
- /** Segment root lookup block has invalid time slot or is not found in the header chain. */
23277
- ReportsError[ReportsError["SegmentRootLookupInvalid"] = 20] = "SegmentRootLookupInvalid";
23278
- /** Signature in credentials is invalid. */
23279
- ReportsError[ReportsError["BadSignature"] = 21] = "BadSignature";
23280
- /** Size of authorizer output and all work-item successful output blobs is too big. */
23281
- ReportsError[ReportsError["WorkReportTooBig"] = 22] = "WorkReportTooBig";
23282
- /** Contains guarantee from validator that is proven to be an offender. */
23283
- ReportsError[ReportsError["BannedValidator"] = 23] = "BannedValidator";
23284
- })(ReportsError || (ReportsError = {}));
23285
-
23286
23336
  const ENTROPY_BYTES = 32;
23287
23337
  /**
23288
23338
  * Deterministic variant of the Fisher–Yates shuffle function
@@ -23331,17 +23381,17 @@ var index$5 = /*#__PURE__*/Object.freeze({
23331
23381
  * reports for it. This is borne out with V= 1023 validators
23332
23382
  * and C = 341 cores, since V/C = 3. The core index assigned to
23333
23383
  * each of the validators, as well as the validators’ Ed25519
23334
- * keys are denoted by G.
23384
+ * keys are denoted by M.
23335
23385
  *
23336
- * https://graypaper.fluffylabs.dev/#/5f542d7/147601147e01
23386
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/144c02145402?v=0.7.2
23337
23387
  */
23338
23388
  /**
23339
23389
  * Returns core assignments for each validator index.
23340
23390
  *
23341
- * https://graypaper.fluffylabs.dev/#/5f542d7/14fd0114fd01
23391
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/155300155d00?v=0.7.2
23342
23392
  */
23343
23393
  function generateCoreAssignment(spec, blake2b,
23344
- /** https://graypaper.fluffylabs.dev/#/5f542d7/149601149601 */
23394
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/147102147102?v=0.7.2 */
23345
23395
  eta2entropy,
23346
23396
  /** timeslot */
23347
23397
  slot) {
@@ -23351,7 +23401,7 @@ slot) {
23351
23401
  function rotationIndex(slot, rotationPeriod) {
23352
23402
  return asOpaqueType(Math.floor(slot / rotationPeriod));
23353
23403
  }
23354
- /** https://graypaper.fluffylabs.dev/#/5f542d7/14c00114c001 */
23404
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/151900151900?v=0.7.2 */
23355
23405
  function permute(blake2b, entropy, slot, spec) {
23356
23406
  const shift = rotationIndex(tryAsTimeSlot(slot % spec.epochLength), spec.rotationPeriod);
23357
23407
  const initialAssignment = Array(spec.validatorsCount)
@@ -23366,58 +23416,14 @@ function permute(blake2b, entropy, slot, spec) {
23366
23416
  // we are sure this is PerValidator, since that's the array we create earlier.
23367
23417
  return asKnownSize(coreAssignment);
23368
23418
  }
23369
- /** https://graypaper.fluffylabs.dev/#/5f542d7/14a50114a501 */
23419
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/148002148002?v=0.7.2 */
23370
23420
  function rotate(cores, n, noOfCores) {
23371
23421
  // modulo `noOfCores` guarantees that we're within `CoreIndex` range.
23372
23422
  return cores.map((x) => asOpaqueType((x + n) % noOfCores));
23373
23423
  }
23374
23424
 
23375
- /**
23376
- * `W_R = 48 * 2**10`: The maximum total size of all output blobs in a work-report, in octets.
23377
- *
23378
- * https://graypaper.fluffylabs.dev/#/5f542d7/41a60041aa00?v=0.6.2
23379
- */
23380
- const MAX_WORK_REPORT_SIZE_BYTES = 48 * 2 ** 10;
23381
- function verifyReportsBasic(input) {
23382
- for (const guarantee of input) {
23383
- const reportView = guarantee.view().report.view();
23384
- /**
23385
- * We limit the sum of the number of items in the
23386
- * segment-root lookup dictionary and the number of
23387
- * prerequisites to J = 8:
23388
- *
23389
- * https://graypaper.fluffylabs.dev/#/5f542d7/13ab0013ad00?v=0.6.2
23390
- */
23391
- const noOfPrerequisites = reportView.context.view().prerequisites.view().length;
23392
- const noOfSegmentRootLookups = reportView.segmentRootLookup.view().length;
23393
- if (noOfPrerequisites + noOfSegmentRootLookups > MAX_REPORT_DEPENDENCIES) {
23394
- return Result$1.error(ReportsError.TooManyDependencies, () => `Report at ${reportView.coreIndex.materialize()} has too many dependencies. Got ${noOfPrerequisites} + ${noOfSegmentRootLookups}, max: ${MAX_REPORT_DEPENDENCIES}`);
23395
- }
23396
- /**
23397
- * In order to ensure fair use of a block’s extrinsic space,
23398
- * work-reports are limited in the maximum total size of the
23399
- * successful output blobs together with the authorizer output
23400
- * blob, effectively limiting their overall size:
23401
- *
23402
- * https://graypaper.fluffylabs.dev/#/5f542d7/141d00142000?v=0.6.2
23403
- */
23404
- // adding is safe here, since the total-encoded size of the report
23405
- // is limited as well. Even though we just have a view, the size
23406
- // should have been verified earlier.
23407
- const authOutputSize = reportView.authorizationOutput.view().length;
23408
- let totalOutputsSize = 0;
23409
- for (const item of reportView.results.view()) {
23410
- totalOutputsSize += item.view().result.view().okBlob?.raw.length ?? 0;
23411
- }
23412
- if (authOutputSize + totalOutputsSize > MAX_WORK_REPORT_SIZE_BYTES) {
23413
- return Result$1.error(ReportsError.WorkReportTooBig, () => `Work report at ${reportView.coreIndex.materialize()} too big. Got ${authOutputSize} + ${totalOutputsSize}, max: ${MAX_WORK_REPORT_SIZE_BYTES}`);
23414
- }
23415
- }
23416
- return Result$1.ok(OK);
23417
- }
23418
-
23419
23425
  const logger$3 = Logger.new(undefined, "stf:reports");
23420
- /** https://graypaper.fluffylabs.dev/#/7e6ff6a/15eb0115eb01?v=0.6.7 */
23426
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/158202158202?v=0.7.2 */
23421
23427
  function verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge) {
23422
23428
  const contexts = [];
23423
23429
  // hashes of work packages reported in this extrinsic
@@ -23439,8 +23445,11 @@ function verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge)
23439
23445
  if (service === null) {
23440
23446
  return Result$1.error(ReportsError.BadServiceId, () => `No service with id: ${result.serviceId}`);
23441
23447
  }
23442
- // check service code hash
23443
- // https://graypaper.fluffylabs.dev/#/5f542d7/154b02154b02
23448
+ /**
23449
+ * Check service code hash
23450
+ *
23451
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/150804150804?v=0.7.2
23452
+ */
23444
23453
  if (!result.codeHash.isEqualTo(service.getInfo().codeHash)) {
23445
23454
  return Result$1.error(ReportsError.BadCodeHash, () => `Service (${result.serviceId}) code hash mismatch. Got: ${result.codeHash}, expected: ${service.getInfo().codeHash}`);
23446
23455
  }
@@ -23450,7 +23459,7 @@ function verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge)
23450
23459
  * There must be no duplicate work-package hashes (i.e.
23451
23460
  * two work-reports of the same package).
23452
23461
  *
23453
- * https://graypaper.fluffylabs.dev/#/5f542d7/151f01152101
23462
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/159c02159e02?v=0.7.2
23454
23463
  */
23455
23464
  if (currentWorkPackages.size !== input.guarantees.length) {
23456
23465
  return Result$1.error(ReportsError.DuplicatePackage, () => "Duplicate work package detected.");
@@ -23504,7 +23513,7 @@ function verifyContextualValidity(input, state, headerChain, maxLookupAnchorAge)
23504
23513
  }
23505
23514
  return Result$1.ok(currentWorkPackages);
23506
23515
  }
23507
- /** https://graypaper.fluffylabs.dev/#/7e6ff6a/152502152502?v=0.6.7 */
23516
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/15cd0215cd02?v=0.7.2 */
23508
23517
  function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate, headerChain) {
23509
23518
  // TODO [ToDr] [opti] This could be cached and updated efficiently between runs.
23510
23519
  const recentBlocks = HashDictionary.new();
@@ -23515,9 +23524,9 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
23515
23524
  /**
23516
23525
  * We require that the anchor block be within the last H
23517
23526
  * blocks and that its details be correct by ensuring that it
23518
- * appears within our most recent blocks β †:
23527
+ * appears within our most recent blocks β†:
23519
23528
  *
23520
- * https://graypaper.fluffylabs.dev/#/5f542d7/152801152b01
23529
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/15ad0215af02?v=0.7.2
23521
23530
  */
23522
23531
  const recentBlock = recentBlocks.get(context.anchor);
23523
23532
  if (recentBlock === undefined) {
@@ -23536,7 +23545,7 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
23536
23545
  * We require that each lookup-anchor block be within the
23537
23546
  * last L timeslots.
23538
23547
  *
23539
- * https://graypaper.fluffylabs.dev/#/5f542d7/154601154701
23548
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/15ce0215cf02?v=0.7.2
23540
23549
  */
23541
23550
  if (context.lookupAnchorSlot < minLookupSlot) {
23542
23551
  return Result$1.error(ReportsError.SegmentRootLookupInvalid, () => `Lookup anchor slot's too old. Got: ${context.lookupAnchorSlot}, minimal: ${minLookupSlot}`);
@@ -23547,7 +23556,7 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
23547
23556
  * on-chain state and must be checked by virtue of retaini
23548
23557
  * ing the series of the last L headers as the ancestor set A.
23549
23558
  *
23550
- * https://graypaper.fluffylabs.dev/#/5f542d7/155c01155f01
23559
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/15e40215e702?v=0.7.2
23551
23560
  */
23552
23561
  const isInChain = recentBlocks.has(context.lookupAnchor) ||
23553
23562
  headerChain.isAncestor(context.lookupAnchorSlot, context.lookupAnchor, context.anchor);
@@ -23570,7 +23579,7 @@ function verifyDependencies({ currentWorkPackages, recentlyReported, prerequisit
23570
23579
  * segment-root lookup, be either in the extrinsic or in our
23571
23580
  * recent history.
23572
23581
  *
23573
- * https://graypaper.fluffylabs.dev/#/5f542d7/15ca0115cd01
23582
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/156b03156e03?v=0.7.2
23574
23583
  */
23575
23584
  for (const preReqHash of dependencies) {
23576
23585
  if (currentWorkPackages.has(preReqHash)) {
@@ -23599,7 +23608,7 @@ function verifyWorkPackagesUniqueness(workPackageHashes, state) {
23599
23608
  /**
23600
23609
  * Make sure that the package does not appear anywhere in the pipeline.
23601
23610
  *
23602
- * https://graypaper.fluffylabs.dev/#/5f542d7/159101159101
23611
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/152803152803?v=0.7.2
23603
23612
  */
23604
23613
  // TODO [ToDr] [opti] this most likely should be cached and either
23605
23614
  // re-computed on invalidity or we could maintain additional
@@ -23640,9 +23649,9 @@ function verifyCredentials(guarantees,
23640
23649
  workReportHashes, slot, getGuarantorAssignment) {
23641
23650
  /**
23642
23651
  * Collect signatures payload for later verification
23643
- * and construct the `reporters set R` from that data.
23652
+ * and construct the `reporters set G` from that data.
23644
23653
  *
23645
- * https://graypaper.fluffylabs.dev/#/5f542d7/15cf0015cf00
23654
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/153002153002?v=0.7.2
23646
23655
  */
23647
23656
  const signaturesToVerify = [];
23648
23657
  const headerTimeSlot = slot;
@@ -23656,7 +23665,7 @@ workReportHashes, slot, getGuarantorAssignment) {
23656
23665
  * The credential is a sequence of two or three tuples of a
23657
23666
  * unique validator index and a signature.
23658
23667
  *
23659
- * https://graypaper.fluffylabs.dev/#/5f542d7/14b90214bb02
23668
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/152b01152d01?v=0.7.2
23660
23669
  */
23661
23670
  const credentialsView = guaranteeView.credentials.view();
23662
23671
  if (credentialsView.length < REQUIRED_CREDENTIALS_RANGE[0] ||
@@ -23686,7 +23695,8 @@ workReportHashes, slot, getGuarantorAssignment) {
23686
23695
  }
23687
23696
  /**
23688
23697
  * Verify core assignment.
23689
- * https://graypaper.fluffylabs.dev/#/5f542d7/14e40214e602
23698
+ *
23699
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/155201155401?v=0.7.2
23690
23700
  */
23691
23701
  if (guarantorData.core !== coreIndex) {
23692
23702
  return Result$1.error(ReportsError.WrongAssignment, () => `Invalid core assignment for validator ${validatorIndex}. Expected: ${guarantorData.core}, got: ${coreIndex}`);
@@ -23705,7 +23715,7 @@ const JAM_GUARANTEE = BytesBlob.blobFromString("jam_guarantee").raw;
23705
23715
  * The signature [...] whose message is the serialization of the hash
23706
23716
  * of the work-report.
23707
23717
  *
23708
- * https://graypaper.fluffylabs.dev/#/5f542d7/155200155200
23718
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/15a20115a201?v=0.7.2
23709
23719
  */
23710
23720
  function signingPayload(hash) {
23711
23721
  return BytesBlob.blobFromParts(JAM_GUARANTEE, hash.raw);
@@ -23716,7 +23726,7 @@ function verifyReportsOrder(input, chainSpec) {
23716
23726
  * The core index of each guarantee must be unique and
23717
23727
  * guarantees must be in ascending order of this.
23718
23728
  *
23719
- * https://graypaper.fluffylabs.dev/#/5f542d7/146902146a02
23729
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/15d60015d700?v=0.7.2
23720
23730
  */
23721
23731
  const noOfCores = chainSpec.coresCount;
23722
23732
  let lastCoreIndex = -1;
@@ -23745,7 +23755,7 @@ function verifyPostSignatureChecks(input, availabilityAssignment, authPools, ser
23745
23755
  * No reports may be placed on cores with a report pending
23746
23756
  * availability on it.
23747
23757
  *
23748
- * https://graypaper.fluffylabs.dev/#/5f542d7/15ea0015ea00
23758
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/155002155002?v=0.7.2
23749
23759
  */
23750
23760
  if (availabilityAssignment[coreIndex] !== null) {
23751
23761
  return Result$1.error(ReportsError.CoreEngaged, () => `Report pending availability at core: ${coreIndex}`);
@@ -23755,7 +23765,7 @@ function verifyPostSignatureChecks(input, availabilityAssignment, authPools, ser
23755
23765
  * in the authorizer pool of the core on which the work is
23756
23766
  * reported.
23757
23767
  *
23758
- * https://graypaper.fluffylabs.dev/#/5f542d7/15eb0015ed00
23768
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/155102155302?v=0.7.2
23759
23769
  */
23760
23770
  const authorizerHash = report.authorizerHash;
23761
23771
  const authorizerPool = authPools.get(coreIndex);
@@ -23765,10 +23775,10 @@ function verifyPostSignatureChecks(input, availabilityAssignment, authPools, ser
23765
23775
  }
23766
23776
  /**
23767
23777
  * We require that the gas allotted for accumulation of each
23768
- * work item in each work-report respects its service’s
23778
+ * work-digest in each work-report respects its service’s
23769
23779
  * minimum gas requirements.
23770
23780
  *
23771
- * https://graypaper.fluffylabs.dev/#/5f542d7/15f80015fa00
23781
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/156602156802?v=0.7.2
23772
23782
  */
23773
23783
  for (const result of report.results) {
23774
23784
  const service = services(result.serviceId);
@@ -23840,10 +23850,11 @@ class Reports {
23840
23850
  /**
23841
23851
  * ρ′ - equivalent to ρ‡, except where the extrinsic replaced
23842
23852
  * an entry. In the case an entry is replaced, the new value
23843
- * includes the present time τ allowing for the value to be
23853
+ * includes the present time τ' allowing for the value to be
23844
23854
  * replaced without respect to its availability once sufficient
23845
23855
  * time has elapsed.
23846
- * https://graypaper.fluffylabs.dev/#/1c979cb/161e00165900?v=0.7.1
23856
+ *
23857
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/161e00165900?v=0.7.2
23847
23858
  */
23848
23859
  const availabilityAssignment = input.assurancesAvailAssignment.slice();
23849
23860
  for (const guarantee of input.guarantees) {
@@ -23873,7 +23884,7 @@ class Reports {
23873
23884
  return asKnownSize(workReportHashes);
23874
23885
  }
23875
23886
  verifyCredentials(input, workReportHashes) {
23876
- return verifyCredentials(input.guarantees, workReportHashes, input.slot, (headerTimeSlot, guaranteeTimeSlot) => this.getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, input.newEntropy));
23887
+ return verifyCredentials(input.guarantees, workReportHashes, input.slot, (headerTimeSlot, guaranteeTimeSlot) => this.getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, input.newEntropy, input.currentValidatorData, input.previousValidatorData));
23877
23888
  }
23878
23889
  verifyPostSignatureChecks(input, assurancesAvailAssignment) {
23879
23890
  const authPoolsView = this.state.view().authPoolsView();
@@ -23901,15 +23912,15 @@ class Reports {
23901
23912
  * Get the guarantor assignment (both core and validator data)
23902
23913
  * depending on the rotation.
23903
23914
  *
23904
- * https://graypaper.fluffylabs.dev/#/5f542d7/158200158200
23915
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/15df0115df01?v=0.7.2
23905
23916
  */
23906
- getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, newEntropy) {
23917
+ getGuarantorAssignment(headerTimeSlot, guaranteeTimeSlot, newEntropy, currentValidatorData, previousValidatorData) {
23907
23918
  const epochLength = this.chainSpec.epochLength;
23908
23919
  const rotationPeriod = this.chainSpec.rotationPeriod;
23909
23920
  const headerRotation = rotationIndex(headerTimeSlot, rotationPeriod);
23910
23921
  const guaranteeRotation = rotationIndex(guaranteeTimeSlot, rotationPeriod);
23911
23922
  const minTimeSlot = Math.max(0, headerRotation - 1) * rotationPeriod;
23912
- // https://graypaper.fluffylabs.dev/#/5f542d7/155e00156900
23923
+ // https://graypaper.fluffylabs.dev/#/ab2cdbd/15980115be01?v=0.7.2
23913
23924
  if (guaranteeTimeSlot > headerTimeSlot) {
23914
23925
  return Result$1.error(ReportsError.FutureReportSlot, () => `Report slot is in future. Block ${headerTimeSlot}, Report: ${guaranteeTimeSlot}`);
23915
23926
  }
@@ -23917,10 +23928,10 @@ class Reports {
23917
23928
  return Result$1.error(ReportsError.ReportEpochBeforeLast, () => `Report slot is too old. Block ${headerTimeSlot}, Report: ${guaranteeTimeSlot}`);
23918
23929
  }
23919
23930
  // TODO [ToDr] [opti] below code needs cache.
23920
- // The `G` and `G*` sets should only be computed once per rotation.
23931
+ // The `M` and `M*` sets should only be computed once per rotation.
23921
23932
  // Default data for the current rotation
23922
23933
  let entropy = newEntropy[2];
23923
- let validatorData = this.state.currentValidatorData;
23934
+ let validatorData = currentValidatorData;
23924
23935
  let timeSlot = headerTimeSlot;
23925
23936
  // we might need a different set of data
23926
23937
  if (headerRotation > guaranteeRotation) {
@@ -23930,11 +23941,11 @@ class Reports {
23930
23941
  // if the epoch changed, we need to take previous entropy and previous validator data.
23931
23942
  if (isPreviousRotationPreviousEpoch(timeSlot, headerTimeSlot, epochLength)) {
23932
23943
  entropy = newEntropy[3];
23933
- validatorData = this.state.previousValidatorData;
23944
+ validatorData = previousValidatorData;
23934
23945
  }
23935
23946
  }
23936
23947
  // we know which entropy, timeSlot and validatorData should be used,
23937
- // so we can compute `G` or `G*` here.
23948
+ // so we can compute `M` or `M*` here.
23938
23949
  const coreAssignment = generateCoreAssignment(this.chainSpec, this.blake2b, entropy, timeSlot);
23939
23950
  return Result$1.ok(zip(coreAssignment, validatorData, (core, validator) => ({
23940
23951
  core,
@@ -24102,22 +24113,23 @@ class Statistics {
24102
24113
  const newPreImagesSize = current[authorIndex].preImagesSize + preImagesSize;
24103
24114
  current[authorIndex].preImagesSize = tryAsU32(newPreImagesSize);
24104
24115
  /**
24105
- * * NOTE [MaSi] Please note I don't use Kappa' here. If I understand correctly we don't need it.
24106
- * Kappa' is not needed because we can use validator indexes directly from guarantees extrinsic.
24107
- * I asked a question to ensure it is true but I didn't get any response yet:
24108
- * https://github.com/w3f/jamtestvectors/pull/28#discussion_r190723700
24116
+ * Update guarantees
24109
24117
  *
24110
- * https://graypaper.fluffylabs.dev/#/1c979cb/19a00119a801?v=0.7.1
24118
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/19ea0119f201?v=0.7.2
24111
24119
  */
24112
- const incrementedGuarantors = new Set();
24113
- for (const guarantee of extrinsic.guarantees) {
24114
- for (const { validatorIndex } of guarantee.credentials) {
24115
- if (!incrementedGuarantors.has(validatorIndex)) {
24116
- const newGuaranteesCount = current[validatorIndex].guarantees + 1;
24117
- current[validatorIndex].guarantees = tryAsU32(newGuaranteesCount);
24118
- incrementedGuarantors.add(validatorIndex);
24119
- }
24120
+ const validatorKeys = input.currentValidatorData.map((v) => v.ed25519);
24121
+ for (const reporter of input.reporters) {
24122
+ const index = validatorKeys.findIndex((x) => x.isEqualTo(reporter));
24123
+ if (index === -1) {
24124
+ /**
24125
+ * it should never happen because:
24126
+ * 1. the extrinsic is verified in reports transition
24127
+ * 2. we use current validators set from safrole
24128
+ */
24129
+ continue;
24120
24130
  }
24131
+ const newGuaranteesCount = current[index].guarantees + 1;
24132
+ current[index].guarantees = tryAsU32(newGuaranteesCount);
24121
24133
  }
24122
24134
  for (const { validatorIndex } of extrinsic.assurances) {
24123
24135
  const newAssurancesCount = current[validatorIndex].assurances + 1;
@@ -24272,7 +24284,7 @@ class OnChain {
24272
24284
  // chapter 13: https://graypaper.fluffylabs.dev/#/68eaa1f/18b60118b601?v=0.6.4
24273
24285
  statistics;
24274
24286
  isReadyForNextEpoch = Promise.resolve(false);
24275
- constructor(chainSpec, state, hasher, pvm, headerChain) {
24287
+ constructor(chainSpec, state, hasher, options, headerChain) {
24276
24288
  this.chainSpec = chainSpec;
24277
24289
  this.state = state;
24278
24290
  this.hasher = hasher;
@@ -24284,9 +24296,9 @@ class OnChain {
24284
24296
  this.disputes = new Disputes(chainSpec, hasher.blake2b, state);
24285
24297
  this.reports = new Reports(chainSpec, hasher.blake2b, state, headerChain);
24286
24298
  this.assurances = new Assurances(chainSpec, state, hasher.blake2b);
24287
- this.accumulate = new Accumulate(chainSpec, hasher.blake2b, state, pvm);
24299
+ this.accumulate = new Accumulate(chainSpec, hasher.blake2b, state, options);
24288
24300
  this.accumulateOutput = new AccumulateOutput();
24289
- this.deferredTransfers = new DeferredTransfers(chainSpec, hasher.blake2b, state, pvm);
24301
+ this.deferredTransfers = new DeferredTransfers(chainSpec, hasher.blake2b, state, options.pvm);
24290
24302
  this.preimages = new Preimages(state, hasher.blake2b);
24291
24303
  this.authorization = new Authorization(chainSpec, state);
24292
24304
  }
@@ -24370,12 +24382,13 @@ class OnChain {
24370
24382
  recentBlocksPartialUpdate,
24371
24383
  assurancesAvailAssignment,
24372
24384
  offenders: offendersMark,
24385
+ currentValidatorData,
24386
+ previousValidatorData,
24373
24387
  });
24374
24388
  if (reportsResult.isError) {
24375
24389
  return stfError(StfErrorKind.Reports, reportsResult);
24376
24390
  }
24377
- // NOTE `reporters` are unused
24378
- const { reported: workPackages, reporters: _, stateUpdate: reportsUpdate, ...reportsRest } = reportsResult.ok;
24391
+ const { reported: workPackages, reporters, stateUpdate: reportsUpdate, ...reportsRest } = reportsResult.ok;
24379
24392
  assertEmpty(reportsRest);
24380
24393
  const { availabilityAssignment: reportsAvailAssignment, ...reportsUpdateRest } = reportsUpdate;
24381
24394
  assertEmpty(reportsUpdateRest);
@@ -24389,7 +24402,7 @@ class OnChain {
24389
24402
  }
24390
24403
  const { preimages, ...preimagesRest } = preimagesResult.ok;
24391
24404
  assertEmpty(preimagesRest);
24392
- const timerAccumulate = measure(`import:accumulate (${PvmBackend[this.accumulate.pvm]})`);
24405
+ const timerAccumulate = measure(`import:accumulate (${PvmBackend[this.accumulate.options.pvm]})`);
24393
24406
  // accumulate
24394
24407
  const accumulateResult = await this.accumulate.transition({
24395
24408
  slot: timeSlot,
@@ -24449,6 +24462,8 @@ class OnChain {
24449
24462
  availableReports,
24450
24463
  accumulationStatistics,
24451
24464
  transferStatistics,
24465
+ reporters: reporters,
24466
+ currentValidatorData,
24452
24467
  });
24453
24468
  const { statistics, ...statisticsRest } = statisticsUpdate;
24454
24469
  assertEmpty(statisticsRest);
@@ -25381,7 +25396,7 @@ var MetricsAPI = /** @class */ (function () {
25381
25396
  var metrics = MetricsAPI.getInstance();
25382
25397
 
25383
25398
  var name = "@typeberry/importer";
25384
- var version = "0.5.0";
25399
+ var version = "0.5.1";
25385
25400
  var packageJson = {
25386
25401
  name: name,
25387
25402
  version: version};
@@ -25491,7 +25506,7 @@ class Importer {
25491
25506
  throw new Error(`Unable to load best state from header hash: ${currentBestHeaderHash}.`);
25492
25507
  }
25493
25508
  this.verifier = new BlockVerifier(hasher, blocks);
25494
- this.stf = new OnChain(spec, state, hasher, pvm, DbHeaderChain.new(blocks));
25509
+ this.stf = new OnChain(spec, state, hasher, { pvm, accumulateSequentially: false }, DbHeaderChain.new(blocks));
25495
25510
  this.state = state;
25496
25511
  this.currentHash = currentBestHeaderHash;
25497
25512
  this.prepareForNextEpoch();
@@ -25637,11 +25652,11 @@ const blake2b = Blake2b.createHasher();
25637
25652
  async function createImporter(config) {
25638
25653
  const chainSpec = config.chainSpec;
25639
25654
  const db = config.openDatabase({ readonly: false });
25640
- const interpreter = config.workerParams.pvm;
25655
+ const pvm = config.workerParams.pvm;
25641
25656
  const blocks = db.getBlocksDb();
25642
25657
  const states = db.getStatesDb();
25643
25658
  const hasher = new TransitionHasher(await keccakHasher, await blake2b);
25644
- const importer = new Importer(chainSpec, interpreter, hasher, logger$1, blocks, states);
25659
+ const importer = new Importer(chainSpec, pvm, hasher, logger$1, blocks, states);
25645
25660
  return {
25646
25661
  importer,
25647
25662
  db,
@@ -25810,7 +25825,7 @@ class DirectWorkerConfig {
25810
25825
  workerParams;
25811
25826
  blocksDb;
25812
25827
  statesDb;
25813
- static new({ nodeName, chainSpec, blocksDb, statesDb, params, }) {
25828
+ static new({ nodeName, chainSpec, blocksDb, statesDb, workerParams: params, }) {
25814
25829
  return new DirectWorkerConfig(nodeName, chainSpec, params, blocksDb, statesDb);
25815
25830
  }
25816
25831
  constructor(nodeName, chainSpec, workerParams, blocksDb, statesDb) {