Unpacking Filecoin’s Gas Usage

Maria Silva
CryptoEconLab
Published in
7 min readMar 22, 2023

Insights from an empirical analysis.

Photo by Khamkéo Vilaysing on Unsplash

Introduction

A blockchain is a digital record of transactions that are created and verified in a trustless manner. Most blockchain networks use “gas” as a unit of measurement to determine the computational resources required to execute a transaction or smart contract. Here, a set of users submit their transactions to a pool of transactions waiting to be executed and announce how much computation is required and how much they are willing to pay for it. On the other side, miners look at this pool of transactions and select the ones that will be executed in the next block.

Filecoin is not different. Filecoin is a decentralized storage network, made of Storage Providers (i.e., the miners) that rent out their storage space and receive rewards by storing client data and maintaining the network functioning. Anyone who wishes to use Filecoin to transfer its native token (FIL) between wallets or to interact with Filecoin’s storage services needs to submit transactions to the blockchain and pay for its gas. Therefore, understanding gas usage can give us unique insights into user demand and the operations of Storage Providers.

In this blog post, I will discuss an empirical analysis of gas fees and consumption pre-FVM (Filecoin Virtual Machine) for the Filecoin network. The analysis was conducted by JP Madrigal-Cianci from CryptoEconLab, and the data used for the analysis was gathered from the Lily Database. The goal was to investigate the statistical properties of gas consumption in the Filecoin network and extract insights about how best to model it.

Filecoin’s Transaction Fee Mechanism

Before we show the results of the analysis, we need to do a short overview of how Filecoin’s transaction fee mechanism works. Filecoin uses the EIP1559 model, which is the model implemented by Ethereum during the summer of 2021.

In the EIP1559 model, transactions include a base fee component that is burned (i.e., destroyed) and a miner tip component that is paid to the miner who includes the transaction in a block. The base fee component is the minimum amount of gas that a transaction must pay when being executed (i.e., adding a miner tip is an option for the user). The full formula for both components is described is the Figure below.

Overview of EIP1559’s Transaction Fee Mechanism

The base fee is dynamically adjusted based on network demand to ensure that blocks are neither too empty nor too full. If demand is significantly higher than expected, the base fee will increase, and fewer users will be willing to pay the required amount to have their transactions included.

Users can still submit transactions with a lower gas price and still have them included in a block, but they might need to wait longer for the transaction to be executed. Conversely, users can pay a higher gas price in the form of miner tips to have their transactions executed more quickly. This model aims to make transaction fees more predictable and efficient while also incentivizing miners to include transactions with lower gas prices.

Aggregate Gas Dynamics

We started by investigating gas consumption at an aggregate level by considering the total gas consumption across all messages for each block. For this analysis, we collected one month of block data (per epoch), from July 22nd, 2022 to August 22nd, 2022.

We focused on the normalized gas consumption per block (G̃ₜ), which is the total gas consumed in a block normalized by the target gas consumption (G*):

The target gas consumption is defined as half the total block size. This means that when:

  • G̃ₜ is close to -1 → block is mostly empty
  • G̃ₜ is close to 0 → block is half full (i.e., close to the target gas consumption)
  • G̃ₜ is close to 1 → block is mostly full
Statistical properties for the time series of normalized gas consumption per block (G̃ₜ)

After computing the statistical properties of G̃ₜ, we found that, for the time period considered, it is slightly more likely to be close to 1 than to -1. This suggests that gas tends to be over-used rather than under-used. In addition, the mean of G̃ₜ is very close to zero, which indicates that the base fee mechanism is working as intended by guiding the users to hit the target consumption on average. Gas consumption stays in this range 70% of the time!

We also observed weak autocorrelations, indicating that G̃ₜ becomes independent of its recent past fairly quickly (after five or so blocks). This means that the recent history of gas consumption has a limited impact on future gas consumption.

Demand Peaks Dynamics

Another way to look at this data is to consider demand peaks and how the system transitions between states of low and high demand. In particular, we define two new time series:

  1. High-demand peaks — which is 1 when G̃ₜ > 0.95 and zero otherwise;
  2. Low-demand valleys — which is 1 when G̃ₜ < -0.6 and zero otherwise.

and we consider, for each time series, its process of interarrival times, which represents the time between two consecutive high/low demand peaks/valleys.

Distribution and autocorrelation for peaks/valleys interarrival times

From this, we conclude that the histograms of the interarrival times are well-approximated by an exponential distribution. The high-demand peaks process has a parameter of λ ≈ 0.04, meaning that, on average, there is a high-demand peak every 25 blocks. Similarly, low-demand valleys distribution has a parameter of λ ≈ 0.02, which leads to, on average, a low-demand valley every 50 blocks.

In addition, for both time series, the autocorrelation function (ACF) goes to zero almost immediately, suggesting that these interarrival times might be statistically independent of each other. This is an interesting fact since the exponential distribution and statistical independence characterize a Poisson process (see Kroese et al (2013), p. 172).

Gas Dynamics by Type

In Filecoin, there are two main types of transactions:

  1. Maintenance transactions (aka “Control Plane”) → transactions critical to the functioning of Filecoin’s storage network. They include transactions related to storage onboarding, client storage deals, and periodic storage proofs.
  2. User transactions (aka “Others”) → all the other non-critical transactions, such as token transfers.

Grouping gas consumption by these two groups is relevant because it allows us to understand how much block space is being occupied by critical storage operations versus other use cases.

In the period analyzed (the summer of 2022), the large majority of gas spent was due to the control plane. In other words, almost all the block space was dedicated to maintenance transactions. Concretely, the average gas usage proportion due to the control plane is about 0.955, while the proportion of the other transactions is about 0.044.

Gas consumption per transaction types — control plane vs. others

We should note that this data is pre-FVM launch, where most of the activity on Filecoin was associated with making storage deals and Storage Provider operations. After the launch of FVM in March 2023, we expect these dynamics to change and to see more non-critical messages increase.

Takeaways and Next Steps

Gas is a crucial component of many crypto economies. Analyzing gas consumption in these blockchains is important for optimizing performance and understanding adoption. In this report, we were able to uncover a few interesting insights about gas consumption in the Filecoin network, namely:

  • Gas tends to be slightly over-used rather than under-used, and the mean of normalized gas consumption is very close to zero, indicating that the EIP1559 mechanism is working as intended.
  • Interarrival times for demand peaks and low-demand valleys in the network follow an exponential distribution. Peaks are more frequent than valleys, with a high-demand peak occurring on average every 25 blocks and a low-demand valley occurring every 50 blocks.
  • Pre-FVM (Filecoin Virtual Machine ), maintenance transactions account for the vast majority of gas consumption in the network, with almost all block space dedicated to these critical storage operations.

In the future, it will be interesting to see how the dynamics of gas usage change as the Filecoin network grows and evolves. With the launch of the Filecoin Virtual Machine in March 2023, we expect to see more non-critical messages being introduced, which could significantly alter the current gas consumption patterns.

At CryptoEconLab, we are currently building models for gas consumption that take FVM into account and we are exploring potential risks and mitigation strategies. If you want to read more on this more recent work, check out this Medium post written by AX and JP Madrigal-Cianci.

Additionally, if you find this post interesting and want to learn more about our work, you can visit our website at cryptoeconlab.io or read our HackMD Almanac.

--

--

Maria Silva
CryptoEconLab

Research Data Scientist at CryptoEconLab (Protocol Labs)