Expand description
Dynamic Evm Base Fee Pallet
§Overview
The pallet is responsible for calculating Base Fee Per Gas
value, according to the current system parameters.
This is not like EIP-1559
, instead it’s intended for Astar
and Astar-like
networks, which allow both
Substrate native transactions (which in Astar
case reuse Polkadot transaction fee approach)
and EVM transactions (which use Base Fee Per Gas
).
For a more detailed description, reader is advised to refer to Astar Network forum post about Tokenomics 2.0.
§Approach
The core formula this pallet tries to satisfy is:
base_fee_per_gas = adjustment_factor * weight_factor * 25 / 98974
Where:
- adjustment_factor - is a value that changes in-between the blocks, related to the block fill ratio.
- weight_factor - fixed constant, used to convert consumed weight to fee.
The implementation doesn’t make any hard requirements on these values, and only requires that a type implementing Get<_>
provides them.
§Implementation
The core logic is implemented in on_finalize
hook, which is called at the end of each block.
This pallet’s hook should be called AFTER whichever pallet’s hook is responsible for updating adjustment factor.
The hook will calculate the ideal new base_fee_per_gas
value, and then clamp it in between the allowed limits.
§Interface
Pallet provides an implementation of FeeCalculator
trait. This makes it usable directly in pallet-evm
.
A root-only extrinsic is provided to allow setting the base_fee_per_gas
value manually.
§Practical Remarks
According to the proposed Tokenomics 2.0, max amount that adjustment factor will be able to change on live networks in-between blocks is:
adjustment_new = adjustment_old * (1 + adj + adj^2/2)
adj = v * (s - s*) –> recommended v value: 0.000_015 –> largest ‘s’ delta: (1 - 0.25) = 0.75
(for variable explanation please check the linked forum post above)
(in short: v
- variability factor, s
- current block fill ratio, s*
- ideal block fill ratio)
adj = 0.000015 * (1 - 0.25) = 0.000_011_25 (1 + 0.000_011_25 + 0.000_011_25^2/2) = (1 + 0.000_011_25 + 0.000_000_000_063_281) = 1,000_011_250_063_281
Discarding the 1, and only considering the decimals, this can be expressed as ratio:
Expressed as ratio: 11_250_063_281 / 1_000_000_000_000_000.
This is a much smaller change compared to the max step limit ratio we’ll use to limit bfpg alignment.
This means that once equilibrium is reached (fees are aligned), the StepLimitRatio
will be larger than the max possible adjustment, essentially eliminating its effect.
Re-exports§
pub use weights::WeightInfo;
pub use self::pallet::*;
Modules§
- The
pallet
module in each FRAME pallet hosts the most important items needed to construct this pallet. - Autogenerated weights for pallet_dynamic_evm_base_fee