Understanding Layer 2 Fees: A behind-the-scenes look into Fees

Understanding Layer 2 Fees

  • A brief history of transaction fees

  • The Mechanics of Layer 2 Fees

Before we start, let me tell you I am proud that you are interested in this topic. :)‚ėļÔłŹ

In light of our recent metric launches on growthepie, namely Throughput and our dedicated Layer 2 Fees Page, I felt that there is a need for an explanation of what these fees mean and how they are affected. Vitalik also posted a more technical article about Multidimensional gas pricing recently which is definitely worth a read!

However, in this article rather than delving into the more technical details like state-diffs or compression, our focus will be on giving a concise, high-level summary of how these technologies affect transaction fees. There is a lot more fascinating stuff happening behind the scenes with fees.

So let’s get into it!

A brief history of transaction fees

So I told you about our new feature page fees.growthepie.xyz, which offers a comprehensive overview of the transaction costs users have paid for various Layer 2s with chronological granularities.

fees.growthepie.xyz
fees.growthepie.xyz

It’s beautiful, yes, but those numbers are not as simple as they seem.

So let’s first get the formulas out of the way. On Ethereum, fees are calculated like this:

Tx Fee = Gas Used * Gas Price

Gas used: The complexity of a transaction. The most simple transactions are native ETH transfers and they take up 21,000 gas.

Gas price: A value that responds to supply/demand. Higher demand for transactions will result in higher gas prices.

In general, fees have been a hot topic for blockchains. Due to the strong demand for Ethereum blockspace during the previous cycle, fees on Ethereum surged to over $100 (with a median of about $30) and the platform became mostly unusable for "normies.‚ÄĚ

Ethereum's scaling barrier can be resolved with Layer 2s. They are less expensive and provide more throughput. Since they also send data to Ethereum, the Layer 2s transaction fee computation closely resembles the Ethereum logic. However, they incur costs on both Layer 2 and Layer 1 (Ethereum). The (abstracted) formula for Layer 2s is as follows:

Tx Fee = L1 Costs + (Layer 2 Gas Used * Layer 2 Gas Price)

For a long time, the transaction fees on Layer 2s were hovering between 20 cents and $1 - still too expensive for mass adoption.

Vitalik also mentioned in his tweet from May 3rd, 2022 that Layer 2 transactions have to become cheaper than 5 cents to be truly acceptable.

The Mechanics of Layer 2 Fees

Data Availability Costs

One of the main reasons why Layer 2s are so expensive is the high Data Availability costs that they had to pay to Ethereum for posting their transaction in batches to common calldata slots.

If you are not so familiar with the Data Availability issue, we have got a nice introduction to it in our Knowledge section on growthepie.

This implies that whenever Ethereum got pricy, Layer 2s became expensive (strong positive correlation). Fortunately, Ethereum researchers foresaw early on that Data Availability would turn into a bottleneck for the network's rollup-centric design. This led to the introduction of EIP4844.

EIP-4844

EIP-4844 introduces a new storage format called blobs. This data will only be stored temporarily on the Ethereum chain (it expires after 4096 epochs, or about 18 days days) and is optimized for data storage which enables Layer 2s to post larger volumes of data at a lower cost. In addition, the blob fee market is decoupled from the general Ethereum gas price.

If you are interested in going deeper into the EIP-4844 topic check out yet another article written in our Knowledge Hub.

EIP-4844 went live on March 14th, 2024. It drastically reduced the data availability costs for Layer 2s which made the switch over to the new blob storage. The following chart shows how the rent paid (the total costs that Layer 2s pay to Ethereum) dropped sharply after March 14th.

In Arbitrum’s case, the expenses dropped from ~$600k per day down to only $4-10k per day (99% cost reduction).

Subsequently, we also saw a drop in transaction costs for Layer 2s, now often being below 1 cent.

Fees Market

So now what? Data Availability is cheap and we are good?

EIP-4844 was a great step in the right direction. Layer 2s became cheaper by a factor of 10 - 100 and user activity also increased.

One mechanic that is also very important to note are fee markets. As mentioned in the beginning, gas prices are supposed to react to supply/demand forces.

Most Layer 2s (and Ethereum) have gas markets that work according the EIP-1559 definition. Each block has a gas limit (fix limit) and a gas target. When demand is high and blocks need more gas than the gas target, the gas price will increase by 12.5%. Gas price will start to go down again once the gas usage is again below the gas target.

The gas markets of most Layer 2s (as well as Ethereum) function in accordance with the EIP-1559 specification. Every block has a gas target and a gas limit (fix limit). The price of gas will rise by 12.5% if blocks require more gas than the target due to excessive demand. As soon as gas use falls below the target once more, gas prices will begin to decline.

The following example is taken from Base on 2024-04-22. We noticed a fees spike on fees.growthepie.xyz and analyzed it further:

Full simulation can be found here:

Go to the link above to play the simulation.
Go to the link above to play the simulation.

Speaking of mechanics you see an interesting Control System behaviour here ‚Äď this might be interesting to the non-developer engineers out there!

Simulation Observations and Control System Analysis

  1. Control System Analogy:

    • Set Point and Process Variable: In control system terms, the gas target acts as the 'set point', the desired state of the system, while the actual gas usage per second is the 'process variable'.

    • Controller: The mechanism adjusting the base fee can be viewed as a proportional controller where the adjustment in the base fee (control effort) is proportional to the deviation of the gas usage from the gas target (error).

  2. Disturbances:

    • Disturbances in this system could be sudden surges in transaction requests, possibly from large-scale smart contract interactions or DDoS-like attacks intended to increase network load.

    • These disturbances affect the gas usage, leading to deviations from the target, which in turn triggers fee adjustments.

  3. System Stability and Response:

    • Overshoot: The peak in the Gas Price graph where the gas cost spikes sharply can be likened to an overshoot in a control system, where the initial response to a disturbance is stronger than necessary.

    • Settling Time: Post-peak, the time it takes for gas prices to stabilize can be viewed as the settling time, which should ideally be minimized for network efficiency and user satisfaction.

  4. Different User Behaviors:

    • Users may respond to high gas prices by delaying transactions, which is analogous to how processes might be adjusted in response to feedback in a physical control system.

    • Strategic users might programmatically plan transactions for times when gas usage is typically lower, effectively using predictive control based on historical data.

  5. Feedback Loops:

    • The feedback loop in this scenario is evident as the system uses past performance (previous block‚Äôs gas usage) to adjust current parameters (base fee), aiming to mitigate any future discrepancies from the target.
  6. Control System Optimization:

    • Adaptive Control: Implementing more complex control strategies like adaptive control could allow the system to adjust more dynamically to changes in user behavior and network load, rather than a fixed percentage adjustment.

    • Robust Control: Designing control mechanisms that handle a wide range of disturbances (like sudden spikes in network usage) without leading to excessive fees or network slowdowns.

In addition, users can also provide priority fees (tips) that increases their chances for being included. This is on top of the base fee.

Usually, setting the gas price is done automatically for users by wallet providers depending on the current market forces. But users can also set gas prices themselves.

I hope you enjoyed this read, stay tuned for more explanations around this topic as we will talk more about Throughput and this system’s inefficiencies.

Make sure you check out our new features!

Subscribe to growthepie
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.