When users transfer money quickly, they need to ensure whether the Gas Fee Cap is larger than the Base Fee and whether the Gas Premium is large enough to ensure that the transfer is executed even if it is done.
Original title: “The Force Research | How to Calculate Gas Fees on Filecoin Network”
Written by: Tony
I wrote an article ” Understanding the Supply and Demand Status and Excess Burning of Filecoin Gas Fees in One Article” and received some feedback from users. Because some users do not understand how to use this formula, this time we will share how to calculate Gas fees step by step. From the perspective of miners, how to pay for Gas is more suitable to avoid transfer failure or late arrival.
First, let’s review the recent status of the Filecoin network.
The high number of messages exceeds 1 million
Excessive amount of information is the direct cause of network congestion. The essence is the insufficient TPS of the Filecoin network. Each block can only complete the packaging of a few hundred pieces of information, which indirectly affects the Block Gas Limit.
Figure 1, Filecoin information quantity from November 14th to December 13th, source: IPFS Force Zone, 2020-12-15
If the Block Gas Limit of a block can only hold 100 boxes, there are 10, 20, 30, 40, 50 (Gas Limit) boxes for five miners on the market that need to be packaged and transported, because the block can only be packaged with no more than 100 boxes. Quantity. Then you can only install (10+20+30+40) or (40+50) in this block.
Then everyone will ask, can the capacity of the block be increased? It is difficult to achieve at present, mainly from the perspective of safety and economic benefits.
safety. We all know the “Mundell Impossibility Triangle”: efficiency, security and “decentralization” cannot be achieved at the same time. At the current level of technology, upgrading one of the indicators inevitably sacrifices the other two indicators. If the TPS is increased and a lot of data cannot be uploaded in time, it will gradually weaken the performance of decentralization, which will affect the consensus and security of the network while affecting decentralization.
economic profit. If the capacity of the blockchain is increased, a lot of information will be delayed in uploading, and empty blocks or orphaned blocks will easily appear, which will reduce the income of miners. Even if the block time is extended, the Filecoin network was originally at a height of 2880 per day, and reducing daily block production is undoubtedly reducing block rewards. Therefore, from the perspective of economic benefits, expanding the capacity will reduce the income of miners.
From the perspective of security and economic benefits, there is currently no strategy that can directly reduce Gas, but recently the official also mentioned that the FIP-08 proposal aggregates and submits the PreCommitSector message to reduce network congestion and reduce gas consumption by merging messages; there is another improvement TPS, but without losing security, is to expand the block capacity to increase the upper limit of the Block Gas Limit, while improving the performance of the miner’s hardware and continuing to invest in new hardware. This method is not very friendly to miners.
Gas fee = BaseToBurn + Miner Fee + OverEstimateToBurn
As mentioned in the previous article on excess combustion, the protocol laboratory does not recommend the use of excessive gas fees, so some penalties will be imposed on the excess, that is, excess combustion fees. Below, we use a certain Gas fee as an example to expand the calculation and explanation.
Figure 2, Source: filfox.info, 2020-12-14
Miner Fee
When BaseFee + GasPremium> GasFeeCap, Miner Fee=Gas Limit* (GasFeeCap-BaseFee)
When BaseFee + GasPremium ≤GasFeeCap, Miner Fee=Gas Limit*GasPremium
BaseFee, GasPremium, and GasFeeCap are three rates respectively. BaseFee is for basic burning fee, GasPremium is for tipping rate, and GasFeeCap is for total payment rate. The official has set a parameter for tip, mainly for the relationship between GasFeeCap and BaseFee + GasPremium, to pay as little tip as possible.
At present, according to the news on the market, the tip is BaseFee + GasPremium ≤ GasFeeCap, that is, Miner Fee=Gas Limit*GasPremium, which is obtained by substituting the data in the above figure
Because the Burn Fee in Figure 2 includes the basic burning fee and the excess burning fee, we need to calculate two values.
Basic Burning Fee (BaseToBurn)
We all know that BaseToBurn=Base Fee*Gas Used, substituting the data in Figure 2 to calculate
OverEstimateToBurn (OverEstimateToBurn)
For the excess burning fee Filecoin has set an indicator Over for gas, mainly to avoid using too high Gas fee, where Over=Gas Limit-11/10*Gas Used.
Figure 3. Over indicator, source: IPFS Force Zone, 2020-12-15
According to the content of the previous article, we need to know the range of Gas Limit/Gas Used after finishing. Figure 3 shows that we have sorted out the Gas Limit/Gas Used from November 14th to December 14th. Most of them are in the range of 1.2-1.3, so the following formula can be used.
Take the data in Figure 2 above as an example, first obtain the Gas Limit/Gas Used=439951486/352018389=1.24979688490081, which meets the conditions in Figure 3, substitute Over to obtain the excess combustion fee
Substituting the OverEstimateToBurn and BaseToBurn obtained above, Burn Fee=OverEstimateToBurn+BaseToBurn=0.0515588402332158+1.37788616484047=1.4294450050FIL, which is the Burn Fee fee in Figure 2.
So the actual total Gas fee paid is OverEstimateToBurn+BaseToBurn+Miner Fee, and the excess will be refunded.
How to set fees can drive miners to pack?
There are two main steps for miners to pack: check whether the Gas Fee Cap is larger than the current Base Fee, and whether the Gas Premium is large enough.
Whether the Gas Fee Cap is greater than the current Base Fee . Because the Gas Fee Cap is the maximum rate that users can pay, if the rate is too low, the miner will be punished three times. For example, originally a transfer user needs to pay 10 yuan, but the user fills in the maximum payment of 9 yuan, but the miner neglects to complete the package, the difference of 1 yuan needs to be paid by the miner, and an additional 2 times penalty, namely 2 yuan, is required. In general, the difference will cause three times the penalty (3 yuan) to the miner. Because there are more than one million messages a day, miners may cause severe FIL penalties for ignoring this.
After ensuring that the information can be packaged, miners need to weigh whether their own interests are the best?
Is Gas Premium large enough? This piece is mainly related to the interests of miners. The larger the Gas Premium, the more the miners will get the handling fee (when BaseFee + GasPremium ≤ GasFeeCap), because Miner Fee=Gas Limit*GasPremium, even if the miners get the most benefits. Otherwise, as shown in Figure 2, the Gas Fee Cap is 19.57 nanoFIL, which is very large, but the Gas Premium is 1 attoFIL. The actual benefits given to miners are small, and the market behavior will be delayed.
Therefore, when users need to transfer money quickly, they need to make sure whether the Gas Fee Cap is larger than the Base Fee and whether the Gas Premium is large enough to ensure that the transfer is executed even if it is done.
The above suggestions are suitable for users and are for reference only for miners. Because miners need to pack a lot of information every day, more sophisticated calculations are needed to ensure the reasonable use of gas fees. Because of the complexity, this is not the case.
This article mainly answers some questions for users. Although the Filecoin network is too congested, miners cannot smoothly increase their computing power. But the author believes that with the optimization of the FIP proposal, the mechanism or technology will gradually solve the problem of high gas fees.
Because Filecoin’s long-cherished aspiration is to become the infrastructure of Web 3.0, the road will be long in the future. I hope all investors will wait patiently.