EIP-7664 Access key opcode (Access-Key opcode)
No call decision · EVM & execution · EIP status Withdrawn · created 2024-03-27
A proposal to let smart contracts read values pre declared in a transaction's access-list directly via a new ACCESS_KEY opcode. It was withdrawn, judged to be a niche use case.
Why it is needed
Today, application layer contracts rely on tx.origin to check whether input came from a transaction's top-level call, a practice the account abstraction camp discourages. Meanwhile, the access-list introduced by EIP-2930 lets a transaction pre declare which addresses and keys it will access, but in practice it is used almost solely for gas cost reduction and is otherwise barely utilized. This proposal attempted to let contracts read access-list values directly, so a contract could reliably confirm that input was statically declared before block construction, without roundabout methods like relying on tx.origin or inferring gas consumption.
What changes
Today
- To confirm static declaration of input, a contract has to indirectly infer top-level call status via tx.origin
- The access-list affects only gas cost, with no way for a contract to query it directly during execution
- The access-list feature is barely used for anything beyond gas savings
After EIP-7664
- The ACCESS_KEY opcode lets tx.access_list[address][index] be loaded directly onto the stack
- Static declaration of input can be confirmed without relying on tx.origin or estimating gas consumption
- Values held in the access-list could have been used as witness data to support statelessness
Who is affected
- Smart contract developers: Top-level call verification logic that relied on tx.origin could have been replaced with ACCESS_KEY
- L2s / block builders: Block construction techniques based on statically declared input could have been leveraged
- Client teams: A single new opcode (0x4B) had to be added to the EVM, but access-list encoding and RPC would not need to change
In depth
Opcode specification
ACCESS_KEY_OPCODE_BYTE is 0x4B, with a fixed gas cost of 3 given by ACCESS_KEY_OPCODE_GAS. It pops an index (big-endian uint256) from the stack, and if the executing address is in the transaction's access-list and index < len(tx.access_list[address]), it pushes the value tx.access_list[address][index]. If the condition is not met, it pushes a zero filled bytes32. The intrinsic gas cost of the transaction's own access-list content is unchanged.
Rationale for the gas cost
ACCESS_KEY_OPCODE_GAS is priced at 3 gas, the same as EIP-4844's BLOBHASH opcode. Both opcodes share the same structure of popping an index-like value from the stack and pushing a 32 byte word based on a list carried in the transaction. However, BLOBHASH's own logic cannot be reused, since this EIP's purpose is accessing a statically declared hash value, not the cost of the blob itself.
Background of the proposal
Until now, application layer contracts have relied on tx.origin, against the usual recommendation from the account abstraction camp, to check whether a transaction is a top-level call, indirectly guaranteeing in the process that contract input was encoded as the transaction's input. The access-list directly affects execution but currently only affects gas cost. This EIP sought to provide the property that contract input was statically declared, without relying on top-level call detection, tx.origin, or gas introspection, moving a step closer to the 'transition toward static state access' goal mentioned in EIP-2930.
Relationship to EIP-1153's TLOAD
Like EIP-1153's TLOAD, ACCESS_KEY gives a contract a global view available throughout the entire message execution of a transaction. Unlike TLOAD, however, the value ACCESS_KEY reads is read only, and it is guaranteed never to change during transaction execution.
Reason for the name ACCESS_KEY
The access-list currently only supports a list of access-keys, and since this list's ordering is not enforced, index based lookup is possible. This opcode is named ACCESS_KEY because, unlike LOAD family opcodes such as SLOAD or TLOAD that fetch a value from storage, it returns a single key from a list.
Backwards compatibility and security
This proposal does not change access-list encoding or existing transaction types. Since EIP-2930, access-list content has already been usable within the EVM execution context and related RPC methods, so no major changes to EVM context construction or RPC are needed. From a security standpoint, since the access-list property was already gas metered under EIP-2930 and the EVM already had access to it when determining storage gas costs, no new denial of service risk is introduced, and the access scope is strictly limited to the contract that would perform a warm SLOAD, so storage layout abstraction does not leak across contracts.
Current status
This EIP is in the Withdrawn state. The stated reason for withdrawal is that it is a niche use case and could be better implemented via EIP-7702. It lists EIP-1153, EIP-2930, and EIP-4844 as requires, and the standardization process has been discontinued.