@typeberry/convert 0.5.8 → 0.5.9-115148

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 +45 -13
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -4500,6 +4500,12 @@ function assertEmpty(value) {
4500
4500
  }
4501
4501
  /** Debug print an object. */
4502
4502
  function debug_inspect(val) {
4503
+ return inspectInternal(val, new WeakSet());
4504
+ }
4505
+ /**
4506
+ * Internal implementation of inspect with circular reference detection.
4507
+ */
4508
+ function inspectInternal(val, seen) {
4503
4509
  const nest = (v) => v
4504
4510
  .split("\n")
4505
4511
  .map((x) => ` ${x}`)
@@ -4512,10 +4518,10 @@ function debug_inspect(val) {
4512
4518
  return "<undefined>";
4513
4519
  }
4514
4520
  if (Array.isArray(val)) {
4515
- return `[${val.map((x) => debug_inspect(x))}]`;
4521
+ return `[${val.map((x) => inspectInternal(x, seen))}]`;
4516
4522
  }
4517
4523
  if (val instanceof Map) {
4518
- return debug_inspect(Array.from(val.entries()));
4524
+ return inspectInternal(Array.from(val.entries()), seen);
4519
4525
  }
4520
4526
  if (typeof val === "number") {
4521
4527
  return `${val} (0x${val.toString(16)})`;
@@ -4523,6 +4529,11 @@ function debug_inspect(val) {
4523
4529
  if (typeof val !== "object") {
4524
4530
  return `${val}`;
4525
4531
  }
4532
+ // Check for circular references
4533
+ if (seen.has(val)) {
4534
+ return "<circular>";
4535
+ }
4536
+ seen.add(val);
4526
4537
  if ("toString" in val &&
4527
4538
  Object.prototype.toString !== val.toString &&
4528
4539
  WithDebug.prototype.toString !== val.toString) {
@@ -4535,7 +4546,7 @@ function debug_inspect(val) {
4535
4546
  for (const k of keys) {
4536
4547
  if (typeof k === "string") {
4537
4548
  v += oneLine ? "" : "\n ";
4538
- v += `${k}: ${nest(debug_inspect(val[k]))}`;
4549
+ v += `${k}: ${nest(inspectInternal(val[k], seen))}`;
4539
4550
  v += oneLine ? "," : "";
4540
4551
  }
4541
4552
  }
@@ -4615,7 +4626,7 @@ function seeThrough(v) {
4615
4626
  }
4616
4627
 
4617
4628
  ;// CONCATENATED MODULE: ./packages/core/utils/package.json
4618
- const package_namespaceObject = {"rE":"0.5.8"};
4629
+ const package_namespaceObject = {"rE":"0.5.9"};
4619
4630
  ;// CONCATENATED MODULE: ./packages/core/utils/result.ts
4620
4631
 
4621
4632
  /**
@@ -9588,14 +9599,31 @@ class RefineContext extends WithDebug {
9588
9599
  ;// CONCATENATED MODULE: ./packages/jam/block/work-item-segment.ts
9589
9600
 
9590
9601
 
9591
- /** `W_E`: The basic size of erasure-coded pieces in octets. See equation H.6. */
9602
+ /**
9603
+ * `W_E`: The basic size of erasure-coded pieces in octets. See equation H.6.
9604
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/449600449700?v=0.7.2
9605
+ */
9592
9606
  const W_E = 684;
9593
- /** `W_S`: The size of an exported segment in erasure-coded pieces in octets. */
9594
- const W_S = 6;
9595
- /** `W_M`: The maximum number of entries in a work-package manifest. */
9596
- const MAX_NUMBER_OF_SEGMENTS = 2048; // 2**11
9597
- /** `W_E * W_S`: Exported segment size in bytes. */
9598
- const SEGMENT_BYTES = W_E * W_S;
9607
+ /**
9608
+ * `W_P`: The size of an exported segment in erasure-coded pieces in octets.
9609
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/44b10044b200?v=0.7.2
9610
+ */
9611
+ const W_P = 6;
9612
+ /**
9613
+ * `W_M`: The maximum number of imports in a work-package manifest.
9614
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/44ad0044ae00?v=0.7.2
9615
+ */
9616
+ const MAX_NUMBER_OF_IMPORTS_WP = 3072;
9617
+ /**
9618
+ * `W_X`: The maximum number of exports in a work-package manifest.
9619
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/44be0044bf00?v=0.7.2
9620
+ */
9621
+ const MAX_NUMBER_OF_EXPORTS_WP = 3072;
9622
+ /**
9623
+ * `W_G = W_E * W_P`: Exported segment size in bytes.
9624
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/449a00449b00?v=0.7.2
9625
+ */
9626
+ const SEGMENT_BYTES = W_E * W_P;
9599
9627
  /** Attempt to convert a number into `SegmentIndex`. */
9600
9628
  const tryAsSegmentIndex = (v) => asOpaqueType(tryAsU16(v));
9601
9629
 
@@ -9705,13 +9733,17 @@ class work_item_WorkItem extends WithDebug {
9705
9733
  codeHash: codec_codec.bytes(hash_HASH_SIZE).asOpaque(),
9706
9734
  refineGasLimit: codec_codec.u64.asOpaque(),
9707
9735
  accumulateGasLimit: codec_codec.u64.asOpaque(),
9736
+ // TODO: [MaSo] It should be validated to not exceed W_X
9737
+ // https://graypaper.fluffylabs.dev/#/ab2cdbd/1a0b011a1c01?v=0.7.2
9708
9738
  exportCount: codec_codec.u16,
9709
9739
  payload: codec_codec.blob,
9710
9740
  importSegments: codecKnownSizeArray(ImportSpec.Codec, {
9711
9741
  minLength: 0,
9712
- maxLength: MAX_NUMBER_OF_SEGMENTS,
9713
- typicalLength: MAX_NUMBER_OF_SEGMENTS,
9742
+ maxLength: MAX_NUMBER_OF_IMPORTS_WP,
9743
+ typicalLength: MAX_NUMBER_OF_IMPORTS_WP,
9714
9744
  }),
9745
+ // TODO: [MaSo] It should be validated to not exceed T = 128
9746
+ // https://graypaper.fluffylabs.dev/#/ab2cdbd/1a0b011a1c01?v=0.7.2
9715
9747
  extrinsic: codec_codec.sequenceVarLen(WorkItemExtrinsicSpec.Codec),
9716
9748
  });
9717
9749
  static create({ service, codeHash, payload, refineGasLimit, accumulateGasLimit, importSegments, extrinsic, exportCount, }) {