diff --git a/CHANGELOG.md b/CHANGELOG.md index 459e9f0d00..457e61bd31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Add `cumulus-pallet-weight-reclaim` to all Kusama system parachains for storage weight reclaim functionality ([#941](https://github.com/polkadot-fellows/runtimes/pull/941)) +- asset-hub-kusama: use inmemorydb weights([polkadot-fellows/runtimes/pull/918](https://github.com/polkadot-fellows/runtimes/pull/918)) ## [2.0.3] 21.11.2025 diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs index 1ececfb4ec..1e728ab530 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs @@ -115,7 +115,7 @@ use system_parachains_constants::{ fee::WeightToFee, }, }; -use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; +use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, InMemoryDbWeight}; use xcm::{ latest::prelude::*, Version as XcmVersion, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm, @@ -198,7 +198,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-kusama/src/weights/inmemorydb_weights.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/weights/inmemorydb_weights.rs new file mode 100644 index 0000000000..abc9dcf6ee --- /dev/null +++ b/system-parachains/asset-hubs/asset-hub-kusama/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-kusama/src/weights/mod.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/weights/mod.rs index 5c85ac77b6..bbbf5d083b 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/weights/mod.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/weights/mod.rs @@ -45,6 +45,7 @@ pub mod pallet_remote_proxy; pub mod pallet_society; // TODO(#840): uncomment this so that pallet-revive is also benchmarked with this runtime // pub mod pallet_revive; +pub mod inmemorydb_weights; pub mod pallet_ah_migrator; pub mod pallet_ah_ops; pub mod pallet_bags_list; @@ -73,4 +74,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;