EIP-2014 Extended State Oracle precompile (Extended State Oracle)

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

A proposal that, instead of adding a new opcode each time off-block data such as chainID needs to be queried, gathers functions into a single extensible precompiled contract (ESO) queried via ABI calls.

Why it is needed

Over the past several years, several proposals have emerged to expand the data the EVM can access, such as the block hash extension (EIP-210) and chainID lookup (EIP-1344). Adding a new opcode each time such a feature is needed consumes limited opcode space on rarely used features. Conversely, creating a new precompile (a special contract built into the client) each time requires defining a new interface and going through consensus every time, which is cumbersome. This proposal places an extensible standard ABI interface at a single address, so that whenever new chain data is needed, a function need only be added to that contract. This lets languages such as Solidity use this feature like an ordinary contract call, without needing dedicated syntax support.

What changes

Today

After EIP-2014

Who is affected

In depth

Location and calling convention of the ESO precompile

A new system contract (precompile) named ESO (Extended State Oracle) is introduced at address 0x0000000000000000000000000000000000000009. It is called via CALL or STATICCALL, with input and output following Contract ABI Encoding. Using elementary types is recommended to reduce complexity. It is currently defined purely as a stateless precompile, and this proposal does not propose turning it into an actual contract that holds state.

getCurrentChainId() function specification

getCurrentChainId() takes no arguments and returns the current chain identifier encoded as a uint64. In the ABI, its stateMutability is pure and payable is false, so sending value causes a revert per EIP-140. The function selector is 5cf0e8a4, and for Ethereum mainnet it returns 0000000000000000000000000000000000000000000000000000000000000001, representing chainID 1.

Relationship to EIP-1344 and EIP-140

The chainID lookup feature itself was previously proposed separately in EIP-1344 as an opcode (CHAINID). This proposal differs in that it provides the same data through a function call via the ESO precompile rather than an opcode. It lists EIP-140 as a requirement, carrying over the rule that a non-payable function call reverts if it includes value.

Potential future extension to a stateful ESO

While the ESO is currently a stateless precompile, the text notes that it could in the future be extended to receive transactions from a system address and store data. This resembles the approach previously proposed by EIP-210. For proposals that would add new state data to state that does not belong to a block or transaction, extending the ESO is the recommended direction. It states that once enough extensions have accumulated and state actually becomes necessary, moving away from a precompile to an actual contract with real code could also be considered.

Potential chainID validation interface

It is also noted that it would be possible to add a separate interface to the ESO for checking whether a chain ID was valid at a specific block point or in chain history, citing EIP-1959 and EIP-1965 as references. However, this proposal itself contains no concrete specification, only the possibility is noted.

Unfinished items and current status

The Rationale, Backwards Compatibility, Test Cases, and Implementation sections all remain TBA (to be announced), so the detailed design has not been finalized. This EIP's status is Stagnant, meaning discussion has halted. Therefore the content here may change or may never be adopted.

Original EIP · ← EIPs