revm_interpreter::gas

Function call_cost

Source
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 [bytecode::opcode::EXTSTATICCALL], [bytecode::opcode::EXTDELEGATECALL] that dont transfer value will not be effected by this field.

[bytecode::opcode::CALL], [bytecode::opcode::EXTCALL] use this field.

While [bytecode::opcode::STATICCALL], [bytecode::opcode::DELEGATECALL], [bytecode::opcode::CALLCODE] need to have this field hardcoded to false as they were present before SPURIOUS_DRAGON hardfork.