Skip to content

Commit

Permalink
piecrust: preservation of caller's economic mode
Browse files Browse the repository at this point in the history
  • Loading branch information
miloszm committed Apr 29, 2024
1 parent 0df33b4 commit ec7ffa8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions piecrust/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ pub(crate) fn c(
// copy back result
callee.read_argument(&mut memory[argbuf_ofs..][..ret_len as usize]);
callee.read_eco_mode_buf(&mut memory[eco_mode_ofs..][..ECO_MODE_LEN]);
// if depth of the stack is 3 or more, economic mode is not read
const ECO_STACK_DEPTH: usize = 2;
if env.nth_from_top(ECO_STACK_DEPTH).is_some() {
callee.clear_eco_mode();
}

let callee_remaining = callee.get_remaining_gas();
let callee_spent = callee_limit - callee_remaining;
Expand Down

0 comments on commit ec7ffa8

Please sign in to comment.