What is Gas Fee and Why is it Important?

What is Gas Fee and Why is it Important?

Gas fees are closely related to every miner. What exactly is a gas fee? This article takes a deep dive into gas fees — how they work, and why they are important to the Filecoin network.

Filecoin is a blockchain-based economy where participants transact on a distributed network. The state of the network is updated by miners recording and processing messages in the blocks they mine. There are a variety of messages, including storage deposits, storage orders, ongoing proofs, digital currency transactions, and more.


However, due to limitations on chain performance, scalability, and verification time, there is a limit to the number of messages that can be processed in a block. Therefore, only a subset of messages on the network can become a block at any given time.

Additionally, executing messages consumes computational and storage resources on the network. This is where "Gas" comes into play as a measure of how much resources are consumed by a message. The Gas consumed by a message directly affects the cost paid by the sender to submit the message to the blockchain. And, the total amount of Gas for all messages in a block is limited.


Gas can be thought of as the fuel of the Filecoin blockchain , just like fuel for a car. Before you start a road trip, you have to pay for the gas consumed by driving the distance and using the engine's braking power when going up and down hills. Similarly, message senders on Filecoin need to pay for the Gas that "drives" the execution of messages on the Filecoin blockchain.

How the Filecoin network uses Gas

Gas was first implemented on the Ethereum blockchain to measure the computational and storage resources consumed by a message. This is where the term "GasUnit" comes from. Historically, miners specify a Gas fee in units of the blockchain currency, and then pay a priority fee to the block production miner based on the amount of Gas consumed by the message.

However, since every node on the network expends storage and computational resources to verify each message and keep the network in a consistent state, Gas consumption becomes a cost that the entire network should bear. Therefore, depending on the Gas usage of a particular message, a certain amount of Gas needs to be used to compensate the network. Not spreading this cost creates incentive bias, as block producing miners may get a computationally expensive piece of information for free at the expense of others.


BaseFee is a concept introduced by Ethereum's EIP1559. BaseFee multiplied by the Gas usage of the message is "Burn". Burn means that it is sent to an address that cannot be used and is removed from the network. It is dynamically adjusted based on the demand for network bandwidth at a certain time. It will rise as the network becomes congested, so that message senders whose valuation is lower than the network base fee will keep waiting until the congestion is eliminated. The rate of change of BaseFee is designed to be fast to quickly increase potential DOS attacks and to decrease quickly when the network becomes less busy. Message senders who cause the network to be more congested will also internalize the cost by paying higher fees. Burn also creates slow deflationary pressure that benefits all network participants.


Continuing with our road trip analogy, think of Gas as the gasoline in your car and the network as normal traffic. If the road is congested, such as during rush hour, and traffic is stuck, your car will use more gas. In this case, it may be necessary to wait a while before continuing on the road. The same theory applies to the Filecoin network - when the network traffic is congested, the gas fee will be high, and it may make sense to wait and try again later.


In addition to paying some fees to compensate the network, the message sender also pays a priority fee to the miner of the block production, which is independent of the amount of gas consumed by the message. This is called GasPremium, and it can also be arranged outside the protocol.

A Practical Guide to Gas

To help readers better understand the gas fee mechanism, the following are the relevant concepts of gas generated by messages and their interactions. These fields can be set by the message sender, but are currently automated in lotus. Of course, you can also develop more tools.


GasLimit – is a limit on the amount of Gas, which means the execution of a message can be used, estimated and specified by the message sender. The sum of GasLimits of all messages included in a block must not exceed BlockGasLimit. This is in GasUnit.


GasUsage is the amount of Gas actually consumed by the execution of a message. The current protocol does not know exactly how much Gas a message will consume before execution. This is in GasUnits.


GasFeeCap The maximum amount of cryptocurrency that a sender is willing to pay per GasUnit for including a message in a block. When sending a message, the sender must have a minimum balance equal to GasFeeCap multiplied by GasLimit, even if all of these balances will not be consumed. Measured in attoFIL/GasUnit.


GasPremium A priority fee paid to block producing miners per unit of GasLimit. This is limited by GasFeeCap and BaseFee has higher priority. This is limited by GasFeeCap, with BaseFee having higher priority. This is in attoFIL/GasUnit and can be as low as 1 attoFIL/GasUnit.


BaseFee A network-wide variable that is dynamically adjusted based on the sum of the GasLimits of all messages in the previous tipset. It will increase when the total GasLimit exceeds the GasLimit target for a block (signal of network congestion), and decrease when it falls below the GasLimit target. Measured in attoFIL/GasUnit.


The message sender only needs to specify a GasFeeCap and GasLimit for each message. As on-chain resources are consumed, GasUsage multiplied by BaseFee will be consumed. Subtracting BaseFee from GasFeeCap will produce GasPremium. GasPremium multiplied by GasLimit will enter the block of the producing miner as a priority fee. Part of the difference between GasLimit and GasUsage will be consumed as an overestimation loss. The rest will be returned to the message sender.


Currently, the default implementation is that miners choose messages based on GasFeeCap/GasLimit to maximize their expected rewards given the GasLimit of a block. When the network is congested and the BaseFee is high, miners can choose to group blocks to reduce the total GasLimit to reduce the BaseFee, but may be at the expense of GasPremium.

Future Work

The Filecoin research and engineering team is working to reduce the resource consumption of different on-chain messages to reduce Gas usage and improve network performance to increase capacity. However, there are currently some messages on Filecoin (such as SubmitWindowedPoSt) that must be included in the chain within a relatively short window, otherwise a penalty will be incurred. In order to improve the economic structure and provide service quality guarantees for these types of messages, the Filecoin team is doing more work. As a collective composed of clients, miners, developers, partners, and virtual currency holders, the Filecoin network will continue to work together to make the network move in a better direction!

For future improvements, please follow the Filecoin Lotus docs

(https://github.com/filecoin-project/lotus) and Filecoin Improvement Protocol

(https://github.com/filecoin-project/FIPs) for future improvements.

<<:  The countdown to the launch of the Filecoin mainnet has begun. Here are the events you need to know

>>:  The real reason behind Bitcoin’s sudden rise

Recommend

Does a woman with a double chin look rich? What is her fortune like?

A face that looks rich and noble is what many peo...

DeepSeek suddenly hits Bitcoin

The development trend of Ai+Crypto seems to be un...

What does the line of indulgence in palmistry mean?

Everyone has heard of the word palmistry , but yo...

What are the characteristics of a smart woman?

Smart people are more likable, so we all hope to ...

What does the man's palm represent?

The "川" palm is a special palm line and...

Russia's largest search engine Yandex is in love with Bitcoin

Author: Velvet Gold Mine Image source: Dazhi Russ...

These people are most likely to break their promises.

Everyone should have a few unreasonable people ar...

A woman with a mole on her right palm

We all have moles of different sizes on our bodie...

What are the facial features of a bad-hearted person?

Whether a person is good or bad can be seen from h...

Women with moles on their belly buttons have good fortune

Moles growing on any part of the body will have t...

How to tell how many children you have in your palm

Palmistry can reveal one's health status and ...

Is it okay to have a prominent double chin? I have very good luck in love.

For a person, the theory of physiognomy also has ...