@typeberry/jam 0.2.0-4c80c6d → 0.2.0-5659c51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -39493,7 +39493,7 @@ class AccumulateExternalities {
39493
39493
  updatedState;
39494
39494
  currentServiceId;
39495
39495
  currentTimeslot;
39496
- checkpointedState = null;
39496
+ checkpointedState;
39497
39497
  /** `x_i`: next service id we are going to create. */
39498
39498
  nextNewServiceId;
39499
39499
  constructor(chainSpec, blake2b, updatedState,
@@ -39504,13 +39504,14 @@ class AccumulateExternalities {
39504
39504
  this.updatedState = updatedState;
39505
39505
  this.currentServiceId = currentServiceId;
39506
39506
  this.currentTimeslot = currentTimeslot;
39507
+ this.checkpointedState = AccumulationStateUpdate.copyFrom(updatedState.stateUpdate);
39507
39508
  this.nextNewServiceId = this.getNextAvailableServiceId(nextNewServiceIdCandidate);
39508
39509
  const service = this.updatedState.getServiceInfo(this.currentServiceId);
39509
39510
  if (service === null) {
39510
39511
  throw new Error(`Invalid state initialization. Service info missing for ${this.currentServiceId}.`);
39511
39512
  }
39512
39513
  }
39513
- /** Return the underlying state update and checkpointed state (if any). */
39514
+ /** Return the underlying state update and checkpointed state. */
39514
39515
  getStateUpdates() {
39515
39516
  return [this.updatedState.stateUpdate, this.checkpointedState];
39516
39517
  }
@@ -47457,9 +47458,25 @@ class Accumulate {
47457
47458
  // https://graypaper.fluffylabs.dev/#/ab2cdbd/193b05193b05?v=0.7.2
47458
47459
  const serviceStatistics = statistics.get(serviceId) ?? { count: numbers_tryAsU32(0), gasUsed: tryAsServiceGas(0) };
47459
47460
  const count = accumulateData.getReportsLength(serviceId);
47460
- // [0.7.1]: do not update statistics, if the service only had incoming transfers
47461
- if ((Compatibility.isLessThan(GpVersion.V0_7_2) && count > 0) ||
47462
- (Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) && (count > 0 || consumedGas > 0n))) {
47461
+ /**
47462
+ * [0.7.1]: We do not update statistics, if the service only had incoming transfers
47463
+ *
47464
+ * https://graypaper.fluffylabs.dev/#/1c979cb/18ae0318ae03?v=0.7.1
47465
+ */
47466
+ const shouldUpdateStatisticsPre072 = Compatibility.isLessThan(GpVersion.V0_7_2) && count > 0;
47467
+ /**
47468
+ * [0.7.2]: We update statistics if anything is changed
47469
+ *
47470
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/18d00318dd03?v=0.7.2
47471
+ */
47472
+ const shouldUpdateStatisticsPost072 = Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) && (count > 0 || consumedGas > 0n);
47473
+ /**
47474
+ * [0.7.1]: Tests are in version 0.7.1 but expect this change from 0.7.2
47475
+ *
47476
+ * https://github.com/davxy/jam-test-vectors/pull/104
47477
+ */
47478
+ const shouldUpdateStatistics071DavxyTraces = Compatibility.isSuite(TestSuite.W3F_DAVXY, GpVersion.V0_7_1) && (count > 0 || consumedGas > 0n);
47479
+ if (shouldUpdateStatisticsPre072 || shouldUpdateStatisticsPost072 || shouldUpdateStatistics071DavxyTraces) {
47463
47480
  serviceStatistics.count = numbers_tryAsU32(serviceStatistics.count + count);
47464
47481
  serviceStatistics.gasUsed = tryAsServiceGas(serviceStatistics.gasUsed + consumedGas);
47465
47482
  statistics.set(serviceId, serviceStatistics);
@@ -47691,9 +47708,8 @@ class DeferredTransfers {
47691
47708
  consumedGas = (await executor.run(args, tryAsGas(gas))).consumedGas;
47692
47709
  }
47693
47710
  transferStatistics.set(serviceId, { count: numbers_tryAsU32(transfers.length), gasUsed: tryAsServiceGas(consumedGas) });
47694
- const [updatedState, checkpointedState] = partialState.getStateUpdates();
47711
+ const [updatedState] = partialState.getStateUpdates();
47695
47712
  currentStateUpdate = updatedState;
47696
- debug_check `${checkpointedState === null} On transfer cannot invoke checkpoint.`;
47697
47713
  }
47698
47714
  return result_Result.ok({
47699
47715
  // NOTE: we return only services, since it's impossible to update