@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/bootstrap-importer.mjs +23 -7
- package/bootstrap-importer.mjs.map +1 -1
- package/index.js +23 -7
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-importer.mjs
CHANGED
|
@@ -14753,7 +14753,7 @@ class AccumulateExternalities {
|
|
|
14753
14753
|
updatedState;
|
|
14754
14754
|
currentServiceId;
|
|
14755
14755
|
currentTimeslot;
|
|
14756
|
-
checkpointedState
|
|
14756
|
+
checkpointedState;
|
|
14757
14757
|
/** `x_i`: next service id we are going to create. */
|
|
14758
14758
|
nextNewServiceId;
|
|
14759
14759
|
constructor(chainSpec, blake2b, updatedState,
|
|
@@ -14764,13 +14764,14 @@ class AccumulateExternalities {
|
|
|
14764
14764
|
this.updatedState = updatedState;
|
|
14765
14765
|
this.currentServiceId = currentServiceId;
|
|
14766
14766
|
this.currentTimeslot = currentTimeslot;
|
|
14767
|
+
this.checkpointedState = AccumulationStateUpdate.copyFrom(updatedState.stateUpdate);
|
|
14767
14768
|
this.nextNewServiceId = this.getNextAvailableServiceId(nextNewServiceIdCandidate);
|
|
14768
14769
|
const service = this.updatedState.getServiceInfo(this.currentServiceId);
|
|
14769
14770
|
if (service === null) {
|
|
14770
14771
|
throw new Error(`Invalid state initialization. Service info missing for ${this.currentServiceId}.`);
|
|
14771
14772
|
}
|
|
14772
14773
|
}
|
|
14773
|
-
/** Return the underlying state update and checkpointed state
|
|
14774
|
+
/** Return the underlying state update and checkpointed state. */
|
|
14774
14775
|
getStateUpdates() {
|
|
14775
14776
|
return [this.updatedState.stateUpdate, this.checkpointedState];
|
|
14776
14777
|
}
|
|
@@ -22719,9 +22720,25 @@ class Accumulate {
|
|
|
22719
22720
|
// https://graypaper.fluffylabs.dev/#/ab2cdbd/193b05193b05?v=0.7.2
|
|
22720
22721
|
const serviceStatistics = statistics.get(serviceId) ?? { count: numbers_tryAsU32(0), gasUsed: tryAsServiceGas(0) };
|
|
22721
22722
|
const count = accumulateData.getReportsLength(serviceId);
|
|
22722
|
-
|
|
22723
|
-
|
|
22724
|
-
|
|
22723
|
+
/**
|
|
22724
|
+
* [0.7.1]: We do not update statistics, if the service only had incoming transfers
|
|
22725
|
+
*
|
|
22726
|
+
* https://graypaper.fluffylabs.dev/#/1c979cb/18ae0318ae03?v=0.7.1
|
|
22727
|
+
*/
|
|
22728
|
+
const shouldUpdateStatisticsPre072 = compatibility_Compatibility.isLessThan(compatibility_GpVersion.V0_7_2) && count > 0;
|
|
22729
|
+
/**
|
|
22730
|
+
* [0.7.2]: We update statistics if anything is changed
|
|
22731
|
+
*
|
|
22732
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/18d00318dd03?v=0.7.2
|
|
22733
|
+
*/
|
|
22734
|
+
const shouldUpdateStatisticsPost072 = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_2) && (count > 0 || consumedGas > 0n);
|
|
22735
|
+
/**
|
|
22736
|
+
* [0.7.1]: Tests are in version 0.7.1 but expect this change from 0.7.2
|
|
22737
|
+
*
|
|
22738
|
+
* https://github.com/davxy/jam-test-vectors/pull/104
|
|
22739
|
+
*/
|
|
22740
|
+
const shouldUpdateStatistics071DavxyTraces = compatibility_Compatibility.isSuite(TestSuite.W3F_DAVXY, compatibility_GpVersion.V0_7_1) && (count > 0 || consumedGas > 0n);
|
|
22741
|
+
if (shouldUpdateStatisticsPre072 || shouldUpdateStatisticsPost072 || shouldUpdateStatistics071DavxyTraces) {
|
|
22725
22742
|
serviceStatistics.count = numbers_tryAsU32(serviceStatistics.count + count);
|
|
22726
22743
|
serviceStatistics.gasUsed = tryAsServiceGas(serviceStatistics.gasUsed + consumedGas);
|
|
22727
22744
|
statistics.set(serviceId, serviceStatistics);
|
|
@@ -22953,9 +22970,8 @@ class DeferredTransfers {
|
|
|
22953
22970
|
consumedGas = (await executor.run(args, tryAsGas(gas))).consumedGas;
|
|
22954
22971
|
}
|
|
22955
22972
|
transferStatistics.set(serviceId, { count: numbers_tryAsU32(transfers.length), gasUsed: tryAsServiceGas(consumedGas) });
|
|
22956
|
-
const [updatedState
|
|
22973
|
+
const [updatedState] = partialState.getStateUpdates();
|
|
22957
22974
|
currentStateUpdate = updatedState;
|
|
22958
|
-
debug_check `${checkpointedState === null} On transfer cannot invoke checkpoint.`;
|
|
22959
22975
|
}
|
|
22960
22976
|
return Result.ok({
|
|
22961
22977
|
// NOTE: we return only services, since it's impossible to update
|