EIPs Explained

EIP-7069 · Stagnant · Core · 2023-05-05

EIP-7069: Revamped CALL instructions

Part of the stagnant EOF upgrade: new EXTCALL, EXTDELEGATECALL and EXTSTATICCALL opcodes with no gas argument, no output buffer and status codes, plus RETURNDATALOAD.

What problem does it solve?

The legacy CALL, DELEGATECALL and STATICCALL opcodes carry a lot of history:

  • The caller chooses how much gas to forward. Contracts that hard-coded small gas amounts broke when opcodes were repriced (for example in EIP-1884), and no amount of extra transaction gas could fix them. It also makes gas observable, which ties contract behaviour to the gas schedule.
  • Value-bearing calls get a special 2300-gas stipend with fiddly cost rules.
  • Calls take an output-memory region that is redundant since RETURNDATACOPY (EIP-211) and has caused bugs, for example with tokens that return nothing.
  • The result is a bare boolean, so a revert cannot be told apart from an out-of-gas failure.

EIP-7069 introduces replacement instructions for EVM Object Format (EIP-3540) code, where the legacy call opcodes are disallowed.

How it works

Opcode Byte Stack inputs
EXTCALL 0xf8 target, input_offset, input_size, value
EXTDELEGATECALL 0xf9 target, input_offset, input_size
EXTSTATICCALL 0xfb target, input_offset, input_size
RETURNDATALOAD 0xf7 offset → 32-byte word of return data (zero-padded)
  • No gas argument. The callee gets all remaining gas minus max(gas/64, 5000) retained by the caller (EIP-150's 63/64 rule plus a floor). If that leaves the callee less than 2300 gas, the call fails "lightly".
  • No stipend. The uniform 2300-gas callee minimum replaces it. Sending value costs a flat extra 9000 gas; creating a new account costs 25000.
  • Status codes instead of a boolean: 0 success, 1 revert (or light failure: insufficient balance, depth 1024, too little callee gas), 2 failure (callee consumed all gas). The scheme can be extended later.
  • Address checks. A target with non-zero high 12 bytes halts rather than being silently truncated.
  • EXTDELEGATECALL may only target EOF code, so EOF contracts can never be destroyed via a delegated SELFDESTRUCT.
  • Inside EOF, RETURNDATACOPY zero-pads out-of-bounds reads instead of halting.

Access costs follow EIP-2929: 100 gas warm, 2600 cold.

Sample code

EOF-style pseudo-assembly calling a token's balanceOf and reading the result:

// memory[0:36] already holds balanceOf(address) calldata
PUSH1 0x24        // input_size  = 36
PUSH0             // input_offset = 0
PUSH20 <token>    // target
EXTSTATICCALL     // pushes status: 0 ok, 1 revert, 2 failure
ISZERO
RJUMPI ok         // EOF relative jump if status == 0
// ... handle failure ...
ok:
PUSH0
RETURNDATALOAD    // first 32-byte word of the return data = balance

Note the stack order: arguments are pushed in reverse so target ends up on top.

Things to know

  • Status is Stagnant. The opcodes exist only inside EOF containers and are undefined in legacy code. The EOF bundle (see the meta EIP-7692) was considered for, then removed from, the Fusaka upgrade, so none of this is live on mainnet.
  • Because gas cannot be capped per call, "send only 2300 gas" is no longer a reentrancy guard. The spec recommends transient-storage locks (EIP-1153) instead.
  • CALLCODE gets no counterpart; it is deprecated.
  • Legacy contracts are unaffected: no existing opcode changes behaviour outside EOF.

#evm #eof #opcodes #gas #stagnant

Details

Authors
Alex Beregszaszi (@axic), Paweł Bylica (@chfast), Danno Ferrin (@shemnon), Andrei Maiboroda (@gumb0), Charles Cooper (@charles-cooper)
Status
Stagnant
Type
Standards Track / Core
Created
2023-05-05
Requires
Required by

Machine-readable: Markdown · JSON