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

After EIP-7557

Who is affected

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.

Original EIP · ← EIPs