ACP-224: Dynamic Gas Limit In Subnet Evm
Details for Avalanche Community Proposal 224: Dynamic Gas Limit In Subnet Evm
| ACP | 224 |
|---|---|
| Title | Introduce ACP-176-Based Dynamic Gas Limits and Fee Manager Precompile in Subnet-EVM |
| Author(s) | Ceyhun Onur (@ceyonur), Michael Kaplan (@michaelkaplan13) |
| Status | Proposed (Discussion) |
| Track | Standards |
Abstract
Proposes implementing ACP-176 in Subnet-EVM, along with the addition of a new optional ACP224FeeManagerPrecompile that can be used to configure fee parameters on-chain dynamically after activation, in the same way that the existing FeeManagerPrecompile can be used today prior to ACP-176.
Motivation
ACP-176 updated the EVM dynamic fee mechanism to more accurately achieve the target gas consumption on-chain. It also added a mechanism for the target gas consumption rate to be dynamically updated. Until now, ACP-176 was only added to Coreth (C-Chain), primarily because most L1s prefer to control their fees and gas targets through the FeeManagerPrecompile and FeeConfig in genesis chain configuration, and the existing FeeManagerPrecompile is not compatible with the ACP-176 fee mechanism.
ACP-194 (SAE) depends on having a gas target and capacity mechanism aligned with ACP-176. Specifically, there must be a known gas capacity added per second, and maximum gas capacity. The existing windower fee mechanism employed by Subnet-EVM does not provide these properties because it does not have a fixed capacity rate, making it difficult to calculate worst-case bounds for gas prices. As such, adding ACP-176 into Subnet-EVM is a functional requirement for L1s to be able to use SAE in the future. Adding ACP-176 fee dynamics to Subnet-EVM also has the added benefit of aligning with Coreth such that only a single mechanism needs to be maintained on a go-forwards basis.
While both ACP-176 and ACP-194 will be required upgrades for L1s, this ACP aims to provide similar controls for chains with a new precompile. A new dynamic fee configuration and fee manager precompile that maps well into the ACP-176 mechanism will be added, optionally allowing admins to adjust fee parameters dynamically.
Specification
ACP-176 Parameters
This ACP uses the same parameters as in the ACP-176 specification, and allows their values to be configured on a chain-by-chain basis. The parameters and their current values used by the C-Chain are as follows:
| Parameter | Description | C-Chain Configuration |
|---|---|---|
| target gas consumed per second | dynamic | |
| gas capacity added per second | 2*T | |
| maximum gas capacity | 10*T | |
| minimum target gas consumption per second | 1,000,000 | |
| target gas consumption rate update constant | 2^25 | |
| target gas consumption rate update factor change limit | 2^15 | |
| minimum gas price | 1 Wei (10^-18 AVAX) | |
| gas price update constant () | 87*T |
Prior Subnet-EVM Fee Configuration Parameters
Prior to this ACP, the Subnet-EVM fee configuration and fee manager precompile used the following parameters to control the fee mechanism:
GasLimit: Sets the max amount of gas consumed per block.
TargetBlockRate: Sets the target rate of block production in seconds used for fee adjustments. If the actual block rate is faster than this target, block gas cost will be increased, and vice versa.
MinBaseFee: The minimum base fee sets a lower bound on the EIP-1559 base fee of a block. Since the block's base fee sets the minimum gas price for any transaction included in that block, this effectively sets a minimum gas price for any transaction.
TargetGas:
Specifies the targeted amount of gas (including block gas cost) to consume within a rolling 10s window. When the dynamic fee algorithm observes that network activity is above/below the TargetGas, it increases/decreases the base fee proportionally to how far above/below the target actual network activity is.
BaseFeeChangeDenominator: Divides the difference between actual and target utilization to determine how much to increase/decrease the base fee. A larger denominator indicates a slower changing, stickier base fee, while a lower denominator allows the base fee to adjust more quickly.
MinBlockGasCost: Sets the minimum amount of gas to charge for the production of a block.
MaxBlockGasCost: Sets the maximum amount of gas to charge for the production of a block.
BlockGasCostStep:
Determines how much to increase/decrease the block gas cost depending on the amount of time elapsed since the previous block. If the block is produced at the target rate, the block gas cost will stay the same as the block gas cost for the parent block. If it is produced faster/slower, the block gas cost will be increased/decreased by the step value for each second faster/slower than the target block rate accordingly.
Note: if the BlockGasCostStep is set to a very large number, it effectively requires block production to go no faster than the TargetBlockRate.
Ex: if a block is produced two seconds faster than the target block rate, the block gas cost will increase by 2 * BlockGasCostStep.
ACP-176 Parameters in Subnet-EVM
ACP-176 will make GasLimit and BaseFeeChangeDenominator configurations obsolete in Subnet-EVM.
TargetBlockRate, MinBlockGasCost, MaxBlockGasCost, and BlockGasCostStep will be also removed by ACP-226.
MinGasPrice is equivalent to M in ACP-176 and will be used to set the minimum gas price for ACP-176. This is similar to MinBaseFee in old Subnet-EVM fee configuration, and roughly gives the same effect. Currently the default value is 25 * 10^-9 AVAX (25 nAVAX / 25 Gwei). This default will be changed to the minimum possible denomination of the native EVM asset (1 Wei), which is aligned with the C-Chain.
TargetGas is equivalent to T (target gas consumed per second) in ACP-176 and will be used to set the target gas consumed per second for ACP-176.
TimeToDouble will be used to control the speed of the fee adjustment. In ACP-176, the gas price update constant is defined as , where is the target gas per second and is a multiplier. The TimeToDouble parameter configures directly via the relationship . The default value for TimeToDouble is 60 seconds, yielding , which is aligned with the C-Chain (where ). At sustained maximum capacity ( gas/second), this results in the gas price doubling approximately every 60 seconds.
As a result parameters will be set as follows:
| Parameter | Description | Default Value | Is Configurable |
|---|---|---|---|
| target gas consumed per second | 1,000,000 | :white_check_mark: | |
| gas capacity added per second | 2*T | :x: | |
| maximum gas capacity | 10*T | :x: | |
| minimum target gas consumption per second | 1,000,000 | :x: | |
| target gas consumption rate update constant | 2^25 | :x: | |
| target gas consumption rate update factor change limit | 2^15 | :x: | |
| minimum gas price | 1 Wei | :white_check_mark: | |
| gas price update constant () | ~87*T | :white_check_mark: Through TimeToDouble (default 60s equivalent to )$ |
The gas capacity added per second (R) always being equal to 2*T keeps it such that the gas price is capable of increase and decrease at the same rate. The values of Q and D affect the magnitude of change to T that each block can have, and the granularity at which the target gas consumption rate can be updated. The proposed values match the C-Chain, allowing each block to modify the current gas target by roughly of its current value. This has provided sufficient responsiveness and granularity as is, removing the need to make D and Q dynamic or configurable. Similarly, 1,000,000 gas/second should be a low enough minimum target gas consumption for any EVM L1. The target gas for a given L1 will be able to be increased from this value dynamically and has no maximum.
Max Capacity Factor (C) Design Rationale
The maximum gas capacity (C) is intentionally not configurable for L1s. ACP-194 (SAE) defines the max gas capacity (i.e., max block size/block gas limit) as , where is the constant delay and is the inverse of the minimum percentage of the gas limit charged. This definition ensures that the transaction queue can always be fully saturated. This means that the max capacity of the C-Chain will actually double upon ACP-194 activation, since it is currently and it will become .
The original motivation to make this configurable was to allow for very high maximum gas usage by a single block, primarily to support large contract deployments. Given that SAE will be activated at the same time as ACP-224, the max capacity of the C-Chain will double upon activation, further reducing the need for configurability. Additionally Ethereum's Fusaka upgrade introduces a maximum transaction gas limit of (~16.7M), which makes this concern largely moot.
Given these considerations, C was changed to not be parametrizable for L1s because:
- SAE provides clear rationale for the max capacity value (ensuring the transaction queue can always be fully saturated).
- The future maximum transaction gas limit of 16.7M makes large contract deployments less of a concern.
- There are very limited benefits to allowing
Cto be higher than the SAE-defined value in the future. - It's still a function of
T, so it can be adjusted dynamically via theACP224FeeManagerPrecompileif needed.
Dynamic Gas Target Via Validator Preference
For L1s that want their gas target to be dynamically adjusted based on the preferences of their validator sets, the same mechanism introduced on the C-Chain in ACP-176 will be employed. Validators will be able to set their gas-target preference in their node's configuration, and block builders can then adjust the target excess in blocks that they propose based on their preference.
Validator target gas preferences are active in the following cases:
- Precompile not activated: When the
ACP224FeeManagerPrecompileis not activated at all, validators can controltargetGasby using thegas-targetpreference in their node's configuration. If a validator does not set agas-targetpreference, the parent block's gas target is maintained. validatorTargetGasenabled: When the precompile is activated andvalidatorTargetGasis set totrue(either viainitialFeeConfigor by an admin callingsetFeeConfigwithvalidatorTargetGas: true), the precompile's storedtargetGasis not used for block building. Validators adjusttargetExcessfrom the parent block's current value within ACP-176's bounded update limits. If a validator does not set agas-targetpreference, the parent block's gas target is maintained.
When validatorTargetGas is false (the default), the precompile's stored targetGas value is authoritative and validator preferences for gas target are ignored.
ACP224FeeManagerPrecompile
Solidity Interface
The ACP224FeeManagerPrecompile provides an on-chain interface for managing fee parameters dynamically. The FeeConfig struct contains all configuration parameters, including both numeric values and mode flags (staticPricing, validatorTargetGas). All changes are made through a single setFeeConfig call, keeping the interface minimal and straightforward. This design ensures configurations are applied atomically and consistently.
The precompile offers similar controls as the existing FeeManagerPrecompile implemented in Subnet-EVM here. The solidity interface is as follows:
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "./IAllowList.sol";
/// @title ACP-224 Fee Manager Interface
/// @notice Interface for managing dynamic gas limit and fee parameters
/// @dev Inherits from IAllowList for access control
interface IACP224FeeManager is IAllowList {
/// @notice Configuration parameters for the dynamic fee mechanism
/// @dev Fields are ordered so each mode flag precedes the parameter(s) it governs,
/// reducing the risk of mis-ordering arguments.
struct FeeConfig {
bool validatorTargetGas; // When true, validators control targetGas via node preferences
uint256 targetGas; // Target gas consumption per second (T)
bool staticPricing; // When true, gas price is always minGasPrice
uint256 minGasPrice; // Minimum gas price in wei (M)
uint256 timeToDouble; // Seconds for gas price to double at max capacity
}
/// @notice Emitted when fee configuration is updated
/// @param sender Address that triggered the update
/// @param oldFeeConfig Previous configuration
/// @param newFeeConfig New configuration
event FeeConfigUpdated(address indexed sender, FeeConfig oldFeeConfig, FeeConfig newFeeConfig);
/// @notice Set the fee configuration
/// @param config New fee configuration parameters
function setFeeConfig(FeeConfig calldata config) external;
/// @notice Get the current fee configuration
/// @return config Current fee configuration
function getFeeConfig() external view returns (FeeConfig memory config);
/// @notice Get the block number when fee config was last changed
/// @return blockNumber Block number of last configuration change
function getFeeConfigLastChangedAt() external view returns (uint256 blockNumber);
}For chains with the precompile activated, setFeeConfig can be used to dynamically change all fee configuration parameters, including both numeric values and mode flags. Importantly, any updates made via calls to setFeeConfig in a transaction will take effect only as of settlement of the transaction, not as of acceptance or execution (for transaction life cycles/status, refer to ACP-194 here). This ensures that all nodes apply the same worst-case bounds validation on transactions being accepted into the queue, since the worst-case bounds are affected by changes to the fee configuration.
FeeConfig Fields
The FeeConfig struct fields are shared by both setFeeConfig and initialFeeConfig:
validatorTargetGas(bool): Whentrue, validators controltargetGasdynamically via their node preferences, using the same mechanism as the C-Chain (see Dynamic Gas Target Via Validator Preference). The storedtargetGasvalue is not used for block building; validators always adjust from the parent block'stargetExcess. Whentrue,targetGasmust be0.targetGas(uint64): Target gas consumption per second (). WhenvalidatorTargetGasisfalse, must be at least 1,000,000 (the minimum target gas consumption ). WhenvalidatorTargetGasistrue, must be0meaning validators determine the gas target from the parent block's state.staticPricing(bool): Whentrue, the gas price is alwaysminGasPrice, bypassing the ACP-176 dynamic fee mechanism entirely. WhenstaticPricingistrue,timeToDoublemust be0.minGasPrice(uint64): Minimum gas price in wei (). Must be greater than0. WhenstaticPricingistrue, this is the fixed gas price.timeToDouble(uint64): Seconds for the gas price to double when the chain is at maximum capacity. Determines as described in ACP-176 Parameters in Subnet-EVM. Must be greater than0whenstaticPricingisfalse. WhenstaticPricingistrue, must be0.
Toggling behavior:
- Enabling (setting
validatorTargetGastotrueviasetFeeConfig):targetGasmust be0. Validators begin adjustingtargetExcessfrom the parent block's current value. Since ACP-176's bounded update mechanism limits changes to roughly of the current value per block, the transition is always gradual. The parent block'stargetExcess(which was set by the precompile) provides an unambiguous starting point. - Disabling (setting
validatorTargetGastofalseviasetFeeConfig): ThetargetGasvalue provided in the samesetFeeConfigcall (must be >= 1,000,000) is immediately authoritative for block building upon settlement. The caller should check the current effective gas target (from block headers or RPC) and provide an appropriatetargetGasvalue, since validators may have drifted the effective gas target far from the previously stored value and using a stale value could cause a dangerous sudden jump in gas capacity.
Initial Fee Configuration
All fee configuration for ACP-224 is done through the ACP224FeeManagerPrecompile. There is no separate genesis chain configuration for the new fee parameters. If the precompile is not activated at all, or no initialFeeConfig is provided, default values aligned with the C-Chain are used.
The precompile can be activated with an initialFeeConfig to set the initial fee parameters at the activation timestamp. This follows the established Subnet-EVM pattern for initial precompile configurations. If no admin, manager, or enabled addresses are provided, the precompile becomes read-only: getFeeConfig and getFeeConfigLastChangedAt remain callable, but setFeeConfig reverts. In this case the precompile has to be disabled and re-enabled with the desired admin, manager, or enabled addresses to change the configuration.
When initialFeeConfig is present, all three uint fields (targetGas, minGasPrice, timeToDouble) are required. This prevents silent misconfiguration from typos (e.g., a misspelled "minGasprice" would otherwise silently fall back to a default, potentially making the chain near-free to spam). Boolean mode flags (staticPricing, validatorTargetGas) default to false when omitted.
The precompile configuration will look like the following:
{
"acp224FeeManagerConfig": {
"blockTimestamp": <activation_timestamp>,
"adminAddresses": ["0x..."],
"managerAddresses": ["0x..."],
"enabledAddresses": ["0x..."],
"initialFeeConfig": {
"validatorTargetGas": true,
"targetGas": 0,
"staticPricing": false,
"minGasPrice": 25000000000,
"timeToDouble": 60
}
}
}Example Configurations
Custom fees, fully locked (read-only precompile, dynamic pricing):
{
"acp224FeeManagerConfig": {
"blockTimestamp": <activation_timestamp>,
"initialFeeConfig": {
"targetGas": 5000000,
"minGasPrice": 25000000000,
"timeToDouble": 60
}
}
}No admin addresses means the precompile is read-only. All boolean flags default to false: dynamic pricing is active, and the precompile controls targetGas.
Validators control target gas, fee parameters locked:
{
"acp224FeeManagerConfig": {
"blockTimestamp": <activation_timestamp>,
"initialFeeConfig": {
"validatorTargetGas": true,
"targetGas": 0,
"minGasPrice": 25000000000,
"timeToDouble": 60
}
}
}Read-only precompile. Validators adjust gas target dynamically via their node preferences. targetGas is 0 because validatorTargetGas is true. minGasPrice and timeToDouble are locked.
Static pricing, fully locked:
{
"acp224FeeManagerConfig": {
"blockTimestamp": <activation_timestamp>,
"initialFeeConfig": {
"targetGas": 15000000,
"staticPricing": true,
"minGasPrice": 25000000000,
"timeToDouble": 0
}
}
}Gas price is always 25 gwei regardless of demand. timeToDouble is 0 because staticPricing is true. targetGas still governs block gas capacity (15,000,000 gas/second).
Static pricing with validator-controlled target gas:
{
"acp224FeeManagerConfig": {
"blockTimestamp": <activation_timestamp>,
"initialFeeConfig": {
"validatorTargetGas": true,
"targetGas": 0,
"staticPricing": true,
"minGasPrice": 1000000000,
"timeToDouble": 0
}
}
}Flat 1 gwei gas price. Validators adjust throughput dynamically. targetGas and timeToDouble are both 0 because validatorTargetGas and staticPricing are true, respectively. Read-only precompile.
Admin controls pricing, validators control target gas:
{
"acp224FeeManagerConfig": {
"blockTimestamp": <activation_timestamp>,
"adminAddresses": ["0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"],
"initialFeeConfig": {
"validatorTargetGas": true,
"targetGas": 0,
"minGasPrice": 25000000000,
"timeToDouble": 60
}
}
}Admin controls all fee parameters via setFeeConfig. Validators control target gas (targetGas is 0 because validatorTargetGas is true). Admin can set validatorTargetGas to false via setFeeConfig to take back control of targetGas (must then provide a targetGas >= 1,000,000).
Internal State
In addition to storing the latest fee configuration to be returned by getFeeConfig, the precompile will also maintain state storing the latest values of (the target excess) and . These values can be derived from the targetGas and timeToDouble values given to the precompile, respectively. The value of can be deterministically calculated using the same method as Coreth currently employs to calculate a node's desired target excess here. Similarly, is approximated directly from timeToDouble according to:
where
The resulting ACP-176 gas price update constant is then . Note that timeToDouble is the user-facing configuration parameter, while is the internally derived multiplier. When changes (via setFeeConfig or validator preferences), adjusts proportionally since remains fixed.
Similar to the desired target excess calculation in Coreth, which takes a node's desired gas target and calculates its desired target excess value, the ACP224FeeManagerPrecompile will use binary search to determine the resulting dynamic target excess value given the targetGas value passed to setFeeConfig. All blocks accepted after the settlement of such a call must have the correct target excess value as derived from the binary search result.
Configuration Precedence
Configuration precedence is as follows:
Adjustment to ACP-176 calculations for price discovery
ACP-176 defines the gas price for a block as:
Now, whenever (minGasPrice) or (derived from timeToDouble) are changed via the ACP224FeeManagerPrecompile, must also be updated.
Specifically, when is updated from to , must also be updated from (the current excess) to . theoretically could be calculated directly as:
However, this would introduce floating point inaccuracies. Instead can be approximated using binary search to find the minimum non-negative integer such that the resulting gas price calculated using is greater than or equal to the current gas price prior to the change in . In effect, this means that both reducing the minimum gas price and increasing the minimum gas price to a value less than the current gas price have no immediate effect on the current gas price. However, increasing the minimum gas price to value greater than the current gas price will cause the gas price to immediately step up to the new minimum value.
Similarly, when is updated from to , must also be updated from (the current excess) to , where is calculated as:
This makes it such that the current gas price stays the same when is changed. Changes to only impact how quickly or slowly the gas price can change going forward based on usage.
Backwards Compatibility
ACP-224 will require a network update in order to activate the new fee mechanism. The ACP224FeeManagerPrecompile requires a separate activation and can be activated before or after the ACP-224 fee mechanism. If activated before, the precompile operates in a pending state where configuration can be set but does not take effect until ACP-224 activates (see Early Activation of ACP224FeeManagerPrecompile).
Activation of the ACP-224 mechanism will deactivate the prior fee mechanism and the prior FeeManagerPrecompile. This ensures that there is no ambiguity or overlap between legacy and new pricing logic. The ACP224FeeManagerPrecompile with initialFeeConfig replaces the prior genesis chain configuration for fee parameters. For existing networks, a network upgrade that activates the ACP224FeeManagerPrecompile with initialFeeConfig should be used to configure the new fee parameters.
ACP-224 will be activated at the same time as ACP-194 (SAE) in the same network upgrade (Helicon). This coordinated activation is required because ACP-194 depends on the gas target and capacity mechanism defined by ACP-176, which this ACP implements for Subnet-EVM. Networks that do not activate ACP-224 will not be able to use ACP-194.
Early Activation of ACP224FeeManagerPrecompile
For continuity purposes, the ACP224FeeManagerPrecompile can be activated before the Helicon network upgrade (which activates ACP-224 and ACP-194). This allows L1 admins to prepare their fee configuration ahead of time.
When the precompile is activated before Helicon:
- Configuration calls are accepted: The precompile's
setFeeConfigcan be called to set desired fee parameters and modes. The values are stored in the precompile's state. IfinitialFeeConfigis provided at activation, its values are also stored. - Values are pending: The stored fee configuration does not affect the current fee mechanism. The existing
FeeManagerPrecompileand legacy fee mechanism remain active and in control. - Activation applies stored values: When Helicon activates, the stored fee configuration immediately takes effect. The legacy fee mechanism and
FeeManagerPrecompileare deactivated at this point.
This approach ensures a smooth migration path where admins can test and verify their configuration before it becomes active, avoiding any race conditions at the moment of activation.
Reference Implementation
A reference implementation is not yet available and must be provided for this ACP to be considered implementable.
Security Considerations
Generally, this has the same security considerations as ACP-176. However, due to the dynamic nature of parameters exposed in the ACP224FeeManagerPrecompile there is an additional risk of misconfiguration. Misconfiguration of parameters could leave the network vulnerable to a DoS attack or result in higher transaction fees than necessary.
Acknowledgements
Copyright
Copyright and related rights waived via CC0.
Is this guide helpful?