diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f5cefa184..63e958d246 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add pay module implementation to system_parachains_common for use in Asset Hub Polkadot/Kusama treasury with XCM V3 to V5 conversion support for asset transactions ([#1019](https://github.com/polkadot-fellows/runtimes/pull/1019)) - asset-hub-kusama: use inmemorydb weights([polkadot-fellows/runtimes/pull/918](https://github.com/polkadot-fellows/runtimes/pull/918)) - Add fast runtime feature for Encointer Kusama([#1021](https://github.com/polkadot-fellows/runtimes/pull/1021)) +- asset-hub-polkadot: use inmemorydb weights([polkadot-fellows/runtimes/pull/918](https://github.com/polkadot-fellows/runtimes/pull/1025)) ## [2.0.3] 21.11.2025 diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs index b385abcad2..cccc77e29f 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs @@ -176,7 +176,7 @@ use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; use polkadot_runtime_common::{ claims as pallet_claims, prod_or_fast, BlockHashCount, SlowAdjustingFeeUpdate, }; -use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; +use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, InMemoryDbWeight}; impl_opaque_keys! { pub struct SessionKeys { @@ -246,7 +246,7 @@ impl frame_system::Config for Runtime { type RuntimeTask = RuntimeTask; type RuntimeOrigin = RuntimeOrigin; type BlockHashCount = BlockHashCount; - type DbWeight = RocksDbWeight; + type DbWeight = InMemoryDbWeight; type Version = Version; type PalletInfo = PalletInfo; type OnNewAccount = (); diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/inmemorydb_weights.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/inmemorydb_weights.rs new file mode 100644 index 0000000000..abc9dcf6ee --- /dev/null +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/inmemorydb_weights.rs @@ -0,0 +1,108 @@ +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 49.1.0 +//! DATE: 2025-09-10 (Y/M/D) +//! HOSTNAME: `versi-developer-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! +//! DATABASE: `InMemoryDb`, RUNTIME: `Polkadot Asset Hub` +//! BLOCK-NUM: `BlockId::Number(9640792)` +//! SKIP-WRITE: `false`, SKIP-READ: `false`, WARMUPS: `1` +//! STATE-VERSION: `V1`, STATE-CACHE-SIZE: `` +//! WEIGHT-PATH: `` +//! METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0` + +// Executed Command: +// ./target/production/polkadot-parachain +// benchmark +// storage +// --warmups +// 1 +// --state-version +// 1 +// --base-path +// /opt/local-ssd/polkadot-asset-hub/ +// --chain +// cumulus/polkadot-parachain/chain-specs/asset-hub-polkadot.json +// --detailed-log-output +// --enable-trie-cache +// --trie-cache-size +// 10737418240 +// --batch-size +// 10000 +// --mode +// validate-block +// --validate-block-rounds +// 100 + +/// Storage DB weights for the `Polkadot Asset Hub` runtime and `InMemoryDb`. +pub mod constants { + use frame_support::weights::constants; + use sp_core::parameter_types; + use sp_weights::RuntimeDbWeight; + + parameter_types! { + /// `InMemoryDb` weights are measured in the context of the validation functions. + /// To avoid submitting overweight blocks to the relay chain this is the configuration + /// parachains should use. + pub const InMemoryDbWeight: RuntimeDbWeight = RuntimeDbWeight { + // Time to read one storage item. + // Calculated by multiplying the *Average* of all values with `1.0` and adding `0`. + // + // Stats nanoseconds: + // Min, Max: 13_036, 14_636 + // Average: 13_701 + // Median: 13_739 + // Std-Dev: 327.35 + // + // Percentiles nanoseconds: + // 99th: 14_322 + // 95th: 14_185 + // 75th: 13_962 + read: 13_701 * constants::WEIGHT_REF_TIME_PER_NANOS, + + // Time to write one storage item. + // Calculated by multiplying the *Average* of all values with `1.0` and adding `0`. + // + // Stats nanoseconds: + // Min, Max: 31_957, 34_238 + // Average: 33_060 + // Median: 33_048 + // Std-Dev: 230.45 + // + // Percentiles nanoseconds: + // 99th: 33_927 + // 95th: 33_440 + // 75th: 33_157 + write: 33_060 * constants::WEIGHT_REF_TIME_PER_NANOS, + }; + } + + #[cfg(test)] + mod test_db_weights { + use super::InMemoryDbWeight as W; + use sp_weights::constants; + + /// Checks that all weights exist and have sane values. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn bound() { + // At least 1 µs. + assert!( + W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Read weight should be at least 1 µs." + ); + assert!( + W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Write weight should be at least 1 µs." + ); + // At most 1 ms. + assert!( + W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Read weight should be at most 1 ms." + ); + assert!( + W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Write weight should be at most 1 ms." + ); + } + } +} diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/mod.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/mod.rs index 00518d202f..217ed280d4 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/mod.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/mod.rs @@ -20,6 +20,7 @@ pub mod cumulus_pallet_xcmp_queue; pub mod extrinsic_weights; pub mod frame_system; pub mod frame_system_extensions; +pub mod inmemorydb_weights; pub mod pallet_ah_migrator; pub mod pallet_ah_ops; pub mod pallet_asset_conversion; @@ -67,4 +68,4 @@ pub mod xcm; pub use block_weights::constants::BlockExecutionWeight; pub use extrinsic_weights::constants::ExtrinsicBaseWeight; -pub use rocksdb_weights::constants::RocksDbWeight; +pub use inmemorydb_weights::constants::InMemoryDbWeight; diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/snowbridge_pallet_system_backend.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/snowbridge_pallet_system_backend.rs index cb9a44c1a5..ea1ea610b8 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/snowbridge_pallet_system_backend.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/snowbridge_pallet_system_backend.rs @@ -18,48 +18,53 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; /// Weight functions for `snowbridge_pallet_system_frontend::BackendWeightInfo`. pub struct WeightInfo(PhantomData); impl snowbridge_pallet_system_frontend::BackendWeightInfo for WeightInfo { /// Copy the weight generated for `fn register_token() -> Weight` from ../../../../bridge-hubs/bridge-hub-polkadot/src/weights/snowbridge_pallet_system_v2.rs + /// Use `RocksDbWeight::get()` to get the weight of reads and writes, in order to keep the weights the same as in Bridge Hub. fn transact_register_token() -> Weight { Weight::from_parts(53_009_000, 0) .saturating_add(Weight::from_parts(0, 4115)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(4)) } /// Copy the weight generated for `fn add_tip() -> Weight` from ../../../../bridge-hubs/bridge-hub-polkadot/src/weights/snowbridge_pallet_system_v2.rs + /// Use `RocksDbWeight::get()` to get the weight of reads and writes, in order to keep the weights the same as in Bridge Hub. fn transact_add_tip() -> Weight { Weight::from_parts(12_440_000, 0) .saturating_add(Weight::from_parts(0, 3505)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) } /// Copy the weight generated for `fn do_process_message() -> Weight` from ../../../../bridge-hubs/bridge-hub-polkadot/src/weights/snowbridge_pallet_outbound_queue_v2.rs + /// Use `RocksDbWeight::get()` to get the weight of reads and writes, in order to keep the weights the same as in Bridge Hub. fn do_process_message() -> Weight { Weight::from_parts(29_560_000, 0) .saturating_add(Weight::from_parts(0, 1527)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(4)) } /// Copy the weight generated for `fn commit_single() -> Weight` from ../../../../bridge-hubs/bridge-hub-polkadot/src/weights/snowbridge_pallet_outbound_queue_v2.rs + /// Use `RocksDbWeight::get()` to get the weight of reads and writes, in order to keep the weights the same as in Bridge Hub. fn commit_single() -> Weight { Weight::from_parts(11_960_000, 0) .saturating_add(Weight::from_parts(0, 1620)) - .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().reads(1)) } /// Copy the weight generated for `fn submit_delivery_receipt() -> Weight` from ../../../../bridge-hubs/bridge-hub-polkadot/src/weights/snowbridge_pallet_outbound_queue_v2.rs + /// Use `RocksDbWeight::get()` to get the weight of reads and writes, in order to keep the weights the same as in Bridge Hub. fn submit_delivery_receipt() -> Weight { Weight::from_parts(142_070_000, 0) .saturating_add(Weight::from_parts(0, 3762)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(1)) } }