EIP-7557 Distribution of block-level state access costs (Block-level Warming with fair cost savings)
No call decision · Fees & gas · EIP status Stagnant · created 2023-10-01
When multiple transactions in the same block first access the same address or storage slot, only one cold access gas fee is actually burned per block, and the rest is fairly refunded to the senders who participated.
Why it is needed
EIP-2929 introduced a model that charges an expensive cold cost on the first access to an address or storage slot within a transaction, and a cheap warm cost on subsequent accesses. But while a validator only needs to actually read a given piece of state once per block, every transaction that touches that state pays the full cold cost separately. EIP-2930's accessList lets you prepay this cost, but each transaction still bears it individually. Once verkle trees (EIP-6800) are introduced, the cost of reading large contracts is expected to rise sharply. As account abstraction spreads, smart contract accounts that share the same wallet code will have to pay the full code loading cost every time, putting them at a disadvantage compared to EOAs, which run validation logic for free. This duplicated charging leads to excessive base fee burn for users and unwarranted excess profit for block builders.
What changes
Today
- When multiple transactions in the same block make a cold access to the same address or slot, each pays the full cost (COLD_ACCOUNT_ACCESS_COST, COLD_SLOAD_COST) separately.
- A validator only needs to read the state once per block, but users bear the cost redundantly.
- Once EIP-6800 is applied, charging per code chunk could push the cost of accessing a large contract from 2600 gas up to 158600 gas.
- Smart contract accounts that share the same wallet implementation pay the full code loading cost every time, putting them at a disadvantage compared to EOAs, whose validation logic is free.
After EIP-7557
- The block builder collects the accessList of every transaction in the block and aggregates, for each sender who accessed the same address or slot, the priorityFeePerGas each of them paid.
- As the final operation of the block, the burned portion of the cold access cost and the excess priority fee are refunded proportionally to the participating senders.
- The effective gas cost drops for transactions that call contracts with a lot of code or that call shared wallet code.
- The refund shows up as a balance change in the next block; nothing changes in the observable behavior during transaction execution.
Who is affected
- Ordinary users: Sending a transaction that accesses the same contract or storage slot as other people reduces your gas cost.
- Wallet and Account Abstraction Developers: The gas cost disadvantage that smart contract accounts sharing the same wallet implementation code had compared to EOAs is reduced.
- Block builders/validators: The accessLists must be aggregated to calculate the refund, and a cost redistribution operation must be processed additionally at the end of the block.
- Client teams: A block_access_list field must be added to execution_payload, and logic implementing per-transaction accessLists as compressed 2-byte references must be built.
In depth
Aggregating the access list and participants
The block builder reads the accessList of every transaction included in the block and builds a data structure that, for each accessed address and each storage slot, collects the list of senders who touched it and the priorityFeePerGas each sender paid. A single sender may appear multiple times for the same entry with different priorityFeePerGas values. This aggregation becomes the input for all subsequent refund calculations.
Base fee refund and the minimum cost floor
Since the actual computation required for a cold access to the same address or slot is the same no matter how many people access it, the protocol only needs to burn that cost once. Since every transaction pays the same baseFeePerGas, the cost of a single cold access is divided by the number of accessing transactions, and the remainder is refunded. However, if the number of accessors grows too large, the per-person cost could become low enough to be exploited as a DoS vector, so the gas cost per entry does not drop below MIN_ACCESS_LIST_ENTRY_COST, which is 32 gas. This value matches the calldata cost of referencing an entry as 2 bytes in block_access_list.
The priorityFee refund algorithm
For a given cold access, the validator is rewarded only once, based on the transaction that paid the highest priorityFeePerGas. The priorityFee paid by the remaining senders is returned to each according to their marginal contribution ratio. Marginal contribution is defined as the difference in total gains between the transaction being included in the block and being excluded from it (MCi = v(S∪{i}) - v(S)), and in actual computation it always works out to priorityFee x gasCost. A standalone access that no transaction shares has a marginal contribution of zero and is not eligible for a refund.
Compressed storage via block_access_list
Once block level warming is introduced, the cost of adding an entry to an accessList becomes very cheap, which could be exploited to bloat block size. To prevent this, a new field called block_access_list is added to execution_payload, storing each unique address or slot entry that appears anywhere in the block only once, and each transaction's accessList is replaced with a 2-byte reference pointing into block_access_list instead of the original entries. What is shown in the RPC API does not change; clients decompress it on the fly for display.
The cost redistribution system operation
Similar to how EIP-4895 handles beacon chain withdrawals as a system-level operation, this proposal introduces a new system operation called cost redistribution. This operation is processed after every user transaction in the block has executed. It increases the balance of each address eligible for a refund by the sum of reimbursementFromBurn and reimbursementFromCoinbase, and decreases the coinbase balance by the total reimbursementFromCoinbase paid out.
Response to post-EIP-6800 code chunk charging
Once EIP-6800 is applied, the cost of a cold account access will no longer be the fixed COLD_ACCOUNT_ACCESS_COST (currently 2600 gas) but will instead depend on the number of 31-byte chunks that make up the contract's code. Each chunk incurs CODE_CHUNK_ACCESS_COST (currently 200 gas). Based on EIP-170's maximum contract size of 24576 bytes, the access cost could rise from 2600 gas to as much as 158600 gas. In that case, accessList would need to be changed so it can specify which code chunks are being accessed. The refund calculation would also be extended the same way, to redistribute the shared cost on a per-chunk basis.
Nothing changes during execution; settlement happens only at the end of the block
This does not use an approach like the SSTORE refund, which returns gas immediately during transaction execution. That's because if whether a transaction is included changes the outcome of earlier transactions in the block, finding a valid set of transactions becomes computationally hard for the block builder. So the refund is applied all at once after every transaction in the block has finished executing. Its effect is only observed in the next block. Nothing changes in the observable behavior of smart contract execution. This EIP is currently in Stagnant status, with no active ongoing discussion.