EIP-7069 Overhaul of call instructions including EXTCALL (Revamped CALL instructions)

No call decision · EVM & execution · EIP status Stagnant · created 2023-05-05

Introduces EXTCALL, EXTDELEGATECALL, EXTSTATICCALL, and RETURNDATALOAD for EOF code only, removing the ability to specify gas directly on a call and returning a status code that distinguishes success, revert, and failure.

Why it is needed

The existing CALL-family instructions let the caller directly set the amount of gas passed to the callee. But whenever gas fees changed (for example, the storage gas increase in EIP-1884), contracts that sent calls with a hardcoded gas value repeatedly broke. Even if the caller sent extra gas, the fixed gas limit on the call meant the problem could not be fixed. In addition, the old approach of specifying an output buffer address for the call's result has seen less use since the introduction of RETURNDATACOPY, and it has also caused bugs such as inconsistent handling of return values across ERC-20 implementations. Within EOF format code, the existing CALL family is blocked and replaced with new call instructions that cannot specify gas directly, so that contracts will not break even if gas fees are adjusted in the future.

What changes

Today

After EIP-7069

Who is affected

In depth

Four new instructions

Introduces EXTCALL (0xf8, arguments target_address, input_offset, input_size, value), EXTDELEGATECALL (0xf9, target_address, input_offset, input_size), EXTSTATICCALL (0xfb, same arguments), and RETURNDATALOAD (0xf7, offset). All four instructions are undefined in legacy code and can only be used in EOF code. The existing CALL, DELEGATECALL, STATICCALL, and CALLCODE are rejected during EOF validation.

Removal of gas selection and the 63/64 rule

EXT*CALL does not let the caller specify the amount of gas passed to the callee. Instead, the value obtained by subtracting max(floor(gas/64), MIN_RETAINED_GAS=5000) from the remaining gas is given to the callee, and if this value is less than MIN_CALLEE_GAS=2300, the call is not executed and ends with status code 1. The existing CALL's 2300 gas stipend was only given when transferring value, but MIN_CALLEE_GAS is a replacement mechanism applied equally to all four instructions.

RETURNDATALOAD and RETURNDATACOPY padding

RETURNDATALOAD costs 3 gas and reads 32 bytes starting at offset from the return data buffer onto the stack. If offset+32 exceeds the buffer length, the missing part is padded with zeros. Within EOF code, RETURNDATACOPY is changed the same way: even if offset+size exceeds the buffer length, the excess is padded with zeros instead of causing an exceptional abort, and the gas cost is fixed at 3*num_words(size) regardless of the number of bytes actually copied. RETURNDATACOPY in legacy code remains unchanged.

Removal of the output buffer parameter

EXT*CALL has no output buffer address argument for the result. Retrieving results via RETURNDATACOPY and RETURNDATASIZE (EIP-211) is already widely used, and the older approach using an output buffer has caused bugs such as inconsistent return value handling across ERC-20 implementations. The MLOAD combination previously used even when the return value size was fixed is replaced by RETURNDATALOAD alone.

Status codes 0/1/2

The existing CALL family returns a boolean value of 1 for success and 0 for failure, which the Solidity compiler used as a branch condition, making it hard to add new code. EXT*CALL returns one of three codes: success (0), revert (1), or failure (2). The reason revert by the callee and a lightweight failure due to the call itself not meeting its conditions are both grouped under 1 is to preserve the existing CALL behavior, where both cases preserve remaining gas and do not need to be distinguished from the caller's perspective. 2 means an exceptional failure where all gas was consumed during the callee's execution.

Handling of the upper 12 bytes of target_address

The existing CALL family simply ignored (masked) the upper bytes when an address value exceeding 20 bytes was supplied. EXT*CALL causes an exceptional abort if the upper 12 bytes of target_address contain a nonzero value. This removes the need to separately handle sending value to a nonexistent address, and also removes the need for warm_access_list to track values other than 20 bytes.

EOF1 contracts can only EXTDELEGATECALL EOF1 contracts

If the target_address account has no EOF code (even with an EIP-7702 delegation in place, this is checked by interpreting it as with EXTCALL), EXTDELEGATECALL fails lightly with status code 1. Legacy contracts could be self-destructed via three paths: SELFDESTRUCT, CALLCODE, and DELEGATECALL. EIP-3670 already blocked the first two, and this restriction further ensures that EOF1 contracts cannot be destroyed via the DELEGATECALL path either.

Current status

This EIP is currently classified as Stagnant, meaning active discussion has stopped, and details may change before it is finalized as a standard.

Original EIP · ← EIPs