Exponential EIP-1559 explainer

In this blog post I will try to help understand how the exponential version of EIP-1559 works – the one that was suggested for the Shard Blob EIP.

I’m not going to try to explain how the EIP-1559 mechanism works – good explainers already exist, for example by Barnabé Monnot.

Linear EIP-1559 mechanics (“original version”)

I will call the current implementation of EIP-1559 the “linear version” of EIP-1559.

In the linear version, we define the constants

Each block has a base fee of and total gas consumed in the block of . There is an update rule for the Basefee:

There is also a constraint that the maximum amoung of gas per block can’t be more than . However, this limit is not important in the scope of this post so I will ignore it.

Exponential EIP-1559

One way to understand this “linear EIP-1559” better is to compute what happens after many updates. In particular, how does depend on ? By substituting the equation into itself many times, we get

Now let’s say that is a large number, so that all the terms of the form are small? Let’s call .

If we assume this, we can use an approximation: The exponential function for small . We use this approximation in the inverse to replace to get

For the last step, we have used the property that . Note that

so we get this new formula for

where we used for the total gas used since block 0 and the cumulative gas target.

This is the exponential form of EIP-1559. The only thing we need to keep track of to compute the basefee current is (1) the total gas used, which is , and the total gas target, which is represented by (so it’s enough to just count the number of blocks).

Analyzing the exponential form

Here is a question I have heard many times about exponential EIP-1559: Isn’t the goal of EIP-1559 that in the long term, the total gas used equals to the gas target ?

And if so, if you evaluate the equation for , the exponential becomes one and thus . So if the target is achieved, then the basefee would always be (which is typically very low)?

Here I will explain why this is not the case. Let’s see how this happens in linear EIP-1559 first. Here is a very simple economic model: Let’s assume a there is a “fair price” for gas at price . For simplicity assume that below , demand is infinite: All blocks will be filled. Above , blocks will be empty. And when the base fee is equal to , then there will be exactly enough demand to fill the blocks to half.

So what will happen in this model in linear EIP-1559?

  • We assume that the base fee starts of low with .
  • Then there will be a number of blocks where the basefee is lower than , which will be completely full by our assumption.
  • When the basefee reaches at , all futher blocks will be filled to target.

To keep things simple, say the max block size is exactly . Then how much gas has been used at any block ? It would be . So it is actually not exactly the target, despite the EIP-1559 mechanism now being in equilibrium.

What happened? Note that it is still correct to say that EIP-1559 will ensure ; for example, if you take the fraction , it will tend to so in asymptotic notation we would write .

But there is a constant difference between and , which is the amount of gas that was needed to shift the basefee from to .

More generally, the current difference between and is a constant determined by the current basefee. In the linear version, this is approximately true; in the exponential version, it is exactly true (it follows directly from the definition )

Graphical illustration

First let’s look at our simplified example. The following graph illustrates what is happening: Above you see the relation between total gas used and the basefee (an exponential function). Once in equilibrium, the basefee is at which means that . Below we see how this adds up. The green shaded area of gas used is the blocks filled up to the target, and the orange area is the gas used above the target that sums up to .

Next we look at a generic example, where some blocks are filled with more than target gas and some blocks are below. In this case, we need to sum up all the gas consumed by each block above the target (marked in green) and substract the gas that was below the target in underfull blocks (marked with red and white diagonal stripes). We can then read the sum on the axis of the basefee relation to determine the basefee .

Appendix: Using differential equations to derive the exponential form

Here is another way of deriving the exponential form, using differential equations:

Let’s start from the update rule of linear EIP-1559

We can rewrite this as

Tis is mathematically a difference equation. This is similar to a differential equation, but for finite differences. However, we can “approximate” it as a differential equation, by changing into a continuous variable and writing

where we use that . You could say that this form comes about naturally if you assume that we are making the blocks smaller and smaller, scaling the target as well. As the size of the blocks goes towards zero, we get the differential equation.

This is a linear ordinary differential equation of first order that can be solved by moving the terms depending on to one side:

Integrating on both sides yields:

This is because

So we can exponentiate and get

Since we want we get and so

This looks almost the same that we derived above – except we now have an integral instead of a sum, because we are working with the continuous form.

The exponential version thus arises naturaly when you consider very small blocks and update the basefee each time. From this perspective, it is the most natural way of implementing EIP-1559.