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