diff --git a/bridges/bin/runtime-common/src/mock.rs b/bridges/bin/runtime-common/src/mock.rs index fed0d15cc080..cb68669bbcb1 100644 --- a/bridges/bin/runtime-common/src/mock.rs +++ b/bridges/bin/runtime-common/src/mock.rs @@ -29,7 +29,7 @@ use bp_runtime::{messages::MessageDispatchResult, Chain, ChainId, Parachain}; use codec::Encode; use frame_support::{ derive_impl, parameter_types, - weights::{ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight}, + weights::{ConstantMultiplier, IdentityFee, RuntimeDbRefTime, Weight}, }; use pallet_transaction_payment::Multiplier; use sp_runtime::{ @@ -116,7 +116,7 @@ crate::generate_bridge_reject_obsolete_headers_and_messages! { parameter_types! { pub const BridgedParasPalletName: &'static str = "Paras"; pub const ExistentialDeposit: ThisChainBalance = 500; - pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { read: 1, write: 2 }; + pub const DbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 1, write: 2 }; pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); pub const TransactionBaseFee: ThisChainBalance = 0; pub const TransactionByteFee: ThisChainBalance = 1; diff --git a/bridges/modules/parachains/src/weights_ext.rs b/bridges/modules/parachains/src/weights_ext.rs index 64dad625de08..fe09d5780b21 100644 --- a/bridges/modules/parachains/src/weights_ext.rs +++ b/bridges/modules/parachains/src/weights_ext.rs @@ -19,7 +19,7 @@ use crate::weights::{BridgeWeight, WeightInfo}; use bp_runtime::Size; -use frame_support::weights::{RuntimeDbWeight, Weight}; +use frame_support::weights::{RuntimeDbRefTime, Weight}; /// Size of the regular parachain head. /// @@ -58,7 +58,7 @@ pub trait WeightInfoExt: WeightInfo { /// Weight of the parachain heads delivery extrinsic. fn submit_parachain_heads_weight( - db_weight: RuntimeDbWeight, + db_weight: RuntimeDbRefTime, proof: &impl Size, parachains_count: u32, ) -> Weight { @@ -90,14 +90,14 @@ pub trait WeightInfoExt: WeightInfo { /// This weight only includes db write operations that happens if parachain head is actually /// updated. All extra weights (weight of storage proof validation, additional checks, ...) is /// not included. - fn parachain_head_storage_write_weight(db_weight: RuntimeDbWeight) -> Weight { + fn parachain_head_storage_write_weight(db_weight: RuntimeDbRefTime) -> Weight { // it's just a couple of operations - we need to write the hash (`ImportedParaHashes`) and // the head itself (`ImportedParaHeads`. Pruning is not included here db_weight.writes(2) } /// Returns weight of single parachain head pruning. - fn parachain_head_pruning_weight(db_weight: RuntimeDbWeight) -> Weight { + fn parachain_head_pruning_weight(db_weight: RuntimeDbRefTime) -> Weight { // it's just one write operation, we don't want any benchmarks for that db_weight.writes(1) } diff --git a/bridges/modules/relayers/src/mock.rs b/bridges/modules/relayers/src/mock.rs index de1d292b7c0f..26334ee14b78 100644 --- a/bridges/modules/relayers/src/mock.rs +++ b/bridges/modules/relayers/src/mock.rs @@ -32,7 +32,7 @@ use codec::Encode; use frame_support::{ derive_impl, parameter_types, traits::fungible::Mutate, - weights::{ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight}, + weights::{ConstantMultiplier, IdentityFee, RuntimeDbRefTime, Weight}, }; use pallet_transaction_payment::Multiplier; use sp_core::{ConstU64, ConstU8, H256}; @@ -177,7 +177,7 @@ frame_support::construct_runtime! { parameter_types! { pub const BridgedParasPalletName: &'static str = "Paras"; - pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { read: 1, write: 2 }; + pub const DbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 1, write: 2 }; pub const ExistentialDeposit: ThisChainBalance = 1; pub const ReserveId: [u8; 8] = *b"brdgrlrs"; pub const Stake: ThisChainBalance = 1_000; diff --git a/bridges/modules/xcm-bridge-hub/src/mock.rs b/bridges/modules/xcm-bridge-hub/src/mock.rs index d32e0989dfd8..85ffe6a882d4 100644 --- a/bridges/modules/xcm-bridge-hub/src/mock.rs +++ b/bridges/modules/xcm-bridge-hub/src/mock.rs @@ -28,7 +28,7 @@ use codec::Encode; use frame_support::{ assert_ok, derive_impl, parameter_types, traits::{EnsureOrigin, Equals, Everything, OriginTrait}, - weights::RuntimeDbWeight, + weights::RuntimeDbRefTime, }; use polkadot_parachain_primitives::primitives::Sibling; use sp_core::H256; @@ -65,7 +65,7 @@ frame_support::construct_runtime! { } parameter_types! { - pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { read: 1, write: 2 }; + pub const DbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 1, write: 2 }; pub const ExistentialDeposit: Balance = 1; } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/paritydb_weights.rs index 4338d928d807..1f43d5ed4042 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/rocksdb_weights.rs index 1d115d963fac..c914a3f72d6e 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/paritydb_weights.rs index 1c6d2ebe568c..1d314a66f580 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/rocksdb_weights.rs index aa0cb2b4bc37..668c4fbe4395 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/paritydb_weights.rs index 4338d928d807..1f43d5ed4042 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/people/people-rococo/src/weights/rocksdb_weights.rs index 1d115d963fac..c914a3f72d6e 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/paritydb_weights.rs index 2699f3abbb1f..3a6487071893 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/paritydb_weights.rs @@ -16,13 +16,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/people/people-westend/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/people/people-westend/src/weights/rocksdb_weights.rs index 61b48fb2350e..d09ba24d61ed 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/weights/rocksdb_weights.rs @@ -16,13 +16,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/testing/penpal/src/weights/paritydb_weights.rs b/cumulus/parachains/runtimes/testing/penpal/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/weights/paritydb_weights.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/cumulus/parachains/runtimes/testing/penpal/src/weights/rocksdb_weights.rs b/cumulus/parachains/runtimes/testing/penpal/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/weights/rocksdb_weights.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/polkadot/runtime/rococo/constants/src/weights/paritydb_weights.rs b/polkadot/runtime/rococo/constants/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/polkadot/runtime/rococo/constants/src/weights/paritydb_weights.rs +++ b/polkadot/runtime/rococo/constants/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/polkadot/runtime/rococo/constants/src/weights/rocksdb_weights.rs b/polkadot/runtime/rococo/constants/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/polkadot/runtime/rococo/constants/src/weights/rocksdb_weights.rs +++ b/polkadot/runtime/rococo/constants/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/polkadot/runtime/test-runtime/constants/src/weights/paritydb_weights.rs b/polkadot/runtime/test-runtime/constants/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/polkadot/runtime/test-runtime/constants/src/weights/paritydb_weights.rs +++ b/polkadot/runtime/test-runtime/constants/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/polkadot/runtime/test-runtime/constants/src/weights/rocksdb_weights.rs b/polkadot/runtime/test-runtime/constants/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/polkadot/runtime/test-runtime/constants/src/weights/rocksdb_weights.rs +++ b/polkadot/runtime/test-runtime/constants/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/polkadot/runtime/westend/constants/src/weights/paritydb_weights.rs b/polkadot/runtime/westend/constants/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/polkadot/runtime/westend/constants/src/weights/paritydb_weights.rs +++ b/polkadot/runtime/westend/constants/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/polkadot/runtime/westend/constants/src/weights/rocksdb_weights.rs b/polkadot/runtime/westend/constants/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/polkadot/runtime/westend/constants/src/weights/rocksdb_weights.rs +++ b/polkadot/runtime/westend/constants/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/prdoc/pr_3640.prdoc b/prdoc/pr_3640.prdoc new file mode 100644 index 000000000000..6f3e20ea334b --- /dev/null +++ b/prdoc/pr_3640.prdoc @@ -0,0 +1,87 @@ +title: Rename `RuntimeDbRefTime` to `RuntimeDbRefTime` +doc: + - audience: Runtime Dev + description: | + The `RuntimeDbRefTime` struct was renamed `RuntimeDbRefTime` + to better reflect the fact that it can only be used to generate the `ref_time` component of the weight. + `RuntimeDbRefTime` is now a (deprecated) type alias for `RuntimeDbRefTime`. + +crates: + - name: sp-weights + bump: patch + + - name: bridge-runtime-common + bump: patch + + - name: frame-support + bump: patch + + - name: frame-support-procedural + bump: patch + + - name: frame-system + bump: patch + + - name: frame-executive + bump: patch + + - name: frame-benchmarking-cli + bump: patch + + - name: pallet-democracy + bump: patch + + - name: pallet-elections-phragmen + bump: patch + + - name: pallet-tips + bump: patch + + - name: rococo-runtime-constants + bump: patch + + - name: westend-runtime-constants + bump: patch + + - name: pallet-bridge-parachains + bump: patch + + - name: pallet-bridge-relayers + bump: patch + + - name: pallet-xcm-bridge-hub + bump: patch + + - name: asset-hub-rococo-runtime + bump: patch + + - name: asset-hub-westend-runtime + bump: patch + + - name: bridge-hub-rococo-runtime + bump: patch + + - name: bridge-hub-westend-runtime + bump: patch + + - name: collectives-westend-runtime + bump: patch + + - name: coretime-rococo-runtime + bump: patch + + - name: coretime-westend-runtime + bump: patch + + - name: people-rococo-runtime + bump: patch + + - name: people-westend-runtime + bump: patch + + - name: penpal-runtime + bump: patch + + - name: contracts-rococo-runtime + bump: patch + diff --git a/substrate/frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs b/substrate/frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs index ca0e0f7a091a..0e0bb7faae69 100644 --- a/substrate/frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs +++ b/substrate/frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs @@ -25,7 +25,7 @@ use frame_support::{ pallet_prelude::ValueQuery, storage_alias, traits::{Currency, LockableCurrency, OnRuntimeUpgrade, ReservableCurrency}, - weights::RuntimeDbWeight, + weights::RuntimeDbRefTime, Parameter, Twox64Concat, }; use sp_core::Get; @@ -52,7 +52,7 @@ pub trait UnlockConfig: 'static { /// The maximum deposit as configured previously in the runtime. type MaxDeposits: Get; /// The DB weight as configured in the runtime to calculate the correct weight. - type DbWeight: Get; + type DbWeight: Get; /// The block number as configured in the runtime. type BlockNumber: Parameter + Zero + Copy + Ord; } diff --git a/substrate/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs b/substrate/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs index ed4569aa25ee..480e0f349655 100644 --- a/substrate/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs +++ b/substrate/frame/elections-phragmen/src/migrations/unlock_and_unreserve_all_funds.rs @@ -24,7 +24,7 @@ use frame_support::{ pallet_prelude::ValueQuery, storage_alias, traits::{Currency, LockIdentifier, LockableCurrency, OnRuntimeUpgrade, ReservableCurrency}, - weights::RuntimeDbWeight, + weights::RuntimeDbRefTime, Parameter, Twox64Concat, }; use sp_core::Get; @@ -52,7 +52,7 @@ pub trait UnlockConfig: 'static { /// runtime. type PalletId: Get; /// The DB weight as configured in the runtime to calculate the correct weight. - type DbWeight: Get; + type DbWeight: Get; } #[storage_alias(dynamic)] diff --git a/substrate/frame/executive/src/tests.rs b/substrate/frame/executive/src/tests.rs index 69a970a89d93..c34f883d1100 100644 --- a/substrate/frame/executive/src/tests.rs +++ b/substrate/frame/executive/src/tests.rs @@ -37,7 +37,9 @@ use frame_support::{ pallet_prelude::*, parameter_types, traits::{fungible, ConstU8, Currency, IsInherent, VariantCount, VariantCountOf}, - weights::{ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight, WeightMeter, WeightToFee}, + weights::{ + ConstantMultiplier, IdentityFee, RuntimeDbRefTime, Weight, WeightMeter, WeightToFee, + }, }; use frame_system::{pallet_prelude::*, ChainContext, LastRuntimeUpgrade, LastRuntimeUpgradeInfo}; use pallet_balances::Call as BalancesCall; @@ -303,7 +305,7 @@ parameter_types! { .for_class(DispatchClass::all(), |weights| weights.base_extrinsic = Weight::from_parts(5, 0)) .for_class(DispatchClass::non_mandatory(), |weights| weights.max_total = Weight::from_parts(1024, u64::MAX).into()) .build_or_panic(); - pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const DbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 10, write: 100, }; diff --git a/substrate/frame/support/procedural/examples/proc_main/main.rs b/substrate/frame/support/procedural/examples/proc_main/main.rs index 4bdfc76dd92f..b3a42d638360 100644 --- a/substrate/frame/support/procedural/examples/proc_main/main.rs +++ b/substrate/frame/support/procedural/examples/proc_main/main.rs @@ -81,7 +81,7 @@ pub mod frame_system { type RuntimeTask: crate::traits::tasks::Task; #[pallet::no_default_bounds] type PalletInfo: crate::traits::PalletInfo; - type DbWeight: Get; + type DbWeight: Get; } #[pallet::error] diff --git a/substrate/frame/support/src/dispatch.rs b/substrate/frame/support/src/dispatch.rs index 351ba3a15efc..dcd39e642190 100644 --- a/substrate/frame/support/src/dispatch.rs +++ b/substrate/frame/support/src/dispatch.rs @@ -662,7 +662,7 @@ mod weight_tests { use super::*; use sp_core::parameter_types; use sp_runtime::{generic, traits::BlakeTwo256}; - use sp_weights::RuntimeDbWeight; + use sp_weights::RuntimeDbRefTime; pub use self::frame_system::{Call, Config}; @@ -697,7 +697,7 @@ mod weight_tests { type RuntimeCall; type RuntimeTask; type PalletInfo: crate::traits::PalletInfo; - type DbWeight: Get; + type DbWeight: Get; } #[pallet::error] @@ -779,7 +779,7 @@ mod weight_tests { ); parameter_types! { - pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const DbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 100, write: 1000, }; diff --git a/substrate/frame/support/src/migrations.rs b/substrate/frame/support/src/migrations.rs index 7f7461469564..7eeb90ceb129 100644 --- a/substrate/frame/support/src/migrations.rs +++ b/substrate/frame/support/src/migrations.rs @@ -22,7 +22,7 @@ use crate::{ Defensive, GetStorageVersion, NoStorageVersionSet, PalletInfoAccess, SafeMode, StorageVersion, }, - weights::{RuntimeDbWeight, Weight, WeightMeter}, + weights::{RuntimeDbRefTime, Weight, WeightMeter}, }; use alloc::vec::Vec; use codec::{Decode, Encode, MaxEncodedLen}; @@ -44,7 +44,7 @@ use sp_runtime::traits::Zero; /// - `To`: The version being upgraded to. /// - `Inner`: An implementation of `UncheckedOnRuntimeUpgrade`. /// - `Pallet`: The Pallet being upgraded. -/// - `Weight`: The runtime's RuntimeDbWeight implementation. +/// - `Weight`: The runtime's RuntimeDbRefTime implementation. /// /// When a [`VersionedMigration`] `on_runtime_upgrade`, `pre_upgrade`, or `post_upgrade` method is /// called, the on-chain version of the pallet is compared to `From`. If they match, the `Inner` @@ -119,7 +119,7 @@ impl< const TO: u16, Inner: crate::traits::UncheckedOnRuntimeUpgrade, Pallet: GetStorageVersion + PalletInfoAccess, - DbWeight: Get, + DbWeight: Get, > crate::traits::OnRuntimeUpgrade for VersionedMigration { /// Executes pre_upgrade if the migration will run, and wraps the pre_upgrade bytes in @@ -214,14 +214,14 @@ impl + PalletIn /// Trait used by [`migrate_from_pallet_version_to_storage_version`] to do the actual migration. pub trait PalletVersionToStorageVersionHelper { - fn migrate(db_weight: &RuntimeDbWeight) -> Weight; + fn migrate(db_weight: &RuntimeDbRefTime) -> Weight; } impl PalletVersionToStorageVersionHelper for T where T::InCodeStorageVersion: StoreInCodeStorageVersion, { - fn migrate(db_weight: &RuntimeDbWeight) -> Weight { + fn migrate(db_weight: &RuntimeDbRefTime) -> Weight { const PALLET_VERSION_STORAGE_KEY_POSTFIX: &[u8] = b":__PALLET_VERSION__:"; fn pallet_version_key(name: &str) -> [u8; 32] { @@ -240,7 +240,7 @@ where #[cfg_attr(all(feature = "tuples-96", not(feature = "tuples-128")), impl_for_tuples(96))] #[cfg_attr(feature = "tuples-128", impl_for_tuples(128))] impl PalletVersionToStorageVersionHelper for T { - fn migrate(db_weight: &RuntimeDbWeight) -> Weight { + fn migrate(db_weight: &RuntimeDbRefTime) -> Weight { let mut weight = Weight::zero(); for_tuples!( #( weight = weight.saturating_add(T::migrate(db_weight)); )* ); @@ -255,7 +255,7 @@ impl PalletVersionToStorageVersionHelper for T { pub fn migrate_from_pallet_version_to_storage_version< Pallets: PalletVersionToStorageVersionHelper, >( - db_weight: &RuntimeDbWeight, + db_weight: &RuntimeDbRefTime, ) -> Weight { Pallets::migrate(db_weight) } @@ -266,7 +266,7 @@ pub fn migrate_from_pallet_version_to_storage_version< /// This struct is generic over two parameters: /// - `P` is a type that implements the `Get` trait for a static string, representing the pallet's /// name. -/// - `DbWeight` is a type that implements the `Get` trait for `RuntimeDbWeight`, providing the +/// - `DbWeight` is a type that implements the `Get` trait for `RuntimeDbRefTime`, providing the /// weight for database operations. /// /// On runtime upgrade, the `on_runtime_upgrade` function will clear all storage items associated @@ -315,10 +315,10 @@ pub fn migrate_from_pallet_version_to_storage_version< /// a multi-block scheduler currently under development which will allow for removal of storage /// items (and performing other heavy migrations) over multiple blocks /// (see ). -pub struct RemovePallet, DbWeight: Get>( +pub struct RemovePallet, DbWeight: Get>( PhantomData<(P, DbWeight)>, ); -impl, DbWeight: Get> frame_support::traits::OnRuntimeUpgrade +impl, DbWeight: Get> frame_support::traits::OnRuntimeUpgrade for RemovePallet { fn on_runtime_upgrade() -> frame_support::weights::Weight { @@ -377,7 +377,7 @@ impl, DbWeight: Get> frame_support::traits /// name. /// - `S` is a type that implements the [`Get`] trait for a static string, representing the storage /// name. -/// - `DbWeight` is a type that implements the [`Get`] trait for [`RuntimeDbWeight`], providing the +/// - `DbWeight` is a type that implements the [`Get`] trait for [`RuntimeDbRefTime`], providing the /// weight for database operations. /// /// On runtime upgrade, the `on_runtime_upgrade` function will clear the storage from the specified @@ -426,10 +426,12 @@ impl, DbWeight: Get> frame_support::traits /// a multi-block scheduler currently under development which will allow for removal of storage /// items (and performing other heavy migrations) over multiple blocks /// (see ). -pub struct RemoveStorage, S: Get<&'static str>, DbWeight: Get>( - PhantomData<(P, S, DbWeight)>, -); -impl, S: Get<&'static str>, DbWeight: Get> +pub struct RemoveStorage< + P: Get<&'static str>, + S: Get<&'static str>, + DbWeight: Get, +>(PhantomData<(P, S, DbWeight)>); +impl, S: Get<&'static str>, DbWeight: Get> frame_support::traits::OnRuntimeUpgrade for RemoveStorage { fn on_runtime_upgrade() -> frame_support::weights::Weight { diff --git a/substrate/frame/support/src/storage/generator/mod.rs b/substrate/frame/support/src/storage/generator/mod.rs index b0b1bda24bb7..580e14ee90d1 100644 --- a/substrate/frame/support/src/storage/generator/mod.rs +++ b/substrate/frame/support/src/storage/generator/mod.rs @@ -66,7 +66,7 @@ mod tests { type RuntimeCall; type RuntimeTask; type PalletInfo: crate::traits::PalletInfo; - type DbWeight: Get; + type DbWeight: Get; } #[pallet::origin] diff --git a/substrate/frame/support/src/tests/mod.rs b/substrate/frame/support/src/tests/mod.rs index a9f8ebdd63f2..ec9677bb0c09 100644 --- a/substrate/frame/support/src/tests/mod.rs +++ b/substrate/frame/support/src/tests/mod.rs @@ -73,7 +73,7 @@ pub mod frame_system { type RuntimeTask: crate::traits::tasks::Task; #[pallet::no_default_bounds] type PalletInfo: crate::traits::PalletInfo; - type DbWeight: Get; + type DbWeight: Get; } #[pallet::error] diff --git a/substrate/frame/support/src/weights/paritydb_weights.rs b/substrate/frame/support/src/weights/paritydb_weights.rs index f69fc0cd93c6..9eea99b25477 100644 --- a/substrate/frame/support/src/weights/paritydb_weights.rs +++ b/substrate/frame/support/src/weights/paritydb_weights.rs @@ -18,12 +18,12 @@ pub mod constants { use frame_support::weights::constants; use sp_core::parameter_types; - use sp_weights::RuntimeDbWeight; + use sp_weights::RuntimeDbRefTime; parameter_types! { /// ParityDB can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/substrate/frame/support/src/weights/rocksdb_weights.rs b/substrate/frame/support/src/weights/rocksdb_weights.rs index 25d2ac1cdec0..7e69ebc42739 100644 --- a/substrate/frame/support/src/weights/rocksdb_weights.rs +++ b/substrate/frame/support/src/weights/rocksdb_weights.rs @@ -18,12 +18,12 @@ pub mod constants { use frame_support::weights::constants; use sp_core::parameter_types; - use sp_weights::RuntimeDbWeight; + use sp_weights::RuntimeDbRefTime; parameter_types! { /// By default, Substrate uses RocksDB, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/substrate/frame/support/test/src/lib.rs b/substrate/frame/support/test/src/lib.rs index b080740b0a4b..989df5aa33aa 100644 --- a/substrate/frame/support/test/src/lib.rs +++ b/substrate/frame/support/test/src/lib.rs @@ -60,7 +60,7 @@ pub mod pallet { /// The information about the pallet setup in the runtime. type PalletInfo: frame_support::traits::PalletInfo; /// The db weights. - type DbWeight: Get; + type DbWeight: Get; } #[pallet::call] diff --git a/substrate/frame/support/test/tests/pallet.rs b/substrate/frame/support/test/tests/pallet.rs index eed8a22e8e79..2be257c751bb 100644 --- a/substrate/frame/support/test/tests/pallet.rs +++ b/substrate/frame/support/test/tests/pallet.rs @@ -27,7 +27,7 @@ use frame_support::{ OnInitialize, OnRuntimeUpgrade, PalletError, PalletInfoAccess, StorageVersion, UnfilteredDispatchable, }, - weights::{RuntimeDbWeight, Weight}, + weights::{RuntimeDbRefTime, Weight}, OrdNoBound, PartialOrdNoBound, }; use scale_info::{meta_type, TypeInfo}; @@ -1340,7 +1340,7 @@ fn migrate_from_pallet_version_to_storage_version() { assert_eq!(Example2::on_chain_storage_version(), StorageVersion::new(0)); assert_eq!(System::on_chain_storage_version(), StorageVersion::new(0)); - let db_weight = RuntimeDbWeight { read: 0, write: 5 }; + let db_weight = RuntimeDbRefTime { read: 0, write: 5 }; let weight = frame_support::migrations::migrate_from_pallet_version_to_storage_version::< AllPalletsWithSystem, >(&db_weight); diff --git a/substrate/frame/support/test/tests/pallet_instance.rs b/substrate/frame/support/test/tests/pallet_instance.rs index 09a49617044d..2e55c285fa06 100644 --- a/substrate/frame/support/test/tests/pallet_instance.rs +++ b/substrate/frame/support/test/tests/pallet_instance.rs @@ -760,7 +760,7 @@ fn metadata() { }, PalletConstantMetadata { name: "DbWeight", - ty: scale_info::meta_type::(), + ty: scale_info::meta_type::(), value: vec![], docs: vec![], }, diff --git a/substrate/frame/support/test/tests/runtime.rs b/substrate/frame/support/test/tests/runtime.rs index 06c2b5b7071c..a1b256fab393 100644 --- a/substrate/frame/support/test/tests/runtime.rs +++ b/substrate/frame/support/test/tests/runtime.rs @@ -23,7 +23,7 @@ use codec::MaxEncodedLen; use frame_support::{ - derive_impl, parameter_types, traits::PalletInfo as _, weights::RuntimeDbWeight, + derive_impl, parameter_types, traits::PalletInfo as _, weights::RuntimeDbRefTime, }; use frame_system::limits::{BlockLength, BlockWeights}; use scale_info::TypeInfo; @@ -806,9 +806,12 @@ fn test_metadata() { }, PalletConstantMetadata { name: "DbWeight", - ty: meta_type::(), - value: RuntimeDbWeight::default().encode(), - docs: maybe_docs(vec![" The weight of runtime database operations the runtime can invoke.",]), + ty: meta_type::(), + value: RuntimeDbRefTime::default().encode(), + docs: maybe_docs(vec![ + " The computational time component (`ref_time`) of runtime database operations the runtime", + " can invoke.", + ]) }, PalletConstantMetadata { name: "Version", diff --git a/substrate/frame/support/test/tests/runtime_legacy_ordering.rs b/substrate/frame/support/test/tests/runtime_legacy_ordering.rs index 4233db21e203..6473e198098b 100644 --- a/substrate/frame/support/test/tests/runtime_legacy_ordering.rs +++ b/substrate/frame/support/test/tests/runtime_legacy_ordering.rs @@ -23,7 +23,7 @@ use codec::MaxEncodedLen; use frame_support::{ - derive_impl, parameter_types, traits::PalletInfo as _, weights::RuntimeDbWeight, + derive_impl, parameter_types, traits::PalletInfo as _, weights::RuntimeDbRefTime, }; use frame_system::limits::{BlockLength, BlockWeights}; use scale_info::TypeInfo; @@ -743,9 +743,12 @@ fn test_metadata() { }, PalletConstantMetadata { name: "DbWeight", - ty: meta_type::(), - value: RuntimeDbWeight::default().encode(), - docs: maybe_docs(vec![" The weight of runtime database operations the runtime can invoke.",]), + ty: meta_type::(), + value: RuntimeDbRefTime::default().encode(), + docs: maybe_docs(vec![ + " The computational time component (`ref_time`) of runtime database operations the runtime", + " can invoke.", + ]), }, PalletConstantMetadata { name: "Version", diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index abacfa7b62cc..20158bb63462 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -145,7 +145,7 @@ use frame_support::{ }; use scale_info::TypeInfo; use sp_core::storage::well_known_keys; -use sp_weights::{RuntimeDbWeight, Weight}; +use sp_weights::{RuntimeDbRefTime, Weight}; #[cfg(any(feature = "std", test))] use sp_io::TestExternalities; @@ -549,9 +549,10 @@ pub mod pallet { #[pallet::no_default_bounds] type BlockHashCount: Get>; - /// The weight of runtime database operations the runtime can invoke. + /// The computational time component (`ref_time`) of runtime database operations the runtime + /// can invoke. #[pallet::constant] - type DbWeight: Get; + type DbWeight: Get; /// Get the chain's in-code version. #[pallet::constant] diff --git a/substrate/frame/system/src/mock.rs b/substrate/frame/system/src/mock.rs index fff848b3b0e5..8ccd717eb9bc 100644 --- a/substrate/frame/system/src/mock.rs +++ b/substrate/frame/system/src/mock.rs @@ -42,7 +42,7 @@ parameter_types! { transaction_version: 1, state_version: 1, }; - pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const DbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 10, write: 100, }; diff --git a/substrate/frame/tips/src/migrations/unreserve_deposits.rs b/substrate/frame/tips/src/migrations/unreserve_deposits.rs index afc424309bf4..23ea7538aa2e 100644 --- a/substrate/frame/tips/src/migrations/unreserve_deposits.rs +++ b/substrate/frame/tips/src/migrations/unreserve_deposits.rs @@ -24,7 +24,7 @@ use frame_support::{ pallet_prelude::OptionQuery, storage_alias, traits::{Currency, LockableCurrency, OnRuntimeUpgrade, ReservableCurrency}, - weights::RuntimeDbWeight, + weights::RuntimeDbRefTime, Parameter, Twox64Concat, }; use sp_runtime::{traits::Zero, Saturating}; @@ -57,7 +57,7 @@ pub trait UnlockConfig: 'static { /// [`construct_runtime!`](frame_support::construct_runtime). type PalletName: sp_core::Get<&'static str>; /// The DB weight as configured in the runtime to calculate the correct weight. - type DbWeight: sp_core::Get; + type DbWeight: sp_core::Get; /// The block number as configured in the runtime. type BlockNumber: Parameter + Zero + Copy + Ord; } diff --git a/substrate/primitives/weights/src/lib.rs b/substrate/primitives/weights/src/lib.rs index b2c956266e2c..2a3e74906b65 100644 --- a/substrate/primitives/weights/src/lib.rs +++ b/substrate/primitives/weights/src/lib.rs @@ -51,23 +51,58 @@ pub mod constants { /// The weight of database operations that the runtime can invoke. /// -/// NOTE: This is currently only measured in computational time, and will probably -/// be updated all together once proof size is accounted for. +/// NOTE: `RuntimeDbRefTime` formerly `RuntimeDbWeight` can only be used to estimate the +/// computational time component (`ref_time`) of database operations. +/// +/// It is primarily intended for use within benchmark-generated [`Weight`] functions to help +/// calculate the computational cost of these operations. +/// It should NOT be used in any context that is meant to be parachain compatible, where a non-zero +/// `pov_weight` component is expected. #[derive(Clone, Copy, Eq, PartialEq, Default, RuntimeDebug, Encode, Decode, TypeInfo)] -pub struct RuntimeDbWeight { +pub struct RuntimeDbRefTime { pub read: u64, pub write: u64, } -impl RuntimeDbWeight { +#[deprecated(note = "Use `RuntimeDbRefTime` instead.")] +pub type RuntimeDbWeight = RuntimeDbRefTime; + +impl RuntimeDbRefTime { + /// The weight of a read operation. + /// + /// Note: `RuntimeDbRefTime` does not know about `proof_size`. The returned [`Weight`] only has + /// a non-zero computational time component (`ref_time`). + /// + /// This function is primarily intended for use within benchmark-generated [`Weight`] functions + /// to help calculate the computational cost of these operations. + /// It should NOT be used in any context that is meant to be parachain compatible, where a + /// non-zero `pov_weight` component is expected. pub fn reads(self, r: u64) -> Weight { Weight::from_parts(self.read.saturating_mul(r), 0) } + /// The weight of a write operation. + /// + /// Note: `RuntimeDbRefTime` does not know about `proof_size`. The returned [`Weight`] only has + /// a non-zero computational time component (`ref_time`). + /// + /// This function is primarily intended for use within benchmark-generated [`Weight`] functions + /// to help calculate the computational cost of these operations. + /// It should NOT be used in any context that is meant to be parachain compatible, where a + /// non-zero `pov_weight` component is expected. pub fn writes(self, w: u64) -> Weight { Weight::from_parts(self.write.saturating_mul(w), 0) } + /// The weight of a read and write operation. + /// + /// Note: `RuntimeDbRefTime` does not know about `proof_size`. The returned [`Weight`] only has + /// a non-zero computational time component (`ref_time`). + /// + /// This function is primarily intended for use within benchmark-generated [`Weight`] functions + /// to help calculate the computational cost of these operations. + /// It should NOT be used in any context that is meant to be parachain compatible, where a + /// non-zero `pov_weight` component is expected. pub fn reads_writes(self, r: u64, w: u64) -> Weight { let read_weight = self.read.saturating_mul(r); let write_weight = self.write.saturating_mul(w); diff --git a/substrate/utils/frame/benchmarking-cli/src/storage/weights.hbs b/substrate/utils/frame/benchmarking-cli/src/storage/weights.hbs index 135b18b19374..a3df8ebc71c9 100644 --- a/substrate/utils/frame/benchmarking-cli/src/storage/weights.hbs +++ b/substrate/utils/frame/benchmarking-cli/src/storage/weights.hbs @@ -19,7 +19,7 @@ pub mod constants { use frame_support::weights::constants; use sp_core::parameter_types; - use sp_weights::RuntimeDbWeight; + use sp_weights::RuntimeDbRefTime; parameter_types! { {{#if (eq db_name "ParityDb")}} @@ -29,7 +29,7 @@ pub mod constants { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. {{/if}} - pub const {{db_name}}Weight: RuntimeDbWeight = RuntimeDbWeight { + pub const {{db_name}}Weight: RuntimeDbRefTime = RuntimeDbRefTime { /// Time to read one storage item. /// Calculated by multiplying the *{{params.weight_params.weight_metric}}* of all values with `{{params.weight_params.weight_mul}}` and adding `{{params.weight_params.weight_add}}`. /// diff --git a/templates/parachain/runtime/src/weights/paritydb_weights.rs b/templates/parachain/runtime/src/weights/paritydb_weights.rs index 25679703831a..937ec76ac602 100644 --- a/templates/parachain/runtime/src/weights/paritydb_weights.rs +++ b/templates/parachain/runtime/src/weights/paritydb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights /// are available for brave runtime engineers who may want to try this out as default. - pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const ParityDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, }; diff --git a/templates/parachain/runtime/src/weights/rocksdb_weights.rs b/templates/parachain/runtime/src/weights/rocksdb_weights.rs index 3dd817aa6f13..bbc95f513f5c 100644 --- a/templates/parachain/runtime/src/weights/rocksdb_weights.rs +++ b/templates/parachain/runtime/src/weights/rocksdb_weights.rs @@ -18,13 +18,13 @@ pub mod constants { use frame_support::{ parameter_types, - weights::{constants, RuntimeDbWeight}, + weights::{constants, RuntimeDbRefTime}, }; parameter_types! { /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout /// the runtime. - pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + pub const RocksDbWeight: RuntimeDbRefTime = RuntimeDbRefTime { read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, };