Why did the Ethereum gas fee suddenly drop sharply?
Foreword: On April 25, data showed that the gas fee of Ethereum dropped by about 50gwei, which is the lowest since 2021. Previously, due to the continuous increase of gas fees, the transaction fee on the chain once approached 1500gwei. Recently, the gas fee of Ethereum has dropped sharply, and the reason may be related to the increase of block Gas Limit in Ethereum. On April 22, Ethereum raised the block Gas Limit from about 12.5 million Gwei to 15 million Gwei, an increase of about 20%. So what factors will affect the Gas fee of Ethereum? This article may give you the answer.
Note: This article was first published on September 23, 2020, and some of the data are current data. When reading, please note that the data may have changed significantly as of today’s publication.
Written by: 0x88, Rhythm BlockBeats
When Uniswap distributed money to more than 200,000 user addresses, perhaps many people thought, "This gas fee is too high."
That day was a memorable day in the history of Ethereum. The gas proposal reached a maximum of 1000 GWEI, which was the highest point in history at that time.
On the morning of witnessing history and the national airdrop, many people encountered problems with gas fees. Expensive gas fees are no longer a problem. The problem is that the maximum value suggested by the gas fee to the wallet cannot be sold within the planned time. Everyone's Metamask shows that they are all pending, and it's annoying to go round and round.
Why can't you use the default gas fee amount, but still can't trade instantly? This article will explain in detail the transaction rate mechanism of Ethereum and the problems encountered in initiating transactions on Ethereum.
Gas logic
This matter must first start with the Ethereum account.
There are two types of accounts in the Ethereum network, Externally Owned Account and Contract Account.
External accounts are accounts used by users, controlled by the private key holder. Contract account refers to a smart contract with application logic, which is controlled by the contract code (often owned by the project party). When users use DeFi applications, they are using their own accounts to interact with the smart contracts of DeFi projects.
Various accounts can interact at will, transfers can be made between wallets, and contracts can also call each other. Every interaction on the chain needs to consume a certain amount of calculation. The amount of calculation consumed is determined by the difficulty of calculation, and Gas is the unit of measurement of the amount of calculation. For example, the addition operation is relatively simple and requires 3 Gas, while the division operation is relatively complicated and requires 5 Gas.
Each unit of Gas has its corresponding price, that is, the Gas Price (Gas Price), and the Gas price is in Wei. Users need to purchase ETH to pay Gas fees. 1 ETH=1e18 Wei, and the unit GWei we usually see is 1e9Wei. Usually, the wallet software will estimate the cost of the transaction that the user will initiate through the historical Gas Price.
In order to avoid the concentration of all nodes, the blockchain that pursues decentralized architecture will strictly limit the capacity of each single block. For example, Bitcoin's Block Size Limit and Ethereum's Block Gas Limit. When Rhythm BlockBeats wrote the article, the Block Gas Limit of each single block in Ethereum is about 12,000,000 Gas, which is the upper limit of the total calculation amount of each block. On average, a block is produced every 15 seconds. When the transaction demand exceeds the block capacity, users need to compete for resources in each block in order to have their transactions confirmed on the chain as soon as possible. At this time, users will bid for Gas, and miners will prioritize transactions with high Gas Price into blocks.
Usually users will also see that the wallet will increase the option to adjust the Gas Limit when making a transfer. Different from the Block Gas Limit, the Gas Limit refers to the upper limit of Gas usage that users can accept for a transaction. Because sometimes there may be loopholes in the contract, a transaction will be calculated in an endless loop. If there is no Gas Limit, this transaction will consume all the ETH in the user's wallet. The fees usually charged by miners are settled according to the calculation amount consumed when actually executing the transaction (Gas Used by Transaction), and the remaining ETH in the Gas Limit will be returned to the user's account.
So we can conclude that the amount of ETH consumed (Ether Cost) = transaction fee (Gas Fee/Transaction Fee) = the amount of Gas consumed by each transaction (Gas Used By Transaction) * Gas Price (Gas Price).
After understanding the fee mechanism and account types of Ethereum, let's take a look at the problems that users often encounter when trading.
Pending/accelerated transactions?
Whenever a user initiates a transaction, the transaction will be put into a transaction pool (Mempool). As mentioned above, miners will give priority to packaging transactions with the highest Gas Price in the pool (the miners' profit-seeking nature). Therefore, the Gas Price set by the user determines the speed at which the transaction is packaged and executed. When the network is congested, due to the soaring Gas Price, the user's transaction may be pending confirmation for a long time. In order to send pending transactions as soon as possible, users can choose to pay more Gas Price to speed up transactions (Rhythm note: understood as giving miners more rewards to achieve the purpose of jumping in the queue).
How does accelerated trading work? In order to understand the logic of accelerated transactions in more detail, we need to understand another parameter: Nonce. The transaction sent by each account will have a sequential transaction number -- Nonce, starting from 0, and each time a transfer is initiated, the Nonce value of the account will increase by 1.
When the user wants to accelerate the transaction, in the Ethereum wallet, the user can choose the accelerated transaction option, and will be required to pay a higher Gas fee. After the user agrees, it is equivalent to initiating a new transaction, and the new transaction Same as the Nonce value of the transaction to be confirmed.
Due to the regulations of the Ethereum network, the Nonce value is continuous and non-jumpable, and the Nonce value of each transaction at the same address cannot be repeated, so the miners will package the newly generated transaction. After the new transaction is packaged and confirmed, the previous lower Gas Price The transaction will be discarded.
If the user does not want to speed up the transaction, as long as the transaction is still unpacked in the transaction pool, the user can choose to cancel the transaction at any time. The logic of canceling a transaction is the same as that of accelerating a transaction. The user initiates a transaction with a higher Gas Price but the same Nonce as the transaction to be confirmed, but the transaction amount becomes 0, so in essence, the cost of canceling the transaction is the same as the cost of accelerating the transaction. cost.
It should be noted that before the confirmation of the pending transaction is completed, the following transactions need to wait in line, so users should not repeatedly initiate multiple transactions due to the long waiting time.
Transaction failed (Fail)
Rhythm BlockBeats found that the most common reason for transaction failure is that the transaction Gas has been exhausted (Out of Gas). That is to say, the computation of this transaction exceeds the Gas Limit set by the user. Generally, in this case, the transaction status will be displayed as failed, indicating that the Gas has been exhausted, and the paid Gas will not be refunded.
Some users may think this is unfair, but in essence, the miners are already doing work calculations, but the gas is not enough after half of the calculations, so the miners can only give up and continue to work, but the previous work needs to be paid "salary", so the previous work It is probably understandable that the gas fee is not refundable. In this case, the user can only re-initiate a transaction and increase the Gas Limit of this transaction.
Another case of transaction failure is when the user initiates a transaction transfer to the smart contract, but some errors prevent the execution of the contract, the transaction will return Bad Instruction. For example, when a user participates in a crowdfunding campaign, the following situations may occur:
Quota is full;
or the user is not whitelisted;
Or user oversubscription tokens and so on.
At this time, the Gas Limit set by the user will be exhausted, which will eventually lead to the failure of the transaction.
However, after the Ethereum Byzantine hard fork, a new operator Reverted (EIP-140) was added. When an error occurs in the contract and the transaction fails, the transaction will not exhaust all the Gas set by the Gas Limit, the contract will stop executing and refund the remaining Gas fee, and inform the user of the cause of the error.
Of course, if the amount of ETH in the user's wallet is not enough to pay the Gas fee, the transaction will also be judged as a failure.
When there are no hot spots, the Ethereum network is peaceful, and all transfer costs, including time and amount, are controllable, but when the wind blows, everyone will encounter various problems in the network. The logic of gas fees is that newcomers use The biggest obstacle is the wallet.
Basically, this article covers all the problems encountered in the gas fee. On-chain transactions are not complicated. To put it simply, if there is any problem with any operation, you can fix it by adding money.
At present, this movement seems to have temporarily come to an end for the upsurge of liquidity mining on Ethereum. In addition to creating a bubble, this movement has also made more users get used to the use of wallets. Wallets have finally become a high-frequency wallet. tool.
The problems that occur in transactions on the chain are actually providing space for the optimization of wallets. Services such as "one-click acceleration" and "one-click cancellation" for newcomers may be seen in more and more wallets.


