@typeberry/jam 0.1.2-ef67dce → 0.1.3-135961b

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.
@@ -5500,13 +5500,15 @@ function validateLength(range, length, context) {
5500
5500
 
5501
5501
  /** A caching wrapper for either object or sequence item. */
5502
5502
  class ViewField {
5503
+ name;
5503
5504
  getView;
5504
5505
  getValue;
5505
5506
  getEncoded;
5506
5507
  cachedValue;
5507
5508
  cachedView;
5508
5509
  cachedBlob;
5509
- constructor(getView, getValue, getEncoded) {
5510
+ constructor(name, getView, getValue, getEncoded) {
5511
+ this.name = name;
5510
5512
  this.getView = getView;
5511
5513
  this.getValue = getValue;
5512
5514
  this.getEncoded = getEncoded;
@@ -5532,6 +5534,9 @@ class ViewField {
5532
5534
  }
5533
5535
  return this.cachedBlob;
5534
5536
  }
5537
+ toString() {
5538
+ return `ViewField<${this.name}>`;
5539
+ }
5535
5540
  }
5536
5541
  /**
5537
5542
  * A base class for all the lazy views.
@@ -5606,7 +5611,7 @@ class ObjectView {
5606
5611
  const fieldDecoder = skipper.decoder.clone();
5607
5612
  const field = this.descriptorsKeys[i];
5608
5613
  const type = this.descriptors[field];
5609
- lastItem = new ViewField(() => type.View.decode(fieldDecoder.clone()), () => type.decode(fieldDecoder.clone()), () => type.skipEncoded(fieldDecoder.clone()));
5614
+ lastItem = new ViewField(`${this.toString()}.${String(field)}`, () => type.View.decode(fieldDecoder.clone()), () => type.decode(fieldDecoder.clone()), () => type.skipEncoded(fieldDecoder.clone()));
5610
5615
  // skip the field
5611
5616
  type.skip(skipper);
5612
5617
  // cache data
@@ -5618,6 +5623,9 @@ class ObjectView {
5618
5623
  }
5619
5624
  return lastItem;
5620
5625
  }
5626
+ toString() {
5627
+ return `View<${this.materializedConstructor.name}>(cache: ${this.cache.size})`;
5628
+ }
5621
5629
  }
5622
5630
  /**
5623
5631
  * A lazy-evaluated decoder of a sequence.
@@ -5706,7 +5714,7 @@ class SequenceView {
5706
5714
  // create new cached prop
5707
5715
  const fieldDecoder = skipper.decoder.clone();
5708
5716
  const type = this.descriptor;
5709
- lastItem = new ViewField(() => type.View.decode(fieldDecoder.clone()), () => type.decode(fieldDecoder.clone()), () => type.skipEncoded(fieldDecoder.clone()));
5717
+ lastItem = new ViewField(`${this.toString()}[${index}]`, () => type.View.decode(fieldDecoder.clone()), () => type.decode(fieldDecoder.clone()), () => type.skipEncoded(fieldDecoder.clone()));
5710
5718
  // skip the field
5711
5719
  type.skip(skipper);
5712
5720
  // cache data
@@ -5718,6 +5726,9 @@ class SequenceView {
5718
5726
  }
5719
5727
  return lastItem;
5720
5728
  }
5729
+ toString() {
5730
+ return `SequenceView<${this.descriptor.name}>(cache: ${this.cache.size})`;
5731
+ }
5721
5732
  }
5722
5733
 
5723
5734
  ;// CONCATENATED MODULE: ./packages/core/codec/descriptors.ts
@@ -9770,6 +9781,10 @@ class DisputesRecords {
9770
9781
  static create({ goodSet, badSet, wonkySet, punishSet }) {
9771
9782
  return new DisputesRecords(goodSet, badSet, wonkySet, punishSet);
9772
9783
  }
9784
+ goodSetDict;
9785
+ badSetDict;
9786
+ wonkySetDict;
9787
+ punishSetDict;
9773
9788
  constructor(
9774
9789
  /** `goodSet`: all work-reports hashes which were judged to be correct */
9775
9790
  goodSet,
@@ -9783,6 +9798,18 @@ class DisputesRecords {
9783
9798
  this.badSet = badSet;
9784
9799
  this.wonkySet = wonkySet;
9785
9800
  this.punishSet = punishSet;
9801
+ this.goodSetDict = HashSet.from(goodSet.array);
9802
+ this.badSetDict = HashSet.from(badSet.array);
9803
+ this.wonkySetDict = HashSet.from(wonkySet.array);
9804
+ this.punishSetDict = HashSet.from(punishSet.array);
9805
+ }
9806
+ asDictionaries() {
9807
+ return {
9808
+ goodSet: this.goodSetDict,
9809
+ badSet: this.badSetDict,
9810
+ wonkySet: this.wonkySetDict,
9811
+ punishSet: this.punishSetDict,
9812
+ };
9786
9813
  }
9787
9814
  static fromSortedArrays({ goodSet, badSet, wonkySet, punishSet, }) {
9788
9815
  return new DisputesRecords(SortedSet.fromSortedArray(hashComparator, goodSet), SortedSet.fromSortedArray(hashComparator, badSet), SortedSet.fromSortedArray(hashComparator, wonkySet), SortedSet.fromSortedArray(hashComparator, punishSet));
@@ -14274,10 +14301,16 @@ function registers_signExtend32To64(value) {
14274
14301
 
14275
14302
  /** Attempt to convert a number into `HostCallIndex`. */
14276
14303
  const host_call_handler_tryAsHostCallIndex = (v) => asOpaqueType(tryAsU32(v));
14304
+ /**
14305
+ * Host-call exit reason.
14306
+ *
14307
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/24a30124a501?v=0.7.2
14308
+ */
14277
14309
  var host_call_handler_PvmExecution;
14278
14310
  (function (PvmExecution) {
14279
14311
  PvmExecution[PvmExecution["Halt"] = 0] = "Halt";
14280
14312
  PvmExecution[PvmExecution["Panic"] = 1] = "Panic";
14313
+ PvmExecution[PvmExecution["OOG"] = 2] = "OOG";
14281
14314
  })(host_call_handler_PvmExecution || (host_call_handler_PvmExecution = {}));
14282
14315
  /** A utility function to easily trace a bunch of registers. */
14283
14316
  function host_call_handler_traceRegisters(...regs) {
@@ -17894,8 +17927,9 @@ class HostCalls {
17894
17927
  const index = tryAsHostCallIndex(hostCallIndex);
17895
17928
  const hostCall = this.hostCalls.get(index);
17896
17929
  const gasBefore = gas.get();
17897
- const gasCost = typeof hostCall.gasCost === "number" ? hostCall.gasCost : hostCall.gasCost(regs);
17898
- const underflow = gas.sub(gasCost);
17930
+ // NOTE: `basicGasCost(regs)` function is for compatibility reasons: pre GP 0.7.2
17931
+ const basicGasCost = typeof hostCall.basicGasCost === "number" ? hostCall.basicGasCost : hostCall.basicGasCost(regs);
17932
+ const underflow = gas.sub(basicGasCost);
17899
17933
  const pcLog = `[PC: ${pvmInstance.getPC()}]`;
17900
17934
  if (underflow) {
17901
17935
  this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
@@ -17912,6 +17946,10 @@ class HostCalls {
17912
17946
  status = Status.PANIC;
17913
17947
  return this.getReturnValue(status, pvmInstance);
17914
17948
  }
17949
+ if (result === PvmExecution.OOG) {
17950
+ status = Status.OOG;
17951
+ return this.getReturnValue(status, pvmInstance);
17952
+ }
17915
17953
  if (result === undefined) {
17916
17954
  pvmInstance.runProgram();
17917
17955
  status = pvmInstance.getStatus();
@@ -17970,7 +18008,7 @@ class host_calls_manager_HostCallsManager {
17970
18008
  }
17971
18009
  class NoopMissing {
17972
18010
  index = tryAsHostCallIndex(2 ** 32 - 1);
17973
- gasCost = tryAsSmallGas(0);
18011
+ basicGasCost = tryAsSmallGas(0);
17974
18012
  currentServiceId = tryAsU32(0);
17975
18013
  tracedRegisters = [];
17976
18014
  async execute() {
@@ -18084,7 +18122,7 @@ function clampU64ToU32(value) {
18084
18122
 
18085
18123
  class missing_Missing {
18086
18124
  index = tryAsHostCallIndex(2 ** 32 - 1);
18087
- gasCost = tryAsSmallGas(10);
18125
+ basicGasCost = tryAsSmallGas(10);
18088
18126
  currentServiceId = CURRENT_SERVICE_ID;
18089
18127
  tracedRegisters = traceRegisters(7);
18090
18128
  execute(_gas, regs, _memory) {