EIPs Explained

EIP-3416 · Stagnant · Core · 2021-03-18

EIP-3416: Median Gas Premium

A stagnant alternative to EIP-1559 in which everyone in a block pays the base fee plus a gas-weighted median premium, aiming to smooth fee spikes without new transaction fields.

What problem does it solve?

Before 2021, Ethereum used a first-price auction: each transaction paid exactly the gasPrice it bid. Users had to guess what others would bid, fees jumped minute to minute, and many overpaid.

EIP-1559 was the leading fix. The authors of EIP-3416 argued that 1559 does not really smooth the tip (priority fee) part of the price, and they proposed a different design. It keeps a protocol base fee, but replaces individual tips with a single block-wide premium derived from a median, so the final price is harder to manipulate and usually below what the user offered.

How it works

  • Base fee: set by the protocol each block from the parent's gas usage, but with an additive update rule instead of 1559's multiplicative one: BASE_FEE = PARENT_BASE_FEE + GAS_DELTA * BASE_FEE_MAX_CHANGE with BASE_FEE_MAX_CHANGE = 1/8. The authors chose this to resist an attack, observed in simulation, that drives a multiplicative base fee towards zero.
  • No new transaction format: legacy transactions are reused, and their gasPrice is reinterpreted as a fee cap. A transaction with fee cap < base fee cannot be included yet.
  • Implied premium: each transaction's premium is (fee cap - base fee) / 2, half of its headroom.
  • Uniform block price: everyone in the block pays BASE_FEE + weighted_median(premiums). The median is weighted by gas used, and the top 5 % of gas by price is excluded as outliers to limit block-producer manipulation.
  • Users are charged that price times gas used, with the usual refund of unused gas. Block producers can still fill blocks greedily by fee cap, because the premium rises with the fee cap.

Sample code

Pseudocode for the per-block price (simplified from the spec):

def block_gas_price(base_fee, txs):
    # each tx: (fee_cap, gas_used)
    units = sorted(
        ((base_fee + (cap - base_fee) // 2, gas) for cap, gas in txs if cap >= base_fee),
        key=lambda x: x[0],
    )
    total = sum(g for _, g in units)
    cutoff = total * 95 // 100        # ignore the most expensive 5 % of gas
    half, seen = cutoff // 2, 0
    for price, gas in units:
        seen += gas
        if seen >= half:
            return price              # gas-weighted median, outliers excluded
    return base_fee

def charge(tx, price, gas_used):
    return price * gas_used           # same price for every tx in the block

Things to know

  • Status: Stagnant. It was never scheduled. Ethereum adopted EIP-1559 in the London upgrade instead, with explicit maxFeePerGas / maxPriorityFeePerGas fields and a burned base fee.
  • Several parameters were left undefined (FORK_BLOCK_NUMBER, how the per-block gas target is derived), and Test Cases are "TBD".
  • Because everyone in a block pays the same price, a user cannot reliably pay extra for priority within a block. The spec argues block producers will still prefer higher fee caps because they raise the median.
  • If you need on-chain access to the actual fee level today, use BASEFEE from EIP-3198.

#gas #fees #core #fee-market #stagnant

Details

Authors
HexZorro (@hexzorro), Mojtaba Tefagh (@mtefagh)
Status
Stagnant
Type
Standards Track / Core
Created
2021-03-18

Machine-readable: Markdown · JSON