EIP-2046 Gas reduction for static-call precompiles (Reduced gas cost for static calls made to precompiles)

No call decision · Fees & gas · EIP status Stagnant · created 2019-05-17

A proposal to lower the base gas cost of calling a precompile via STATICCALL from 700 to 40.

Why it is needed

The Spurious Dragon hard fork significantly raised the gas cost of CALL-family instructions to reflect the cost of loading contract code from state. However, precompiles were not made an exception at that time. Unlike regular contracts, precompiles do not need to load code from state and are always loaded, yet every call to them still cost the same 700 gas as a regular contract. As a result, precompiles with a total execution cost lower than 700 became inefficient to use, since the call cost itself exceeded the actual computation cost.

What changes

Today

After EIP-2046

Who is affected

In depth

Gas cost change rule

After the HF hard fork, the base gas cost of the STATICCALL (0xfa) instruction (denoted G_call in the Yellow Paper) varies depending on the destination address. If the destination falls within the precompile address range defined by EIP-1352, the cost is 40. A STATICCALL to any other address remains at the existing cost of 700.

Why only STATICCALL was changed

Only STATICCALL was modified, not CALL, in order to limit the scope of impact of the change. Because precompiles currently (at the time of this EIP's writing) have no state and cannot modify state, fixing only STATICCALL does not restrict the use cases for precompiles. However, contracts deployed before Byzantium are likely not to use STATICCALL at all, so such contracts do not benefit from this cost reduction.

Why the cost was set to 40 rather than 0

EIP-1109 proposed lowering the precompile call cost to 0, but this EIP keeps it at 40 instead of 0. The value of 40 is retained to represent the cost of the context switching that occurs when calling a precompile.

Backward compatibility

This change only reduces the cost and does not alter any other behavior, so it is backwards compatible. Because the cost remains at 40 rather than 0, it is not possible for a malicious proxy contract deployed before the hard fork to exploit this cost reduction to perform state-changing operations.

Relationship to earlier proposals

The problem of precompile call costs was addressed earlier by EIP-1109 and EIP-1231 before this EIP. EIP-1109 was later changed to an entirely different approach, and the author also proposed reverting EIP-1109 back to its original direction (removing precompile call costs). This EIP is an extension of that discussion.

Current status

This EIP is in Stagnant status, with concrete test cases or implementations left as TBA. It presupposes EIP-214 (which defines the STATICCALL instruction) and EIP-1352 (which specifies the precompile address range), and neither call records nor the source text indicate any decision to include it in a specific hard fork.

Original EIP · ← EIPs