EIP-7378 · Stagnant · Core · 2023-07-22
EIP-7378: Add time-weighted averaging to the base fee
A proposed change to EIP-1559 that updates the base fee from an exponential moving average of recent block sizes instead of only the last block, making fee manipulation through bribed empty blocks less profitable.
What problem does it solve?
Under EIP-1559 the base fee for the next block depends only on how full the last block was. If it was above the gas target the fee goes up; below, it goes down by up to 12.5 %.
Academic work cited by the proposal points out that this makes the base fee cheap to push around. A user with a lot of gas to spend can bribe a proposer to publish an empty block. The bribe only needs to cover the tips the proposer gives up (roughly tip × target size), but the base fee then drops by 1/8 for everyone in the next block, including the briber. Since the base fee is burned, neither the user nor the proposer loses anything from cutting it, so both can profit. The same research also describes the current rule as prone to oscillation.
How it works
The formula keeps the EIP-1559 shape but swaps the last block size s[i] for a smoothed size s_avg[i]:
b[i+1] = b[i] * (1 + 1/8 * (s_avg[i] - s_target) / s_target)
s_avg[i] = α * s[i] + (1 - α) * s_avg[i-1] with 0 < α < 1
αis a smoothing factor. A largerαreacts faster to recent blocks; atα = 1the rule becomes the current EIP-1559 rule.- Because older blocks fade out geometrically, a single empty (or overfull) block only nudges the base fee a little, so a one-block bribe buys much less.
- The running average needs one stored value and constant computation per block.
The author considered simply shrinking the 1/8 "max change denominator" instead, but rejected it because that would make the fee slow to follow real, lasting changes in demand. The moving average aims to keep responsiveness while damping outliers.
Sample code
Python pseudocode for the proposed update. The spec does not fix a value for α; the one below is illustrative only.
BASE_FEE_MAX_CHANGE_DENOMINATOR = 8
ALPHA_NUM, ALPHA_DEN = 1, 4 # α = 0.25, placeholder
def next_size_avg(parent_size_avg: int, parent_gas_used: int) -> int:
return (ALPHA_NUM * parent_gas_used
+ (ALPHA_DEN - ALPHA_NUM) * parent_size_avg) // ALPHA_DEN
def next_base_fee(parent_base_fee: int, size_avg: int, gas_target: int) -> int:
if size_avg == gas_target:
return parent_base_fee
diff = abs(size_avg - gas_target)
delta = parent_base_fee * diff // gas_target // BASE_FEE_MAX_CHANGE_DENOMINATOR
if size_avg > gas_target:
return parent_base_fee + max(delta, 1)
return parent_base_fee - delta
Things to know
- Status: Stagnant. It was not scheduled for any network upgrade, and mainnet still uses the plain EIP-1559 rule.
- It would require a hard fork, since block validity depends on the base fee.
- The spec leaves the value of
α, test cases and security analysis open ("TBD" / "Needs discussion"), and does not say how the average would be stored or initialised. - The authors note the bribery problem grows with demand and only mildly affects Ethereum today; the proposal is framed as preparation.