| ACP | 176 |
|---|---|
| Title | Dynamic EVM Gas Limits and Price Discovery Updates |
| Author(s) | Stephen Buttolph (@StephenButtolph), Michael Kaplan (@michaelkaplan13) |
| Status | Activated (Discussion) |
| Track | Standards |
Proposes that the C-Chain and Subnet-EVM chains adopt a dynamic fee mechanism similar to the one introduced on the P-Chain as part of ACP-103, with modifications to allow for block proposers (i.e. validators) to dynamically adjust the target gas consumption per unit time.
Currently, the C-Chain has a static gas target of 15,000,000 gas per 10 second rolling window, and uses a modified version of the EIP-1559 dynamic fee mechanism to adjust the base fee of blocks based on the gas consumed in the previous 10 second window. This has two notable drawbacks:
- The windower mechanism used to determine the base fee of blocks can lead to outsized spikes in the gas price when there is a large block. This is because after a large block that uses all of its gas limit, blocks that follow in the same window continue to result in increased gas prices even if they are relatively small blocks that are under the target gas consumption.
- The static gas target necessitates a required network upgrade in order to modify. This is cumbersome and makes it difficult for the network to adjust its capacity in response to performance optimizations or hardware requirement increases.
To better position Avalanche EVM chains, including the C-Chain, to be able to handle future increases in load, we propose replacing the above mechanism with one that better handles blocks that consume a large amount of gas, and that allows for validators to dynamically adjust the target rate of consumption.
The mechanism to determine the base fee of a block is the same as the one used in ACP-103 to determine the gas price of a block on the P-Chain. This mechanism calculates the gas price for a given block
| the target gas consumed per second | |
| minimum gas price | |
| gas price update constant | |
| maximum gas capacity | |
| gas capacity added per second |
As noted above, the gas price determination mechanism relies on a target gas consumption per second,
Let
where
After the execution of transactions in block
Block builders (i.e. validators), may set their desired value for
Note that since
When building a block, builders can calculate their next preferred value for q_current) according to:
# Calculates a node's new desired value for q given for a given block
def calc_next_q(q_current: int, q_desired: int, max_change: int) -> int:
if q_desired > q_current:
return q_current + min(q_desired - q_current, max_change)
else:
return q_current - min(q_current - q_desired, max_change)As
This ensures that the gas price can increase and decrease at the same rate.
The value of
This means that the maximum stored gas capacity would be reached after 5 seconds where no blocks have been accepted.
In order to keep roughly constant the time it takes for the gas price to double at sustained maximum network capacity usage, the value of
In order to have the gas price not be directly impacted by the change in
Note that the value of
Allowing block builders to adjust the target gas consumption rate in blocks that they produce makes it such that the effective target gas consumption rate should converge over time to the point where 50% of the voting stake weight wants it increased and 50% of the voting stake weight wants it decreased. This is because the number of blocks each validator produces is proportional to their stake weight.
As noted in ACP-103, the maximum gas consumed in a given period of time
As noted above, the gas price determination mechanism depends on the values of
Parameters at activation on the C-Chain are:
| Parameter | Description | C-Chain Configuration |
|---|---|---|
| minimum target gas consumption per second | ||
| target gas consumption rate update constant | ||
| target gas consumption rate update factor change limit | ||
| minimum gas price |
|
|
| initial gas price update factor |
The maximum instantaneous price multiplier is:
As mentioned above, this new mechanism allows for validators to specify their desired target gas consumption rate (
While Avalanche Network Clients can set default configuration values for the desired target gas consumption rate, each validator can choose to set this value independently based on their own considerations.
The changes proposed in this ACP require a required network upgrade in order to take effect. Prior to its activation, the current gas limit and price discovery mechanisms will continue to be used. Its activation should have relatively minor compatibility effects on any developer tooling. Notably, transaction formats, and thus wallets, are not impacted. After its activation, given that the value of
Note
After the activation of this ACP, concerns were raised around the latency of inclusion for large transactions when the fee is increasing. To address these concerns, block producers SHOULD only produce blocks when there is sufficient capacity to include large transactions. Prior to this ACP, the maximum size of a transaction was
This ACP was implemented and merged into Coreth behind the Fortuna upgrade flag. The full implementation can be found in coreth@v0.14.1-acp-176.1.
This ACP changes the mechanism for determining the gas price on Avalanche EVM chains. The gas price is meant to adapt dynamically to respond to changes in demand for using the chain. If it does not react as expected, the chain could be at risk for a DOS attack (if the usage price is too low), or over charge users during period of low activity. This price discovery mechanism has already been employed on the P-Chain, but should again be thoroughly tested for use on the C-Chain prior to activation on the Avalanche Mainnet.
Further, this ACP also introduces a mechanism for validators to change the gas limit of the C-Chain. If this limit is set too high, it is possible that validator nodes will not be able to keep up in the processing of blocks. An upper bound on the maximum possible gas limit could be considered to try to mitigate this risk, though it would then take further required network upgrades to scale the network past that limit.
Thanks to the following non-exhaustive list of individuals for input, discussion, and feedback on this ACP.
- Emin Gün Sirer
- Luigi D'Onorio DeMeo
- Darioush Jalali
- Aaron Buchwald
- Geoff Stuart
- Meag FitzGerald
- Austin Larson
Copyright and related rights waived via CC0.