@typeberry/jam 0.1.1-e48de40 → 0.1.2-3178190

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/importer/index.js CHANGED
@@ -4245,6 +4245,7 @@ var GpVersion;
4245
4245
  GpVersion["V0_6_7"] = "0.6.7";
4246
4246
  GpVersion["V0_7_0"] = "0.7.0";
4247
4247
  GpVersion["V0_7_1"] = "0.7.1-preview";
4248
+ GpVersion["V0_7_2"] = "0.7.2-preview";
4248
4249
  })(GpVersion || (GpVersion = {}));
4249
4250
  var TestSuite;
4250
4251
  (function (TestSuite) {
@@ -4252,7 +4253,7 @@ var TestSuite;
4252
4253
  TestSuite["JAMDUNA"] = "jamduna";
4253
4254
  })(TestSuite || (TestSuite = {}));
4254
4255
  const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
4255
- const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
4256
+ const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
4256
4257
  const env = typeof process === "undefined" ? {} : process.env;
4257
4258
  const DEFAULT_VERSION = GpVersion.V0_7_0;
4258
4259
  let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
@@ -4261,20 +4262,26 @@ function parseCurrentVersion(env) {
4261
4262
  if (env === undefined) {
4262
4263
  return undefined;
4263
4264
  }
4264
- const version = env;
4265
- if (!Object.values(GpVersion).includes(version)) {
4266
- throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
4265
+ switch (env) {
4266
+ case GpVersion.V0_6_7:
4267
+ case GpVersion.V0_7_0:
4268
+ case GpVersion.V0_7_1:
4269
+ case GpVersion.V0_7_2:
4270
+ return env;
4271
+ default:
4272
+ throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
4267
4273
  }
4268
- return version;
4269
4274
  }
4270
4275
  function parseCurrentSuite(env) {
4271
4276
  if (env === undefined)
4272
4277
  return undefined;
4273
- const val = env;
4274
- if (!Object.values(TestSuite).includes(val)) {
4275
- throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
4278
+ switch (env) {
4279
+ case TestSuite.W3F_DAVXY:
4280
+ case TestSuite.JAMDUNA:
4281
+ return env;
4282
+ default:
4283
+ throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
4276
4284
  }
4277
- return val;
4278
4285
  }
4279
4286
  class Compatibility {
4280
4287
  static override(version) {
@@ -13406,8 +13413,8 @@ function print(level, levelAndName, strings, data) {
13406
13413
  return;
13407
13414
  }
13408
13415
  const lvlText = Level[level].padEnd(5);
13409
- const val = strings.map((v, idx) => `${v}${data[idx]}`);
13410
- const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
13416
+ const val = strings.map((v, idx) => `${v}${idx < data.length ? data[idx] : ""}`);
13417
+ const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
13411
13418
  if (level === Level.WARN) {
13412
13419
  console.warn(msg);
13413
13420
  }
@@ -15932,6 +15939,17 @@ class PageRange {
15932
15939
  }
15933
15940
  return new PageRange(start, length);
15934
15941
  }
15942
+ /** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
15943
+ isWrapped() {
15944
+ return this.start >= this.end && !this.isEmpty();
15945
+ }
15946
+ /** Checks if given page number is within the range */
15947
+ isInRange(page) {
15948
+ if (this.isWrapped()) {
15949
+ return page >= this.start || page < this.end;
15950
+ }
15951
+ return page >= this.start && page < this.end;
15952
+ }
15935
15953
  /** Checks if a range is empty (`length === 0`) */
15936
15954
  isEmpty() {
15937
15955
  return this.length === 0;
@@ -16311,10 +16329,11 @@ class MemoryBuilder {
16311
16329
  startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
16312
16330
  `;
16313
16331
  this.ensureNotFinalized();
16314
- const range = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
16315
- const pages = PageRange.fromMemoryRange(range);
16316
- for (const pageNumber of pages) {
16317
- if (this.initialMemory.has(pageNumber)) {
16332
+ const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
16333
+ const heapPagesRange = PageRange.fromMemoryRange(heapRange);
16334
+ const initializedPageNumbers = Array.from(this.initialMemory.keys());
16335
+ for (const pageNumber of initializedPageNumbers) {
16336
+ if (heapPagesRange.isInRange(pageNumber)) {
16318
16337
  throw new IncorrectSbrkIndex();
16319
16338
  }
16320
16339
  }
@@ -20219,16 +20238,12 @@ class PartiallyUpdatedState {
20219
20238
  *
20220
20239
  * NOTE the info may be updated compared to what is in the state.
20221
20240
  *
20222
- * Takes into account newly created services as well.
20241
+ * Takes into account ejected and newly created services as well.
20223
20242
  */
20224
20243
  getServiceInfo(destination) {
20225
20244
  if (destination === null) {
20226
20245
  return null;
20227
20246
  }
20228
- const isEjected = this.stateUpdate.services.servicesRemoved.some((x) => x === destination);
20229
- if (isEjected) {
20230
- return null;
20231
- }
20232
20247
  const maybeNewService = this.stateUpdate.services.servicesUpdates.find((update) => update.serviceId === destination);
20233
20248
  if (maybeNewService !== undefined) {
20234
20249
  return maybeNewService.action.account;
@@ -22773,8 +22788,8 @@ var FetchKind;
22773
22788
 
22774
22789
 
22775
22790
  const info_IN_OUT_REG = 7;
22776
- const OFFSET_REG = Compatibility.isSuite(TestSuite.W3F_DAVXY) ? 9 : 11;
22777
- const LEN_REG = Compatibility.isSuite(TestSuite.W3F_DAVXY) ? 10 : 12;
22791
+ const OFFSET_REG = Compatibility.isSuite(TestSuite.W3F_DAVXY) || Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) ? 9 : 11;
22792
+ const LEN_REG = Compatibility.isSuite(TestSuite.W3F_DAVXY) || Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) ? 10 : 12;
22778
22793
  /**
22779
22794
  * Return info about some account.
22780
22795
  *
@@ -22791,7 +22806,7 @@ const LEN_REG = Compatibility.isSuite(TestSuite.W3F_DAVXY) ? 10 : 12;
22791
22806
  * a = last accumulation timeslot
22792
22807
  * p = parent service
22793
22808
  *
22794
- * https://graypaper.fluffylabs.dev/#/38c4e62/338302338302?v=0.7.0
22809
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/333b00333b00?v=0.7.2
22795
22810
  */
22796
22811
  class Info {
22797
22812
  currentServiceId;
@@ -22821,6 +22836,8 @@ class Info {
22821
22836
  const offset = minU64(regs.get(OFFSET_REG), valueLength);
22822
22837
  // l
22823
22838
  const length = minU64(regs.get(LEN_REG), numbers_tryAsU64(valueLength - offset));
22839
+ // NOTE: casting to `Number` is safe in both places, since we are always bounded
22840
+ // by the actual `encodedInfo.length`, which is equal `96`.
22824
22841
  const chunk = encodedInfo.raw.subarray(Number(offset), Number(offset + length));
22825
22842
  const writeResult = memory.storeFrom(outputStart, chunk);
22826
22843
  if (writeResult.isError) {
@@ -22840,7 +22857,7 @@ class Info {
22840
22857
  *
22841
22858
  * Used exclusively by `info` host call.
22842
22859
  *
22843
- * https://graypaper.fluffylabs.dev/#/7e6ff6a/337602337602?v=0.6.7
22860
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/33920033b500?v=0.7.2
22844
22861
  */
22845
22862
  const codecServiceAccountInfoWithThresholdBalance = descriptors_codec.object({
22846
22863
  codeHash: descriptors_codec.bytes(hash_HASH_SIZE),