- On August 5th, 2021, the Ethereum upgrade will go through a major and long-anticipated upgrade known as the “London Upgrade”.
- One of the most discussed features added as part of the upgrade is EIP-1559.
- EIP-1559 tries to solve a long-standing UX issue with Ethereum where gas prices were highly unstable leading to inefficiencies in the way users interact with the blockchain.
- EIP-1559 suggests to split the fees within each transaction into two fees: a base_fee which will be burned and a tip to the miner.
- The base_fee will be reevaluated for each block according to the base_fee of the previous block and the utilization of the space in the previous block.
- The blocks’ sizes are flexible and the maximum block size is doubled.
- If blocks are more than half full, base_fee gets bigger, and if they are half empty, it will get smaller.
- EIP-1559 does not reduce fees in the long term, but only absorbs short term volatility in the fees.
Starting from block 12,965,000 on August 5th, 2021, the Ethereum network will go through a long-anticipated update in the form of a hard-fork. This update is also known as the “London Upgrade”.
This upgrade introduces some interesting features into the Ethereum network, blockchain and protocol that we will cover in this document, but first, let’s give some background on the current state of affairs in the Ethereum blockchain.
Why do we need fees?
When interacting with any blockchain, and the Ethereum blockchain in particular, some fees are incurred by the network. This is because there is a limited resource for which the supply is lower than the demand where:
- The limited resource is storage space inside the blocks of the blockchain.
- The demand is in the form of transactions sent to the network, willing to be confirmed, each confirmation consumes some amount of space from the block in which it is included.
- The supply is determined by the “size” of the blocks. Where the meaning of “size” can differ from one network to another. In ethereum, in particular, the size of a block is 15 million gas units. So, the sum of the gas used by all transactions in a block of the ethereum blockchain can’t go higher than 15 million.
Thus, when the sum of all pending transactions that are yet to be confirmed is higher than 15 million we obviously can’t fit them all into the next block and this is why there should be some sort of mechanism to decide which transactions will be added to the next block and which will not.
The miner is the entity which is in charge of adding blocks to the blockchain and therefore decides which transactions are to be included in the next block and which are not.
To incentivize the miners to work on creating new blocks, the ethereum protocol dictates that a miner which successfully adds a block to the ethereum blockchain gets as a reward all the fees of all the transactions that are included in the block.
Therefore, a miner will add the transactions into the block in a way that maximizes its profit. This implies that a transaction will contain a high fee if the sender wants the transaction to be confirmed within a short period of time. On the other hand, a transaction will contain a small amount of fee if the sender is willing to wait for a longer period of time until confirmation.
Fees in Ethereum
The fees of a transaction are determined by two pieces of information found in the transaction.
- gas_limit – This is the maximum amount of gas that can be used to process the transaction. Each transaction sent in the ethereum network requires some processing and the Ethereum protocol specifies how much gas each operation costs. For example, simply moving some ETH from one address to another costs 21000 units of gas. When interacting with contracts (for example go get some ERC20 tokens) the contracts can perform more complex operations with varying amounts of gas required to complete. See below the Appendix G. of the ethereum yellow paper to get a sense of how much gas each operation cost.
2. gas_price – How much Ethereum is the sender willing to pay per unit of gas. This is typically measured in gwei units.
So, from the user’s perspective the total fees paid to process its transaction is gas_limit multiplied by gas_price.
Motivation: Why do we need EIP-1559?
An important question users typically face is “How much should I pay per unit of gas?”. On the one hand, a user doesn’t want to pay a very low fee, because the transaction will not get confirmed. On the other hand, paying excessive fees is just a waste of money, as the transaction could have been accepted with lower fees.
There are plenty of fee estimation services available for Ethereum, but all of them make a subtle assumption that the fees aren’t changing dramatically within short periods of time. Imagine if you wanted to move all your Ether coins to another address, you consult a fee estimation service and pick a high-priority fee, you send the transaction and wait for confirmation. You keep refreshing the transaction page but your transaction doesn’t get confirmed. This is odd right?
You are starting to get worried about your transaction not getting confirmed when you find out that a new NFT or a DeFi project has just spread some news that caused a spike in the number of transactions for a short period of time (e.g. a few hours or days). This is a very inconvenient experience, especially for new Ethereum users.
Preventing these types of short-term fluctuations in gas_price is exactly one of the main goals that was set by EIP-1559, the most anticipated part of the London upgrade.
You can think of paying these fees as a public auction with multiple winners in which the bidders set bids for space in the next block. Just like an auction, the highest bidders can leave with some regret, as they could have bid a lower price and still win the auction. Thus, an important notion from the field of game-theory is a Uniform-price Auctions in which winners in auctions pay the lowest bid by one of the winners. So if 10 people had won an auction, they would all have paid the price of the 10th highest bid.
You could have imagined that uniform-price auctions would be suitable for Ethereum, in which all transactions in a block pay the gas_price of the transaction with the smallest gas_price amongst all transactions in the block. However, there are some issues with it such as miners adding “fake” transactions into the block to raise the minimum gas_price in the block. A miner could also collude with some bidders asking them to raise their bid to make a profit from the rest of the block and send the bidders back a portion of the fee. (See the full Vitalik’s review of this approach here).
What is EIP-1559?
To prevent miners from colluding or adding some “fake” transactions, at least some of the fees can’t go to the miner of the block. And this is where EIP-1559 kicks in. According to EIP-1559, each sent transaction will pay two kinds of fees.
The first will be a base_fee; this fee is determined by the protocol of the Ethereum network and changes from block to block. The base_fee portion of the fee is burned, so the miners will not receive it. The fee is mandatory so to be included in a block, a transaction must pay at least the base_fee. As we will see later, the base_fee is designed to absorb fluctuations so it can’t change more than 12.5% between two consecutive blocks.
The second part of the fee is the tip which is sent to the miners to incentivize them to include this transaction in the next block, just like they used to.
To stabilize the gas prices and prevent fluctuations in the fees, blocks aren’t hard-capped at 15M gas but at 30M gas. But here is the twist, if blocks are more than half full (i.e. more than 15M gas of transactions in the block), the base_fee will rise by some percentage. In contrast, if they are more than half empty, the base_fee will drop. This mechanism ensures that while in the long term the base_fee can drop or rise, in the short term, fluctuations in the number of transactions in the Ethereum network will be absorbed by a short-term increase in the block size. Later, when the demand subsides, blocks will be less than half empty and the base fee will return to its original values.
The exact formula for computing the base_fee of the current block based on the previous block is:
- fcur is the base_fee for the current block.
- fprev is the base_fee of the previous block.
- Sprev is the size of the previous block in gas units.
- Starget is the target size of a block which is 15M gas.
A few examples:
- If the previous block is exactly half full, the base_fee will stay exactly the same.
- If the previous block was full (30M gas), the base fee will increase by 12.5%.
- If the previous block was empty the base fee will decrease by 12.5%
In practice, after the upgrade a transaction will have three pieces of information related to the fee.
- gas_limit – Just like before the update.
- max_fee_per_gas – This is the maximum price of gas the user is willing to pay in total (base_fee + tip).
- max_priority_fee_per_gas – This is the maximum price of gas the user is willing to pay for the tip.
It is important to mention that to ease the transition the network will accept transactions of the previous form with the gas_price having the same implications as it used to, which may result in paying higher fees than what one would have paid with the new transaction format.
One myth revolving around EIP-1559 that we have to bust is that it is intended to lower the fees. So, to be clear, if demand remains high, the base_fee will surge, incurring increased fees for users. It is only intended to absorb short-term volatility in demand by increasing and decreasing the block sizes and adapting the base_fee accordingly. If the demand surges in the long term, EIP-1559 will not prevent the increase in block size.
To summarize, the EIP-1559 tries to solve an old UX issue users have had with Ethereum by making the block size more flexible and splitting the fees into two different parts, one which is burned and is set algorithmically by the network based on past demand and the other is given as a tip to the miner. The interested reader is highly encouraged to read deeper about the implications and considerations regarding the design of EIP-1559, one great source of information is Tim Roughgarden’s analysis of EIP-1559 and the great corresponding talk on YouTube about his work.