@typeberry/convert 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.
Files changed (3) hide show
  1. package/index.js +32 -16
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -4247,13 +4247,13 @@ var compatibility_GpVersion;
4247
4247
  GpVersion["V0_7_1"] = "0.7.1";
4248
4248
  GpVersion["V0_7_2"] = "0.7.2";
4249
4249
  })(compatibility_GpVersion || (compatibility_GpVersion = {}));
4250
- var TestSuite;
4250
+ var compatibility_TestSuite;
4251
4251
  (function (TestSuite) {
4252
4252
  TestSuite["W3F_DAVXY"] = "w3f-davxy";
4253
4253
  TestSuite["JAMDUNA"] = "jamduna";
4254
- })(TestSuite || (TestSuite = {}));
4254
+ })(compatibility_TestSuite || (compatibility_TestSuite = {}));
4255
4255
  const ALL_VERSIONS_IN_ORDER = [compatibility_GpVersion.V0_6_7, compatibility_GpVersion.V0_7_0, compatibility_GpVersion.V0_7_1, compatibility_GpVersion.V0_7_2];
4256
- const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
4256
+ const DEFAULT_SUITE = compatibility_TestSuite.W3F_DAVXY;
4257
4257
  const DEFAULT_VERSION = compatibility_GpVersion.V0_7_2;
4258
4258
  const env = typeof process === "undefined" ? {} : process.env;
4259
4259
  let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
