Skip to content

Commit 2cca7fd

Browse files
committed
Consume gas in VmState::jump_to
1 parent e04965c commit 2cca7fd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

crypto/vm/vm.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class VmState final : public VmStateInterface {
118118
stack_entry_gas_price = 1,
119119
runvm_gas_price = 40,
120120
hash_ext_entry_gas_price = 1,
121+
free_nested_cont_jump = 8,
121122

122123
rist255_mul_gas_price = 2000,
123124
rist255_mulbase_gas_price = 750,
@@ -366,14 +367,18 @@ class VmState final : public VmStateInterface {
366367
return cond ? c1_envelope(std::move(cont), save) : std::move(cont);
367368
}
368369
void c1_save_set(bool save = true);
369-
void fatal(void) const {
370+
void fatal() const {
370371
throw VmFatal{};
371372
}
372373
int jump_to(Ref<Continuation> cont) {
373-
int res = 0;
374+
int res = 0, cnt = 0;
374375
while (cont.not_null()) {
376+
cnt++;
375377
cont = cont->is_unique() ? cont.unique_write().jump_w(this, res) : cont->jump(this, res);
376378
}
379+
if (global_version >= 9 && cnt > free_nested_cont_jump) {
380+
consume_gas(cnt - free_nested_cont_jump);
381+
}
377382
return res;
378383
}
379384
static Ref<CellSlice> convert_code_cell(Ref<Cell> code_cell);

doc/GlobalVersions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,5 @@ Operations for working with Merkle proofs, where cells can have non-zero level a
114114
## Version 9
115115

116116
- Fix `RAWRESERVE` action with flag `4` (use original balance of the account) by explicitly setting `original_balance` to `balance - msg_balance_remaining`.
117-
- Previously it did not work if storage fee was greater than the original balance.
117+
- Previously it did not work if storage fee was greater than the original balance.
118+
- Jumps to nested continuations of depth more than 8 consume 1 gas for eact subsequent continuation (this does not affect most of TVM code).

0 commit comments

Comments
 (0)