@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.
@@ -6908,13 +6908,15 @@ function validateLength(range, length, context) {
6908
6908
 
6909
6909
  /** A caching wrapper for either object or sequence item. */
6910
6910
  class ViewField {
6911
+ name;
6911
6912
  getView;
6912
6913
  getValue;
6913
6914
  getEncoded;
6914
6915
  cachedValue;
6915
6916
  cachedView;
6916
6917
  cachedBlob;
6917
- constructor(getView, getValue, getEncoded) {
6918
+ constructor(name, getView, getValue, getEncoded) {
6919
+ this.name = name;
6918
6920
  this.getView = getView;
6919
6921
  this.getValue = getValue;
6920
6922
  this.getEncoded = getEncoded;
@@ -6940,6 +6942,9 @@ class ViewField {
6940
6942
  }
6941
6943
  return this.cachedBlob;
6942
6944
  }
6945
+ toString() {
6946
+ return `ViewField<${this.name}>`;
6947
+ }
6943
6948
  }
6944
6949
  /**
6945
6950
  * A base class for all the lazy views.
@@ -7014,7 +7019,7 @@ class ObjectView {
7014
7019
  const fieldDecoder = skipper.decoder.clone();
7015
7020
  const field = this.descriptorsKeys[i];
7016
7021
  const type = this.descriptors[field];
7017
- lastItem = new ViewField(() => type.View.decode(fieldDecoder.clone()), () => type.decode(fieldDecoder.clone()), () => type.skipEncoded(fieldDecoder.clone()));
7022
+ lastItem = new ViewField(`${this.toString()}.${String(field)}`, () => type.View.decode(fieldDecoder.clone()), () => type.decode(fieldDecoder.clone()), () => type.skipEncoded(fieldDecoder.clone()));
7018
7023
  // skip the field
7019
7024
  type.skip(skipper);
7020
7025
  // cache data
@@ -7026,6 +7031,9 @@ class ObjectView {
7026
7031
  }
7027
7032
  return lastItem;
7028
7033
  }
7034
+ toString() {
7035
+ return `View<${this.materializedConstructor.name}>(cache: ${this.cache.size})`;
7036
+ }
7029
7037
  }
7030
7038
  /**
7031
7039
  * A lazy-evaluated decoder of a sequence.
@@ -7114,7 +7122,7 @@ class SequenceView {
7114
7122
  // create new cached prop
7115
7123
  const fieldDecoder = skipper.decoder.clone();
7116
7124
  const type = this.descriptor;
7117
- lastItem = new ViewField(() => type.View.decode(fieldDecoder.clone()), () => type.decode(fieldDecoder.clone()), () => type.skipEncoded(fieldDecoder.clone()));
7125
+ lastItem = new ViewField(`${this.toString()}[${index}]`, () => type.View.decode(fieldDecoder.clone()), () => type.decode(fieldDecoder.clone()), () => type.skipEncoded(fieldDecoder.clone()));
7118
7126
  // skip the field
7119
7127
  type.skip(skipper);
7120
7128
  // cache data
@@ -7126,6 +7134,9 @@ class SequenceView {
7126
7134
  }
7127
7135
  return lastItem;
7128
7136
  }
7137
+ toString() {
7138
+ return `SequenceView<${this.descriptor.name}>(cache: ${this.cache.size})`;
7139
+ }
7129
7140
  }
7130
7141
 
7131
7142
  ;// CONCATENATED MODULE: ./packages/core/codec/descriptors.ts
@@ -10196,6 +10207,10 @@ class DisputesRecords {
10196
10207
  static create({ goodSet, badSet, wonkySet, punishSet }) {
10197
10208
  return new DisputesRecords(goodSet, badSet, wonkySet, punishSet);
10198
10209
  }
10210
+ goodSetDict;
10211
+ badSetDict;
10212
+ wonkySetDict;
10213
+ punishSetDict;
10199
10214
  constructor(
10200
10215
  /** `goodSet`: all work-reports hashes which were judged to be correct */
10201
10216
  goodSet,
@@ -10209,6 +10224,18 @@ class DisputesRecords {
10209
10224
  this.badSet = badSet;
10210
10225
  this.wonkySet = wonkySet;
10211
10226
  this.punishSet = punishSet;
10227
+ this.goodSetDict = HashSet.from(goodSet.array);
10228
+ this.badSetDict = HashSet.from(badSet.array);
10229
+ this.wonkySetDict = HashSet.from(wonkySet.array);
10230
+ this.punishSetDict = HashSet.from(punishSet.array);
10231
+ }
10232
+ asDictionaries() {
10233
+ return {
10234
+ goodSet: this.goodSetDict,
10235
+ badSet: this.badSetDict,
10236
+ wonkySet: this.wonkySetDict,
10237
+ punishSet: this.punishSetDict,
10238
+ };
10212
10239
  }
10213
10240
  static fromSortedArrays({ goodSet, badSet, wonkySet, punishSet, }) {
10214
10241
  return new DisputesRecords(SortedSet.fromSortedArray(hashComparator, goodSet), SortedSet.fromSortedArray(hashComparator, badSet), SortedSet.fromSortedArray(hashComparator, wonkySet), SortedSet.fromSortedArray(hashComparator, punishSet));
@@ -14621,10 +14648,16 @@ function signExtend32To64(value) {
14621
14648
 
14622
14649
  /** Attempt to convert a number into `HostCallIndex`. */
14623
14650
  const host_call_handler_tryAsHostCallIndex = (v) => opaque_asOpaqueType(numbers_tryAsU32(v));
14651
+ /**
14652
+ * Host-call exit reason.
14653
+ *
14654
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/24a30124a501?v=0.7.2
14655
+ */
14624
14656
  var PvmExecution;
14625
14657
  (function (PvmExecution) {
14626
14658
  PvmExecution[PvmExecution["Halt"] = 0] = "Halt";
14627
14659
  PvmExecution[PvmExecution["Panic"] = 1] = "Panic";
14660
+ PvmExecution[PvmExecution["OOG"] = 2] = "OOG";
14628
14661
  })(PvmExecution || (PvmExecution = {}));
14629
14662
  /** A utility function to easily trace a bunch of registers. */
14630
14663
  function traceRegisters(...regs) {
@@ -18548,8 +18581,9 @@ class HostCalls {
18548
18581
  const index = host_call_handler_tryAsHostCallIndex(hostCallIndex);
18549
18582
  const hostCall = this.hostCalls.get(index);
18550
18583
  const gasBefore = gas.get();
18551
- const gasCost = typeof hostCall.gasCost === "number" ? hostCall.gasCost : hostCall.gasCost(regs);
18552
- const underflow = gas.sub(gasCost);
18584
+ // NOTE: `basicGasCost(regs)` function is for compatibility reasons: pre GP 0.7.2
18585
+ const basicGasCost = typeof hostCall.basicGasCost === "number" ? hostCall.basicGasCost : hostCall.basicGasCost(regs);
18586
+ const underflow = gas.sub(basicGasCost);
18553
18587
  const pcLog = `[PC: ${pvmInstance.getPC()}]`;
18554
18588
  if (underflow) {
18555
18589
  this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
@@ -18566,6 +18600,10 @@ class HostCalls {
18566
18600
  status = status_Status.PANIC;
18567
18601
  return this.getReturnValue(status, pvmInstance);
18568
18602
  }
18603
+ if (result === PvmExecution.OOG) {
18604
+ status = status_Status.OOG;
18605
+ return this.getReturnValue(status, pvmInstance);
18606
+ }
18569
18607
  if (result === undefined) {
18570
18608
  pvmInstance.runProgram();
18571
18609
  status = pvmInstance.getStatus();
@@ -18624,7 +18662,7 @@ class host_calls_manager_HostCallsManager {
18624
18662
  }
18625
18663
  class NoopMissing {
18626
18664
  index = tryAsHostCallIndex(2 ** 32 - 1);
18627
- gasCost = tryAsSmallGas(0);
18665
+ basicGasCost = tryAsSmallGas(0);
18628
18666
  currentServiceId = tryAsU32(0);
18629
18667
  tracedRegisters = [];
18630
18668
  async execute() {
@@ -18738,7 +18776,7 @@ function clampU64ToU32(value) {
18738
18776
 
18739
18777
  class missing_Missing {
18740
18778
  index = host_call_handler_tryAsHostCallIndex(2 ** 32 - 1);
18741
- gasCost = gas_tryAsSmallGas(10);
18779
+ basicGasCost = gas_tryAsSmallGas(10);
18742
18780
  currentServiceId = CURRENT_SERVICE_ID;
18743
18781
  tracedRegisters = traceRegisters(7);
18744
18782
  execute(_gas, regs, _memory) {
@@ -19273,7 +19311,7 @@ class Disputes {
19273
19311
  const { key, workReportHash } = disputes.culprits[i];
19274
19312
  // check if some offenders weren't reported earlier
19275
19313
  // https://graypaper.fluffylabs.dev/#/579bd12/125501125501
19276
- const isInPunishSet = this.state.disputesRecords.punishSet.findExact(key) !== undefined;
19314
+ const isInPunishSet = this.state.disputesRecords.asDictionaries().punishSet.has(key);
19277
19315
  if (isInPunishSet) {
19278
19316
  return result_Result.error(DisputesErrorCode.OffenderAlreadyReported);
19279
19317
  }
@@ -19284,8 +19322,8 @@ class Disputes {
19284
19322
  }
19285
19323
  // verify if the culprit will be in new bad set
19286
19324
  // https://graypaper.fluffylabs.dev/#/579bd12/124601124601
19287
- const isInNewBadSet = newItems.toAddToBadSet.findExact(workReportHash);
19288
- if (isInNewBadSet === undefined) {
19325
+ const isInNewBadSet = newItems.asDictionaries().badSet.has(workReportHash);
19326
+ if (!isInNewBadSet) {
19289
19327
  return result_Result.error(DisputesErrorCode.CulpritsVerdictNotBad);
19290
19328
  }
19291
19329
  // verify culprit signature
@@ -19308,7 +19346,7 @@ class Disputes {
19308
19346
  const { key, workReportHash, wasConsideredValid } = disputes.faults[i];
19309
19347
  // check if some offenders weren't reported earlier
19310
19348
  // https://graypaper.fluffylabs.dev/#/579bd12/12a20112a201
19311
- const isInPunishSet = this.state.disputesRecords.punishSet.findExact(key) !== undefined;
19349
+ const isInPunishSet = this.state.disputesRecords.asDictionaries().punishSet.has(key);
19312
19350
  if (isInPunishSet) {
19313
19351
  return result_Result.error(DisputesErrorCode.OffenderAlreadyReported);
19314
19352
  }
@@ -19323,9 +19361,10 @@ class Disputes {
19323
19361
  // but it does not pass the tests
19324
19362
  // https://graypaper.fluffylabs.dev/#/579bd12/128a01129601
19325
19363
  if (wasConsideredValid) {
19326
- const isInNewGoodSet = newItems.toAddToGoodSet.findExact(workReportHash);
19327
- const isInNewBadSet = newItems.toAddToBadSet.findExact(workReportHash);
19328
- if (isInNewGoodSet !== undefined || isInNewBadSet === undefined) {
19364
+ const { goodSet, badSet } = newItems.asDictionaries();
19365
+ const isInNewGoodSet = goodSet.has(workReportHash);
19366
+ const isInNewBadSet = badSet.has(workReportHash);
19367
+ if (isInNewGoodSet || !isInNewBadSet) {
19329
19368
  return result_Result.error(DisputesErrorCode.FaultVerdictWrong);
19330
19369
  }
19331
19370
  }
@@ -19378,10 +19417,11 @@ class Disputes {
19378
19417
  for (const verdict of disputes.verdicts) {
19379
19418
  // current verdicts should not be reported earlier
19380
19419
  // https://graypaper.fluffylabs.dev/#/579bd12/122202122202
19381
- const isInGoodSet = this.state.disputesRecords.goodSet.findExact(verdict.workReportHash);
19382
- const isInBadSet = this.state.disputesRecords.badSet.findExact(verdict.workReportHash);
19383
- const isInWonkySet = this.state.disputesRecords.wonkySet.findExact(verdict.workReportHash);
19384
- if (isInGoodSet !== undefined || isInBadSet !== undefined || isInWonkySet !== undefined) {
19420
+ const { goodSet, badSet, wonkySet } = this.state.disputesRecords.asDictionaries();
19421
+ const isInGoodSet = goodSet.has(verdict.workReportHash);
19422
+ const isInBadSet = badSet.has(verdict.workReportHash);
19423
+ const isInWonkySet = wonkySet.has(verdict.workReportHash);
19424
+ if (isInGoodSet || isInBadSet || isInWonkySet) {
19385
19425
  return result_Result.error(DisputesErrorCode.AlreadyJudged);
19386
19426
  }
19387
19427
  }
@@ -19451,11 +19491,12 @@ class Disputes {
19451
19491
  toAddToWonkySet.push(r);
19452
19492
  }
19453
19493
  }
19454
- return {
19455
- toAddToGoodSet: SortedSet.fromArrayUnique(hashComparator, toAddToGoodSet),
19456
- toAddToBadSet: SortedSet.fromArrayUnique(hashComparator, toAddToBadSet),
19457
- toAddToWonkySet: SortedSet.fromArrayUnique(hashComparator, toAddToWonkySet),
19458
- };
19494
+ return DisputesRecords.create({
19495
+ goodSet: SortedSet.fromArrayUnique(hashComparator, toAddToGoodSet),
19496
+ badSet: SortedSet.fromArrayUnique(hashComparator, toAddToBadSet),
19497
+ wonkySet: SortedSet.fromArrayUnique(hashComparator, toAddToWonkySet),
19498
+ punishSet: SortedSet.fromArray(hashComparator, []),
19499
+ });
19459
19500
  }
19460
19501
  getClearedCoreAssignment(v) {
19461
19502
  /**
@@ -19490,9 +19531,9 @@ class Disputes {
19490
19531
  const toAddToPunishSet = SortedArray.fromArray(hashComparator, Array.from(offenders));
19491
19532
  return DisputesRecords.create({
19492
19533
  // https://graypaper.fluffylabs.dev/#/579bd12/12690312bc03
19493
- goodSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.goodSet, newItems.toAddToGoodSet),
19494
- badSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.badSet, newItems.toAddToBadSet),
19495
- wonkySet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.wonkySet, newItems.toAddToWonkySet),
19534
+ goodSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.goodSet, newItems.goodSet),
19535
+ badSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.badSet, newItems.badSet),
19536
+ wonkySet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.wonkySet, newItems.wonkySet),
19496
19537
  punishSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.punishSet, toAddToPunishSet),
19497
19538
  });
19498
19539
  }
@@ -21880,7 +21921,7 @@ class Assign {
21880
21921
  partialState;
21881
21922
  chainSpec;
21882
21923
  index = host_call_handler_tryAsHostCallIndex(15);
21883
- gasCost = gas_tryAsSmallGas(10);
21924
+ basicGasCost = gas_tryAsSmallGas(10);
21884
21925
  tracedRegisters = traceRegisters(IN_OUT_REG, 8);
21885
21926
  constructor(currentServiceId, partialState, chainSpec) {
21886
21927
  this.currentServiceId = currentServiceId;
@@ -21958,7 +21999,7 @@ class Bless {
21958
21999
  partialState;
21959
22000
  chainSpec;
21960
22001
  index = host_call_handler_tryAsHostCallIndex(14);
21961
- gasCost = gas_tryAsSmallGas(10);
22002
+ basicGasCost = gas_tryAsSmallGas(10);
21962
22003
  tracedRegisters = traceRegisters(bless_IN_OUT_REG, 8, 9, 10, 11);
21963
22004
  constructor(currentServiceId, partialState, chainSpec) {
21964
22005
  this.currentServiceId = currentServiceId;
@@ -22043,7 +22084,7 @@ class Bless {
22043
22084
  class GasHostCall {
22044
22085
  currentServiceId;
22045
22086
  index = host_call_handler_tryAsHostCallIndex(0);
22046
- gasCost = gas_tryAsSmallGas(10);
22087
+ basicGasCost = gas_tryAsSmallGas(10);
22047
22088
  tracedRegisters = traceRegisters(7);
22048
22089
  constructor(currentServiceId) {
22049
22090
  this.currentServiceId = currentServiceId;
@@ -22070,7 +22111,7 @@ class Checkpoint {
22070
22111
  currentServiceId;
22071
22112
  partialState;
22072
22113
  index = host_call_handler_tryAsHostCallIndex(17);
22073
- gasCost = gas_tryAsSmallGas(10);
22114
+ basicGasCost = gas_tryAsSmallGas(10);
22074
22115
  tracedRegisters;
22075
22116
  gasHostCall;
22076
22117
  constructor(currentServiceId, partialState) {
@@ -22107,7 +22148,7 @@ class Designate {
22107
22148
  partialState;
22108
22149
  chainSpec;
22109
22150
  index = host_call_handler_tryAsHostCallIndex(16);
22110
- gasCost = gas_tryAsSmallGas(10);
22151
+ basicGasCost = gas_tryAsSmallGas(10);
22111
22152
  tracedRegisters = traceRegisters(designate_IN_OUT_REG);
22112
22153
  constructor(currentServiceId, partialState, chainSpec) {
22113
22154
  this.currentServiceId = currentServiceId;
@@ -22158,7 +22199,7 @@ class Eject {
22158
22199
  currentServiceId;
22159
22200
  partialState;
22160
22201
  index = host_call_handler_tryAsHostCallIndex(21);
22161
- gasCost = gas_tryAsSmallGas(10);
22202
+ basicGasCost = gas_tryAsSmallGas(10);
22162
22203
  tracedRegisters = traceRegisters(eject_IN_OUT_REG, 8);
22163
22204
  constructor(currentServiceId, partialState) {
22164
22205
  this.currentServiceId = currentServiceId;
@@ -22220,7 +22261,7 @@ class Forget {
22220
22261
  currentServiceId;
22221
22262
  partialState;
22222
22263
  index = host_call_handler_tryAsHostCallIndex(24);
22223
- gasCost = gas_tryAsSmallGas(10);
22264
+ basicGasCost = gas_tryAsSmallGas(10);
22224
22265
  tracedRegisters = traceRegisters(forget_IN_OUT_REG, 8);
22225
22266
  constructor(currentServiceId, partialState) {
22226
22267
  this.currentServiceId = currentServiceId;
@@ -22270,7 +22311,7 @@ class New {
22270
22311
  currentServiceId;
22271
22312
  partialState;
22272
22313
  index = host_call_handler_tryAsHostCallIndex(18);
22273
- gasCost = gas_tryAsSmallGas(10);
22314
+ basicGasCost = gas_tryAsSmallGas(10);
22274
22315
  tracedRegisters = traceRegisters(new_IN_OUT_REG, 8, 9, 10, 11);
22275
22316
  constructor(currentServiceId, partialState) {
22276
22317
  this.currentServiceId = currentServiceId;
@@ -22333,7 +22374,7 @@ class Provide {
22333
22374
  currentServiceId;
22334
22375
  partialState;
22335
22376
  index = host_call_handler_tryAsHostCallIndex(26);
22336
- gasCost = gas_tryAsSmallGas(10);
22377
+ basicGasCost = gas_tryAsSmallGas(10);
22337
22378
  tracedRegisters = traceRegisters(provide_IN_OUT_REG, 8, 9);
22338
22379
  constructor(currentServiceId, partialState) {
22339
22380
  this.currentServiceId = currentServiceId;
@@ -22394,7 +22435,7 @@ class Query {
22394
22435
  currentServiceId;
22395
22436
  partialState;
22396
22437
  index = host_call_handler_tryAsHostCallIndex(22);
22397
- gasCost = gas_tryAsSmallGas(10);
22438
+ basicGasCost = gas_tryAsSmallGas(10);
22398
22439
  tracedRegisters = traceRegisters(IN_OUT_REG_1, IN_OUT_REG_2);
22399
22440
  constructor(currentServiceId, partialState) {
22400
22441
  this.currentServiceId = currentServiceId;
@@ -22460,7 +22501,7 @@ class Solicit {
22460
22501
  currentServiceId;
22461
22502
  partialState;
22462
22503
  index = host_call_handler_tryAsHostCallIndex(23);
22463
- gasCost = gas_tryAsSmallGas(10);
22504
+ basicGasCost = gas_tryAsSmallGas(10);
22464
22505
  tracedRegisters = traceRegisters(solicit_IN_OUT_REG, 8);
22465
22506
  constructor(currentServiceId, partialState) {
22466
22507
  this.currentServiceId = currentServiceId;
@@ -22508,12 +22549,12 @@ class Solicit {
22508
22549
 
22509
22550
  const transfer_IN_OUT_REG = 7; // `d`
22510
22551
  const AMOUNT_REG = 8; // `a`
22511
- const ON_TRANSFER_GAS_REG = 9; // `l`
22552
+ const TRANSFER_GAS_FEE_REG = 9; // `l`
22512
22553
  const MEMO_START_REG = 10; // `o`
22513
22554
  /**
22514
22555
  * Transfer balance from one service account to another.
22515
22556
  *
22516
- * https://graypaper.fluffylabs.dev/#/7e6ff6a/373b00373b00?v=0.6.7
22557
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/373f00373f00?v=0.7.2
22517
22558
  */
22518
22559
  class Transfer {
22519
22560
  currentServiceId;
@@ -22525,38 +22566,50 @@ class Transfer {
22525
22566
  },
22526
22567
  }));
22527
22568
  /**
22528
- * `g = 10 + ω9`
22529
- * https://graypaper.fluffylabs.dev/#/7e6ff6a/373d00373d00?v=0.6.7
22569
+ * `g = 10 + t`
22570
+ *
22571
+ * `t` has positive value, only when status of a transfer is `OK`
22572
+ * `0` otherwise
22573
+ *
22574
+ * Pre0.7.2: `g = 10 + ω9`
22575
+ *
22576
+ * https://graypaper.fluffylabs.dev/#/ab2cdbd/373f00373f00?v=0.7.2
22530
22577
  */
22531
- gasCost = (regs) => {
22532
- const gas = 10n + regs.get(ON_TRANSFER_GAS_REG);
22533
- return gas_tryAsGas(gas);
22534
- };
22535
- tracedRegisters = traceRegisters(transfer_IN_OUT_REG, AMOUNT_REG, ON_TRANSFER_GAS_REG, MEMO_START_REG);
22578
+ basicGasCost = Compatibility.isGreaterOrEqual(GpVersion.V0_7_2)
22579
+ ? gas_tryAsSmallGas(10)
22580
+ : (regs) => gas_tryAsGas(10n + regs.get(TRANSFER_GAS_FEE_REG));
22581
+ tracedRegisters = traceRegisters(transfer_IN_OUT_REG, AMOUNT_REG, TRANSFER_GAS_FEE_REG, MEMO_START_REG);
22536
22582
  constructor(currentServiceId, partialState) {
22537
22583
  this.currentServiceId = currentServiceId;
22538
22584
  this.partialState = partialState;
22539
22585
  }
22540
- async execute(_gas, regs, memory) {
22586
+ async execute(gas, regs, memory) {
22541
22587
  // `d`: destination
22542
22588
  const destination = getServiceId(regs.get(transfer_IN_OUT_REG));
22543
22589
  // `a`: amount
22544
22590
  const amount = regs.get(AMOUNT_REG);
22545
22591
  // `l`: gas
22546
- const onTransferGas = common_tryAsServiceGas(regs.get(ON_TRANSFER_GAS_REG));
22592
+ const transferGasFee = common_tryAsServiceGas(regs.get(TRANSFER_GAS_FEE_REG));
22547
22593
  // `o`: transfer memo
22548
22594
  const memoStart = regs.get(MEMO_START_REG);
22549
22595
  const memo = bytes_Bytes.zero(TRANSFER_MEMO_BYTES);
22550
22596
  const memoryReadResult = memory.loadInto(memo.raw, memoStart);
22551
22597
  // page fault while reading the memory.
22552
22598
  if (memoryReadResult.isError) {
22553
- logger_logger.trace `TRANSFER(${destination}, ${amount}, ${onTransferGas}, ${memo}) <- PANIC`;
22599
+ logger_logger.trace `TRANSFER(${destination}, ${amount}, ${transferGasFee}, ${memo}) <- PANIC`;
22554
22600
  return PvmExecution.Panic;
22555
22601
  }
22556
- const transferResult = this.partialState.transfer(destination, amount, onTransferGas, memo);
22557
- logger_logger.trace `TRANSFER(${destination}, ${amount}, ${onTransferGas}, ${memo}) <- ${resultToString(transferResult)}`;
22602
+ const transferResult = this.partialState.transfer(destination, amount, transferGasFee, memo);
22603
+ logger_logger.trace `TRANSFER(${destination}, ${amount}, ${transferGasFee}, ${memo}) <- ${resultToString(transferResult)}`;
22558
22604
  // All good!
22559
22605
  if (transferResult.isOk) {
22606
+ if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_2)) {
22607
+ // substracting value `t`
22608
+ const underflow = gas.sub(gas_tryAsGas(transferGasFee));
22609
+ if (underflow) {
22610
+ return PvmExecution.OOG;
22611
+ }
22612
+ }
22560
22613
  regs.set(transfer_IN_OUT_REG, HostCallResult.OK);
22561
22614
  return;
22562
22615
  }
@@ -22596,7 +22649,7 @@ class Upgrade {
22596
22649
  currentServiceId;
22597
22650
  partialState;
22598
22651
  index = host_call_handler_tryAsHostCallIndex(19);
22599
- gasCost = gas_tryAsSmallGas(10);
22652
+ basicGasCost = gas_tryAsSmallGas(10);
22600
22653
  tracedRegisters = traceRegisters(upgrade_IN_OUT_REG, GAS_REG, ALLOWANCE_REG);
22601
22654
  constructor(currentServiceId, partialState) {
22602
22655
  this.currentServiceId = currentServiceId;
@@ -22639,7 +22692,7 @@ class Yield {
22639
22692
  currentServiceId;
22640
22693
  partialState;
22641
22694
  index = host_call_handler_tryAsHostCallIndex(25);
22642
- gasCost = gas_tryAsSmallGas(10);
22695
+ basicGasCost = gas_tryAsSmallGas(10);
22643
22696
  tracedRegisters = traceRegisters(yield_IN_OUT_REG);
22644
22697
  constructor(currentServiceId, partialState) {
22645
22698
  this.currentServiceId = currentServiceId;
@@ -22675,7 +22728,7 @@ class Fetch {
22675
22728
  currentServiceId;
22676
22729
  fetch;
22677
22730
  index = host_call_handler_tryAsHostCallIndex(1);
22678
- gasCost = gas_tryAsSmallGas(10);
22731
+ basicGasCost = gas_tryAsSmallGas(10);
22679
22732
  tracedRegisters = traceRegisters(fetch_IN_OUT_REG, 8, 9, 10, 11, 12);
22680
22733
  constructor(currentServiceId, fetch) {
22681
22734
  this.currentServiceId = currentServiceId;
@@ -22832,7 +22885,7 @@ class Info {
22832
22885
  currentServiceId;
22833
22886
  account;
22834
22887
  index = host_call_handler_tryAsHostCallIndex(5);
22835
- gasCost = gas_tryAsSmallGas(10);
22888
+ basicGasCost = gas_tryAsSmallGas(10);
22836
22889
  tracedRegisters = traceRegisters(info_IN_OUT_REG, 8, OFFSET_REG, LEN_REG);
22837
22890
  constructor(currentServiceId, account) {
22838
22891
  this.currentServiceId = currentServiceId;
@@ -22907,7 +22960,7 @@ const decoder = new TextDecoder("utf8");
22907
22960
  class LogHostCall {
22908
22961
  currentServiceId;
22909
22962
  index = host_call_handler_tryAsHostCallIndex(100);
22910
- gasCost = gas_tryAsSmallGas(0);
22963
+ basicGasCost = gas_tryAsSmallGas(0);
22911
22964
  // intentionally not tracing anything here, since the message will be printed anyway.
22912
22965
  tracedRegisters = traceRegisters();
22913
22966
  constructor(currentServiceId) {
@@ -22949,7 +23002,7 @@ class Lookup {
22949
23002
  currentServiceId;
22950
23003
  account;
22951
23004
  index = host_call_handler_tryAsHostCallIndex(2);
22952
- gasCost = gas_tryAsSmallGas(10);
23005
+ basicGasCost = gas_tryAsSmallGas(10);
22953
23006
  tracedRegisters = traceRegisters(lookup_IN_OUT_REG, 8, 9, 10, 11);
22954
23007
  constructor(currentServiceId, account) {
22955
23008
  this.currentServiceId = currentServiceId;
@@ -23012,7 +23065,7 @@ class Read {
23012
23065
  currentServiceId;
23013
23066
  account;
23014
23067
  index = host_call_handler_tryAsHostCallIndex(3);
23015
- gasCost = gas_tryAsSmallGas(10);
23068
+ basicGasCost = gas_tryAsSmallGas(10);
23016
23069
  tracedRegisters = traceRegisters(read_IN_OUT_REG, 8, 9, 10, 11, 12);
23017
23070
  constructor(currentServiceId, account) {
23018
23071
  this.currentServiceId = currentServiceId;
@@ -23082,7 +23135,7 @@ class Write {
23082
23135
  currentServiceId;
23083
23136
  account;
23084
23137
  index = host_call_handler_tryAsHostCallIndex(4);
23085
- gasCost = gas_tryAsSmallGas(10);
23138
+ basicGasCost = gas_tryAsSmallGas(10);
23086
23139
  tracedRegisters = traceRegisters(write_IN_OUT_REG, 8, 9, 10);
23087
23140
  constructor(currentServiceId, account) {
23088
23141
  this.currentServiceId = currentServiceId;