@typeberry/jam 0.5.0-70ae055 → 0.5.0-7f94e30

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.
@@ -23811,12 +23811,15 @@ class accumulate_Accumulate {
23811
23811
  chainSpec;
23812
23812
  blake2b;
23813
23813
  state;
23814
- pvm;
23815
- constructor(chainSpec, blake2b, state, pvm) {
23814
+ options;
23815
+ constructor(chainSpec, blake2b, state, options) {
23816
23816
  this.chainSpec = chainSpec;
23817
23817
  this.blake2b = blake2b;
23818
23818
  this.state = state;
23819
- this.pvm = pvm;
23819
+ this.options = options;
23820
+ if (options.accumulateSequentially === true) {
23821
+ accumulate_logger.warn `⚠️ Parallel accumulation is disabled. Running in sequential mode.`;
23822
+ }
23820
23823
  }
23821
23824
  /**
23822
23825
  * Returns an index that determines how many WorkReports can be processed before exceeding a given gasLimit.
@@ -23868,7 +23871,7 @@ class accumulate_Accumulate {
23868
23871
  serviceExternalities: partialState,
23869
23872
  fetchExternalities,
23870
23873
  };
23871
- const executor = await PvmExecutor.createAccumulateExecutor(serviceId, code, externalities, this.chainSpec, this.pvm);
23874
+ const executor = await PvmExecutor.createAccumulateExecutor(serviceId, code, externalities, this.chainSpec, this.options.pvm);
23872
23875
  const invocationArgs = Encoder.encodeObject(ARGS_CODEC, {
23873
23876
  slot,
23874
23877
  serviceId,
@@ -24085,6 +24088,9 @@ class accumulate_Accumulate {
24085
24088
  ];
24086
24089
  return resultEntry;
24087
24090
  });
24091
+ if (this.options.accumulateSequentially === true) {
24092
+ await promise;
24093
+ }
24088
24094
  resultPromises[serviceIndex] = promise;
24089
24095
  }
24090
24096
  return Promise.all(resultPromises).then((results) => new Map(results));
@@ -24316,6 +24322,7 @@ class deferred_transfers_DeferredTransfers {
24316
24322
 
24317
24323
 
24318
24324
 
24325
+
24319
24326
  ;// CONCATENATED MODULE: ./packages/jam/transition/authorization.ts
24320
24327
 
24321
24328
 
@@ -27669,22 +27676,23 @@ class statistics_Statistics {
27669
27676
  const newPreImagesSize = current[authorIndex].preImagesSize + preImagesSize;
27670
27677
  current[authorIndex].preImagesSize = tryAsU32(newPreImagesSize);
27671
27678
  /**
27672
- * * NOTE [MaSi] Please note I don't use Kappa' here. If I understand correctly we don't need it.
27673
- * Kappa' is not needed because we can use validator indexes directly from guarantees extrinsic.
27674
- * I asked a question to ensure it is true but I didn't get any response yet:
27675
- * https://github.com/w3f/jamtestvectors/pull/28#discussion_r190723700
27679
+ * Update guarantees
27676
27680
  *
27677
- * https://graypaper.fluffylabs.dev/#/1c979cb/19a00119a801?v=0.7.1
27681
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/19ea0119f201?v=0.7.2
27678
27682
  */
27679
- const incrementedGuarantors = new Set();
27680
- for (const guarantee of extrinsic.guarantees) {
27681
- for (const { validatorIndex } of guarantee.credentials) {
27682
- if (!incrementedGuarantors.has(validatorIndex)) {
27683
- const newGuaranteesCount = current[validatorIndex].guarantees + 1;
27684
- current[validatorIndex].guarantees = tryAsU32(newGuaranteesCount);
27685
- incrementedGuarantors.add(validatorIndex);
27686
- }
27683
+ const validatorKeys = input.currentValidatorData.map((v) => v.ed25519);
27684
+ for (const reporter of input.reporters) {
27685
+ const index = validatorKeys.findIndex((x) => x.isEqualTo(reporter));
27686
+ if (index === -1) {
27687
+ /**
27688
+ * it should never happen because:
27689
+ * 1. the extrinsic is verified in reports transition
27690
+ * 2. we use current validators set from safrole
27691
+ */
27692
+ continue;
27687
27693
  }
27694
+ const newGuaranteesCount = current[index].guarantees + 1;
27695
+ current[index].guarantees = tryAsU32(newGuaranteesCount);
27688
27696
  }
27689
27697
  for (const { validatorIndex } of extrinsic.assurances) {
27690
27698
  const newAssurancesCount = current[validatorIndex].assurances + 1;
@@ -27856,7 +27864,7 @@ class OnChain {
27856
27864
  // chapter 13: https://graypaper.fluffylabs.dev/#/68eaa1f/18b60118b601?v=0.6.4
27857
27865
  statistics;
27858
27866
  isReadyForNextEpoch = Promise.resolve(false);
27859
- constructor(chainSpec, state, hasher, pvm, headerChain) {
27867
+ constructor(chainSpec, state, hasher, options, headerChain) {
27860
27868
  this.chainSpec = chainSpec;
27861
27869
  this.state = state;
27862
27870
  this.hasher = hasher;
@@ -27868,9 +27876,9 @@ class OnChain {
27868
27876
  this.disputes = new Disputes(chainSpec, hasher.blake2b, state);
27869
27877
  this.reports = new Reports(chainSpec, hasher.blake2b, state, headerChain);
27870
27878
  this.assurances = new Assurances(chainSpec, state, hasher.blake2b);
27871
- this.accumulate = new Accumulate(chainSpec, hasher.blake2b, state, pvm);
27879
+ this.accumulate = new Accumulate(chainSpec, hasher.blake2b, state, options);
27872
27880
  this.accumulateOutput = new AccumulateOutput();
27873
- this.deferredTransfers = new DeferredTransfers(chainSpec, hasher.blake2b, state, pvm);
27881
+ this.deferredTransfers = new DeferredTransfers(chainSpec, hasher.blake2b, state, options.pvm);
27874
27882
  this.preimages = new Preimages(state, hasher.blake2b);
27875
27883
  this.authorization = new Authorization(chainSpec, state);
27876
27884
  }
@@ -27958,8 +27966,7 @@ class OnChain {
27958
27966
  if (reportsResult.isError) {
27959
27967
  return stfError(StfErrorKind.Reports, reportsResult);
27960
27968
  }
27961
- // NOTE `reporters` are unused
27962
- const { reported: workPackages, reporters: _, stateUpdate: reportsUpdate, ...reportsRest } = reportsResult.ok;
27969
+ const { reported: workPackages, reporters, stateUpdate: reportsUpdate, ...reportsRest } = reportsResult.ok;
27963
27970
  assertEmpty(reportsRest);
27964
27971
  const { availabilityAssignment: reportsAvailAssignment, ...reportsUpdateRest } = reportsUpdate;
27965
27972
  assertEmpty(reportsUpdateRest);
@@ -27973,7 +27980,7 @@ class OnChain {
27973
27980
  }
27974
27981
  const { preimages, ...preimagesRest } = preimagesResult.ok;
27975
27982
  assertEmpty(preimagesRest);
27976
- const timerAccumulate = measure(`import:accumulate (${PvmBackend[this.accumulate.pvm]})`);
27983
+ const timerAccumulate = measure(`import:accumulate (${PvmBackend[this.accumulate.options.pvm]})`);
27977
27984
  // accumulate
27978
27985
  const accumulateResult = await this.accumulate.transition({
27979
27986
  slot: timeSlot,
@@ -28033,6 +28040,8 @@ class OnChain {
28033
28040
  availableReports,
28034
28041
  accumulationStatistics,
28035
28042
  transferStatistics,
28043
+ reporters: reporters,
28044
+ currentValidatorData,
28036
28045
  });
28037
28046
  const { statistics, ...statisticsRest } = statisticsUpdate;
28038
28047
  assertEmpty(statisticsRest);