diff --git a/pallets/dynamic-evm-base-fee/src/benchmarking.rs b/pallets/dynamic-evm-base-fee/src/benchmarking.rs index c30ea7e0f9..c0d4ab9f23 100644 --- a/pallets/dynamic-evm-base-fee/src/benchmarking.rs +++ b/pallets/dynamic-evm-base-fee/src/benchmarking.rs @@ -62,6 +62,24 @@ mod benchmarks { assert_eq!(BaseFeePerGas::::get(), new_bfpg); } + #[benchmark] + fn min_gas_price() { + let first_block = T::BlockNumber::from(1u32); + + // Setup actions, should ensure some value is written to storage. + Pallet::::on_initialize(first_block); + Pallet::::on_finalize(first_block); + assert!( + BaseFeePerGas::::exists(), + "Value should exist in storage after first on_finalize call" + ); + + #[block] + { + let _ = Pallet::::min_gas_price(); + } + } + impl_benchmark_test_suite!( Pallet, crate::benchmarking::tests::new_test_ext(), diff --git a/pallets/dynamic-evm-base-fee/src/lib.rs b/pallets/dynamic-evm-base-fee/src/lib.rs index 2baeccd89f..5574346825 100644 --- a/pallets/dynamic-evm-base-fee/src/lib.rs +++ b/pallets/dynamic-evm-base-fee/src/lib.rs @@ -75,7 +75,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::weights::Weight; use sp_core::U256; use sp_runtime::{traits::UniqueSaturatedInto, FixedPointNumber, FixedU128, Perquintill}; @@ -99,7 +99,11 @@ pub mod pallet { use super::*; + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + #[pallet::pallet] + #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(PhantomData); #[pallet::config] @@ -229,7 +233,6 @@ pub mod pallet { impl fp_evm::FeeCalculator for Pallet { fn min_gas_price() -> (U256, Weight) { - // TODO: account for PoV? - (BaseFeePerGas::::get(), T::DbWeight::get().reads(1)) + (BaseFeePerGas::::get(), T::WeightInfo::min_gas_price()) } } diff --git a/pallets/dynamic-evm-base-fee/src/weights.rs b/pallets/dynamic-evm-base-fee/src/weights.rs index 467ff6470d..aabce1015f 100644 --- a/pallets/dynamic-evm-base-fee/src/weights.rs +++ b/pallets/dynamic-evm-base-fee/src/weights.rs @@ -51,6 +51,7 @@ use core::marker::PhantomData; pub trait WeightInfo { fn base_fee_per_gas_adjustment() -> Weight; fn set_base_fee_per_gas() -> Weight; + fn min_gas_price() -> Weight; } /// Weights for pallet_dynamic_evm_base_fee using the Substrate node and recommended hardware. @@ -79,6 +80,9 @@ impl WeightInfo for SubstrateWeight { Weight::from_parts(9_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } + fn min_gas_price() -> Weight { + Weight::from_parts(0, 0) + } } // For backwards compatibility and tests @@ -106,4 +110,7 @@ impl WeightInfo for () { Weight::from_parts(9_000_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + fn min_gas_price() -> Weight { + Weight::from_parts(0, 0) + } } diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 571fa3a297..242bfb82fc 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1329,7 +1329,7 @@ parameter_types! { } /// Simple `OnRuntimeUpgrade` logic to prepare Shibuya runtime for `DynamicEvmBaseFee` pallet. -pub use frame_support::traits::OnRuntimeUpgrade; +pub use frame_support::traits::{OnRuntimeUpgrade, StorageVersion}; pub struct DynamicEvmBaseFeeMigration; impl OnRuntimeUpgrade for DynamicEvmBaseFeeMigration { fn on_runtime_upgrade() -> Weight { @@ -1344,6 +1344,9 @@ impl OnRuntimeUpgrade for DynamicEvmBaseFeeMigration { // Shibuya's multiplier is so low that we have to set it to minimum value directly. pallet_transaction_payment::NextFeeMultiplier::::put(MinimumMultiplier::get()); + // Set init storage version for the pallet + StorageVersion::new(1).put::>(); + ::DbWeight::get().reads_writes(1, 2) } }