@typeberry/lib 0.4.0-fcdfbb1 → 0.4.1-dae2283

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 +200 -254
  2. package/index.d.ts +910 -1369
  3. package/index.js +175 -228
  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,
@@ -5008,7 +5012,7 @@ class TruncatedHashDictionary {
5008
5012
  }
5009
5013
  }
5010
5014
 
5011
- var index$o = /*#__PURE__*/Object.freeze({
5015
+ var index$n = /*#__PURE__*/Object.freeze({
5012
5016
  __proto__: null,
5013
5017
  ArrayView: ArrayView,
5014
5018
  FixedSizeArray: FixedSizeArray,
@@ -5195,7 +5199,7 @@ var PvmBackend;
5195
5199
  PvmBackend[PvmBackend["Ananas"] = 1] = "Ananas";
5196
5200
  })(PvmBackend || (PvmBackend = {}));
5197
5201
 
5198
- var index$n = /*#__PURE__*/Object.freeze({
5202
+ var index$m = /*#__PURE__*/Object.freeze({
5199
5203
  __proto__: null,
5200
5204
  Bootnode: Bootnode,
5201
5205
  ChainSpec: ChainSpec,
@@ -6702,7 +6706,7 @@ function reencodeAsView(codec, object, chainSpec) {
6702
6706
  return Decoder.decodeObject(codec.View, encoded, chainSpec);
6703
6707
  }
6704
6708
 
6705
- var index$m = /*#__PURE__*/Object.freeze({
6709
+ var index$l = /*#__PURE__*/Object.freeze({
6706
6710
  __proto__: null,
6707
6711
  Block: Block,
6708
6712
  EpochMarker: EpochMarker,
@@ -6712,6 +6716,8 @@ var index$m = /*#__PURE__*/Object.freeze({
6712
6716
  SEGMENT_BYTES: SEGMENT_BYTES,
6713
6717
  TicketsMarker: TicketsMarker,
6714
6718
  ValidatorKeys: ValidatorKeys,
6719
+ W_E: W_E,
6720
+ W_S: W_S,
6715
6721
  assurances: assurances,
6716
6722
  codecPerEpochBlock: codecPerEpochBlock,
6717
6723
  codecPerValidator: codecPerValidator,
@@ -6972,7 +6978,7 @@ var json;
6972
6978
  json.object = object;
6973
6979
  })(json || (json = {}));
6974
6980
 
6975
- var index$l = /*#__PURE__*/Object.freeze({
6981
+ var index$k = /*#__PURE__*/Object.freeze({
6976
6982
  __proto__: null,
6977
6983
  get json () { return json; },
6978
6984
  parseFromJson: parseFromJson
@@ -7242,7 +7248,7 @@ const blockFromJson = (spec) => json.object({
7242
7248
  extrinsic: getExtrinsicFromJson(spec),
7243
7249
  }, ({ header, extrinsic }) => Block.create({ header, extrinsic }));
7244
7250
 
7245
- var index$k = /*#__PURE__*/Object.freeze({
7251
+ var index$j = /*#__PURE__*/Object.freeze({
7246
7252
  __proto__: null,
7247
7253
  blockFromJson: blockFromJson,
7248
7254
  disputesExtrinsicFromJson: disputesExtrinsicFromJson,
@@ -7736,7 +7742,7 @@ class Logger {
7736
7742
  }
7737
7743
  }
7738
7744
 
7739
- var index$j = /*#__PURE__*/Object.freeze({
7745
+ var index$i = /*#__PURE__*/Object.freeze({
7740
7746
  __proto__: null,
7741
7747
  get Level () { return Level; },
7742
7748
  Logger: Logger,
@@ -7951,7 +7957,7 @@ function isJsonObject(value) {
7951
7957
  return typeof value === "object" && value !== null && !Array.isArray(value);
7952
7958
  }
7953
7959
 
7954
- var index$i = /*#__PURE__*/Object.freeze({
7960
+ var index$h = /*#__PURE__*/Object.freeze({
7955
7961
  __proto__: null,
7956
7962
  DEFAULT_CONFIG: DEFAULT_CONFIG,
7957
7963
  DEV_CONFIG: DEV_CONFIG,
@@ -9160,11 +9166,32 @@ const ENTROPY_ENTRIES = 4;
9160
9166
 
9161
9167
  var UpdatePreimageKind;
9162
9168
  (function (UpdatePreimageKind) {
9163
- /** Insert new preimage and optionally update it's lookup history. */
9169
+ /**
9170
+ * Insert new preimage and optionally update it's lookup history.
9171
+ *
9172
+ * Used in: `provide`
9173
+ *
9174
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/383904383904?v=0.7.2
9175
+ */
9164
9176
  UpdatePreimageKind[UpdatePreimageKind["Provide"] = 0] = "Provide";
9165
- /** Remove a preimage and it's lookup history. */
9177
+ /**
9178
+ * Remove a preimage and it's lookup history.
9179
+ *
9180
+ * Used in: `forget` and `eject`
9181
+ *
9182
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/38c701380202?v=0.7.2
9183
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/379102379302?v=0.7.2
9184
+ */
9166
9185
  UpdatePreimageKind[UpdatePreimageKind["Remove"] = 1] = "Remove";
9167
- /** update or add lookup history for preimage hash/len to given value. */
9186
+ /**
9187
+ * Update or add lookup history for preimage hash/len to given value.
9188
+ *
9189
+ * Used in: `solicit` and `forget`
9190
+ *
9191
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/382802382802?v=0.7.2
9192
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/384002384b02?v=0.7.2
9193
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/38c60038ea00?v=0.7.2
9194
+ */
9168
9195
  UpdatePreimageKind[UpdatePreimageKind["UpdateOrAdd"] = 2] = "UpdateOrAdd";
9169
9196
  })(UpdatePreimageKind || (UpdatePreimageKind = {}));
9170
9197
  /**
@@ -9172,7 +9199,7 @@ var UpdatePreimageKind;
9172
9199
  *
9173
9200
  * Can be one of the following cases:
9174
9201
  * 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.
9202
+ * 2. Remove (forget) a preimage and it's lookup history.
9176
9203
  * 3. Update `LookupHistory` with given value.
9177
9204
  */
9178
9205
  class UpdatePreimage {
@@ -9745,7 +9772,7 @@ const serviceDataCodec = codec$1.dictionary(codec$1.u32.asOpaque(), serviceEntri
9745
9772
  sortKeys: (a, b) => a - b,
9746
9773
  });
9747
9774
 
9748
- var index$h = /*#__PURE__*/Object.freeze({
9775
+ var index$g = /*#__PURE__*/Object.freeze({
9749
9776
  __proto__: null,
9750
9777
  AUTHORIZATION_QUEUE_SIZE: AUTHORIZATION_QUEUE_SIZE,
9751
9778
  AccumulationOutput: AccumulationOutput,
@@ -10376,7 +10403,6 @@ class LeafNode {
10376
10403
  /**
10377
10404
  * Get the byte length of embedded value.
10378
10405
  *
10379
- * @remark
10380
10406
  * Note in case this node only contains hash this is going to be 0.
10381
10407
  */
10382
10408
  getValueLength() {
@@ -10387,7 +10413,6 @@ class LeafNode {
10387
10413
  /**
10388
10414
  * Returns the embedded value.
10389
10415
  *
10390
- * @remark
10391
10416
  * Note that this is going to be empty for a regular leaf node (i.e. containing a hash).
10392
10417
  */
10393
10418
  getValue() {
@@ -10397,7 +10422,6 @@ class LeafNode {
10397
10422
  /**
10398
10423
  * Returns contained value hash.
10399
10424
  *
10400
- * @remark
10401
10425
  * Note that for embedded value this is going to be full 0-padded 32 bytes.
10402
10426
  */
10403
10427
  getValueHash() {
@@ -10819,7 +10843,7 @@ const bitLookup = [
10819
10843
  [0b00000000, 8],
10820
10844
  ];
10821
10845
 
10822
- var index$g = /*#__PURE__*/Object.freeze({
10846
+ var index$f = /*#__PURE__*/Object.freeze({
10823
10847
  __proto__: null,
10824
10848
  BranchNode: BranchNode,
10825
10849
  InMemoryTrie: InMemoryTrie,
@@ -11186,7 +11210,7 @@ function loadState(spec, blake2b, entries) {
11186
11210
  * hashmap of `key -> value` entries.
11187
11211
  */
11188
11212
 
11189
- var index$f = /*#__PURE__*/Object.freeze({
11213
+ var index$e = /*#__PURE__*/Object.freeze({
11190
11214
  __proto__: null,
11191
11215
  SerializedService: SerializedService,
11192
11216
  SerializedState: SerializedState,
@@ -11435,7 +11459,7 @@ class InMemoryStates {
11435
11459
  async close() { }
11436
11460
  }
11437
11461
 
11438
- var index$e = /*#__PURE__*/Object.freeze({
11462
+ var index$d = /*#__PURE__*/Object.freeze({
11439
11463
  __proto__: null,
11440
11464
  InMemoryBlocks: InMemoryBlocks,
11441
11465
  InMemorySerializedStates: InMemorySerializedStates,
@@ -11799,7 +11823,7 @@ const initEc = async () => {
11799
11823
  await init.reedSolomon();
11800
11824
  };
11801
11825
 
11802
- var index$d = /*#__PURE__*/Object.freeze({
11826
+ var index$c = /*#__PURE__*/Object.freeze({
11803
11827
  __proto__: null,
11804
11828
  N_CHUNKS_REDUNDANCY: N_CHUNKS_REDUNDANCY,
11805
11829
  N_CHUNKS_REQUIRED: N_CHUNKS_REQUIRED,
@@ -12233,7 +12257,7 @@ class FuzzTarget {
12233
12257
  }
12234
12258
  }
12235
12259
 
12236
- var index$c = /*#__PURE__*/Object.freeze({
12260
+ var index$b = /*#__PURE__*/Object.freeze({
12237
12261
  __proto__: null,
12238
12262
  AncestryItem: AncestryItem,
12239
12263
  ErrorMessage: ErrorMessage,
@@ -12251,9 +12275,9 @@ var index$c = /*#__PURE__*/Object.freeze({
12251
12275
  stateRootCodec: stateRootCodec
12252
12276
  });
12253
12277
 
12254
- var index$b = /*#__PURE__*/Object.freeze({
12278
+ var index$a = /*#__PURE__*/Object.freeze({
12255
12279
  __proto__: null,
12256
- v1: index$c
12280
+ v1: index$b
12257
12281
  });
12258
12282
 
12259
12283
  /** Size of the transfer memo. */
@@ -12682,7 +12706,11 @@ class PartiallyUpdatedState {
12682
12706
  const service = this.state.getService(serviceId);
12683
12707
  return service?.getPreimage(hash) ?? null;
12684
12708
  }
12685
- /** Get status of a preimage of current service taking into account any updates. */
12709
+ /**
12710
+ * Get status of a preimage of current service taking into account any updates.
12711
+ *
12712
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/110201110201?v=0.7.2
12713
+ */
12686
12714
  getLookupHistory(currentTimeslot, serviceId, hash, length) {
12687
12715
  const updatedService = this.stateUpdate.services.updated.get(serviceId);
12688
12716
  /** Return lookup history item for newly created service */
@@ -12719,12 +12747,7 @@ class PartiallyUpdatedState {
12719
12747
  return new LookupHistoryItem(hash, updatedPreimage.length, tryAsLookupHistorySlots([currentTimeslot]));
12720
12748
  }
12721
12749
  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]));
12750
+ return null;
12728
12751
  }
12729
12752
  case UpdatePreimageKind.UpdateOrAdd: {
12730
12753
  return action.item;
@@ -13116,42 +13139,6 @@ class HostCallsManager {
13116
13139
  }
13117
13140
  }
13118
13141
 
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
13142
  const tryAsMemoryIndex = (index) => {
13156
13143
  check `${index >= 0 && index <= MAX_MEMORY_INDEX} Incorrect memory index: ${index}!`;
13157
13144
  return asOpaqueType(index);
@@ -13874,7 +13861,7 @@ function getRegisters(argsLength) {
13874
13861
  return regs;
13875
13862
  }
13876
13863
 
13877
- var index$a = /*#__PURE__*/Object.freeze({
13864
+ var index$9 = /*#__PURE__*/Object.freeze({
13878
13865
  __proto__: null,
13879
13866
  MemorySegment: MemorySegment,
13880
13867
  SpiMemory: SpiMemory,
@@ -13933,7 +13920,7 @@ function extractCodeAndMetadata(blobWithMetadata) {
13933
13920
  return { metadata, code };
13934
13921
  }
13935
13922
 
13936
- var index$9 = /*#__PURE__*/Object.freeze({
13923
+ var index$8 = /*#__PURE__*/Object.freeze({
13937
13924
  __proto__: null,
13938
13925
  Program: Program,
13939
13926
  extractCodeAndMetadata: extractCodeAndMetadata
@@ -14897,6 +14884,42 @@ class BasicBlocks {
14897
14884
  }
14898
14885
  }
14899
14886
 
14887
+ /** Create a new gas counter instance depending on the gas value. */
14888
+ function gasCounter(gas) {
14889
+ return new GasCounterU64(tryAsU64(gas));
14890
+ }
14891
+ class GasCounterU64 {
14892
+ gas;
14893
+ initialGas;
14894
+ constructor(gas) {
14895
+ this.gas = gas;
14896
+ this.initialGas = tryAsGas(gas);
14897
+ }
14898
+ set(g) {
14899
+ this.gas = tryAsU64(g);
14900
+ }
14901
+ get() {
14902
+ return tryAsGas(this.gas);
14903
+ }
14904
+ sub(g) {
14905
+ const result = this.gas - tryAsU64(g);
14906
+ if (result >= 0n) {
14907
+ this.gas = tryAsU64(result);
14908
+ return false;
14909
+ }
14910
+ this.gas = tryAsU64(0n);
14911
+ return true;
14912
+ }
14913
+ used() {
14914
+ const gasConsumed = tryAsU64(this.initialGas) - this.gas;
14915
+ // In we have less than zero left we assume that all gas has been consumed.
14916
+ if (gasConsumed < 0) {
14917
+ return this.initialGas;
14918
+ }
14919
+ return tryAsGas(gasConsumed);
14920
+ }
14921
+ }
14922
+
14900
14923
  const instructionGasMap = (() => {
14901
14924
  const instructionGasMap = new Array(HIGHEST_INSTRUCTION_NUMBER + 1);
14902
14925
  for (let i = 0; i < HIGHEST_INSTRUCTION_NUMBER + 1; i++) {
@@ -16805,8 +16828,77 @@ class Interpreter {
16805
16828
  }
16806
16829
  }
16807
16830
 
16808
- var index$8 = /*#__PURE__*/Object.freeze({
16831
+ class DebuggerAdapter {
16832
+ pvm;
16833
+ constructor(useSbrkGas = false) {
16834
+ this.pvm = new Interpreter({ useSbrkGas });
16835
+ }
16836
+ resetGeneric(rawProgram, flatRegisters, initialGas) {
16837
+ this.pvm.resetGeneric(rawProgram, 0, tryAsGas(initialGas), new Registers(flatRegisters));
16838
+ }
16839
+ reset(rawProgram, pc, gas, maybeRegisters, maybeMemory) {
16840
+ this.pvm.resetGeneric(rawProgram, pc, tryAsGas(gas), maybeRegisters, maybeMemory);
16841
+ }
16842
+ getPageDump(pageNumber) {
16843
+ const page = this.pvm.getMemoryPage(pageNumber);
16844
+ if (page === null) {
16845
+ // page wasn't allocated so we return an empty page
16846
+ return safeAllocUint8Array(PAGE_SIZE$1);
16847
+ }
16848
+ if (page.length === PAGE_SIZE$1) {
16849
+ // page was allocated and has a proper size so we can simply return it
16850
+ return page;
16851
+ }
16852
+ // page was allocated but it is shorter than PAGE_SIZE so we have to extend it
16853
+ const fullPage = safeAllocUint8Array(PAGE_SIZE$1);
16854
+ fullPage.set(page);
16855
+ return fullPage;
16856
+ }
16857
+ setMemory(address, value) {
16858
+ this.pvm.memory.storeFrom(tryAsMemoryIndex(address), value);
16859
+ }
16860
+ getExitArg() {
16861
+ return this.pvm.getExitParam() ?? 0;
16862
+ }
16863
+ getStatus() {
16864
+ return this.pvm.getStatus();
16865
+ }
16866
+ nextStep() {
16867
+ return this.pvm.nextStep() === Status.OK;
16868
+ }
16869
+ nSteps(steps) {
16870
+ check `${steps >>> 0 > 0} Expected a positive integer got ${steps}`;
16871
+ for (let i = 0; i < steps; i++) {
16872
+ const isOk = this.nextStep();
16873
+ if (!isOk) {
16874
+ return false;
16875
+ }
16876
+ }
16877
+ return true;
16878
+ }
16879
+ getRegisters() {
16880
+ return this.pvm.registers.getAllU64();
16881
+ }
16882
+ setRegisters(registers) {
16883
+ this.pvm.registers.copyFrom(new Registers(registers));
16884
+ }
16885
+ getProgramCounter() {
16886
+ return this.pvm.getPC();
16887
+ }
16888
+ setNextProgramCounter(nextPc) {
16889
+ this.pvm.setNextPC(nextPc);
16890
+ }
16891
+ getGasLeft() {
16892
+ return BigInt(this.pvm.gas.get());
16893
+ }
16894
+ setGasLeft(gas) {
16895
+ this.pvm.gas.set(tryAsGas(gas));
16896
+ }
16897
+ }
16898
+
16899
+ var index$7 = /*#__PURE__*/Object.freeze({
16809
16900
  __proto__: null,
16901
+ DebuggerAdapter: DebuggerAdapter,
16810
16902
  Interpreter: Interpreter,
16811
16903
  Memory: Memory,
16812
16904
  MemoryBuilder: MemoryBuilder,
@@ -17396,7 +17488,7 @@ class InterpreterInstanceManager {
17396
17488
  }
17397
17489
  }
17398
17490
 
17399
- var index$7 = /*#__PURE__*/Object.freeze({
17491
+ var index$6 = /*#__PURE__*/Object.freeze({
17400
17492
  __proto__: null,
17401
17493
  HostCallMemory: HostCallMemory,
17402
17494
  HostCallRegisters: HostCallRegisters,
@@ -17489,7 +17581,7 @@ const codecServiceAccountInfoWithThresholdBalance = codec$1.object({
17489
17581
  parentService: codec$1.u32.convert((x) => x, tryAsServiceId),
17490
17582
  }, "ServiceAccountInfoWithThresholdBalance");
17491
17583
 
17492
- var index$6 = /*#__PURE__*/Object.freeze({
17584
+ var index$5 = /*#__PURE__*/Object.freeze({
17493
17585
  __proto__: null,
17494
17586
  AccumulationStateUpdate: AccumulationStateUpdate,
17495
17587
  CURRENT_SERVICE_ID: CURRENT_SERVICE_ID,
@@ -17644,154 +17736,9 @@ class Mountain {
17644
17736
  }
17645
17737
  }
17646
17738
 
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
17739
  var index$4 = /*#__PURE__*/Object.freeze({
17721
17740
  __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
17741
+ MerkleMountainRange: MerkleMountainRange
17795
17742
  });
17796
17743
 
17797
17744
  const ENTROPY_BYTES = 32;
@@ -18433,34 +18380,33 @@ var index = /*#__PURE__*/Object.freeze({
18433
18380
  TransitionHasher: TransitionHasher
18434
18381
  });
18435
18382
 
18436
- exports.block = index$m;
18437
- exports.block_json = index$k;
18438
- exports.bytes = index$t;
18439
- exports.codec = index$r;
18440
- exports.collections = index$o;
18441
- exports.config = index$n;
18442
- exports.config_node = index$i;
18443
- exports.crypto = index$q;
18444
- exports.database = index$e;
18445
- exports.erasure_coding = index$d;
18446
- exports.fuzz_proto = index$b;
18447
- exports.hash = index$p;
18448
- exports.jam_host_calls = index$6;
18449
- exports.json_parser = index$l;
18450
- exports.logger = index$j;
18451
- exports.mmr = index$5;
18452
- exports.numbers = index$s;
18453
- exports.ordering = index$u;
18454
- exports.pvm = index$4;
18455
- exports.pvm_host_calls = index$7;
18456
- exports.pvm_interpreter = index$8;
18457
- exports.pvm_program = index$9;
18458
- exports.pvm_spi_decoder = index$a;
18383
+ exports.block = index$l;
18384
+ exports.block_json = index$j;
18385
+ exports.bytes = index$s;
18386
+ exports.codec = index$q;
18387
+ exports.collections = index$n;
18388
+ exports.config = index$m;
18389
+ exports.config_node = index$h;
18390
+ exports.crypto = index$p;
18391
+ exports.database = index$d;
18392
+ exports.erasure_coding = index$c;
18393
+ exports.fuzz_proto = index$a;
18394
+ exports.hash = index$o;
18395
+ exports.jam_host_calls = index$5;
18396
+ exports.json_parser = index$k;
18397
+ exports.logger = index$i;
18398
+ exports.mmr = index$4;
18399
+ exports.numbers = index$r;
18400
+ exports.ordering = index$t;
18401
+ exports.pvm = index$7;
18402
+ exports.pvm_host_calls = index$6;
18403
+ exports.pvm_program = index$8;
18404
+ exports.pvm_spi_decoder = index$9;
18459
18405
  exports.shuffling = index$3;
18460
- exports.state = index$h;
18406
+ exports.state = index$g;
18461
18407
  exports.state_json = index$2;
18462
- exports.state_merkleization = index$f;
18408
+ exports.state_merkleization = index$e;
18463
18409
  exports.state_vectors = index$1;
18464
18410
  exports.transition = index;
18465
- exports.trie = index$g;
18466
- exports.utils = index$v;
18411
+ exports.trie = index$f;
18412
+ exports.utils = index$u;