Skip to content

Commit

Permalink
Consume gas in VmState::jump_to
Browse files Browse the repository at this point in the history
  • Loading branch information
SpyCheese committed Sep 23, 2024
1 parent e04965c commit 2cca7fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions crypto/vm/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<Continuation> 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<CellSlice> convert_code_cell(Ref<Cell> code_cell);
Expand Down
3 changes: 2 additions & 1 deletion doc/GlobalVersions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- 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).

0 comments on commit 2cca7fd

Please sign in to comment.