@typeberry/lib 0.4.0 → 0.4.1-0a3acb2

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 (4) hide show
  1. package/index.cjs +725 -342
  2. package/index.d.ts +1468 -1410
  3. package/index.js +700 -316
  4. package/package.json +1 -1
package/index.cjs CHANGED
@@ -19,7 +19,11 @@ var TestSuite;
19
19
  })(TestSuite || (TestSuite = {}));
20
20
  const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
21
21
  const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
22
- const DEFAULT_VERSION = GpVersion.V0_7_2;
22
+ /**
23
+ * Current version is set to track the jam-conformance testing.
24
+ * Since we are currently at 0.7.1 not 0.7.2, we set our default version accordingly.
25
+ */
26
+ const DEFAULT_VERSION = GpVersion.V0_7_1;
23
27
  const env$1 = typeof process === "undefined" ? {} : process.env;
24
28
  let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
25
29
  let CURRENT_SUITE = parseCurrentSuite(env$1.TEST_SUITE) ?? DEFAULT_SUITE;
@@ -78,8 +82,8 @@ class Compatibility {
78
82
  /**
79
83
  * Allows selecting different values for different Gray Paper versions from one record.
80
84
  *
81
- * @param fallback The default value to return if no value is found for the current.
82
- * @param record A record mapping versions to values, checking if the version is greater or equal to the current version.
85
+ * fallback The default value to return if no value is found for the current.
86
+ * versions A record mapping versions to values, checking if the version is greater or equal to the current version.
83
87
  * @returns The value for the current version, or the default value.
84
88
  */
85
89
  static selectIfGreaterOrEqual({ fallback, versions, }) {
@@ -239,7 +243,7 @@ const workspacePathFix = env.NODE_ENV === "development"
239
243
  : () => (p) => p;
240
244
 
241
245
  /**
242
- * @fileoverview `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
246
+ * `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
243
247
  * specified unique token Token. It means that base type cannot be assigned to unique type by accident.
244
248
  * Good examples of opaque types include:
245
249
  * - JWTs or other tokens - these are special kinds of string used for authorization purposes.
@@ -582,7 +586,7 @@ function isResult(x) {
582
586
  * as an afterthought.
583
587
  */
584
588
 
585
- var index$v = /*#__PURE__*/Object.freeze({
589
+ var index$u = /*#__PURE__*/Object.freeze({
586
590
  __proto__: null,
587
591
  get CURRENT_SUITE () { return CURRENT_SUITE; },
588
592
  get CURRENT_VERSION () { return CURRENT_VERSION; },
@@ -739,7 +743,7 @@ class Ordering {
739
743
  }
740
744
  }
741
745
 
742
- var index$u = /*#__PURE__*/Object.freeze({
746
+ var index$t = /*#__PURE__*/Object.freeze({
743
747
  __proto__: null,
744
748
  Ordering: Ordering
745
749
  });
@@ -991,7 +995,7 @@ function u8ArraySameLengthEqual(self, other) {
991
995
  }
992
996
  const bytesBlobComparator = (a, b) => a.compare(b);
993
997
 
994
- var index$t = /*#__PURE__*/Object.freeze({
998
+ var index$s = /*#__PURE__*/Object.freeze({
995
999
  __proto__: null,
996
1000
  BitVec: BitVec,
997
1001
  Bytes: Bytes,
@@ -1093,7 +1097,7 @@ const minU64 = (a, ...values) => values.reduce((min, value) => (value > min ? mi
1093
1097
  /** Get the biggest value between U64 a and values given as input parameters. */
1094
1098
  const maxU64 = (a, ...values) => values.reduce((max, value) => (value < max ? max : value), a);
1095
1099
 
1096
- var index$s = /*#__PURE__*/Object.freeze({
1100
+ var index$r = /*#__PURE__*/Object.freeze({
1097
1101
  __proto__: null,
1098
1102
  isU16: isU16,
1099
1103
  isU32: isU32,
@@ -2532,7 +2536,7 @@ function sequenceViewFixLen(type, { fixedLength }) {
2532
2536
  }, skipper);
2533
2537
  }
2534
2538
 
2535
- var index$r = /*#__PURE__*/Object.freeze({
2539
+ var index$q = /*#__PURE__*/Object.freeze({
2536
2540
  __proto__: null,
2537
2541
  Decoder: Decoder,
2538
2542
  Descriptor: Descriptor,
@@ -3733,7 +3737,7 @@ var keyDerivation = /*#__PURE__*/Object.freeze({
3733
3737
  trivialSeed: trivialSeed
3734
3738
  });
3735
3739
 
3736
- var index$q = /*#__PURE__*/Object.freeze({
3740
+ var index$p = /*#__PURE__*/Object.freeze({
3737
3741
  __proto__: null,
3738
3742
  BANDERSNATCH_KEY_BYTES: BANDERSNATCH_KEY_BYTES,
3739
3743
  BANDERSNATCH_PROOF_BYTES: BANDERSNATCH_PROOF_BYTES,
@@ -4371,7 +4375,7 @@ var keccak = /*#__PURE__*/Object.freeze({
4371
4375
  // TODO [ToDr] (#213) this should most likely be moved to a separate
4372
4376
  // package to avoid pulling in unnecessary deps.
4373
4377
 
4374
- var index$p = /*#__PURE__*/Object.freeze({
4378
+ var index$o = /*#__PURE__*/Object.freeze({
4375
4379
  __proto__: null,
4376
4380
  Blake2b: Blake2b,
4377
4381
  HASH_SIZE: HASH_SIZE,
@@ -4423,8 +4427,434 @@ class ArrayView {
4423
4427
  }
4424
4428
  }
4425
4429
 
4426
- /** A map which uses hashes as keys. */
4427
- class HashDictionary {
4430
+ /** A map which uses byte blobs as keys */
4431
+ class BlobDictionary extends WithDebug {
4432
+ mapNodeThreshold;
4433
+ /**
4434
+ * The root node of the dictionary.
4435
+ *
4436
+ * This is the main internal data structure that organizes entries
4437
+ * in a tree-like fashion (array-based nodes up to `mapNodeThreshold`,
4438
+ * map-based nodes beyond it). All insertions, updates, and deletions
4439
+ * operate through this structure.
4440
+ */
4441
+ root = Node.withList();
4442
+ /**
4443
+ * Auxiliary map that stores references to the original keys and their values.
4444
+ *
4445
+ * - Overriding a value in the main structure does not replace the original key reference.
4446
+ * - Used for efficient iteration over `keys()`, `values()`, `entries()`, and computing `size`.
4447
+ */
4448
+ keyvals = new Map();
4449
+ /**
4450
+ * Protected constructor used internally by `BlobDictionary.new`
4451
+ * and `BlobDictionary.fromEntries`.
4452
+ *
4453
+ * This enforces controlled instantiation — users should create instances
4454
+ * through the provided static factory methods instead of calling the
4455
+ * constructor directly.
4456
+ *
4457
+ * @param mapNodeThreshold - The threshold that determines when the dictionary
4458
+ * switches from using an array-based (`ListChildren`) node to a map-based (`MapChildren`) node for storing entries.
4459
+ */
4460
+ constructor(mapNodeThreshold) {
4461
+ super();
4462
+ this.mapNodeThreshold = mapNodeThreshold;
4463
+ }
4464
+ /**
4465
+ * Returns the number of entries in the dictionary.
4466
+ *
4467
+ * The count is derived from the auxiliary `keyvals` map, which stores
4468
+ * all original key references and their associated values. This ensures
4469
+ * that the `size` reflects the actual number of entries, independent of
4470
+ * internal overrides in the main `root` structure.
4471
+ *
4472
+ * @returns The total number of entries in the dictionary.
4473
+ */
4474
+ get size() {
4475
+ return this.keyvals.size;
4476
+ }
4477
+ [TEST_COMPARE_USING]() {
4478
+ const vals = Array.from(this);
4479
+ vals.sort((a, b) => a[0].compare(b[0]).value);
4480
+ return vals;
4481
+ }
4482
+ /**
4483
+ * Creates an empty `BlobDictionary`.
4484
+ *
4485
+ * @param mapNodeThreshold - The threshold that determines when the dictionary
4486
+ * switches from using an array-based (`ListChildren`) node to a map-based (`MapChildren`) node for storing entries.
4487
+ * Defaults to `0`.
4488
+ *
4489
+ * @returns A new, empty `BlobDictionary` instance.
4490
+ */
4491
+ static new(mapNodeThreshold = 0) {
4492
+ return new BlobDictionary(mapNodeThreshold);
4493
+ }
4494
+ /**
4495
+ * Creates a new `BlobDictionary` initialized with the given entries.
4496
+ *
4497
+ * @param entries - An array of `[key, value]` pairs used to populate the dictionary.
4498
+ * @param mapNodeThreshold - The threshold that determines when the dictionary
4499
+ * switches from using an array-based (`ListChildren`) node to a map-based (`MapChildren`) node for storing entries.
4500
+ * Defaults to `0`.
4501
+ *
4502
+ * @returns A new `BlobDictionary` containing the provided entries.
4503
+ */
4504
+ static fromEntries(entries, mapNodeThreshold) {
4505
+ const dict = BlobDictionary.new(mapNodeThreshold);
4506
+ for (const [key, value] of entries) {
4507
+ dict.set(key, value);
4508
+ }
4509
+ return dict;
4510
+ }
4511
+ /**
4512
+ * Internal helper that inserts, updates or deletes an entry in the dictionary.
4513
+ *
4514
+ * Behaviour details:
4515
+ * - Passing `undefined` as `value` indicates a deletion. (E.g. `delete` uses `internalSet(key, undefined)`.)
4516
+ * - When an add (new entry) or a delete actually changes the structure, the method returns the affected leaf node.
4517
+ * - When the call only overrides an existing value (no structural add/delete), the method returns `null`.
4518
+ *
4519
+ * This method is intended for internal use by the dictionary implementation and allows `undefined` as a
4520
+ * sentinel value to signal removals.
4521
+ *
4522
+ * @param key - The key to insert, update or remove.
4523
+ * @param value - The value to associate with the key, or `undefined` to remove the key.
4524
+ * @returns The leaf node created or removed on add/delete, or `null` if the operation only overwrote an existing value.
4525
+ */
4526
+ internalSet(key, value) {
4527
+ let node = this.root;
4528
+ const keyChunkGenerator = key.chunks(CHUNK_SIZE);
4529
+ let depth = 0;
4530
+ for (;;) {
4531
+ const maybeKeyChunk = keyChunkGenerator.next().value;
4532
+ if (maybeKeyChunk === undefined) {
4533
+ if (value === undefined) {
4534
+ return node.remove(key);
4535
+ }
4536
+ return node.set(key, value);
4537
+ }
4538
+ const keyChunk = asOpaqueType(maybeKeyChunk);
4539
+ if (node.children instanceof ListChildren) {
4540
+ const subkey = BytesBlob.blobFrom(key.raw.subarray(CHUNK_SIZE * depth));
4541
+ const leaf = value !== undefined ? node.children.insert(subkey, { key, value }) : node.children.remove(subkey);
4542
+ if (subkey.length > CHUNK_SIZE && node.children.children.length > this.mapNodeThreshold) {
4543
+ node.convertListChildrenToMap();
4544
+ }
4545
+ return leaf;
4546
+ }
4547
+ depth += 1;
4548
+ const children = node.children;
4549
+ if (children instanceof ListChildren) {
4550
+ throw new Error("We handle list node earlier. If we fall through, we know it's for the `Map` case.");
4551
+ }
4552
+ if (children instanceof MapChildren) {
4553
+ const maybeNode = children.getChild(keyChunk);
4554
+ if (maybeNode !== undefined) {
4555
+ // simply go one level deeper
4556
+ node = maybeNode;
4557
+ }
4558
+ else {
4559
+ // we are trying to remove an item, but it does not exist
4560
+ if (value === undefined) {
4561
+ return null;
4562
+ }
4563
+ // no more child nodes, we insert a new one.
4564
+ const newNode = Node.withList();
4565
+ children.setChild(keyChunk, newNode);
4566
+ node = newNode;
4567
+ }
4568
+ continue;
4569
+ }
4570
+ assertNever(children);
4571
+ }
4572
+ }
4573
+ /**
4574
+ * Adds a new entry to the dictionary or updates the value of an existing key.
4575
+ *
4576
+ * If an entry with the given key already exists, its value is replaced
4577
+ * with the new one.
4578
+ *
4579
+ * @param key - The key to add or update in the dictionary.
4580
+ * @param value - The value to associate with the specified key.
4581
+ * @returns Nothing (`void`).
4582
+ */
4583
+ set(key, value) {
4584
+ const leaf = this.internalSet(key, value);
4585
+ if (leaf !== null) {
4586
+ this.keyvals.set(leaf.key, leaf);
4587
+ }
4588
+ }
4589
+ /**
4590
+ * Retrieves the value associated with the given key from the dictionary.
4591
+ *
4592
+ * If the key does not exist, this method returns `undefined`.
4593
+ *
4594
+ * @param key - The key whose associated value should be retrieved.
4595
+ * @returns The value associated with the specified key, or `undefined` if the key is not present.
4596
+ */
4597
+ get(key) {
4598
+ let node = this.root;
4599
+ const pathChunksGenerator = key.chunks(CHUNK_SIZE);
4600
+ let depth = 0;
4601
+ while (node !== undefined) {
4602
+ const maybePathChunk = pathChunksGenerator.next().value;
4603
+ if (node.children instanceof ListChildren) {
4604
+ const subkey = BytesBlob.blobFrom(key.raw.subarray(depth * CHUNK_SIZE));
4605
+ const child = node.children.find(subkey);
4606
+ if (child !== null) {
4607
+ return child.value;
4608
+ }
4609
+ }
4610
+ if (maybePathChunk === undefined) {
4611
+ return node.getLeaf()?.value;
4612
+ }
4613
+ if (node.children instanceof MapChildren) {
4614
+ const pathChunk = asOpaqueType(maybePathChunk);
4615
+ node = node.children.getChild(pathChunk);
4616
+ depth += 1;
4617
+ }
4618
+ }
4619
+ return undefined;
4620
+ }
4621
+ /**
4622
+ * Checks whether the dictionary contains an entry for the given key.
4623
+ *
4624
+ * ⚠️ **Note:** Avoid using `has(...)` together with `get(...)` in a pattern like this:
4625
+ *
4626
+ * ```ts
4627
+ * if (dict.has(key)) {
4628
+ * const value = dict.get(key);
4629
+ * ...
4630
+ * }
4631
+ * ```
4632
+ *
4633
+ * This approach performs two lookups for the same key.
4634
+ *
4635
+ * Instead, prefer the following pattern, which retrieves the value once:
4636
+ *
4637
+ * ```ts
4638
+ * const value = dict.get(key);
4639
+ * if (value !== undefined) {
4640
+ * ...
4641
+ * }
4642
+ * ```
4643
+ *
4644
+ * @param key - The key to check for.
4645
+ * @returns `true` if the dictionary contains an entry for the given key, otherwise `false`.
4646
+ */
4647
+ has(key) {
4648
+ return this.get(key) !== undefined;
4649
+ }
4650
+ /**
4651
+ * Removes an entry with the specified key from the dictionary.
4652
+ *
4653
+ * Internally, this calls {@link internalSet} with `undefined` to mark the entry as deleted.
4654
+ *
4655
+ * @param key - The key of the entry to remove.
4656
+ * @returns `true` if an entry was removed (i.e. the key existed), otherwise `false`.
4657
+ */
4658
+ delete(key) {
4659
+ const leaf = this.internalSet(key, undefined);
4660
+ if (leaf !== null) {
4661
+ this.keyvals.delete(leaf.key);
4662
+ return true;
4663
+ }
4664
+ return false;
4665
+ }
4666
+ /**
4667
+ * Returns an iterator over the keys in the dictionary.
4668
+ *
4669
+ * The iterator yields each key in insertion order.
4670
+ *
4671
+ * @returns An iterator over all keys in the dictionary.
4672
+ */
4673
+ keys() {
4674
+ return this.keyvals.keys();
4675
+ }
4676
+ /**
4677
+ * Returns an iterator over the values in the dictionary.
4678
+ *
4679
+ * The iterator yields each value in insertion order.
4680
+ *
4681
+ * @returns An iterator over all values in the dictionary.
4682
+ */
4683
+ *values() {
4684
+ for (const leaf of this.keyvals.values()) {
4685
+ yield leaf.value;
4686
+ }
4687
+ }
4688
+ /**
4689
+ * Returns an iterator over the `[key, value]` pairs in the dictionary.
4690
+ *
4691
+ * The iterator yields entries in insertion order.
4692
+ *
4693
+ * @returns An iterator over `[key, value]` tuples for each entry in the dictionary.
4694
+ */
4695
+ *entries() {
4696
+ for (const leaf of this.keyvals.values()) {
4697
+ yield [leaf.key, leaf.value];
4698
+ }
4699
+ }
4700
+ /**
4701
+ * Default iterator for the dictionary.
4702
+ *
4703
+ * Equivalent to calling {@link entries}.
4704
+ * Enables iteration with `for...of`:
4705
+ *
4706
+ * ```ts
4707
+ * for (const [key, value] of dict) {
4708
+ * ...
4709
+ * }
4710
+ * ```
4711
+ *
4712
+ * @returns An iterator over `[key, value]` pairs.
4713
+ */
4714
+ [Symbol.iterator]() {
4715
+ return this.entries();
4716
+ }
4717
+ /**
4718
+ * Creates a new sorted array of values, ordered by their corresponding keys.
4719
+ *
4720
+ * Iterates over all entries in the dictionary and sorts them according
4721
+ * to the provided comparator function applied to the keys.
4722
+ *
4723
+ * @param comparator - A comparator function that can compare two keys.
4724
+ *
4725
+ * @returns A new array containing all values from the dictionary,
4726
+ * sorted according to their keys.
4727
+ */
4728
+ toSortedArray(comparator) {
4729
+ const vals = Array.from(this);
4730
+ vals.sort((a, b) => comparator(a[0], b[0]).value);
4731
+ return vals.map((x) => x[1]);
4732
+ }
4733
+ }
4734
+ const CHUNK_SIZE = 6;
4735
+ /**
4736
+ * A function to transform a bytes chunk (up to 6 bytes into U48 number)
4737
+ *
4738
+ * Note that it uses 3 additional bits to store length(`value * 8 + len;`),
4739
+ * It is needed to distinguish shorter chunks that have 0s at the end, for example: [1, 2] and [1, 2, 0]
4740
+ * */
4741
+ function bytesAsU48(bytes) {
4742
+ const len = bytes.length;
4743
+ check `${len <= CHUNK_SIZE} Length has to be <= ${CHUNK_SIZE}, got: ${len}`;
4744
+ let value = bytes[3] | (bytes[2] << 8) | (bytes[1] << 16) | (bytes[0] << 24);
4745
+ for (let i = 4; i < bytes.length; i++) {
4746
+ value = value * 256 + bytes[i];
4747
+ }
4748
+ return value * 8 + len;
4749
+ }
4750
+ class Node {
4751
+ leaf;
4752
+ children;
4753
+ convertListChildrenToMap() {
4754
+ if (!(this.children instanceof ListChildren)) {
4755
+ return;
4756
+ }
4757
+ this.children = MapChildren.fromListNode(this.children);
4758
+ }
4759
+ static withList() {
4760
+ return new Node(undefined, ListChildren.new());
4761
+ }
4762
+ static withMap() {
4763
+ return new Node(undefined, MapChildren.new());
4764
+ }
4765
+ constructor(leaf, children) {
4766
+ this.leaf = leaf;
4767
+ this.children = children;
4768
+ }
4769
+ getLeaf() {
4770
+ return this.leaf;
4771
+ }
4772
+ remove(_key) {
4773
+ if (this.leaf === undefined) {
4774
+ return null;
4775
+ }
4776
+ const removedLeaf = this.leaf;
4777
+ this.leaf = undefined;
4778
+ return removedLeaf;
4779
+ }
4780
+ set(key, value) {
4781
+ if (this.leaf === undefined) {
4782
+ this.leaf = { key, value };
4783
+ return this.leaf;
4784
+ }
4785
+ this.leaf.value = value;
4786
+ return null;
4787
+ }
4788
+ }
4789
+ class ListChildren {
4790
+ children = [];
4791
+ constructor() { }
4792
+ find(key) {
4793
+ const result = this.children.find((item) => item[0].isEqualTo(key));
4794
+ if (result !== undefined) {
4795
+ return result[1];
4796
+ }
4797
+ return null;
4798
+ }
4799
+ remove(key) {
4800
+ const existingIndex = this.children.findIndex((item) => item[0].isEqualTo(key));
4801
+ if (existingIndex >= 0) {
4802
+ const ret = this.children.splice(existingIndex, 1);
4803
+ return ret[0][1];
4804
+ }
4805
+ return null;
4806
+ }
4807
+ insert(key, leaf) {
4808
+ const existingIndex = this.children.findIndex((item) => item[0].isEqualTo(key));
4809
+ if (existingIndex >= 0) {
4810
+ const existing = this.children[existingIndex];
4811
+ existing[1].value = leaf.value;
4812
+ return null;
4813
+ }
4814
+ this.children.push([key, leaf]);
4815
+ return leaf;
4816
+ }
4817
+ static new() {
4818
+ return new ListChildren();
4819
+ }
4820
+ }
4821
+ class MapChildren {
4822
+ children = new Map();
4823
+ constructor() { }
4824
+ static new() {
4825
+ return new MapChildren();
4826
+ }
4827
+ static fromListNode(node) {
4828
+ const mapNode = new MapChildren();
4829
+ for (const [key, leaf] of node.children) {
4830
+ const currentKeyChunk = asOpaqueType(BytesBlob.blobFrom(key.raw.subarray(0, CHUNK_SIZE)));
4831
+ const subKey = BytesBlob.blobFrom(key.raw.subarray(CHUNK_SIZE));
4832
+ let child = mapNode.getChild(currentKeyChunk);
4833
+ if (child === undefined) {
4834
+ child = Node.withList();
4835
+ mapNode.setChild(currentKeyChunk, child);
4836
+ }
4837
+ const children = child.children;
4838
+ children.insert(subKey, leaf);
4839
+ }
4840
+ return mapNode;
4841
+ }
4842
+ getChild(keyChunk) {
4843
+ const chunkAsNumber = bytesAsU48(keyChunk.raw);
4844
+ return this.children.get(chunkAsNumber);
4845
+ }
4846
+ setChild(keyChunk, node) {
4847
+ const chunkAsNumber = bytesAsU48(keyChunk.raw);
4848
+ this.children.set(chunkAsNumber, node);
4849
+ }
4850
+ }
4851
+
4852
+ /**
4853
+ * A map which uses hashes as keys.
4854
+ *
4855
+ * @deprecated
4856
+ * */
4857
+ class StringHashDictionary {
4428
4858
  // TODO [ToDr] [crit] We can't use `TrieHash` directly in the map,
4429
4859
  // because of the way it's being compared. Hence having `string` here.
4430
4860
  // This has to be benchmarked and re-written to a custom map most likely.
@@ -4489,6 +4919,16 @@ class HashDictionary {
4489
4919
  return this.map.delete(key.toString());
4490
4920
  }
4491
4921
  }
4922
+ /**
4923
+ * A value that indicates when `BlobDictionary` transforms Array nodes into Map nodes.
4924
+ * In practice, it doesn't matter much because, in real life, arrays in this structure usually have a length close to 1.
4925
+ */
4926
+ const BLOB_DICTIONARY_THRESHOLD$1 = 5;
4927
+ class HashDictionary extends BlobDictionary {
4928
+ constructor() {
4929
+ super(BLOB_DICTIONARY_THRESHOLD$1);
4930
+ }
4931
+ }
4492
4932
 
4493
4933
  /** A set specialized for storing hashes. */
4494
4934
  class HashSet {
@@ -4938,6 +5378,18 @@ class SortedSet extends SortedArray {
4938
5378
  }
4939
5379
  }
4940
5380
 
5381
+ function getTruncatedKey(key) {
5382
+ // Always return exactly TRUNCATED_HASH_SIZE bytes.
5383
+ if (key.length === TRUNCATED_HASH_SIZE) {
5384
+ return key;
5385
+ }
5386
+ return Bytes.fromBlob(key.raw.subarray(0, TRUNCATED_HASH_SIZE), TRUNCATED_HASH_SIZE);
5387
+ }
5388
+ /**
5389
+ * A value that indicates when `BlobDictionary` transforms Array nodes into Map nodes.
5390
+ * In practice, it doesn't matter much because, in real life, arrays in this structure usually have a length close to 1.
5391
+ */
5392
+ const BLOB_DICTIONARY_THRESHOLD = 5;
4941
5393
  /**
4942
5394
  * A collection of hash-based keys (likely `StateKey`s) which ignores
4943
5395
  * differences on the last byte.
@@ -4950,48 +5402,37 @@ class TruncatedHashDictionary {
4950
5402
  * Each key will be copied and have the last byte replace with a 0.
4951
5403
  */
4952
5404
  static fromEntries(entries) {
4953
- /** Copy key bytes of an entry and replace the last one with 0. */
4954
- const mapped = Array.from(entries).map(([key, value]) => {
4955
- const newKey = Bytes.zero(HASH_SIZE).asOpaque();
4956
- newKey.raw.set(key.raw.subarray(0, TRUNCATED_HASH_SIZE));
4957
- return [newKey, value];
4958
- });
4959
- return new TruncatedHashDictionary(HashDictionary.fromEntries(mapped));
5405
+ return new TruncatedHashDictionary(BlobDictionary.fromEntries(Array.from(entries).map(([key, value]) => [getTruncatedKey(key), value]), BLOB_DICTIONARY_THRESHOLD));
4960
5406
  }
4961
- /** A truncated key which we re-use to query the dictionary. */
4962
- truncatedKey = Bytes.zero(HASH_SIZE).asOpaque();
4963
5407
  constructor(dict) {
4964
5408
  this.dict = dict;
4965
5409
  }
4966
5410
  [TEST_COMPARE_USING]() {
4967
- return this.dict;
5411
+ return Array.from(this.dict);
4968
5412
  }
4969
5413
  /** Return number of items in the dictionary. */
4970
5414
  get size() {
4971
5415
  return this.dict.size;
4972
5416
  }
4973
5417
  /** Retrieve a value that matches the key on `TRUNCATED_HASH_SIZE`. */
4974
- get(fullKey) {
4975
- this.truncatedKey.raw.set(fullKey.raw.subarray(0, TRUNCATED_HASH_SIZE));
4976
- return this.dict.get(this.truncatedKey);
5418
+ get(key) {
5419
+ const truncatedKey = getTruncatedKey(key);
5420
+ return this.dict.get(truncatedKey);
4977
5421
  }
4978
5422
  /** Return true if the key is present in the dictionary */
4979
- has(fullKey) {
4980
- this.truncatedKey.raw.set(fullKey.raw.subarray(0, TRUNCATED_HASH_SIZE));
4981
- return this.dict.has(this.truncatedKey);
5423
+ has(key) {
5424
+ const truncatedKey = getTruncatedKey(key);
5425
+ return this.dict.has(truncatedKey);
4982
5426
  }
4983
5427
  /** Set or update a value that matches the key on `TRUNCATED_HASH_SIZE`. */
4984
- set(fullKey, value) {
4985
- // NOTE we can't use the the shared key here, since the collection will
4986
- // store the key for us, hence the copy.
4987
- const key = Bytes.zero(HASH_SIZE);
4988
- key.raw.set(fullKey.raw.subarray(0, TRUNCATED_HASH_SIZE));
4989
- this.dict.set(key.asOpaque(), value);
5428
+ set(key, value) {
5429
+ const truncatedKey = getTruncatedKey(key);
5430
+ this.dict.set(truncatedKey, value);
4990
5431
  }
4991
5432
  /** Remove a value that matches the key on `TRUNCATED_HASH_SIZE`. */
4992
- delete(fullKey) {
4993
- this.truncatedKey.raw.set(fullKey.raw.subarray(0, TRUNCATED_HASH_SIZE));
4994
- this.dict.delete(this.truncatedKey);
5433
+ delete(key) {
5434
+ const truncatedKey = getTruncatedKey(key);
5435
+ this.dict.delete(truncatedKey);
4995
5436
  }
4996
5437
  /** Iterator over values of the dictionary. */
4997
5438
  values() {
@@ -4999,26 +5440,28 @@ class TruncatedHashDictionary {
4999
5440
  }
5000
5441
  /** Iterator over entries of the dictionary (with truncated keys) */
5001
5442
  *entries() {
5002
- for (const [key, value] of this.dict.entries()) {
5003
- yield [Bytes.fromBlob(key.raw.subarray(0, TRUNCATED_HASH_SIZE), TRUNCATED_HASH_SIZE).asOpaque(), value];
5004
- }
5443
+ yield* this.dict.entries();
5005
5444
  }
5006
5445
  [Symbol.iterator]() {
5007
5446
  return this.entries();
5008
5447
  }
5009
5448
  }
5010
5449
 
5011
- var index$o = /*#__PURE__*/Object.freeze({
5450
+ var index$n = /*#__PURE__*/Object.freeze({
5012
5451
  __proto__: null,
5013
5452
  ArrayView: ArrayView,
5453
+ BlobDictionary: BlobDictionary,
5014
5454
  FixedSizeArray: FixedSizeArray,
5015
5455
  HashDictionary: HashDictionary,
5016
5456
  HashSet: HashSet,
5457
+ ListChildren: ListChildren,
5017
5458
  MultiMap: MultiMap,
5018
5459
  SortedArray: SortedArray,
5019
5460
  SortedSet: SortedSet,
5461
+ StringHashDictionary: StringHashDictionary,
5020
5462
  TruncatedHashDictionary: TruncatedHashDictionary,
5021
- asKnownSize: asKnownSize
5463
+ asKnownSize: asKnownSize,
5464
+ bytesAsU48: bytesAsU48
5022
5465
  });
5023
5466
 
5024
5467
  /**
@@ -5195,7 +5638,7 @@ var PvmBackend;
5195
5638
  PvmBackend[PvmBackend["Ananas"] = 1] = "Ananas";
5196
5639
  })(PvmBackend || (PvmBackend = {}));
5197
5640
 
5198
- var index$n = /*#__PURE__*/Object.freeze({
5641
+ var index$m = /*#__PURE__*/Object.freeze({
5199
5642
  __proto__: null,
5200
5643
  Bootnode: Bootnode,
5201
5644
  ChainSpec: ChainSpec,
@@ -6702,7 +7145,7 @@ function reencodeAsView(codec, object, chainSpec) {
6702
7145
  return Decoder.decodeObject(codec.View, encoded, chainSpec);
6703
7146
  }
6704
7147
 
6705
- var index$m = /*#__PURE__*/Object.freeze({
7148
+ var index$l = /*#__PURE__*/Object.freeze({
6706
7149
  __proto__: null,
6707
7150
  Block: Block,
6708
7151
  EpochMarker: EpochMarker,
@@ -6712,6 +7155,8 @@ var index$m = /*#__PURE__*/Object.freeze({
6712
7155
  SEGMENT_BYTES: SEGMENT_BYTES,
6713
7156
  TicketsMarker: TicketsMarker,
6714
7157
  ValidatorKeys: ValidatorKeys,
7158
+ W_E: W_E,
7159
+ W_S: W_S,
6715
7160
  assurances: assurances,
6716
7161
  codecPerEpochBlock: codecPerEpochBlock,
6717
7162
  codecPerValidator: codecPerValidator,
@@ -6972,7 +7417,7 @@ var json;
6972
7417
  json.object = object;
6973
7418
  })(json || (json = {}));
6974
7419
 
6975
- var index$l = /*#__PURE__*/Object.freeze({
7420
+ var index$k = /*#__PURE__*/Object.freeze({
6976
7421
  __proto__: null,
6977
7422
  get json () { return json; },
6978
7423
  parseFromJson: parseFromJson
@@ -7100,12 +7545,12 @@ const workRefineLoadFromJson = json.object({
7100
7545
  extrinsic_count: "number",
7101
7546
  extrinsic_size: "number",
7102
7547
  exports: "number",
7103
- }, ({ gas_used, imports, extrinsic_count, extrinsic_size, exports }) => WorkRefineLoad.create({
7548
+ }, ({ gas_used, imports, extrinsic_count, extrinsic_size, exports: exports$1 }) => WorkRefineLoad.create({
7104
7549
  gasUsed: tryAsServiceGas(gas_used),
7105
7550
  importedSegments: tryAsU32(imports),
7106
7551
  extrinsicCount: tryAsU32(extrinsic_count),
7107
7552
  extrinsicSize: tryAsU32(extrinsic_size),
7108
- exportedSegments: tryAsU32(exports),
7553
+ exportedSegments: tryAsU32(exports$1),
7109
7554
  }));
7110
7555
  const workResultFromJson = json.object({
7111
7556
  service_id: "number",
@@ -7242,7 +7687,7 @@ const blockFromJson = (spec) => json.object({
7242
7687
  extrinsic: getExtrinsicFromJson(spec),
7243
7688
  }, ({ header, extrinsic }) => Block.create({ header, extrinsic }));
7244
7689
 
7245
- var index$k = /*#__PURE__*/Object.freeze({
7690
+ var index$j = /*#__PURE__*/Object.freeze({
7246
7691
  __proto__: null,
7247
7692
  blockFromJson: blockFromJson,
7248
7693
  disputesExtrinsicFromJson: disputesExtrinsicFromJson,
@@ -7267,7 +7712,7 @@ function parseBootnode(v) {
7267
7712
  if (name === "" || ip === "" || port === "") {
7268
7713
  throw new Error(`Invalid bootnode format, expected: <name>@<ip>:<port>, got: "${v}"`);
7269
7714
  }
7270
- const portNumber = Number.parseInt(port);
7715
+ const portNumber = Number.parseInt(port, 10);
7271
7716
  if (!isU16(portNumber)) {
7272
7717
  throw new Error(`Invalid port number: "${port}"`);
7273
7718
  }
@@ -7736,7 +8181,7 @@ class Logger {
7736
8181
  }
7737
8182
  }
7738
8183
 
7739
- var index$j = /*#__PURE__*/Object.freeze({
8184
+ var index$i = /*#__PURE__*/Object.freeze({
7740
8185
  __proto__: null,
7741
8186
  get Level () { return Level; },
7742
8187
  Logger: Logger,
@@ -7951,7 +8396,7 @@ function isJsonObject(value) {
7951
8396
  return typeof value === "object" && value !== null && !Array.isArray(value);
7952
8397
  }
7953
8398
 
7954
- var index$i = /*#__PURE__*/Object.freeze({
8399
+ var index$h = /*#__PURE__*/Object.freeze({
7955
8400
  __proto__: null,
7956
8401
  DEFAULT_CONFIG: DEFAULT_CONFIG,
7957
8402
  DEV_CONFIG: DEV_CONFIG,
@@ -8872,7 +9317,7 @@ class CoreStatistics {
8872
9317
  /** `i` */
8873
9318
  imports,
8874
9319
  /** `e` */
8875
- exports,
9320
+ exports$1,
8876
9321
  /** `z` */
8877
9322
  extrinsicSize,
8878
9323
  /** `x` */
@@ -8884,7 +9329,7 @@ class CoreStatistics {
8884
9329
  this.dataAvailabilityLoad = dataAvailabilityLoad;
8885
9330
  this.popularity = popularity;
8886
9331
  this.imports = imports;
8887
- this.exports = exports;
9332
+ this.exports = exports$1;
8888
9333
  this.extrinsicSize = extrinsicSize;
8889
9334
  this.extrinsicCount = extrinsicCount;
8890
9335
  this.bundleSize = bundleSize;
@@ -8977,7 +9422,7 @@ class ServiceStatistics {
8977
9422
  /** `i` */
8978
9423
  imports,
8979
9424
  /** `e` */
8980
- exports,
9425
+ exports$1,
8981
9426
  /** `z` */
8982
9427
  extrinsicSize,
8983
9428
  /** `x` */
@@ -8995,7 +9440,7 @@ class ServiceStatistics {
8995
9440
  this.refinementCount = refinementCount;
8996
9441
  this.refinementGasUsed = refinementGasUsed;
8997
9442
  this.imports = imports;
8998
- this.exports = exports;
9443
+ this.exports = exports$1;
8999
9444
  this.extrinsicSize = extrinsicSize;
9000
9445
  this.extrinsicCount = extrinsicCount;
9001
9446
  this.accumulateCount = accumulateCount;
@@ -9160,11 +9605,32 @@ const ENTROPY_ENTRIES = 4;
9160
9605
 
9161
9606
  var UpdatePreimageKind;
9162
9607
  (function (UpdatePreimageKind) {
9163
- /** Insert new preimage and optionally update it's lookup history. */
9608
+ /**
9609
+ * Insert new preimage and optionally update it's lookup history.
9610
+ *
9611
+ * Used in: `provide`
9612
+ *
9613
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/383904383904?v=0.7.2
9614
+ */
9164
9615
  UpdatePreimageKind[UpdatePreimageKind["Provide"] = 0] = "Provide";
9165
- /** Remove a preimage and it's lookup history. */
9616
+ /**
9617
+ * Remove a preimage and it's lookup history.
9618
+ *
9619
+ * Used in: `forget` and `eject`
9620
+ *
9621
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/38c701380202?v=0.7.2
9622
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/379102379302?v=0.7.2
9623
+ */
9166
9624
  UpdatePreimageKind[UpdatePreimageKind["Remove"] = 1] = "Remove";
9167
- /** update or add lookup history for preimage hash/len to given value. */
9625
+ /**
9626
+ * Update or add lookup history for preimage hash/len to given value.
9627
+ *
9628
+ * Used in: `solicit` and `forget`
9629
+ *
9630
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/382802382802?v=0.7.2
9631
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/384002384b02?v=0.7.2
9632
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/38c60038ea00?v=0.7.2
9633
+ */
9168
9634
  UpdatePreimageKind[UpdatePreimageKind["UpdateOrAdd"] = 2] = "UpdateOrAdd";
9169
9635
  })(UpdatePreimageKind || (UpdatePreimageKind = {}));
9170
9636
  /**
@@ -9172,7 +9638,7 @@ var UpdatePreimageKind;
9172
9638
  *
9173
9639
  * Can be one of the following cases:
9174
9640
  * 1. Provide a new preimage blob and set the lookup history to available at `slot`.
9175
- * 2. Remove (expunge) a preimage and it's lookup history.
9641
+ * 2. Remove (forget) a preimage and it's lookup history.
9176
9642
  * 3. Update `LookupHistory` with given value.
9177
9643
  */
9178
9644
  class UpdatePreimage {
@@ -9745,7 +10211,7 @@ const serviceDataCodec = codec$1.dictionary(codec$1.u32.asOpaque(), serviceEntri
9745
10211
  sortKeys: (a, b) => a - b,
9746
10212
  });
9747
10213
 
9748
- var index$h = /*#__PURE__*/Object.freeze({
10214
+ var index$g = /*#__PURE__*/Object.freeze({
9749
10215
  __proto__: null,
9750
10216
  AUTHORIZATION_QUEUE_SIZE: AUTHORIZATION_QUEUE_SIZE,
9751
10217
  AccumulationOutput: AccumulationOutput,
@@ -10376,7 +10842,6 @@ class LeafNode {
10376
10842
  /**
10377
10843
  * Get the byte length of embedded value.
10378
10844
  *
10379
- * @remark
10380
10845
  * Note in case this node only contains hash this is going to be 0.
10381
10846
  */
10382
10847
  getValueLength() {
@@ -10387,7 +10852,6 @@ class LeafNode {
10387
10852
  /**
10388
10853
  * Returns the embedded value.
10389
10854
  *
10390
- * @remark
10391
10855
  * Note that this is going to be empty for a regular leaf node (i.e. containing a hash).
10392
10856
  */
10393
10857
  getValue() {
@@ -10397,7 +10861,6 @@ class LeafNode {
10397
10861
  /**
10398
10862
  * Returns contained value hash.
10399
10863
  *
10400
- * @remark
10401
10864
  * Note that for embedded value this is going to be full 0-padded 32 bytes.
10402
10865
  */
10403
10866
  getValueHash() {
@@ -10819,7 +11282,7 @@ const bitLookup = [
10819
11282
  [0b00000000, 8],
10820
11283
  ];
10821
11284
 
10822
- var index$g = /*#__PURE__*/Object.freeze({
11285
+ var index$f = /*#__PURE__*/Object.freeze({
10823
11286
  __proto__: null,
10824
11287
  BranchNode: BranchNode,
10825
11288
  InMemoryTrie: InMemoryTrie,
@@ -11186,7 +11649,7 @@ function loadState(spec, blake2b, entries) {
11186
11649
  * hashmap of `key -> value` entries.
11187
11650
  */
11188
11651
 
11189
- var index$f = /*#__PURE__*/Object.freeze({
11652
+ var index$e = /*#__PURE__*/Object.freeze({
11190
11653
  __proto__: null,
11191
11654
  SerializedService: SerializedService,
11192
11655
  SerializedState: SerializedState,
@@ -11435,7 +11898,7 @@ class InMemoryStates {
11435
11898
  async close() { }
11436
11899
  }
11437
11900
 
11438
- var index$e = /*#__PURE__*/Object.freeze({
11901
+ var index$d = /*#__PURE__*/Object.freeze({
11439
11902
  __proto__: null,
11440
11903
  InMemoryBlocks: InMemoryBlocks,
11441
11904
  InMemorySerializedStates: InMemorySerializedStates,
@@ -11799,7 +12262,7 @@ const initEc = async () => {
11799
12262
  await init.reedSolomon();
11800
12263
  };
11801
12264
 
11802
- var index$d = /*#__PURE__*/Object.freeze({
12265
+ var index$c = /*#__PURE__*/Object.freeze({
11803
12266
  __proto__: null,
11804
12267
  N_CHUNKS_REDUNDANCY: N_CHUNKS_REDUNDANCY,
11805
12268
  N_CHUNKS_REQUIRED: N_CHUNKS_REQUIRED,
@@ -12233,7 +12696,7 @@ class FuzzTarget {
12233
12696
  }
12234
12697
  }
12235
12698
 
12236
- var index$c = /*#__PURE__*/Object.freeze({
12699
+ var index$b = /*#__PURE__*/Object.freeze({
12237
12700
  __proto__: null,
12238
12701
  AncestryItem: AncestryItem,
12239
12702
  ErrorMessage: ErrorMessage,
@@ -12251,9 +12714,9 @@ var index$c = /*#__PURE__*/Object.freeze({
12251
12714
  stateRootCodec: stateRootCodec
12252
12715
  });
12253
12716
 
12254
- var index$b = /*#__PURE__*/Object.freeze({
12717
+ var index$a = /*#__PURE__*/Object.freeze({
12255
12718
  __proto__: null,
12256
- v1: index$c
12719
+ v1: index$b
12257
12720
  });
12258
12721
 
12259
12722
  /** Size of the transfer memo. */
@@ -12682,7 +13145,11 @@ class PartiallyUpdatedState {
12682
13145
  const service = this.state.getService(serviceId);
12683
13146
  return service?.getPreimage(hash) ?? null;
12684
13147
  }
12685
- /** Get status of a preimage of current service taking into account any updates. */
13148
+ /**
13149
+ * Get status of a preimage of current service taking into account any updates.
13150
+ *
13151
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/110201110201?v=0.7.2
13152
+ */
12686
13153
  getLookupHistory(currentTimeslot, serviceId, hash, length) {
12687
13154
  const updatedService = this.stateUpdate.services.updated.get(serviceId);
12688
13155
  /** Return lookup history item for newly created service */
@@ -12719,12 +13186,7 @@ class PartiallyUpdatedState {
12719
13186
  return new LookupHistoryItem(hash, updatedPreimage.length, tryAsLookupHistorySlots([currentTimeslot]));
12720
13187
  }
12721
13188
  case UpdatePreimageKind.Remove: {
12722
- const state = stateFallback();
12723
- // kinda impossible, since we know it's there because it's removed.
12724
- if (state === null) {
12725
- return null;
12726
- }
12727
- return new LookupHistoryItem(hash, state.length, tryAsLookupHistorySlots([...state.slots, currentTimeslot]));
13189
+ return null;
12728
13190
  }
12729
13191
  case UpdatePreimageKind.UpdateOrAdd: {
12730
13192
  return action.item;
@@ -13116,42 +13578,6 @@ class HostCallsManager {
13116
13578
  }
13117
13579
  }
13118
13580
 
13119
- /** Create a new gas counter instance depending on the gas value. */
13120
- function gasCounter(gas) {
13121
- return new GasCounterU64(tryAsU64(gas));
13122
- }
13123
- class GasCounterU64 {
13124
- gas;
13125
- initialGas;
13126
- constructor(gas) {
13127
- this.gas = gas;
13128
- this.initialGas = tryAsGas(gas);
13129
- }
13130
- set(g) {
13131
- this.gas = tryAsU64(g);
13132
- }
13133
- get() {
13134
- return tryAsGas(this.gas);
13135
- }
13136
- sub(g) {
13137
- const result = this.gas - tryAsU64(g);
13138
- if (result >= 0n) {
13139
- this.gas = tryAsU64(result);
13140
- return false;
13141
- }
13142
- this.gas = tryAsU64(0n);
13143
- return true;
13144
- }
13145
- used() {
13146
- const gasConsumed = tryAsU64(this.initialGas) - this.gas;
13147
- // In we have less than zero left we assume that all gas has been consumed.
13148
- if (gasConsumed < 0) {
13149
- return this.initialGas;
13150
- }
13151
- return tryAsGas(gasConsumed);
13152
- }
13153
- }
13154
-
13155
13581
  const tryAsMemoryIndex = (index) => {
13156
13582
  check `${index >= 0 && index <= MAX_MEMORY_INDEX} Incorrect memory index: ${index}!`;
13157
13583
  return asOpaqueType(index);
@@ -13874,7 +14300,7 @@ function getRegisters(argsLength) {
13874
14300
  return regs;
13875
14301
  }
13876
14302
 
13877
- var index$a = /*#__PURE__*/Object.freeze({
14303
+ var index$9 = /*#__PURE__*/Object.freeze({
13878
14304
  __proto__: null,
13879
14305
  MemorySegment: MemorySegment,
13880
14306
  SpiMemory: SpiMemory,
@@ -13933,7 +14359,7 @@ function extractCodeAndMetadata(blobWithMetadata) {
13933
14359
  return { metadata, code };
13934
14360
  }
13935
14361
 
13936
- var index$9 = /*#__PURE__*/Object.freeze({
14362
+ var index$8 = /*#__PURE__*/Object.freeze({
13937
14363
  __proto__: null,
13938
14364
  Program: Program,
13939
14365
  extractCodeAndMetadata: extractCodeAndMetadata
@@ -14897,6 +15323,42 @@ class BasicBlocks {
14897
15323
  }
14898
15324
  }
14899
15325
 
15326
+ /** Create a new gas counter instance depending on the gas value. */
15327
+ function gasCounter(gas) {
15328
+ return new GasCounterU64(tryAsU64(gas));
15329
+ }
15330
+ class GasCounterU64 {
15331
+ gas;
15332
+ initialGas;
15333
+ constructor(gas) {
15334
+ this.gas = gas;
15335
+ this.initialGas = tryAsGas(gas);
15336
+ }
15337
+ set(g) {
15338
+ this.gas = tryAsU64(g);
15339
+ }
15340
+ get() {
15341
+ return tryAsGas(this.gas);
15342
+ }
15343
+ sub(g) {
15344
+ const result = this.gas - tryAsU64(g);
15345
+ if (result >= 0n) {
15346
+ this.gas = tryAsU64(result);
15347
+ return false;
15348
+ }
15349
+ this.gas = tryAsU64(0n);
15350
+ return true;
15351
+ }
15352
+ used() {
15353
+ const gasConsumed = tryAsU64(this.initialGas) - this.gas;
15354
+ // In we have less than zero left we assume that all gas has been consumed.
15355
+ if (gasConsumed < 0) {
15356
+ return this.initialGas;
15357
+ }
15358
+ return tryAsGas(gasConsumed);
15359
+ }
15360
+ }
15361
+
14900
15362
  const instructionGasMap = (() => {
14901
15363
  const instructionGasMap = new Array(HIGHEST_INSTRUCTION_NUMBER + 1);
14902
15364
  for (let i = 0; i < HIGHEST_INSTRUCTION_NUMBER + 1; i++) {
@@ -16805,8 +17267,77 @@ class Interpreter {
16805
17267
  }
16806
17268
  }
16807
17269
 
16808
- var index$8 = /*#__PURE__*/Object.freeze({
17270
+ class DebuggerAdapter {
17271
+ pvm;
17272
+ constructor(useSbrkGas = false) {
17273
+ this.pvm = new Interpreter({ useSbrkGas });
17274
+ }
17275
+ resetGeneric(rawProgram, flatRegisters, initialGas) {
17276
+ this.pvm.resetGeneric(rawProgram, 0, tryAsGas(initialGas), new Registers(flatRegisters));
17277
+ }
17278
+ reset(rawProgram, pc, gas, maybeRegisters, maybeMemory) {
17279
+ this.pvm.resetGeneric(rawProgram, pc, tryAsGas(gas), maybeRegisters, maybeMemory);
17280
+ }
17281
+ getPageDump(pageNumber) {
17282
+ const page = this.pvm.getMemoryPage(pageNumber);
17283
+ if (page === null) {
17284
+ // page wasn't allocated so we return an empty page
17285
+ return safeAllocUint8Array(PAGE_SIZE$1);
17286
+ }
17287
+ if (page.length === PAGE_SIZE$1) {
17288
+ // page was allocated and has a proper size so we can simply return it
17289
+ return page;
17290
+ }
17291
+ // page was allocated but it is shorter than PAGE_SIZE so we have to extend it
17292
+ const fullPage = safeAllocUint8Array(PAGE_SIZE$1);
17293
+ fullPage.set(page);
17294
+ return fullPage;
17295
+ }
17296
+ setMemory(address, value) {
17297
+ this.pvm.memory.storeFrom(tryAsMemoryIndex(address), value);
17298
+ }
17299
+ getExitArg() {
17300
+ return this.pvm.getExitParam() ?? 0;
17301
+ }
17302
+ getStatus() {
17303
+ return this.pvm.getStatus();
17304
+ }
17305
+ nextStep() {
17306
+ return this.pvm.nextStep() === Status.OK;
17307
+ }
17308
+ nSteps(steps) {
17309
+ check `${steps >>> 0 > 0} Expected a positive integer got ${steps}`;
17310
+ for (let i = 0; i < steps; i++) {
17311
+ const isOk = this.nextStep();
17312
+ if (!isOk) {
17313
+ return false;
17314
+ }
17315
+ }
17316
+ return true;
17317
+ }
17318
+ getRegisters() {
17319
+ return this.pvm.registers.getAllU64();
17320
+ }
17321
+ setRegisters(registers) {
17322
+ this.pvm.registers.copyFrom(new Registers(registers));
17323
+ }
17324
+ getProgramCounter() {
17325
+ return this.pvm.getPC();
17326
+ }
17327
+ setNextProgramCounter(nextPc) {
17328
+ this.pvm.setNextPC(nextPc);
17329
+ }
17330
+ getGasLeft() {
17331
+ return BigInt(this.pvm.gas.get());
17332
+ }
17333
+ setGasLeft(gas) {
17334
+ this.pvm.gas.set(tryAsGas(gas));
17335
+ }
17336
+ }
17337
+
17338
+ var index$7 = /*#__PURE__*/Object.freeze({
16809
17339
  __proto__: null,
17340
+ DebuggerAdapter: DebuggerAdapter,
16810
17341
  Interpreter: Interpreter,
16811
17342
  Memory: Memory,
16812
17343
  MemoryBuilder: MemoryBuilder,
@@ -16837,18 +17368,18 @@ async function instantiate$1(module, imports = {}) {
16837
17368
  },
16838
17369
  }, Object.assign(Object.create(globalThis), imports.env || {})),
16839
17370
  };
16840
- const { exports } = await WebAssembly.instantiate(module, adaptedImports);
16841
- const memory = exports.memory || imports.env.memory;
17371
+ const { exports: exports$1 } = await WebAssembly.instantiate(module, adaptedImports);
17372
+ const memory = exports$1.memory || imports.env.memory;
16842
17373
  const adaptedExports = Object.setPrototypeOf({
16843
17374
  getAssembly(p) {
16844
17375
  // assembly/api-internal/getAssembly(assembly/program/Program) => ~lib/string/String
16845
17376
  p = __lowerInternref(p) || __notnull();
16846
- return __liftString(exports.getAssembly(p) >>> 0);
17377
+ return __liftString(exports$1.getAssembly(p) >>> 0);
16847
17378
  },
16848
17379
  wrapAsProgram(bytecode) {
16849
17380
  // assembly/program-build/wrapAsProgram(~lib/typedarray/Uint8Array) => ~lib/typedarray/Uint8Array
16850
17381
  bytecode = __lowerTypedArray(Uint8Array, 10, 0, bytecode) || __notnull();
16851
- return __liftTypedArray(Uint8Array, exports.wrapAsProgram(bytecode) >>> 0);
17382
+ return __liftTypedArray(Uint8Array, exports$1.wrapAsProgram(bytecode) >>> 0);
16852
17383
  },
16853
17384
  resetJAM(program, pc, initialGas, args, hasMetadata) {
16854
17385
  // assembly/api-debugger/resetJAM(~lib/array/Array<u8>, f64, i64, ~lib/array/Array<u8>, bool?) => void
@@ -16857,8 +17388,8 @@ async function instantiate$1(module, imports = {}) {
16857
17388
  args = __lowerArray(__setU8, 6, 0, args) || __notnull();
16858
17389
  hasMetadata = hasMetadata ? 1 : 0;
16859
17390
  try {
16860
- exports.__setArgumentsLength(arguments.length);
16861
- exports.resetJAM(program, pc, initialGas, args, hasMetadata);
17391
+ exports$1.__setArgumentsLength(arguments.length);
17392
+ exports$1.resetJAM(program, pc, initialGas, args, hasMetadata);
16862
17393
  } finally {
16863
17394
  __release(program);
16864
17395
  }
@@ -16870,8 +17401,8 @@ async function instantiate$1(module, imports = {}) {
16870
17401
  initialGas = initialGas || 0n;
16871
17402
  hasMetadata = hasMetadata ? 1 : 0;
16872
17403
  try {
16873
- exports.__setArgumentsLength(arguments.length);
16874
- exports.resetGeneric(program, flatRegisters, initialGas, hasMetadata);
17404
+ exports$1.__setArgumentsLength(arguments.length);
17405
+ exports$1.resetGeneric(program, flatRegisters, initialGas, hasMetadata);
16875
17406
  } finally {
16876
17407
  __release(program);
16877
17408
  }
@@ -16885,8 +17416,8 @@ async function instantiate$1(module, imports = {}) {
16885
17416
  initialGas = initialGas || 0n;
16886
17417
  hasMetadata = hasMetadata ? 1 : 0;
16887
17418
  try {
16888
- exports.__setArgumentsLength(arguments.length);
16889
- exports.resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata);
17419
+ exports$1.__setArgumentsLength(arguments.length);
17420
+ exports$1.resetGenericWithMemory(program, flatRegisters, pageMap, chunks, initialGas, hasMetadata);
16890
17421
  } finally {
16891
17422
  __release(program);
16892
17423
  __release(flatRegisters);
@@ -16895,68 +17426,68 @@ async function instantiate$1(module, imports = {}) {
16895
17426
  },
16896
17427
  nextStep() {
16897
17428
  // assembly/api-debugger/nextStep() => bool
16898
- return exports.nextStep() != 0;
17429
+ return exports$1.nextStep() != 0;
16899
17430
  },
16900
17431
  nSteps(steps) {
16901
17432
  // assembly/api-debugger/nSteps(u32) => bool
16902
- return exports.nSteps(steps) != 0;
17433
+ return exports$1.nSteps(steps) != 0;
16903
17434
  },
16904
17435
  getProgramCounter() {
16905
17436
  // assembly/api-debugger/getProgramCounter() => u32
16906
- return exports.getProgramCounter() >>> 0;
17437
+ return exports$1.getProgramCounter() >>> 0;
16907
17438
  },
16908
17439
  getExitArg() {
16909
17440
  // assembly/api-debugger/getExitArg() => u32
16910
- return exports.getExitArg() >>> 0;
17441
+ return exports$1.getExitArg() >>> 0;
16911
17442
  },
16912
17443
  setGasLeft(gas) {
16913
17444
  // assembly/api-debugger/setGasLeft(i64) => void
16914
17445
  gas = gas || 0n;
16915
- exports.setGasLeft(gas);
17446
+ exports$1.setGasLeft(gas);
16916
17447
  },
16917
17448
  getRegisters() {
16918
17449
  // assembly/api-debugger/getRegisters() => ~lib/typedarray/Uint8Array
16919
- return __liftTypedArray(Uint8Array, exports.getRegisters() >>> 0);
17450
+ return __liftTypedArray(Uint8Array, exports$1.getRegisters() >>> 0);
16920
17451
  },
16921
17452
  setRegisters(flatRegisters) {
16922
17453
  // assembly/api-debugger/setRegisters(~lib/array/Array<u8>) => void
16923
17454
  flatRegisters = __lowerArray(__setU8, 6, 0, flatRegisters) || __notnull();
16924
- exports.setRegisters(flatRegisters);
17455
+ exports$1.setRegisters(flatRegisters);
16925
17456
  },
16926
17457
  getPageDump(index) {
16927
17458
  // assembly/api-debugger/getPageDump(u32) => ~lib/typedarray/Uint8Array
16928
- return __liftTypedArray(Uint8Array, exports.getPageDump(index) >>> 0);
17459
+ return __liftTypedArray(Uint8Array, exports$1.getPageDump(index) >>> 0);
16929
17460
  },
16930
17461
  getMemory(address, length) {
16931
17462
  // assembly/api-debugger/getMemory(u32, u32) => ~lib/typedarray/Uint8Array | null
16932
- return __liftTypedArray(Uint8Array, exports.getMemory(address, length) >>> 0);
17463
+ return __liftTypedArray(Uint8Array, exports$1.getMemory(address, length) >>> 0);
16933
17464
  },
16934
17465
  setMemory(address, data) {
16935
17466
  // assembly/api-debugger/setMemory(u32, ~lib/typedarray/Uint8Array) => bool
16936
17467
  data = __lowerTypedArray(Uint8Array, 10, 0, data) || __notnull();
16937
- return exports.setMemory(address, data) != 0;
17468
+ return exports$1.setMemory(address, data) != 0;
16938
17469
  },
16939
17470
  InputKind: (values => (
16940
17471
  // assembly/api-utils/InputKind
16941
- values[values.Generic = exports["InputKind.Generic"].valueOf()] = "Generic",
16942
- values[values.SPI = exports["InputKind.SPI"].valueOf()] = "SPI",
17472
+ values[values.Generic = exports$1["InputKind.Generic"].valueOf()] = "Generic",
17473
+ values[values.SPI = exports$1["InputKind.SPI"].valueOf()] = "SPI",
16943
17474
  values
16944
17475
  ))({}),
16945
17476
  HasMetadata: (values => (
16946
17477
  // assembly/api-utils/HasMetadata
16947
- values[values.Yes = exports["HasMetadata.Yes"].valueOf()] = "Yes",
16948
- values[values.No = exports["HasMetadata.No"].valueOf()] = "No",
17478
+ values[values.Yes = exports$1["HasMetadata.Yes"].valueOf()] = "Yes",
17479
+ values[values.No = exports$1["HasMetadata.No"].valueOf()] = "No",
16949
17480
  values
16950
17481
  ))({}),
16951
17482
  getGasCosts(input, kind, withMetadata) {
16952
17483
  // assembly/api-utils/getGasCosts(~lib/array/Array<u8>, i32, i32) => ~lib/array/Array<assembly/gas-costs/BlockGasCost>
16953
17484
  input = __lowerArray(__setU8, 6, 0, input) || __notnull();
16954
- return __liftArray(pointer => __liftRecord50(__getU32(pointer)), 2, exports.getGasCosts(input, kind, withMetadata) >>> 0);
17485
+ return __liftArray(pointer => __liftRecord50(__getU32(pointer)), 2, exports$1.getGasCosts(input, kind, withMetadata) >>> 0);
16955
17486
  },
16956
17487
  disassemble(input, kind, withMetadata) {
16957
17488
  // assembly/api-utils/disassemble(~lib/array/Array<u8>, i32, i32) => ~lib/string/String
16958
17489
  input = __lowerArray(__setU8, 6, 0, input) || __notnull();
16959
- return __liftString(exports.disassemble(input, kind, withMetadata) >>> 0);
17490
+ return __liftString(exports$1.disassemble(input, kind, withMetadata) >>> 0);
16960
17491
  },
16961
17492
  prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) {
16962
17493
  // assembly/api-utils/prepareProgram(i32, i32, ~lib/array/Array<u8>, ~lib/array/Array<u64>, ~lib/array/Array<assembly/api-internal/InitialPage>, ~lib/array/Array<assembly/api-internal/InitialChunk>, ~lib/array/Array<u8>) => assembly/spi/StandardProgram
@@ -16966,7 +17497,7 @@ async function instantiate$1(module, imports = {}) {
16966
17497
  initialMemory = __retain(__lowerArray((pointer, value) => { __setU32(pointer, __lowerRecord48(value) || __notnull()); }, 49, 2, initialMemory) || __notnull());
16967
17498
  args = __lowerArray(__setU8, 6, 0, args) || __notnull();
16968
17499
  try {
16969
- return __liftInternref(exports.prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) >>> 0);
17500
+ return __liftInternref(exports$1.prepareProgram(kind, hasMetadata, program, initialRegisters, initialPageMap, initialMemory, args) >>> 0);
16970
17501
  } finally {
16971
17502
  __release(program);
16972
17503
  __release(initialRegisters);
@@ -16980,10 +17511,10 @@ async function instantiate$1(module, imports = {}) {
16980
17511
  initialGas = initialGas || 0n;
16981
17512
  logs = logs ? 1 : 0;
16982
17513
  useSbrkGas = useSbrkGas ? 1 : 0;
16983
- exports.__setArgumentsLength(arguments.length);
16984
- return __liftRecord55(exports.runProgram(program, initialGas, programCounter, logs, useSbrkGas) >>> 0);
17514
+ exports$1.__setArgumentsLength(arguments.length);
17515
+ return __liftRecord55(exports$1.runProgram(program, initialGas, programCounter, logs, useSbrkGas) >>> 0);
16985
17516
  },
16986
- }, exports);
17517
+ }, exports$1);
16987
17518
  function __liftRecord50(pointer) {
16988
17519
  // assembly/gas-costs/BlockGasCost
16989
17520
  // Hint: Opt-out from lifting as a record by providing an empty constructor
@@ -16997,21 +17528,21 @@ async function instantiate$1(module, imports = {}) {
16997
17528
  // assembly/api-internal/InitialPage
16998
17529
  // Hint: Opt-out from lowering as a record by providing an empty constructor
16999
17530
  if (value == null) return 0;
17000
- const pointer = exports.__pin(exports.__new(12, 46));
17531
+ const pointer = exports$1.__pin(exports$1.__new(12, 46));
17001
17532
  __setU32(pointer + 0, value.address);
17002
17533
  __setU32(pointer + 4, value.length);
17003
17534
  __setU32(pointer + 8, value.access);
17004
- exports.__unpin(pointer);
17535
+ exports$1.__unpin(pointer);
17005
17536
  return pointer;
17006
17537
  }
17007
17538
  function __lowerRecord48(value) {
17008
17539
  // assembly/api-internal/InitialChunk
17009
17540
  // Hint: Opt-out from lowering as a record by providing an empty constructor
17010
17541
  if (value == null) return 0;
17011
- const pointer = exports.__pin(exports.__new(8, 48));
17542
+ const pointer = exports$1.__pin(exports$1.__new(8, 48));
17012
17543
  __setU32(pointer + 0, value.address);
17013
17544
  __setU32(pointer + 4, __lowerArray(__setU8, 6, 0, value.data) || __notnull());
17014
- exports.__unpin(pointer);
17545
+ exports$1.__unpin(pointer);
17015
17546
  return pointer;
17016
17547
  }
17017
17548
  function __liftRecord48(pointer) {
@@ -17060,15 +17591,15 @@ async function instantiate$1(module, imports = {}) {
17060
17591
  if (values == null) return 0;
17061
17592
  const
17062
17593
  length = values.length,
17063
- buffer = exports.__pin(exports.__new(length << align, 1)) >>> 0,
17064
- header = exports.__pin(exports.__new(16, id)) >>> 0;
17594
+ buffer = exports$1.__pin(exports$1.__new(length << align, 1)) >>> 0,
17595
+ header = exports$1.__pin(exports$1.__new(16, id)) >>> 0;
17065
17596
  __setU32(header + 0, buffer);
17066
17597
  __dataview.setUint32(header + 4, buffer, true);
17067
17598
  __dataview.setUint32(header + 8, length << align, true);
17068
17599
  __dataview.setUint32(header + 12, length, true);
17069
17600
  for (let i = 0; i < length; ++i) lowerElement(buffer + (i << align >>> 0), values[i]);
17070
- exports.__unpin(buffer);
17071
- exports.__unpin(header);
17601
+ exports$1.__unpin(buffer);
17602
+ exports$1.__unpin(header);
17072
17603
  return header;
17073
17604
  }
17074
17605
  function __liftTypedArray(constructor, pointer) {
@@ -17083,13 +17614,13 @@ async function instantiate$1(module, imports = {}) {
17083
17614
  if (values == null) return 0;
17084
17615
  const
17085
17616
  length = values.length,
17086
- buffer = exports.__pin(exports.__new(length << align, 1)) >>> 0,
17087
- header = exports.__new(12, id) >>> 0;
17617
+ buffer = exports$1.__pin(exports$1.__new(length << align, 1)) >>> 0,
17618
+ header = exports$1.__new(12, id) >>> 0;
17088
17619
  __setU32(header + 0, buffer);
17089
17620
  __dataview.setUint32(header + 4, buffer, true);
17090
17621
  __dataview.setUint32(header + 8, length << align, true);
17091
17622
  new constructor(memory.buffer, buffer, length).set(values);
17092
- exports.__unpin(buffer);
17623
+ exports$1.__unpin(buffer);
17093
17624
  return header;
17094
17625
  }
17095
17626
  class Internref extends Number {}
@@ -17110,14 +17641,14 @@ async function instantiate$1(module, imports = {}) {
17110
17641
  if (pointer) {
17111
17642
  const refcount = refcounts.get(pointer);
17112
17643
  if (refcount) refcounts.set(pointer, refcount + 1);
17113
- else refcounts.set(exports.__pin(pointer), 1);
17644
+ else refcounts.set(exports$1.__pin(pointer), 1);
17114
17645
  }
17115
17646
  return pointer;
17116
17647
  }
17117
17648
  function __release(pointer) {
17118
17649
  if (pointer) {
17119
17650
  const refcount = refcounts.get(pointer);
17120
- if (refcount === 1) exports.__unpin(pointer), refcounts.delete(pointer);
17651
+ if (refcount === 1) exports$1.__unpin(pointer), refcounts.delete(pointer);
17121
17652
  else if (refcount) refcounts.set(pointer, refcount - 1);
17122
17653
  else throw Error(`invalid refcount '${refcount}' for reference '${pointer}'`);
17123
17654
  }
@@ -17396,7 +17927,7 @@ class InterpreterInstanceManager {
17396
17927
  }
17397
17928
  }
17398
17929
 
17399
- var index$7 = /*#__PURE__*/Object.freeze({
17930
+ var index$6 = /*#__PURE__*/Object.freeze({
17400
17931
  __proto__: null,
17401
17932
  HostCallMemory: HostCallMemory,
17402
17933
  HostCallRegisters: HostCallRegisters,
@@ -17489,7 +18020,7 @@ const codecServiceAccountInfoWithThresholdBalance = codec$1.object({
17489
18020
  parentService: codec$1.u32.convert((x) => x, tryAsServiceId),
17490
18021
  }, "ServiceAccountInfoWithThresholdBalance");
17491
18022
 
17492
- var index$6 = /*#__PURE__*/Object.freeze({
18023
+ var index$5 = /*#__PURE__*/Object.freeze({
17493
18024
  __proto__: null,
17494
18025
  AccumulationStateUpdate: AccumulationStateUpdate,
17495
18026
  CURRENT_SERVICE_ID: CURRENT_SERVICE_ID,
@@ -17644,154 +18175,9 @@ class Mountain {
17644
18175
  }
17645
18176
  }
17646
18177
 
17647
- var index$5 = /*#__PURE__*/Object.freeze({
17648
- __proto__: null,
17649
- MerkleMountainRange: MerkleMountainRange
17650
- });
17651
-
17652
- class DebuggerAdapter {
17653
- pvm;
17654
- constructor(useSbrkGas = false) {
17655
- this.pvm = new Interpreter({ useSbrkGas });
17656
- }
17657
- resetGeneric(rawProgram, flatRegisters, initialGas) {
17658
- this.pvm.resetGeneric(rawProgram, 0, tryAsGas(initialGas), new Registers(flatRegisters));
17659
- }
17660
- reset(rawProgram, pc, gas, maybeRegisters, maybeMemory) {
17661
- this.pvm.resetGeneric(rawProgram, pc, tryAsGas(gas), maybeRegisters, maybeMemory);
17662
- }
17663
- getPageDump(pageNumber) {
17664
- const page = this.pvm.getMemoryPage(pageNumber);
17665
- if (page === null) {
17666
- // page wasn't allocated so we return an empty page
17667
- return safeAllocUint8Array(PAGE_SIZE$1);
17668
- }
17669
- if (page.length === PAGE_SIZE$1) {
17670
- // page was allocated and has a proper size so we can simply return it
17671
- return page;
17672
- }
17673
- // page was allocated but it is shorter than PAGE_SIZE so we have to extend it
17674
- const fullPage = safeAllocUint8Array(PAGE_SIZE$1);
17675
- fullPage.set(page);
17676
- return fullPage;
17677
- }
17678
- setMemory(address, value) {
17679
- this.pvm.memory.storeFrom(tryAsMemoryIndex(address), value);
17680
- }
17681
- getExitArg() {
17682
- return this.pvm.getExitParam() ?? 0;
17683
- }
17684
- getStatus() {
17685
- return this.pvm.getStatus();
17686
- }
17687
- nextStep() {
17688
- return this.pvm.nextStep() === Status.OK;
17689
- }
17690
- nSteps(steps) {
17691
- check `${steps >>> 0 > 0} Expected a positive integer got ${steps}`;
17692
- for (let i = 0; i < steps; i++) {
17693
- const isOk = this.nextStep();
17694
- if (!isOk) {
17695
- return false;
17696
- }
17697
- }
17698
- return true;
17699
- }
17700
- getRegisters() {
17701
- return this.pvm.registers.getAllU64();
17702
- }
17703
- setRegisters(registers) {
17704
- this.pvm.registers.copyFrom(new Registers(registers));
17705
- }
17706
- getProgramCounter() {
17707
- return this.pvm.getPC();
17708
- }
17709
- setNextProgramCounter(nextPc) {
17710
- this.pvm.setNextPC(nextPc);
17711
- }
17712
- getGasLeft() {
17713
- return BigInt(this.pvm.gas.get());
17714
- }
17715
- setGasLeft(gas) {
17716
- this.pvm.gas.set(tryAsGas(gas));
17717
- }
17718
- }
17719
-
17720
18178
  var index$4 = /*#__PURE__*/Object.freeze({
17721
18179
  __proto__: null,
17722
- AccumulationStateUpdate: AccumulationStateUpdate,
17723
- ArgsDecoder: ArgsDecoder,
17724
- get ArgumentType () { return ArgumentType; },
17725
- BasicBlocks: BasicBlocks,
17726
- CURRENT_SERVICE_ID: CURRENT_SERVICE_ID,
17727
- get EjectError () { return EjectError; },
17728
- ExtendedWitdthImmediateDecoder: ExtendedWitdthImmediateDecoder,
17729
- get ForgetPreimageError () { return ForgetPreimageError; },
17730
- HostCallMemory: HostCallMemory,
17731
- HostCallRegisters: HostCallRegisters,
17732
- HostCallResult: HostCallResult,
17733
- ImmediateDecoder: ImmediateDecoder,
17734
- InsufficientFundsError: InsufficientFundsError,
17735
- MachineInstance: MachineInstance,
17736
- Mask: Mask,
17737
- get MemoryOperation () { return MemoryOperation; },
17738
- MemorySegment: MemorySegment,
17739
- NO_OF_REGISTERS: NO_OF_REGISTERS$1,
17740
- get NewServiceError () { return NewServiceError; },
17741
- NibblesDecoder: NibblesDecoder,
17742
- NoMachineError: NoMachineError,
17743
- OK: OK,
17744
- get PagesError () { return PagesError; },
17745
- PartiallyUpdatedState: PartiallyUpdatedState,
17746
- get PeekPokeError () { return PeekPokeError; },
17747
- PendingTransfer: PendingTransfer,
17748
- get PreimageStatusKind () { return PreimageStatusKind; },
17749
- Program: Program,
17750
- ProgramDecoder: ProgramDecoder,
17751
- get ProvidePreimageError () { return ProvidePreimageError; },
17752
- Pvm: DebuggerAdapter,
17753
- Registers: Registers,
17754
- get RequestPreimageError () { return RequestPreimageError; },
17755
- Result: Result$1,
17756
- SERVICE_ID_BYTES: SERVICE_ID_BYTES,
17757
- SegmentExportError: SegmentExportError,
17758
- SpiMemory: SpiMemory,
17759
- SpiProgram: SpiProgram,
17760
- TRANSFER_MEMO_BYTES: TRANSFER_MEMO_BYTES,
17761
- get TransferError () { return TransferError; },
17762
- UnprivilegedError: UnprivilegedError,
17763
- get UpdatePrivilegesError () { return UpdatePrivilegesError; },
17764
- WithDebug: WithDebug,
17765
- get ZeroVoidError () { return ZeroVoidError; },
17766
- asOpaqueType: asOpaqueType,
17767
- assertEmpty: assertEmpty,
17768
- assertNever: assertNever,
17769
- block: index$m,
17770
- bytes: index$t,
17771
- check: check,
17772
- clampU64ToU32: clampU64ToU32,
17773
- createResults: createResults,
17774
- decodeStandardProgram: decodeStandardProgram,
17775
- emptyRegistersBuffer: emptyRegistersBuffer,
17776
- extractCodeAndMetadata: extractCodeAndMetadata,
17777
- getServiceId: getServiceId,
17778
- getServiceIdOrCurrent: getServiceIdOrCurrent,
17779
- hash: index$p,
17780
- hostCallInfoAccount: codecServiceAccountInfoWithThresholdBalance,
17781
- inspect: inspect,
17782
- instructionArgumentTypeMap: instructionArgumentTypeMap,
17783
- interpreter: index$8,
17784
- isBrowser: isBrowser,
17785
- lazyInspect: lazyInspect,
17786
- measure: measure,
17787
- numbers: index$s,
17788
- resultToString: resultToString,
17789
- seeThrough: seeThrough,
17790
- slotsToPreimageStatus: slotsToPreimageStatus,
17791
- toMemoryOperation: toMemoryOperation,
17792
- tryAsMachineId: tryAsMachineId,
17793
- tryAsProgramCounter: tryAsProgramCounter,
17794
- writeServiceIdAsLeBytes: writeServiceIdAsLeBytes
18180
+ MerkleMountainRange: MerkleMountainRange
17795
18181
  });
17796
18182
 
17797
18183
  const ENTROPY_BYTES = 32;
@@ -18065,12 +18451,12 @@ class JsonCoreStatistics {
18065
18451
  extrinsic_count: "number",
18066
18452
  bundle_size: "number",
18067
18453
  gas_used: json.fromBigInt(tryAsServiceGas),
18068
- }, ({ da_load, popularity, imports, exports, extrinsic_size, extrinsic_count, bundle_size, gas_used }) => {
18454
+ }, ({ da_load, popularity, imports, exports: exports$1, extrinsic_size, extrinsic_count, bundle_size, gas_used }) => {
18069
18455
  return CoreStatistics.create({
18070
18456
  dataAvailabilityLoad: da_load,
18071
18457
  popularity,
18072
18458
  imports,
18073
- exports,
18459
+ exports: exports$1,
18074
18460
  extrinsicSize: extrinsic_size,
18075
18461
  extrinsicCount: extrinsic_count,
18076
18462
  bundleSize: bundle_size,
@@ -18104,14 +18490,14 @@ class JsonServiceStatistics {
18104
18490
  on_transfers_gas_used: json.fromBigInt(tryAsServiceGas),
18105
18491
  }
18106
18492
  : {}),
18107
- }, ({ provided_count, provided_size, refinement_count, refinement_gas_used, imports, exports, extrinsic_size, extrinsic_count, accumulate_count, accumulate_gas_used, on_transfers_count, on_transfers_gas_used, }) => {
18493
+ }, ({ provided_count, provided_size, refinement_count, refinement_gas_used, imports, exports: exports$1, extrinsic_size, extrinsic_count, accumulate_count, accumulate_gas_used, on_transfers_count, on_transfers_gas_used, }) => {
18108
18494
  return ServiceStatistics.create({
18109
18495
  providedCount: provided_count,
18110
18496
  providedSize: provided_size,
18111
18497
  refinementCount: refinement_count,
18112
18498
  refinementGasUsed: refinement_gas_used,
18113
18499
  imports,
18114
- exports,
18500
+ exports: exports$1,
18115
18501
  extrinsicSize: extrinsic_size,
18116
18502
  extrinsicCount: extrinsic_count,
18117
18503
  accumulateCount: accumulate_count,
@@ -18319,11 +18705,9 @@ var index$1 = /*#__PURE__*/Object.freeze({
18319
18705
 
18320
18706
  /** Helper function to create most used hashes in the block */
18321
18707
  class TransitionHasher {
18322
- context;
18323
18708
  keccakHasher;
18324
18709
  blake2b;
18325
- constructor(context, keccakHasher, blake2b) {
18326
- this.context = context;
18710
+ constructor(keccakHasher, blake2b) {
18327
18711
  this.keccakHasher = keccakHasher;
18328
18712
  this.blake2b = blake2b;
18329
18713
  }
@@ -18435,34 +18819,33 @@ var index = /*#__PURE__*/Object.freeze({
18435
18819
  TransitionHasher: TransitionHasher
18436
18820
  });
18437
18821
 
18438
- exports.block = index$m;
18439
- exports.block_json = index$k;
18440
- exports.bytes = index$t;
18441
- exports.codec = index$r;
18442
- exports.collections = index$o;
18443
- exports.config = index$n;
18444
- exports.config_node = index$i;
18445
- exports.crypto = index$q;
18446
- exports.database = index$e;
18447
- exports.erasure_coding = index$d;
18448
- exports.fuzz_proto = index$b;
18449
- exports.hash = index$p;
18450
- exports.jam_host_calls = index$6;
18451
- exports.json_parser = index$l;
18452
- exports.logger = index$j;
18453
- exports.mmr = index$5;
18454
- exports.numbers = index$s;
18455
- exports.ordering = index$u;
18456
- exports.pvm = index$4;
18457
- exports.pvm_host_calls = index$7;
18458
- exports.pvm_interpreter = index$8;
18459
- exports.pvm_program = index$9;
18460
- exports.pvm_spi_decoder = index$a;
18822
+ exports.block = index$l;
18823
+ exports.block_json = index$j;
18824
+ exports.bytes = index$s;
18825
+ exports.codec = index$q;
18826
+ exports.collections = index$n;
18827
+ exports.config = index$m;
18828
+ exports.config_node = index$h;
18829
+ exports.crypto = index$p;
18830
+ exports.database = index$d;
18831
+ exports.erasure_coding = index$c;
18832
+ exports.fuzz_proto = index$a;
18833
+ exports.hash = index$o;
18834
+ exports.jam_host_calls = index$5;
18835
+ exports.json_parser = index$k;
18836
+ exports.logger = index$i;
18837
+ exports.mmr = index$4;
18838
+ exports.numbers = index$r;
18839
+ exports.ordering = index$t;
18840
+ exports.pvm = index$7;
18841
+ exports.pvm_host_calls = index$6;
18842
+ exports.pvm_program = index$8;
18843
+ exports.pvm_spi_decoder = index$9;
18461
18844
  exports.shuffling = index$3;
18462
- exports.state = index$h;
18845
+ exports.state = index$g;
18463
18846
  exports.state_json = index$2;
18464
- exports.state_merkleization = index$f;
18847
+ exports.state_merkleization = index$e;
18465
18848
  exports.state_vectors = index$1;
18466
18849
  exports.transition = index;
18467
- exports.trie = index$g;
18468
- exports.utils = index$v;
18850
+ exports.trie = index$f;
18851
+ exports.utils = index$u;