Apricot Phase Three: C-Chain Dynamic Fees
Apricot Phase Three upgrade will activate on the Avalanche Mainnet at 7 a.m. EDT (11 a.m. UTC) on Tuesday, August 24th.
Today, we are publishing the pre-release code for Phase Three of the Apricot Upgrade (“AP3”), which will activate at 3 p.m. EDT (7 p.m. UTC) on Monday, August 16th on the Fuji Testnet. Note, the pre-release code referenced above only works on Fuji. If you run it on Avalanche Mainnet, it will exit on startup.
Pending a successful AP3 activation on Fuji, we will publish the official release that will be used on Avalanche Mainnet for AP3. AP3 will activate at 7 a.m. EDT (11 a.m. UTC) on Tuesday, August 24th on Avalanche Mainnet.
This upgrade includes breaking changes and once we publish the official Avalanche Mainnet release we recommend that all validators upgrade their nodes to AvalancheGo >= v1.5.0.
Moderato: Dynamic Fees Overview
AP3 introduces dynamic fees on the C-Chain using a new algorithm (“Moderato”) that targets a specific network utilization over time. When the network operates over the target utilization, the minimum fee a transaction must pay to be included in a block increases. When the network operates under the target utilization, the minimum fee a transaction must pay to be included in a block decreases. As the network gains capacity to handle additional load (through the activation of future protocol enhancements), this algorithm can be tuned to increase this targeted utilization (increasing the number of transactions that can be processed at a specific fee rate).
Because block production is asynchronous in Snowman, Moderato cannot depend on a height-based mechanism to determine if utilization is above or below the target (many blocks could be produced in a short window to game the fee mechanism) nor can it rely on the content of blocks alone (there is additional overhead to splitting the same content in 20 blocks instead of 1). To satisfy these constraints, Moderato forms a view of the network using a rolling, time-based window of activity, where block production is reduced into the same measure of activity as the block content itself.
When applied to the Coreth (the VM that powers the C-Chain), the result is a mechanism that computes the minimum gas price a transaction must pay as a function of the gas usage over a recent window where each block produced in the window contributes some synthetic gas overhead. When the gas usage of the window is above the gas target for the parameterized window, the gas price will increase. When the gas usage of the window is below the gas target for the parameterized window, the gas price will decrease. To ease the transition for ecosystem participants to this new mechanism, the gas price computed using this mechanism is upper-bounded by the current static gas price of 225 nAVAX (225 gwei) that was introduced in AP1.
In summary, Moderato has the following characteristics:
- Time-Based, Rolling Window Fee Calculation: The minimum gas price any transaction must pay is calculated based on the amount of gas consumed in the last 10 seconds (including the synthetic gas usage of any blocks produced during that same window). If that amount of gas used is below the target usage, the minimum gas price decreases. If it is above the target gas usage, it increases.
- Capped Fee Range (75–225 nAVAX): The dynamic fee algorithm caps the gas price at 225 nAVAX (static price introduced in AP1). This means that if you don’t change how you create transactions, your transactions will still be valid and included in a block. If you decide to take advantage of the new dynamic fee mechanism, however, you could pay a gas price as low as 75 gwei (a 66% fee reduction!). In future upgrades, these bounds may be relaxed so that the minimum gas price can drift even lower when there is low network usage.
- Fee Burning: The entire fee paid by each transaction is burned (as has been the case since the launch of the Avalanche Network).
- Block Gas Limit (8 Million Gas): The block gas limit on the C-Chain does not expand or contract depending on congestion. Instead, it is fixed at its current value (introduced in AP1): 8 million gas.
To maintain compatibility with EVM tooling that has/is upgrading to utilize the recently activated EIP-1559 (Fee market change for ETH 1.0 chain), we mapped “BaseFeePerGas” and the new “Transaction1559Payload” to the new algorithm’s minimum gas price mechanism. When broadcasting a transaction using this new format, you are charged the minimum gas price allowed in the block your transaction is included in (instead of the gas price you specify). Using the “TransactionLegacy” format, however, will still result in the gas price specified being paid. Because the “BaseFeePerGas” field is populated after AP3 activates, common tooling (like MetaMask) will automatically take advantage of flexibility provided by this new transaction type.
London EIPs Support
Additionally, AP3 activates 2 London EIPs in an unmodified form (which activated on Ethereum in early-August). These are:
- EIP-3198 (BASEFEE opcode): Access the current value of the BASEFEE
- EIP-3541 (Reject new contracts starting with the 0xEF byte): Disallow new code starting with the 0xEF byte to be deployed
EIP-1559 (Fee market change for ETH 1.0 chain) was applied in the modified form described above. EIP-3529 (Reduction in refunds) was not applied because gas refunds were removed entirely in Apricot Phase 1. EIP-3554 (Difficulty bomb delay to December 1st, 2021) was not applied because the C-Chain does not use Proof-of-Work.
- Apricot Phase Three Upgrade code and full details can be found here.
- A tutorial for upgrading your node is available here.
- If you have any questions, please connect with the Ava Labs developer team here.
- For a full list of all the items we are targeting in the upcoming Apricot upgrades, check out the Apricot Phase 1 post.
How do I upgrade my node?
The process to upgrade to AvalancheGo v1.5.0 is the same as any other upgrade. If you build from source, run the build script as before. If you use the pre-compiled binaries, invoke them as before. If you use the installer script, use that as before.
Once you start AvalancheGo v1.5.0, you do not need to do anything else. More information on updating a node can be found here. As a reminder, it is best practice to have a backup of your staking key/certificate.
Please note that AvalancheGo >= v1.5.0 no longer places binaries in the “build/avalanchego-latest” and “build/avalanchego-preupgrade” directories because the node wrapper is no longer required (used to support the v1.4.5 database migration). Binaries are now placed in their pre-v1.4.5 locations, “build/avalanchego” and “build/plugins/evm”.
I use MetaMask. Do I need to change anything?
No. MetaMask will automatically account for dynamic fees once they go into effect.
How can I know the current gas price?
You can call the eth_gasPrice API method. For example:
What are the minimum/maximum gas prices?
75 nAVAX and 225nAVAX, respectively. This means that the gas price will always be less than or equal to the old, static gas price.
What if the price of AVAX increases, causing transactions to become more expensive?
The minimum/maximum gas prices may be updated in future network upgrades.
Do I have to upgrade my node?
Yes, you must upgrade your node to AvalancheGo >= v1.5.0 by 7 a.m. EDT (11 a.m. UTC) on Tuesday, August 24th. If you don’t upgrade to v1.5.0 by this time, your node will be marked as offline and other nodes will report your node as having lower uptime, which may jeopardize your staking rewards.
Is there any change in hardware requirements?
Will updating decrease my validator’s uptime?
I think something is wrong. What should I do?
First, make sure that you’ve read the documentation thoroughly. It might answer your question somewhere. If you don’t see the answer, go to our Discord server and search for your question. If it has not already been asked, please post it in the most appropriate channel.