cast::revm::interpreter::gas

Function call_cost

pub const fn call_cost(
    spec_id: SpecId,
    transfers_value: bool,
    account_load: AccountLoad,
) -> u64
Expand description

Calculate call gas cost for the call instruction.

There is three types of gas.

  • Account access gas. after berlin it can be cold or warm.
  • Transfer value gas. If value is transferred and balance of target account is updated.
  • If account is not existing and needs to be created. After Spurious dragon this is only accounted if value is transferred.

account_load.is_empty will be accounted only if hardfork is SPURIOUS_DRAGON and there is transfer value.

This means that crate::OpCode::EXTSTATICCALL, crate::OpCode::EXTDELEGATECALL that dont transfer value will not be effected by this field.

crate::OpCode::CALL, crate::OpCode::EXTCALL use this field.

While crate::OpCode::STATICCALL, crate::OpCode::DELEGATECALL, crate::OpCode::CALLCODE need to have this field hardcoded to false as they were present before SPURIOUS_DRAGON hardfork.