EIP-4396 · Stagnant · Core · 2021-10-28
EIP-4396: Time-Aware Base Fee Calculation
Proposed scaling EIP-1559's per-block gas target by the actual time since the previous block, so missed slots do not cause fake fee spikes or permanently lost throughput.
What problem does it solve?
EIP-1559 raises or lowers the base fee depending on whether the parent block used more or less than a fixed gas target. That target is the same no matter how much time passed since the block before.
Under proof of stake, blocks are normally 12 seconds apart, but a missed slot produces a 24-second (or longer) gap. The next block then contains roughly twice the usual demand, looks overfull, and pushes the base fee up even though demand did not change. The following blocks come out under-full while the fee settles, and the block space of the missed slot is simply lost. The spec notes this makes a DoS attack on proposers more damaging, and that when many validators are offline (for example during consensus issues) chain throughput can stay reduced for a long time.
The goal is to target a stable throughput per unit of time, not per block.
How it works
The change is deliberately minimal. Only the gas target used in the base fee formula changes:
BLOCK_TIME_TARGET = 12seconds.- The parent's block time is
parent.timestamp - grandparent.timestamp. - Adjusted target = base target × block time / 12, capped at
MAX_GAS_TARGET_PERCENT = 95% of the gas limit. - The base fee rises or falls by comparing gas used with this adjusted target. The size of the change is still divided by the normal (unadjusted) target and the usual max change denominator of 8.
So after one missed slot (24 s) the target roughly doubles (up to the 95 % cap), and a full block no longer signals a demand spike.
The cap exists so a full block can still push the fee up when demand really grows. The downside, which the spec admits, is that it only partly makes up for a single missed slot and not at all for several missed in a row. The spec mentions a multi-slot gas buffer or higher elasticity as possible extensions.
Sample code
The updated base fee rule, following the spec's pseudocode:
BASE_FEE_MAX_CHANGE_DENOMINATOR = 8
ELASTICITY_MULTIPLIER = 2
BLOCK_TIME_TARGET = 12
MAX_GAS_TARGET_PERCENT = 95
def next_base_fee(parent, grandparent):
block_time = parent.timestamp - grandparent.timestamp
base_target = parent.gas_limit // ELASTICITY_MULTIPLIER
target = min(base_target * block_time // BLOCK_TIME_TARGET,
parent.gas_limit * MAX_GAS_TARGET_PERCENT // 100)
if parent.gas_used == target:
return parent.base_fee
if parent.gas_used > target:
delta = parent.base_fee * (parent.gas_used - target) // base_target // BASE_FEE_MAX_CHANGE_DENOMINATOR
return parent.base_fee + max(delta, 1)
delta = parent.base_fee * (target - parent.gas_used) // base_target // BASE_FEE_MAX_CHANGE_DENOMINATOR
return parent.base_fee - delta
Things to know
- Status: Stagnant. It was aimed at the Merge but was not included; mainnet still uses the original EIP-1559 per-block rule.
- Under proof of stake every slot has a fixed timestamp, so proposers cannot game the formula by moving timestamps. Under proof of work the spec leaves timestamp manipulation unexplored.
- A high
MAX_GAS_TARGET_PERCENTleaves little room for real demand to raise the fee when many slots are missed, which makes it cheaper to hold the base fee down. The spec calls the result graceful: the fee burn is weakened only until proposers come back online. - Tools that compute the next base fee off-chain would need updating if this were ever adopted.