EIP-1109 The PRECOMPILEDCALL opcode (PRECOMPILEDCALL opcode (Remove CALL costs for precompiled contracts))

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

A proposal to create a dedicated opcode, PRECOMPILEDCALL (0xfb), that only calls precompiled contracts, charging just the base 2 gas plus the precompile's own gas, without the 700-gas overhead attached to a regular CALL.

Why it is needed

Calling a precompiled contract (a contract built into the EVM to handle specific operations at a low level, such as SHA256 or ECADD) currently requires using the regular CALL opcode. Because CALL itself consumes 700 gas, even a precompile with an intrinsic cost of 60 gas, like SHA256, or 500 gas (50 gas under the EIP-1108 proposal), like ECADD, ends up costing at least 700 gas to actually call. As a result, it is effectively impossible to design a precompile whose effective cost is cheaper than 700 gas. This EIP aims to remove this unnecessary overhead by providing a separate call path dedicated to precompiles.

What changes

Today

After EIP-1109

Who is affected

In depth

Opcode definitions

The new opcode PRECOMPILEDCALL has the value 0xfb, taking the number immediately after STATICCALL (0xfa). The original text states it activates when block.number >= XXXXX, but the actual block number remains an unconfirmed placeholder (XXXXX).

Stack inputs and outputs

The opcode takes 5 values from the stack. mu_s[0] is the address of the precompile to call, mu_s[1] is the memory pointer to the input parameters, mu_s[2] is the length of the input parameters in bytes, mu_s[3] is the memory pointer where the output is stored, and mu_s[4] is the length of the output buffer. After execution, only a single word is returned on the stack: 1 on success, 0 on failure.

Gas cost calculation

Gas cost equals Gbase (2) plus the intrinsic gas cost defined in the given precompile contract. Since precompiles do not execute EVM opcodes, there is no need to pass a separate gas parameter on the stack as with a normal CALL. If the remaining gas is less than 2 plus the intrinsic gas, the context immediately halts with an Out of Gas error.

Failure conditions and absence of stack check

There are two cases where the call returns 0: when mu_s[0] points to an undefined precompile address, or when the precompile itself fails according to its own definition (for example, due to invalid input parameters). The spec states explicitly that this opcode has no stack check.

Calling a regular address or contract

If PRECOMPILEDCALL is used to call a regular account or a regular smart contract, it is treated as a call to an undefined precompile. The VM MUST NOT execute that address, and the opcode MUST return 0x0.

Backward compatibility

Calling a precompile via the existing CALL (0xf1) still works exactly as before, and this EIP is backward compatible. Only contracts that use the new opcode get the reduced cost; existing contracts are unaffected.

Current status

This EIP is in Stagnant status, and its Implementation entry still reads Not implemented yet, meaning it has not been implemented. The activation block number is also only given as a placeholder (XXXXX), so the source material does not state whether it has actually been adopted or included in any specific hard fork.

Original EIP · ← EIPs