@@ -4273,12 +4273,12 @@ function parseCurrentSuite(env) {
4273
4273
  if (env === undefined) {
4274
4274
  return undefined;
4275
4275
  }
4276
- for (const s of Object.values(TestSuite)) {
4276
+ for (const s of Object.values(compatibility_TestSuite)) {
4277
4277
  if (env === s) {
4278
4278
  return s;
4279
4279
  }
4280
4280
  }
4281
- throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
4281
+ throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(compatibility_TestSuite)}`);
4282
4282
  }
4283
4283
  class compatibility_Compatibility {
4284
4284
  static override(version) {
@@ -12259,7 +12259,7 @@ class service_LookupHistoryItem {
12259
12259
 
12260
12260
 
12261
12261
 
12262
- const codecServiceId = compatibility_Compatibility.isSuite(TestSuite.W3F_DAVXY) || compatibility_Compatibility.isSuite(TestSuite.JAMDUNA, compatibility_GpVersion.V0_6_7)
12262
+ const codecServiceId = compatibility_Compatibility.isSuite(compatibility_TestSuite.W3F_DAVXY) || compatibility_Compatibility.isSuite(compatibility_TestSuite.JAMDUNA, compatibility_GpVersion.V0_6_7)
12263
12263
  ? descriptors_codec.u32.asOpaque()
12264
12264
  : descriptors_codec.varU32.convert((s) => numbers_tryAsU32(s), (i) => common_tryAsServiceId(i));
12265
12265
  /**
@@ -17794,7 +17794,7 @@ class accumulate_externalities_AccumulateExternalities {
17794
17794
  updatedState;
17795
17795
  currentServiceId;
17796
17796
  currentTimeslot;
17797
- checkpointedState = null;
17797
+ checkpointedState;
17798
17798
  /** `x_i`: next service id we are going to create. */
17799
17799
  nextNewServiceId;
17800
17800
  constructor(chainSpec, blake2b, updatedState,
@@ -17805,13 +17805,14 @@ class accumulate_externalities_AccumulateExternalities {
17805
17805
  this.updatedState = updatedState;
17806
17806
  this.currentServiceId = currentServiceId;
17807
17807
  this.currentTimeslot = currentTimeslot;
17808
+ this.checkpointedState = AccumulationStateUpdate.copyFrom(updatedState.stateUpdate);
17808
17809
  this.nextNewServiceId = this.getNextAvailableServiceId(nextNewServiceIdCandidate);
17809
17810
  const service = this.updatedState.getServiceInfo(this.currentServiceId);
17810
17811
  if (service === null) {
17811
17812
  throw new Error(`Invalid state initialization. Service info missing for ${this.currentServiceId}.`);
17812
17813
  }
17813
17814
  }
17814
- /** Return the underlying state update and checkpointed state (if any). */
17815
+ /** Return the underlying state update and checkpointed state. */
17815
17816
  getStateUpdates() {
17816
17817
  return [this.updatedState.stateUpdate, this.checkpointedState];
17817
17818
  }
@@ -18346,7 +18347,7 @@ function bumpServiceId(serviceId) {
18346
18347
  */
18347
18348
  class operand_Operand extends WithDebug {
18348
18349
  // JamDuna uses a different order of operands.
18349
- static Codec = descriptors_codec.Class(operand_Operand, compatibility_Compatibility.isSuite(TestSuite.JAMDUNA)
18350
+ static Codec = descriptors_codec.Class(operand_Operand, compatibility_Compatibility.isSuite(compatibility_TestSuite.JAMDUNA)
18350
18351
  ? {
18351
18352
  hash: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
18352
18353
  exportsRoot: descriptors_codec.bytes(hash_HASH_SIZE).asOpaque(),
@@ -24226,8 +24227,8 @@ var FetchKind;
24226
24227
 
24227
24228
 
24228
24229
  const info_IN_OUT_REG = 7;
24229
- const OFFSET_REG = compatibility_Compatibility.isSuite(TestSuite.W3F_DAVXY) || compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_2) ? 9 : 11;
24230
- const LEN_REG = compatibility_Compatibility.isSuite(TestSuite.W3F_DAVXY) || compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_2) ? 10 : 12;
24230
+ const OFFSET_REG = compatibility_Compatibility.isSuite(compatibility_TestSuite.W3F_DAVXY) || compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_2) ? 9 : 11;
24231
+ const LEN_REG = compatibility_Compatibility.isSuite(compatibility_TestSuite.W3F_DAVXY) || compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_2) ? 10 : 12;
24231
24232
  /**
24232
24233
  * Return info about some account.
24233
24234
  *
@@ -24942,9 +24943,25 @@ class accumulate_Accumulate {
24942
24943
  // https://graypaper.fluffylabs.dev/#/ab2cdbd/193b05193b05?v=0.7.2
24943
24944
  const serviceStatistics = statistics.get(serviceId) ?? { count: tryAsU32(0), gasUsed: tryAsServiceGas(0) };
24944
24945
  const count = accumulateData.getReportsLength(serviceId);
24945
- // [0.7.1]: do not update statistics, if the service only had incoming transfers
24946
- if ((Compatibility.isLessThan(GpVersion.V0_7_2) && count > 0) ||
24947
- (Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) && (count > 0 || consumedGas > 0n))) {
24946
+ /**
24947
+ * [0.7.1]: We do not update statistics, if the service only had incoming transfers
24948
+ *
24949
+ * https://graypaper.fluffylabs.dev/#/1c979cb/18ae0318ae03?v=0.7.1
24950
+ */
24951
+ const shouldUpdateStatisticsPre072 = Compatibility.isLessThan(GpVersion.V0_7_2) && count > 0;
24952
+ /**
24953
+ * [0.7.2]: We update statistics if anything is changed
24954
+ *
24955
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/18d00318dd03?v=0.7.2
24956
+ */
24957
+ const shouldUpdateStatisticsPost072 = Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) && (count > 0 || consumedGas > 0n);
24958
+ /**
24959
+ * [0.7.1]: Tests are in version 0.7.1 but expect this change from 0.7.2
24960
+ *
24961
+ * https://github.com/davxy/jam-test-vectors/pull/104
24962
+ */
24963
+ const shouldUpdateStatistics071DavxyTraces = Compatibility.isSuite(TestSuite.W3F_DAVXY, GpVersion.V0_7_1) && (count > 0 || consumedGas > 0n);
24964
+ if (shouldUpdateStatisticsPre072 || shouldUpdateStatisticsPost072 || shouldUpdateStatistics071DavxyTraces) {
24948
24965
  serviceStatistics.count = tryAsU32(serviceStatistics.count + count);
24949
24966
  serviceStatistics.gasUsed = tryAsServiceGas(serviceStatistics.gasUsed + consumedGas);
24950
24967
  statistics.set(serviceId, serviceStatistics);
@@ -25176,9 +25193,8 @@ class deferred_transfers_DeferredTransfers {
25176
25193
  consumedGas = (await executor.run(args, tryAsGas(gas))).consumedGas;
25177
25194
  }
25178
25195
  transferStatistics.set(serviceId, { count: tryAsU32(transfers.length), gasUsed: tryAsServiceGas(consumedGas) });
25179
- const [updatedState, checkpointedState] = partialState.getStateUpdates();
25196
+ const [updatedState] = partialState.getStateUpdates();
25180
25197
  currentStateUpdate = updatedState;
25181
- check `${checkpointedState === null} On transfer cannot invoke checkpoint.`;
25182
25198
  }
25183
25199
  return Result.ok({
25184
25200
  // NOTE: we return only services, since it's impossible to update