@typeberry/convert 0.1.3-707962d → 0.1.3-ea24911
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.
- package/index.js +98 -56
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12190,6 +12190,10 @@ class disputes_DisputesRecords {
|
|
|
12190
12190
|
static create({ goodSet, badSet, wonkySet, punishSet }) {
|
|
12191
12191
|
return new disputes_DisputesRecords(goodSet, badSet, wonkySet, punishSet);
|
|
12192
12192
|
}
|
|
12193
|
+
goodSetDict;
|
|
12194
|
+
badSetDict;
|
|
12195
|
+
wonkySetDict;
|
|
12196
|
+
punishSetDict;
|
|
12193
12197
|
constructor(
|
|
12194
12198
|
/** `goodSet`: all work-reports hashes which were judged to be correct */
|
|
12195
12199
|
goodSet,
|
|
@@ -12203,6 +12207,18 @@ class disputes_DisputesRecords {
|
|
|
12203
12207
|
this.badSet = badSet;
|
|
12204
12208
|
this.wonkySet = wonkySet;
|
|
12205
12209
|
this.punishSet = punishSet;
|
|
12210
|
+
this.goodSetDict = hash_set_HashSet.from(goodSet.array);
|
|
12211
|
+
this.badSetDict = hash_set_HashSet.from(badSet.array);
|
|
12212
|
+
this.wonkySetDict = hash_set_HashSet.from(wonkySet.array);
|
|
12213
|
+
this.punishSetDict = hash_set_HashSet.from(punishSet.array);
|
|
12214
|
+
}
|
|
12215
|
+
asDictionaries() {
|
|
12216
|
+
return {
|
|
12217
|
+
goodSet: this.goodSetDict,
|
|
12218
|
+
badSet: this.badSetDict,
|
|
12219
|
+
wonkySet: this.wonkySetDict,
|
|
12220
|
+
punishSet: this.punishSetDict,
|
|
12221
|
+
};
|
|
12206
12222
|
}
|
|
12207
12223
|
static fromSortedArrays({ goodSet, badSet, wonkySet, punishSet, }) {
|
|
12208
12224
|
return new disputes_DisputesRecords(sorted_set_SortedSet.fromSortedArray(disputes_hashComparator, goodSet), sorted_set_SortedSet.fromSortedArray(disputes_hashComparator, badSet), sorted_set_SortedSet.fromSortedArray(disputes_hashComparator, wonkySet), sorted_set_SortedSet.fromSortedArray(disputes_hashComparator, punishSet));
|
|
@@ -16247,10 +16263,16 @@ function registers_signExtend32To64(value) {
|
|
|
16247
16263
|
|
|
16248
16264
|
/** Attempt to convert a number into `HostCallIndex`. */
|
|
16249
16265
|
const host_call_handler_tryAsHostCallIndex = (v) => opaque_asOpaqueType(numbers_tryAsU32(v));
|
|
16266
|
+
/**
|
|
16267
|
+
* Host-call exit reason.
|
|
16268
|
+
*
|
|
16269
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/24a30124a501?v=0.7.2
|
|
16270
|
+
*/
|
|
16250
16271
|
var host_call_handler_PvmExecution;
|
|
16251
16272
|
(function (PvmExecution) {
|
|
16252
16273
|
PvmExecution[PvmExecution["Halt"] = 0] = "Halt";
|
|
16253
16274
|
PvmExecution[PvmExecution["Panic"] = 1] = "Panic";
|
|
16275
|
+
PvmExecution[PvmExecution["OOG"] = 2] = "OOG";
|
|
16254
16276
|
})(host_call_handler_PvmExecution || (host_call_handler_PvmExecution = {}));
|
|
16255
16277
|
/** A utility function to easily trace a bunch of registers. */
|
|
16256
16278
|
function host_call_handler_traceRegisters(...regs) {
|
|
@@ -19867,8 +19889,9 @@ class host_calls_HostCalls {
|
|
|
19867
19889
|
const index = tryAsHostCallIndex(hostCallIndex);
|
|
19868
19890
|
const hostCall = this.hostCalls.get(index);
|
|
19869
19891
|
const gasBefore = gas.get();
|
|
19870
|
-
|
|
19871
|
-
const
|
|
19892
|
+
// NOTE: `basicGasCost(regs)` function is for compatibility reasons: pre GP 0.7.2
|
|
19893
|
+
const basicGasCost = typeof hostCall.basicGasCost === "number" ? hostCall.basicGasCost : hostCall.basicGasCost(regs);
|
|
19894
|
+
const underflow = gas.sub(basicGasCost);
|
|
19872
19895
|
const pcLog = `[PC: ${pvmInstance.getPC()}]`;
|
|
19873
19896
|
if (underflow) {
|
|
19874
19897
|
this.hostCalls.traceHostCall(`${pcLog} OOG`, index, hostCall, regs, gas.get());
|
|
@@ -19885,6 +19908,10 @@ class host_calls_HostCalls {
|
|
|
19885
19908
|
status = Status.PANIC;
|
|
19886
19909
|
return this.getReturnValue(status, pvmInstance);
|
|
19887
19910
|
}
|
|
19911
|
+
if (result === PvmExecution.OOG) {
|
|
19912
|
+
status = Status.OOG;
|
|
19913
|
+
return this.getReturnValue(status, pvmInstance);
|
|
19914
|
+
}
|
|
19888
19915
|
if (result === undefined) {
|
|
19889
19916
|
pvmInstance.runProgram();
|
|
19890
19917
|
status = pvmInstance.getStatus();
|
|
@@ -19943,7 +19970,7 @@ class host_calls_manager_HostCallsManager {
|
|
|
19943
19970
|
}
|
|
19944
19971
|
class NoopMissing {
|
|
19945
19972
|
index = tryAsHostCallIndex(2 ** 32 - 1);
|
|
19946
|
-
|
|
19973
|
+
basicGasCost = tryAsSmallGas(0);
|
|
19947
19974
|
currentServiceId = tryAsU32(0);
|
|
19948
19975
|
tracedRegisters = [];
|
|
19949
19976
|
async execute() {
|
|
@@ -20057,7 +20084,7 @@ function utils_clampU64ToU32(value) {
|
|
|
20057
20084
|
|
|
20058
20085
|
class missing_Missing {
|
|
20059
20086
|
index = tryAsHostCallIndex(2 ** 32 - 1);
|
|
20060
|
-
|
|
20087
|
+
basicGasCost = tryAsSmallGas(10);
|
|
20061
20088
|
currentServiceId = CURRENT_SERVICE_ID;
|
|
20062
20089
|
tracedRegisters = traceRegisters(7);
|
|
20063
20090
|
execute(_gas, regs, _memory) {
|
|
@@ -20434,7 +20461,7 @@ class disputes_Disputes {
|
|
|
20434
20461
|
const { key, workReportHash } = disputes.culprits[i];
|
|
20435
20462
|
// check if some offenders weren't reported earlier
|
|
20436
20463
|
// https://graypaper.fluffylabs.dev/#/579bd12/125501125501
|
|
20437
|
-
const isInPunishSet = this.state.disputesRecords.punishSet.
|
|
20464
|
+
const isInPunishSet = this.state.disputesRecords.asDictionaries().punishSet.has(key);
|
|
20438
20465
|
if (isInPunishSet) {
|
|
20439
20466
|
return Result.error(DisputesErrorCode.OffenderAlreadyReported);
|
|
20440
20467
|
}
|
|
@@ -20445,8 +20472,8 @@ class disputes_Disputes {
|
|
|
20445
20472
|
}
|
|
20446
20473
|
// verify if the culprit will be in new bad set
|
|
20447
20474
|
// https://graypaper.fluffylabs.dev/#/579bd12/124601124601
|
|
20448
|
-
const isInNewBadSet = newItems.
|
|
20449
|
-
if (isInNewBadSet
|
|
20475
|
+
const isInNewBadSet = newItems.asDictionaries().badSet.has(workReportHash);
|
|
20476
|
+
if (!isInNewBadSet) {
|
|
20450
20477
|
return Result.error(DisputesErrorCode.CulpritsVerdictNotBad);
|
|
20451
20478
|
}
|
|
20452
20479
|
// verify culprit signature
|
|
@@ -20469,7 +20496,7 @@ class disputes_Disputes {
|
|
|
20469
20496
|
const { key, workReportHash, wasConsideredValid } = disputes.faults[i];
|
|
20470
20497
|
// check if some offenders weren't reported earlier
|
|
20471
20498
|
// https://graypaper.fluffylabs.dev/#/579bd12/12a20112a201
|
|
20472
|
-
const isInPunishSet = this.state.disputesRecords.punishSet.
|
|
20499
|
+
const isInPunishSet = this.state.disputesRecords.asDictionaries().punishSet.has(key);
|
|
20473
20500
|
if (isInPunishSet) {
|
|
20474
20501
|
return Result.error(DisputesErrorCode.OffenderAlreadyReported);
|
|
20475
20502
|
}
|
|
@@ -20484,9 +20511,10 @@ class disputes_Disputes {
|
|
|
20484
20511
|
// but it does not pass the tests
|
|
20485
20512
|
// https://graypaper.fluffylabs.dev/#/579bd12/128a01129601
|
|
20486
20513
|
if (wasConsideredValid) {
|
|
20487
|
-
const
|
|
20488
|
-
const
|
|
20489
|
-
|
|
20514
|
+
const { goodSet, badSet } = newItems.asDictionaries();
|
|
20515
|
+
const isInNewGoodSet = goodSet.has(workReportHash);
|
|
20516
|
+
const isInNewBadSet = badSet.has(workReportHash);
|
|
20517
|
+
if (isInNewGoodSet || !isInNewBadSet) {
|
|
20490
20518
|
return Result.error(DisputesErrorCode.FaultVerdictWrong);
|
|
20491
20519
|
}
|
|
20492
20520
|
}
|
|
@@ -20539,10 +20567,11 @@ class disputes_Disputes {
|
|
|
20539
20567
|
for (const verdict of disputes.verdicts) {
|
|
20540
20568
|
// current verdicts should not be reported earlier
|
|
20541
20569
|
// https://graypaper.fluffylabs.dev/#/579bd12/122202122202
|
|
20542
|
-
const
|
|
20543
|
-
const
|
|
20544
|
-
const
|
|
20545
|
-
|
|
20570
|
+
const { goodSet, badSet, wonkySet } = this.state.disputesRecords.asDictionaries();
|
|
20571
|
+
const isInGoodSet = goodSet.has(verdict.workReportHash);
|
|
20572
|
+
const isInBadSet = badSet.has(verdict.workReportHash);
|
|
20573
|
+
const isInWonkySet = wonkySet.has(verdict.workReportHash);
|
|
20574
|
+
if (isInGoodSet || isInBadSet || isInWonkySet) {
|
|
20546
20575
|
return Result.error(DisputesErrorCode.AlreadyJudged);
|
|
20547
20576
|
}
|
|
20548
20577
|
}
|
|
@@ -20612,11 +20641,12 @@ class disputes_Disputes {
|
|
|
20612
20641
|
toAddToWonkySet.push(r);
|
|
20613
20642
|
}
|
|
20614
20643
|
}
|
|
20615
|
-
return {
|
|
20616
|
-
|
|
20617
|
-
|
|
20618
|
-
|
|
20619
|
-
|
|
20644
|
+
return DisputesRecords.create({
|
|
20645
|
+
goodSet: SortedSet.fromArrayUnique(hashComparator, toAddToGoodSet),
|
|
20646
|
+
badSet: SortedSet.fromArrayUnique(hashComparator, toAddToBadSet),
|
|
20647
|
+
wonkySet: SortedSet.fromArrayUnique(hashComparator, toAddToWonkySet),
|
|
20648
|
+
punishSet: SortedSet.fromArray(hashComparator, []),
|
|
20649
|
+
});
|
|
20620
20650
|
}
|
|
20621
20651
|
getClearedCoreAssignment(v) {
|
|
20622
20652
|
/**
|
|
@@ -20651,9 +20681,9 @@ class disputes_Disputes {
|
|
|
20651
20681
|
const toAddToPunishSet = SortedArray.fromArray(hashComparator, Array.from(offenders));
|
|
20652
20682
|
return DisputesRecords.create({
|
|
20653
20683
|
// https://graypaper.fluffylabs.dev/#/579bd12/12690312bc03
|
|
20654
|
-
goodSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.goodSet, newItems.
|
|
20655
|
-
badSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.badSet, newItems.
|
|
20656
|
-
wonkySet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.wonkySet, newItems.
|
|
20684
|
+
goodSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.goodSet, newItems.goodSet),
|
|
20685
|
+
badSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.badSet, newItems.badSet),
|
|
20686
|
+
wonkySet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.wonkySet, newItems.wonkySet),
|
|
20657
20687
|
punishSet: SortedSet.fromTwoSortedCollections(this.state.disputesRecords.punishSet, toAddToPunishSet),
|
|
20658
20688
|
});
|
|
20659
20689
|
}
|
|
@@ -23037,7 +23067,7 @@ class Assign {
|
|
|
23037
23067
|
partialState;
|
|
23038
23068
|
chainSpec;
|
|
23039
23069
|
index = host_call_handler_tryAsHostCallIndex(15);
|
|
23040
|
-
|
|
23070
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23041
23071
|
tracedRegisters = host_call_handler_traceRegisters(IN_OUT_REG, 8);
|
|
23042
23072
|
constructor(currentServiceId, partialState, chainSpec) {
|
|
23043
23073
|
this.currentServiceId = currentServiceId;
|
|
@@ -23115,7 +23145,7 @@ class Bless {
|
|
|
23115
23145
|
partialState;
|
|
23116
23146
|
chainSpec;
|
|
23117
23147
|
index = host_call_handler_tryAsHostCallIndex(14);
|
|
23118
|
-
|
|
23148
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23119
23149
|
tracedRegisters = host_call_handler_traceRegisters(bless_IN_OUT_REG, 8, 9, 10, 11);
|
|
23120
23150
|
constructor(currentServiceId, partialState, chainSpec) {
|
|
23121
23151
|
this.currentServiceId = currentServiceId;
|
|
@@ -23200,7 +23230,7 @@ class Bless {
|
|
|
23200
23230
|
class gas_GasHostCall {
|
|
23201
23231
|
currentServiceId;
|
|
23202
23232
|
index = host_call_handler_tryAsHostCallIndex(0);
|
|
23203
|
-
|
|
23233
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23204
23234
|
tracedRegisters = host_call_handler_traceRegisters(7);
|
|
23205
23235
|
constructor(currentServiceId) {
|
|
23206
23236
|
this.currentServiceId = currentServiceId;
|
|
@@ -23227,7 +23257,7 @@ class Checkpoint {
|
|
|
23227
23257
|
currentServiceId;
|
|
23228
23258
|
partialState;
|
|
23229
23259
|
index = host_call_handler_tryAsHostCallIndex(17);
|
|
23230
|
-
|
|
23260
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23231
23261
|
tracedRegisters;
|
|
23232
23262
|
gasHostCall;
|
|
23233
23263
|
constructor(currentServiceId, partialState) {
|
|
@@ -23264,7 +23294,7 @@ class Designate {
|
|
|
23264
23294
|
partialState;
|
|
23265
23295
|
chainSpec;
|
|
23266
23296
|
index = host_call_handler_tryAsHostCallIndex(16);
|
|
23267
|
-
|
|
23297
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23268
23298
|
tracedRegisters = host_call_handler_traceRegisters(designate_IN_OUT_REG);
|
|
23269
23299
|
constructor(currentServiceId, partialState, chainSpec) {
|
|
23270
23300
|
this.currentServiceId = currentServiceId;
|
|
@@ -23315,7 +23345,7 @@ class Eject {
|
|
|
23315
23345
|
currentServiceId;
|
|
23316
23346
|
partialState;
|
|
23317
23347
|
index = host_call_handler_tryAsHostCallIndex(21);
|
|
23318
|
-
|
|
23348
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23319
23349
|
tracedRegisters = host_call_handler_traceRegisters(eject_IN_OUT_REG, 8);
|
|
23320
23350
|
constructor(currentServiceId, partialState) {
|
|
23321
23351
|
this.currentServiceId = currentServiceId;
|
|
@@ -23377,7 +23407,7 @@ class Forget {
|
|
|
23377
23407
|
currentServiceId;
|
|
23378
23408
|
partialState;
|
|
23379
23409
|
index = host_call_handler_tryAsHostCallIndex(24);
|
|
23380
|
-
|
|
23410
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23381
23411
|
tracedRegisters = host_call_handler_traceRegisters(forget_IN_OUT_REG, 8);
|
|
23382
23412
|
constructor(currentServiceId, partialState) {
|
|
23383
23413
|
this.currentServiceId = currentServiceId;
|
|
@@ -23427,7 +23457,7 @@ class New {
|
|
|
23427
23457
|
currentServiceId;
|
|
23428
23458
|
partialState;
|
|
23429
23459
|
index = host_call_handler_tryAsHostCallIndex(18);
|
|
23430
|
-
|
|
23460
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23431
23461
|
tracedRegisters = host_call_handler_traceRegisters(new_IN_OUT_REG, 8, 9, 10, 11);
|
|
23432
23462
|
constructor(currentServiceId, partialState) {
|
|
23433
23463
|
this.currentServiceId = currentServiceId;
|
|
@@ -23490,7 +23520,7 @@ class Provide {
|
|
|
23490
23520
|
currentServiceId;
|
|
23491
23521
|
partialState;
|
|
23492
23522
|
index = host_call_handler_tryAsHostCallIndex(26);
|
|
23493
|
-
|
|
23523
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23494
23524
|
tracedRegisters = host_call_handler_traceRegisters(provide_IN_OUT_REG, 8, 9);
|
|
23495
23525
|
constructor(currentServiceId, partialState) {
|
|
23496
23526
|
this.currentServiceId = currentServiceId;
|
|
@@ -23551,7 +23581,7 @@ class Query {
|
|
|
23551
23581
|
currentServiceId;
|
|
23552
23582
|
partialState;
|
|
23553
23583
|
index = host_call_handler_tryAsHostCallIndex(22);
|
|
23554
|
-
|
|
23584
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23555
23585
|
tracedRegisters = host_call_handler_traceRegisters(IN_OUT_REG_1, IN_OUT_REG_2);
|
|
23556
23586
|
constructor(currentServiceId, partialState) {
|
|
23557
23587
|
this.currentServiceId = currentServiceId;
|
|
@@ -23617,7 +23647,7 @@ class Solicit {
|
|
|
23617
23647
|
currentServiceId;
|
|
23618
23648
|
partialState;
|
|
23619
23649
|
index = host_call_handler_tryAsHostCallIndex(23);
|
|
23620
|
-
|
|
23650
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23621
23651
|
tracedRegisters = host_call_handler_traceRegisters(solicit_IN_OUT_REG, 8);
|
|
23622
23652
|
constructor(currentServiceId, partialState) {
|
|
23623
23653
|
this.currentServiceId = currentServiceId;
|
|
@@ -23665,12 +23695,12 @@ class Solicit {
|
|
|
23665
23695
|
|
|
23666
23696
|
const transfer_IN_OUT_REG = 7; // `d`
|
|
23667
23697
|
const AMOUNT_REG = 8; // `a`
|
|
23668
|
-
const
|
|
23698
|
+
const TRANSFER_GAS_FEE_REG = 9; // `l`
|
|
23669
23699
|
const MEMO_START_REG = 10; // `o`
|
|
23670
23700
|
/**
|
|
23671
23701
|
* Transfer balance from one service account to another.
|
|
23672
23702
|
*
|
|
23673
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
23703
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/373f00373f00?v=0.7.2
|
|
23674
23704
|
*/
|
|
23675
23705
|
class Transfer {
|
|
23676
23706
|
currentServiceId;
|
|
@@ -23682,38 +23712,50 @@ class Transfer {
|
|
|
23682
23712
|
},
|
|
23683
23713
|
}));
|
|
23684
23714
|
/**
|
|
23685
|
-
* `g = 10 +
|
|
23686
|
-
*
|
|
23715
|
+
* `g = 10 + t`
|
|
23716
|
+
*
|
|
23717
|
+
* `t` has positive value, only when status of a transfer is `OK`
|
|
23718
|
+
* `0` otherwise
|
|
23719
|
+
*
|
|
23720
|
+
* Pre0.7.2: `g = 10 + ω9`
|
|
23721
|
+
*
|
|
23722
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/373f00373f00?v=0.7.2
|
|
23687
23723
|
*/
|
|
23688
|
-
|
|
23689
|
-
|
|
23690
|
-
|
|
23691
|
-
|
|
23692
|
-
tracedRegisters = host_call_handler_traceRegisters(transfer_IN_OUT_REG, AMOUNT_REG, ON_TRANSFER_GAS_REG, MEMO_START_REG);
|
|
23724
|
+
basicGasCost = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_2)
|
|
23725
|
+
? gas_tryAsSmallGas(10)
|
|
23726
|
+
: (regs) => gas_tryAsGas(10n + regs.get(TRANSFER_GAS_FEE_REG));
|
|
23727
|
+
tracedRegisters = host_call_handler_traceRegisters(transfer_IN_OUT_REG, AMOUNT_REG, TRANSFER_GAS_FEE_REG, MEMO_START_REG);
|
|
23693
23728
|
constructor(currentServiceId, partialState) {
|
|
23694
23729
|
this.currentServiceId = currentServiceId;
|
|
23695
23730
|
this.partialState = partialState;
|
|
23696
23731
|
}
|
|
23697
|
-
async execute(
|
|
23732
|
+
async execute(gas, regs, memory) {
|
|
23698
23733
|
// `d`: destination
|
|
23699
23734
|
const destination = getServiceId(regs.get(transfer_IN_OUT_REG));
|
|
23700
23735
|
// `a`: amount
|
|
23701
23736
|
const amount = regs.get(AMOUNT_REG);
|
|
23702
23737
|
// `l`: gas
|
|
23703
|
-
const
|
|
23738
|
+
const transferGasFee = common_tryAsServiceGas(regs.get(TRANSFER_GAS_FEE_REG));
|
|
23704
23739
|
// `o`: transfer memo
|
|
23705
23740
|
const memoStart = regs.get(MEMO_START_REG);
|
|
23706
23741
|
const memo = bytes_Bytes.zero(TRANSFER_MEMO_BYTES);
|
|
23707
23742
|
const memoryReadResult = memory.loadInto(memo.raw, memoStart);
|
|
23708
23743
|
// page fault while reading the memory.
|
|
23709
23744
|
if (memoryReadResult.isError) {
|
|
23710
|
-
logger_logger.trace `TRANSFER(${destination}, ${amount}, ${
|
|
23745
|
+
logger_logger.trace `TRANSFER(${destination}, ${amount}, ${transferGasFee}, ${memo}) <- PANIC`;
|
|
23711
23746
|
return host_call_handler_PvmExecution.Panic;
|
|
23712
23747
|
}
|
|
23713
|
-
const transferResult = this.partialState.transfer(destination, amount,
|
|
23714
|
-
logger_logger.trace `TRANSFER(${destination}, ${amount}, ${
|
|
23748
|
+
const transferResult = this.partialState.transfer(destination, amount, transferGasFee, memo);
|
|
23749
|
+
logger_logger.trace `TRANSFER(${destination}, ${amount}, ${transferGasFee}, ${memo}) <- ${result_resultToString(transferResult)}`;
|
|
23715
23750
|
// All good!
|
|
23716
23751
|
if (transferResult.isOk) {
|
|
23752
|
+
if (compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_2)) {
|
|
23753
|
+
// substracting value `t`
|
|
23754
|
+
const underflow = gas.sub(gas_tryAsGas(transferGasFee));
|
|
23755
|
+
if (underflow) {
|
|
23756
|
+
return host_call_handler_PvmExecution.OOG;
|
|
23757
|
+
}
|
|
23758
|
+
}
|
|
23717
23759
|
regs.set(transfer_IN_OUT_REG, results_HostCallResult.OK);
|
|
23718
23760
|
return;
|
|
23719
23761
|
}
|
|
@@ -23753,7 +23795,7 @@ class Upgrade {
|
|
|
23753
23795
|
currentServiceId;
|
|
23754
23796
|
partialState;
|
|
23755
23797
|
index = host_call_handler_tryAsHostCallIndex(19);
|
|
23756
|
-
|
|
23798
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23757
23799
|
tracedRegisters = host_call_handler_traceRegisters(upgrade_IN_OUT_REG, GAS_REG, ALLOWANCE_REG);
|
|
23758
23800
|
constructor(currentServiceId, partialState) {
|
|
23759
23801
|
this.currentServiceId = currentServiceId;
|
|
@@ -23796,7 +23838,7 @@ class Yield {
|
|
|
23796
23838
|
currentServiceId;
|
|
23797
23839
|
partialState;
|
|
23798
23840
|
index = host_call_handler_tryAsHostCallIndex(25);
|
|
23799
|
-
|
|
23841
|
+
basicGasCost = gas_tryAsSmallGas(10);
|
|
23800
23842
|
tracedRegisters = host_call_handler_traceRegisters(yield_IN_OUT_REG);
|
|
23801
23843
|
constructor(currentServiceId, partialState) {
|
|
23802
23844
|
this.currentServiceId = currentServiceId;
|
|
@@ -23832,7 +23874,7 @@ class fetch_Fetch {
|
|
|
23832
23874
|
currentServiceId;
|
|
23833
23875
|
fetch;
|
|
23834
23876
|
index = tryAsHostCallIndex(1);
|
|
23835
|
-
|
|
23877
|
+
basicGasCost = tryAsSmallGas(10);
|
|
23836
23878
|
tracedRegisters = traceRegisters(fetch_IN_OUT_REG, 8, 9, 10, 11, 12);
|
|
23837
23879
|
constructor(currentServiceId, fetch) {
|
|
23838
23880
|
this.currentServiceId = currentServiceId;
|
|
@@ -23989,7 +24031,7 @@ class info_Info {
|
|
|
23989
24031
|
currentServiceId;
|
|
23990
24032
|
account;
|
|
23991
24033
|
index = tryAsHostCallIndex(5);
|
|
23992
|
-
|
|
24034
|
+
basicGasCost = tryAsSmallGas(10);
|
|
23993
24035
|
tracedRegisters = traceRegisters(info_IN_OUT_REG, 8, OFFSET_REG, LEN_REG);
|
|
23994
24036
|
constructor(currentServiceId, account) {
|
|
23995
24037
|
this.currentServiceId = currentServiceId;
|
|
@@ -24064,7 +24106,7 @@ const decoder = new TextDecoder("utf8");
|
|
|
24064
24106
|
class log_LogHostCall {
|
|
24065
24107
|
currentServiceId;
|
|
24066
24108
|
index = tryAsHostCallIndex(100);
|
|
24067
|
-
|
|
24109
|
+
basicGasCost = tryAsSmallGas(0);
|
|
24068
24110
|
// intentionally not tracing anything here, since the message will be printed anyway.
|
|
24069
24111
|
tracedRegisters = traceRegisters();
|
|
24070
24112
|
constructor(currentServiceId) {
|
|
@@ -24106,7 +24148,7 @@ class lookup_Lookup {
|
|
|
24106
24148
|
currentServiceId;
|
|
24107
24149
|
account;
|
|
24108
24150
|
index = tryAsHostCallIndex(2);
|
|
24109
|
-
|
|
24151
|
+
basicGasCost = tryAsSmallGas(10);
|
|
24110
24152
|
tracedRegisters = traceRegisters(lookup_IN_OUT_REG, 8, 9, 10, 11);
|
|
24111
24153
|
constructor(currentServiceId, account) {
|
|
24112
24154
|
this.currentServiceId = currentServiceId;
|
|
@@ -24169,7 +24211,7 @@ class read_Read {
|
|
|
24169
24211
|
currentServiceId;
|
|
24170
24212
|
account;
|
|
24171
24213
|
index = tryAsHostCallIndex(3);
|
|
24172
|
-
|
|
24214
|
+
basicGasCost = tryAsSmallGas(10);
|
|
24173
24215
|
tracedRegisters = traceRegisters(read_IN_OUT_REG, 8, 9, 10, 11, 12);
|
|
24174
24216
|
constructor(currentServiceId, account) {
|
|
24175
24217
|
this.currentServiceId = currentServiceId;
|
|
@@ -24239,7 +24281,7 @@ class write_Write {
|
|
|
24239
24281
|
currentServiceId;
|
|
24240
24282
|
account;
|
|
24241
24283
|
index = tryAsHostCallIndex(4);
|
|
24242
|
-
|
|
24284
|
+
basicGasCost = tryAsSmallGas(10);
|
|
24243
24285
|
tracedRegisters = traceRegisters(write_IN_OUT_REG, 8, 9, 10);
|
|
24244
24286
|
constructor(currentServiceId, account) {
|
|
24245
24287
|
this.currentServiceId = currentServiceId;
|