diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 5acc429e952be..936dc1c35c84c 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. spec_version: 267, - impl_version: 0, + impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 2, }; diff --git a/frame/elections-phragmen/src/migrations/v3.rs b/frame/elections-phragmen/src/migrations/v3.rs index fae191373fa1b..728e0c4b0c915 100644 --- a/frame/elections-phragmen/src/migrations/v3.rs +++ b/frame/elections-phragmen/src/migrations/v3.rs @@ -19,6 +19,7 @@ use codec::{Decode, Encode, FullCodec}; use frame_support::{ + pallet_prelude::ValueQuery, traits::{PalletInfoAccess, StorageVersion}, weights::Weight, RuntimeDebug, Twox64Concat, @@ -52,13 +53,22 @@ pub trait V2ToV3 { } frame_support::generate_storage_alias!( - PhragmenElection, Candidates => Value> + PhragmenElection, Candidates => Value< + Vec<(T::AccountId, T::Balance)>, + ValueQuery + > ); frame_support::generate_storage_alias!( - PhragmenElection, Members => Value>> + PhragmenElection, Members => Value< + Vec>, + ValueQuery + > ); frame_support::generate_storage_alias!( - PhragmenElection, RunnersUp => Value>> + PhragmenElection, RunnersUp => Value< + Vec>, + ValueQuery + > ); frame_support::generate_storage_alias!( PhragmenElection, Voting => Map< diff --git a/frame/offences/src/migration.rs b/frame/offences/src/migration.rs index ee95d111a22b2..b6e32cbe69e26 100644 --- a/frame/offences/src/migration.rs +++ b/frame/offences/src/migration.rs @@ -16,7 +16,9 @@ // limitations under the License. use super::{Config, OffenceDetails, Perbill, SessionIndex}; -use frame_support::{generate_storage_alias, traits::Get, weights::Weight}; +use frame_support::{ + generate_storage_alias, pallet_prelude::ValueQuery, traits::Get, weights::Weight, +}; use sp_staking::offence::OnOffenceHandler; use sp_std::vec::Vec; @@ -31,7 +33,7 @@ type DeferredOffenceOf = ( // at a later time. generate_storage_alias!( Offences, - DeferredOffences => Value>> + DeferredOffences => Value>, ValueQuery> ); pub fn remove_deferred_storage() -> Weight { diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 105b2328f2325..9dee6da89b256 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -130,6 +130,18 @@ impl TypeId for PalletId { /// > /// ); /// +/// // optionally specify the query type +/// use frame_support::pallet_prelude::{ValueQuery, OptionQuery}; +/// generate_storage_alias!(Prefix, ValueName => Value); +/// generate_storage_alias!( +/// Prefix, SomeStorageName => DoubleMap< +/// (u32, Twox64Concat), +/// (u32, Twox64Concat), +/// Vec, +/// ValueQuery +/// > +/// ); +/// /// // generate a map from `Config::AccountId` (with hasher `Twox64Concat`) to `Vec` /// trait Config { type AccountId: codec::FullCodec; } /// generate_storage_alias!( @@ -140,7 +152,7 @@ impl TypeId for PalletId { #[macro_export] macro_rules! generate_storage_alias { // without generic for $name. - ($pallet:ident, $name:ident => Map<($key:ty, $hasher:ty), $value:ty>) => { + ($pallet:ident, $name:ident => Map<($key:ty, $hasher:ty), $value:ty $(, $querytype:ty)?>) => { $crate::paste::paste! { $crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name); type $name = $crate::storage::types::StorageMap< @@ -148,10 +160,15 @@ macro_rules! generate_storage_alias { $hasher, $key, $value, + $( $querytype )? >; } }; - ($pallet:ident, $name:ident => DoubleMap<($key1:ty, $hasher1:ty), ($key2:ty, $hasher2:ty), $value:ty>) => { + ( + $pallet:ident, + $name:ident + => DoubleMap<($key1:ty, $hasher1:ty), ($key2:ty, $hasher2:ty), $value:ty $(, $querytype:ty)?> + ) => { $crate::paste::paste! { $crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name); type $name = $crate::storage::types::StorageDoubleMap< @@ -161,10 +178,15 @@ macro_rules! generate_storage_alias { $hasher2, $key2, $value, + $( $querytype )? >; } }; - ($pallet:ident, $name:ident => NMap, $value:ty>) => { + ( + $pallet:ident, + $name:ident + => NMap, $value:ty $(, $querytype:ty)?> + ) => { $crate::paste::paste! { $crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name); type $name = $crate::storage::types::StorageNMap< @@ -173,20 +195,26 @@ macro_rules! generate_storage_alias { $( $crate::storage::types::Key<$hasher, $key>, )+ ), $value, + $( $querytype )? >; } }; - ($pallet:ident, $name:ident => Value<$value:ty>) => { + ($pallet:ident, $name:ident => Value<$value:ty $(, $querytype:ty)?>) => { $crate::paste::paste! { $crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name); type $name = $crate::storage::types::StorageValue< [<$name Instance>], $value, + $( $querytype )? >; } }; // with generic for $name. - ($pallet:ident, $name:ident<$t:ident : $bounds:tt> => Map<($key:ty, $hasher:ty), $value:ty>) => { + ( + $pallet:ident, + $name:ident<$t:ident : $bounds:tt> + => Map<($key:ty, $hasher:ty), $value:ty $(, $querytype:ty)?> + ) => { $crate::paste::paste! { $crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name); #[allow(type_alias_bounds)] @@ -195,13 +223,15 @@ macro_rules! generate_storage_alias { $key, $hasher, $value, + $( $querytype )? >; } }; ( $pallet:ident, $name:ident<$t:ident : $bounds:tt> - => DoubleMap<($key1:ty, $hasher1:ty), ($key2:ty, $hasher2:ty), $value:ty>) => { + => DoubleMap<($key1:ty, $hasher1:ty), ($key2:ty, $hasher2:ty), $value:ty $(, $querytype:ty)?> + ) => { $crate::paste::paste! { $crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name); #[allow(type_alias_bounds)] @@ -212,12 +242,14 @@ macro_rules! generate_storage_alias { $key2, $hasher2, $value, + $( $querytype )? >; } }; ( $pallet:ident, - $name:ident<$t:ident : $bounds:tt> => NMap<$(($key:ty, $hasher:ty),)+ $value:ty> + $name:ident<$t:ident : $bounds:tt> + => NMap<$(($key:ty, $hasher:ty),)+ $value:ty $(, $querytype:ty)?> ) => { $crate::paste::paste! { $crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name); @@ -228,17 +260,18 @@ macro_rules! generate_storage_alias { $( $crate::storage::types::Key<$hasher, $key>, )+ ), $value, + $( $querytype )? >; } }; - ($pallet:ident, $name:ident<$t:ident : $bounds:tt> => Value<$value:ty>) => { + ($pallet:ident, $name:ident<$t:ident : $bounds:tt> => Value<$value:ty $(, $querytype:ty)?>) => { $crate::paste::paste! { $crate::generate_storage_alias!(@GENERATE_INSTANCE_STRUCT $pallet, $name); #[allow(type_alias_bounds)] type $name<$t : $bounds> = $crate::storage::types::StorageValue< [<$name Instance>], $value, - $crate::storage::types::ValueQuery, + $( $querytype )? >; } };