EIP-7650 Programmable access list (Programmable access lists)
No call decision · Fees & gas · EIP status Stagnant · created 2024-03-10
Lets a contract call the prefetch precompile during execution to pre-register addresses and storage keys it will use into the access list, pulling in data at lower gas cost than an external access would.
Why it is needed
Ethereum's EIP-2930 lets a transaction declare, in advance, a list of addresses and storage keys it will access. However, this list must be set externally when the transaction is created, so it cannot be used when a contract's internal logic dynamically determines which keys or addresses are needed based on the execution flow. For example, UniswapV2's swap() function reads token addresses and storage slots one by one in sequence; if a node could prefetch these in parallel ahead of time, it would save gas. This EIP adds a prefetch precompile that lets a contract declare during execution, 'I will use this key and address,' making use of a node's concurrent processing capability and lowering cold access costs.
What changes
Today
- EIP-2930 access lists can only be specified externally when sending a transaction.
- Addresses and keys that a contract's internal logic dynamically needs cannot be reflected in the access list.
- When a contract accesses an external address or a storage key it is using for the first time, it pays the full cold cost (2600, 2100).
After EIP-7650
- A contract can call the prefetch precompile during execution to add local storage keys and addresses to the access list.
- The node reads up to CONCURRENCY keys/addresses at once, charging the cold cost divided by the degree of concurrency.
- When that same key or address is actually read afterward, only EIP-2929's WARM_STORAGE_READ_COST applies.
Who is affected
- Contract developer: Functions like swap() that read multiple storage slots and external addresses in sequence can call prefetch to save gas.
- Client teams: The prefetch precompile and the logic for reading storage and addresses concurrently must be implemented.
- Users: Contracts that use prefetch can execute transactions at lower gas cost.
- Validators and node operators: IO processing capacity capable of reading storage and addresses concurrently, up to CONCURRENCY at a time, becomes necessary.
In depth
Input format of the prefetch precompile
The prefetch precompile, placed at PREFETCH_PRECOMPILE_ADDRESS, takes input in the format [32-byte count of local storage keys n][n*32-byte local storage keys][32-byte count of addresses m][m*32-byte addresses]. The storage keys can only refer to local slots of the calling contract itself, while the addresses can include addresses of other contracts. When called, the node adds these keys and addresses to EIP-2929's accessed_storage_keys and accessed_addresses global sets.
Concurrency-based gas charging
At call start, charges 2100 * (N + CONCURRENCY - 1) // CONCURRENCY + 2600 * (M + CONCURRENCY - 1) // CONCURRENCY gas. N is the number of storage keys not yet in accessed_storage_keys, and M is the number of addresses not yet in accessed_addresses. // is integer division, and CONCURRENCY is a constant representing how many the node can process simultaneously, with its value still TBD. Charging for this batched, divided value is cheaper than charging for each cold access individually.
Subsequent access is warm cost
The cost of actually reading a key or address once it has been added to the list via prefetch follows EIP-2929's WARM_STORAGE_READ_COST. In other words, once the discounted cold cost has been paid once in the prefetch call, the actual SLOAD or external call does not pay the cold cost again.
Why only local storage keys are accepted
Unlike EIP-2930, prefetch does not accept storage keys of external contracts, only local storage keys and addresses of the calling contract itself. Assuming knowledge of an external contract's storage slot layout is not good practice. Pre-fetching data from an external contract would require a mechanism that accepts a list of static calls along with calldata, which this EIP states could be addressed in a future separate EIP rather than this one.
Duplicates allowed in the list
As with EIP-2930, the list of storage keys and addresses passed to prefetch may contain duplicates. This choice avoids requiring duplicate checks, keeping the implementation simple.
Calls before implementation are no-ops
On a chain where this EIP has not yet been implemented, calling the prefetch precompile address does nothing (no operation). This means no separate backward compatibility handling is needed.
Status and undetermined values
This EIP's status is Stagnant, and all three constants FORK_BLOCK_NUMBER, PREFETCH_PRECOMPILE_ADDRESS, and CONCURRENCY remain TBD. Whether it will be included in a fork, as well as the specific deployment address and concurrency value, have not been determined, and no inclusion decision has been made at core developer calls.