diff --git a/crypto/vm/vm.h b/crypto/vm/vm.h index e67d54f1c..f202e55fa 100644 --- a/crypto/vm/vm.h +++ b/crypto/vm/vm.h @@ -118,6 +118,7 @@ class VmState final : public VmStateInterface { stack_entry_gas_price = 1, runvm_gas_price = 40, hash_ext_entry_gas_price = 1, + free_nested_cont_jump = 8, rist255_mul_gas_price = 2000, rist255_mulbase_gas_price = 750, @@ -366,14 +367,18 @@ class VmState final : public VmStateInterface { return cond ? c1_envelope(std::move(cont), save) : std::move(cont); } void c1_save_set(bool save = true); - void fatal(void) const { + void fatal() const { throw VmFatal{}; } int jump_to(Ref cont) { - int res = 0; + int res = 0, cnt = 0; while (cont.not_null()) { + cnt++; cont = cont->is_unique() ? cont.unique_write().jump_w(this, res) : cont->jump(this, res); } + if (global_version >= 9 && cnt > free_nested_cont_jump) { + consume_gas(cnt - free_nested_cont_jump); + } return res; } static Ref convert_code_cell(Ref code_cell); diff --git a/doc/GlobalVersions.md b/doc/GlobalVersions.md index 5feb49d8b..36d1ab360 100644 --- a/doc/GlobalVersions.md +++ b/doc/GlobalVersions.md @@ -114,4 +114,5 @@ Operations for working with Merkle proofs, where cells can have non-zero level a ## Version 9 - Fix `RAWRESERVE` action with flag `4` (use original balance of the account) by explicitly setting `original_balance` to `balance - msg_balance_remaining`. - - Previously it did not work if storage fee was greater than the original balance. \ No newline at end of file + - Previously it did not work if storage fee was greater than the original balance. +- Jumps to nested continuations of depth more than 8 consume 1 gas for eact subsequent continuation (this does not affect most of TVM code). \ No newline at end of file