Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(EOF): MIN_CALLEE_GAS light failure, static-mode check #1599

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
readd min caller gas
rakita committed Jul 10, 2024

Verified

This commit was signed with the committer’s verified signature.
caarlos0 Carlos Alexandro Becker
commit 212ca3dbef790122beecab46508fe4042ce9540b
14 changes: 14 additions & 0 deletions crates/interpreter/src/instructions/contract.rs
Original file line number Diff line number Diff line change
@@ -183,6 +183,20 @@ pub fn extcall_gas_calc<H: Host + ?Sized>(
let gas_reduce = max(interpreter.gas.remaining() / 64, 5000);
let gas_limit = interpreter.gas().remaining().saturating_sub(gas_reduce);

// The MIN_CALLEE_GAS rule is a replacement for stipend:
// it simplifies the reasoning about the gas costs and is
// applied uniformly for all introduced EXT*CALL instructions.
//
// If Gas available to callee is less than MIN_CALLEE_GAS trigger light failure (Same as Revert).
if gas_limit < MIN_CALLEE_GAS {
// Push 1 to stack to indicate that call light failed.
// It is safe to ignore stack overflow error as we already popped multiple values from stack.
let _ = interpreter.stack_mut().push(U256::from(1));
interpreter.return_data_buffer.clear();
// Return none to continue execution.
return None;
}

gas!(interpreter, gas_limit, None);
Some(gas_limit)
}