You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Biggest possible adjustment between 2 blocks is: 0.000015 * (1 - 0.25) = 0.000_011_25
29
-
// Expressed as ratio: 11_250 / 1_000_000_000.
30
-
// This is a much smaller change compared to the max step limit ratio we'll use to limit bfpg adaptation.
31
-
// This means that once equilibrium is reached, the `StepLimitRatio` will be larger than the max possible adjustment, essentially eliminating it's effect.
19
+
//! Dynamic Evm Base Fee Pallet
20
+
//!
21
+
//! ## Overview
22
+
//!
23
+
//! The pallet is responsible for calculating `Base Fee Per Gas` value, according to the current system parameters.
24
+
//! This is not like `EIP-1559`, instead it's intended for `Astar` and `Astar-like` networks, which allow both
25
+
//! **Substrate native transactions** (which in `Astar` case reuse Polkadot transaction fee approach)
26
+
//! and **EVM transactions** (which use `Base Fee Per Gas`).
27
+
//!
28
+
//! For a more detailed description, reader is advised to refer to Astar Network forum post about [Tokenomics 2.0](https://forum.astar.network/t/astar-tokenomics-2-0-a-dynamically-adjusted-inflation/4924).
29
+
//!
30
+
//! ## Approach
31
+
//!
32
+
//! The core formula this pallet tries to satisfy is:
//! Discarding the **1**, and only considering the decimals, this can be expressed as ratio:
69
+
//! Expressed as ratio: 11_250_063_281 / 1_000_000_000_000_000.
70
+
//! This is a much smaller change compared to the max step limit ratio we'll use to limit bfpg alignment.
71
+
//! This means that once equilibrium is reached (fees are aligned), the `StepLimitRatio` will be larger than the max possible adjustment, essentially eliminating it's effect.
32
72
33
73
#![cfg_attr(not(feature = "std"), no_std)]
34
74
@@ -43,6 +83,15 @@ mod mock;
43
83
#[cfg(test)]
44
84
mod tests;
45
85
86
+
#[cfg(feature = "runtime-benchmarks")]
87
+
mod benchmarking;
88
+
89
+
// TODO: remove this after proper benchmarking!
90
+
pubtraitWeightInfo{
91
+
fnbase_fee_per_gas_adjustment() -> Weight;
92
+
fnset_base_fee_per_gas() -> Weight;
93
+
}
94
+
46
95
#[frame_support::pallet]
47
96
pubmod pallet {
48
97
use frame_support::pallet_prelude::*;
@@ -71,6 +120,8 @@ pub mod pallet {
71
120
/// It's expressed as percentage, and used to calculate the delta between the old and new value.
72
121
/// E.g. if the current 'base fee per gas' is 100, and the limit is 10%, then the new base fee per gas can be between 90 and 110.
73
122
typeStepLimitRatio:Get<Perquintill>;
123
+
/// Weight information for extrinsics & functions of this pallet.
0 commit comments