EIP-2970 Adding the IS_STATIC opcode (IS_STATIC opcode)
No call decision · EVM & execution · EIP status Stagnant · created 2020-09-13
A proposal to add the IS_STATIC opcode to the EVM. This opcode directly reports whether the current execution is inside a static call (STATICCALL) that cannot modify state.
Why it is needed
The EVM currently has no direct way to check whether the current execution is inside a STATICCALL, i.e. a static context in which state cannot be changed. Determining this requires a hacky technique: making a CALL with limited gas, executing a single LOG inside it, then terminating, and inferring the answer from whether the CALL succeeds or fails. This technique is fragile to even small changes in gas cost and wastes gas unnecessarily. In particular, extending EIP-2938 account abstraction so that an account accepts safe static calls that do not change state while blocking calls that do change state requires the contract to reliably know whether it is in a static context.
What changes
Today
- Determining whether a call is static requires a hacky technique: making a CALL with limited gas and executing a LOG to observe success or failure
- This technique breaks if gas costs change and wastes gas
- There is no guarantee that code behaves identically in static and non-static contexts
After EIP-2970
- A single IS_STATIC (0x4A) opcode directly checks whether the current context is static
- It pushes 1 onto the stack if static, 0 otherwise
- Logic for account abstraction contracts can be made safe, by allowing only static calls and blocking calls that change state
Who is affected
- Contract developer: Logic can be written that directly determines whether the current call is static, without gas hacks
- Implementers of account abstraction (EIP-2938): A security model can be built where an account allows safe static calls while blocking calls that change state
- Client teams: A new opcode 0x4A must be added to the EVM
In depth
Opcode definitions
IS_STATIC is added at address 0x4A. It pushes 1 onto the stack if the current execution context is a STATICCALL or a descendant of one, meaning state-changing operations are disallowed, and 0 otherwise
Background and motivation
The primary purpose of this proposal is to extend EIP-2938 account abstraction so that an account can accept incoming static calls, which are harmless to AA's security model, while blocking calls that change state
Limitations of the existing approach
Currently, one technique can be used to guess whether the context is static: making a CALL with limited gas, executing a single LOG inside it, then terminating. If the context is static, the CALL fails leaving 0 on the stack; if non-static, the CALL succeeds. However, this technique is vulnerable to changes in gas cost and wastes gas unnecessarily.
Invariant provided
The existing approach offers no guarantee that code behaves identically in static and non-static contexts, barring an execution failure. Using IS_STATIC allows checking whether the context is static directly and unambiguously.
Status and remaining work
This EIP leaves both Backwards Compatibility and Security Considerations as TBD, and its status is Stagnant. No further review or decisions have proceeded.