Move PalletVersion away from the crate version (#9165)

* Move `PalletVersion` away from the crate version

Before this pr, `PalletVersion` was referring to the crate version that
hosted the pallet. This pr introduces a custom `package.metadata.frame`
section in the `Cargo.toml` that can contain a `pallet-version` key
value pair. While the value is expected to be a valid u16. If this
key/value pair isn't given, the version is set to 1.

It also changes the `PalletVersion` declaration. We now only have one
`u16` that represents the version. Not a major/minor/patch version. As
the old `PalletVersion` was starting with the `u16` major, decoding the
old values will work.

* Overhaul the entire implementation

- Drop PalletVersion
- Introduce StorageVersion
- StorageVersion needs to be set in the crate and set for the macros
- Added migration

* Fix migrations

* Review feedback

* Remove unneeded dep

* remove pub consts

* Brings back logging and implements `GetStorageVersion`

* Return weight from migration

* Fmt and remove unused import

* Update frame/support/src/dispatch.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

* Update frame/support/src/traits/metadata.rs

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>

Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Bastian Köcher
2021-07-27 23:21:27 +02:00
committed by GitHub
parent 988c399983
commit 4fe55f0bcb
24 changed files with 550 additions and 657 deletions
+179 -53
View File
@@ -26,7 +26,7 @@ pub use crate::{
result,
},
traits::{
CallMetadata, GetCallMetadata, GetCallName, GetPalletVersion, UnfilteredDispatchable,
CallMetadata, GetCallMetadata, GetCallName, GetStorageVersion, UnfilteredDispatchable,
},
weights::{
ClassifyDispatch, DispatchInfo, GetDispatchInfo, PaysFee, PostDispatchInfo,
@@ -352,6 +352,7 @@ macro_rules! decl_module {
{}
{}
{}
{}
[]
$($t)*
);
@@ -388,6 +389,7 @@ macro_rules! decl_module {
{}
{}
{}
{}
[]
$($t)*
);
@@ -408,6 +410,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
$vis:vis fn deposit_event() = default;
@@ -426,7 +429,8 @@ macro_rules! decl_module {
{ $( $offchain )* }
{ $( $constants )* }
{ $( $error_type )* }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[ $( $dispatchables )* ]
$($rest)*
);
@@ -445,6 +449,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
$vis:vis fn deposit_event
@@ -471,6 +476,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
$vis:vis fn deposit_event() = default;
@@ -493,6 +499,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn on_finalize( $( $param_name:ident : $param:ty ),* $(,)? ) { $( $impl:tt )* }
@@ -513,7 +520,8 @@ macro_rules! decl_module {
{ $( $offchain )* }
{ $( $constants )* }
{ $( $error_type )* }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[ $( $dispatchables )* ]
$($rest)*
);
@@ -533,6 +541,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
#[weight = $weight:expr]
@@ -561,6 +570,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
#[weight = $weight:expr]
@@ -585,6 +595,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn on_idle($param_name1:ident : $param1:ty, $param_name2:ident: $param2:ty $(,)? ) -> $return:ty { $( $impl:tt )* }
@@ -605,7 +616,8 @@ macro_rules! decl_module {
{ $( $offchain )* }
{ $( $constants )* }
{ $( $error_type )* }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[ $( $dispatchables )* ]
$($rest)*
);
@@ -626,6 +638,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
$(#[weight = $weight:expr])?
@@ -652,6 +665,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn on_runtime_upgrade( $( $param_name:ident : $param:ty ),* $(,)? ) { $( $impl:tt )* }
@@ -678,6 +692,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
#[weight = $weight:expr]
@@ -706,6 +721,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn on_runtime_upgrade( $( $param_name:ident : $param:ty ),* $(,)? ) -> $return:ty { $( $impl:tt )* }
@@ -726,7 +742,8 @@ macro_rules! decl_module {
{ $( $offchain )* }
{ $( $constants )* }
{ $( $error_type )* }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[ $( $dispatchables )* ]
$($rest)*
);
@@ -748,6 +765,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn on_runtime_upgrade( $( $param_name:ident : $param:ty ),* $(,)? ) -> $return:ty { $( $impl:tt )* }
@@ -772,6 +790,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{}
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn integrity_test() { $( $impl:tt )* }
@@ -794,6 +813,7 @@ macro_rules! decl_module {
$(#[doc = $doc_attr])*
fn integrity_test() { $( $impl)* }
}
{ $( $storage_version )* }
[ $( $dispatchables )* ]
$($rest)*
);
@@ -815,6 +835,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )+ }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn integrity_test() { $( $impl:tt )* }
@@ -839,6 +860,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn on_initialize( $( $param_name:ident : $param:ty ),* $(,)? ) { $( $impl:tt )* }
@@ -865,6 +887,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
#[weight = $weight:expr]
@@ -893,6 +916,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn on_initialize( $( $param_name:ident : $param:ty ),* $(,)? ) -> $return:ty { $( $impl:tt )* }
@@ -913,7 +937,8 @@ macro_rules! decl_module {
{ $( $offchain )* }
{ $( $constants )* }
{ $( $error_type )* }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[ $( $dispatchables )* ]
$($rest)*
);
@@ -935,6 +960,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn on_initialize( $( $param_name:ident : $param:ty ),* $(,)? ) -> $return:ty { $( $impl:tt )* }
@@ -959,6 +985,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn offchain_worker( $( $param_name:ident : $param:ty ),* $(,)? ) { $( $impl:tt )* }
@@ -979,7 +1006,8 @@ macro_rules! decl_module {
{ fn offchain_worker( $( $param_name : $param ),* ) { $( $impl )* } }
{ $( $constants )* }
{ $( $error_type )* }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[ $( $dispatchables )* ]
$($rest)*
);
@@ -1001,6 +1029,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
fn offchain_worker( $( $param_name:ident : $param:ty ),* $(,)? ) -> $return:ty { $( $impl:tt )* }
@@ -1026,6 +1055,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$( #[doc = $doc_attr:tt] )*
const $name:ident: $ty:ty = $value:expr;
@@ -1051,7 +1081,8 @@ macro_rules! decl_module {
$name: $ty = $value;
}
{ $( $error_type )* }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[ $( $dispatchables )* ]
$($rest)*
);
@@ -1075,6 +1106,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
type Error = $error_type:ty;
@@ -1095,7 +1127,8 @@ macro_rules! decl_module {
{ $( $offchain )* }
{ $( $constants )* }
{ $error_type }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[ $( $dispatchables )* ]
$($rest)*
);
@@ -1118,6 +1151,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $($t:tt)* ]
$($rest:tt)*
) => {
@@ -1136,12 +1170,59 @@ macro_rules! decl_module {
{ $( $offchain )* }
{ $( $constants )* }
{ &'static str }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[ $($t)* ]
$($rest)*
);
};
// Parse storage version
(@normalize
$(#[$attr:meta])*
pub struct $mod_type:ident<
$trait_instance:ident:
$trait_name:ident$(<I>, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?
>
for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident
{ $( $other_where_bounds:tt )* }
{ $( $deposit_event:tt )* }
{ $( $on_initialize:tt )* }
{ $( $on_runtime_upgrade:tt )* }
{ $( $on_idle:tt )* }
{ $( $on_finalize:tt )* }
{ $( $offchain:tt )* }
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
type StorageVersion = $storage_version:path;
$($rest:tt)*
) => {
$crate::decl_module!(@normalize
$(#[$attr])*
pub struct $mod_type<
$trait_instance: $trait_name$(<I>, $instance: $instantiable $(= $module_default_instance)?)?
>
for enum $call_type where origin: $origin_type, system = $system
{ $( $other_where_bounds )* }
{ $( $deposit_event )* }
{ $( $on_initialize )* }
{ $( $on_runtime_upgrade )* }
{ $( $on_idle )* }
{ $( $on_finalize )* }
{ $( $offchain )* }
{ $( $constants )* }
{ $( $error_type )* }
{ $( $integrity_test)* }
{ $storage_version }
[ $( $dispatchables )* ]
$($rest)*
);
};
// This puts the function statement into the [], decreasing `$rest` and moving toward finishing the parse.
(@normalize
$(#[$attr:meta])*
@@ -1160,6 +1241,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $error_type:ty }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
#[weight = $weight:expr]
@@ -1184,7 +1266,8 @@ macro_rules! decl_module {
{ $( $offchain )* }
{ $( $constants )* }
{ $error_type }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
[
$( $dispatchables )*
$(#[doc = $doc_attr])*
@@ -1216,6 +1299,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
$(#[$fn_attr:meta])*
@@ -1245,6 +1329,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
$(#[weight = $weight:expr])?
@@ -1274,6 +1359,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
$(#[weight = $weight:expr])?
@@ -1303,6 +1389,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
$(#[doc = $doc_attr:tt])*
$(#[weight = $weight:expr])?
@@ -1333,6 +1420,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $( $error_type:tt )* }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
[ $( $dispatchables:tt )* ]
) => {
$crate::decl_module!(@imp
@@ -1350,7 +1438,8 @@ macro_rules! decl_module {
{ $( $offchain )* }
{ $( $constants )* }
{ $( $error_type )* }
{ $( $integrity_test)* }
{ $( $integrity_test )* }
{ $( $storage_version )* }
);
};
@@ -1451,25 +1540,17 @@ macro_rules! decl_module {
as
$system::Config
>::PalletInfo as $crate::traits::PalletInfo>::name::<Self>().unwrap_or("<unknown pallet name>");
let new_storage_version = $crate::crate_to_pallet_version!();
$crate::log::info!(
target: $crate::LOG_TARGET,
"⚠️ {} declares internal migrations (which *might* execute), setting storage version to {:?}",
"⚠️ {} declares internal migrations (which *might* execute). \
On-chain `{:?}` vs current storage version `{:?}`",
pallet_name,
new_storage_version,
<Self as $crate::traits::GetStorageVersion>::on_chain_storage_version(),
<Self as $crate::traits::GetStorageVersion>::current_storage_version(),
);
let result: $return = (|| { $( $impl )* })();
new_storage_version
.put_into_storage::<<$trait_instance as $system::Config>::PalletInfo, Self>();
let additional_write = <
<$trait_instance as $system::Config>::DbWeight as $crate::traits::Get<_>
>::get().writes(1);
result.saturating_add(additional_write)
(|| { $( $impl )* })()
}
#[cfg(feature = "try-runtime")]
@@ -1500,19 +1581,14 @@ macro_rules! decl_module {
as
$system::Config
>::PalletInfo as $crate::traits::PalletInfo>::name::<Self>().unwrap_or("<unknown pallet name>");
let new_storage_version = $crate::crate_to_pallet_version!();
$crate::log::info!(
target: $crate::LOG_TARGET,
"✅ no migration for {}, setting storage version to {:?}",
"✅ no migration for {}",
pallet_name,
new_storage_version,
);
new_storage_version
.put_into_storage::<<$trait_instance as $system::Config>::PalletInfo, Self>();
<<$trait_instance as $system::Config>::DbWeight as $crate::traits::Get<_>>::get().writes(1)
0
}
#[cfg(feature = "try-runtime")]
@@ -1823,6 +1899,45 @@ macro_rules! decl_module {
}
};
// Implementation for `GetStorageVersion`.
(@impl_get_storage_version
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
{ $( $other_where_bounds:tt )* }
$( $storage_version:tt )+
) => {
// Implement `GetStorageVersion` for `Pallet`
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::traits::GetStorageVersion
for $module<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
{
fn current_storage_version() -> $crate::traits::StorageVersion {
$( $storage_version )*
}
fn on_chain_storage_version() -> $crate::traits::StorageVersion {
$crate::traits::StorageVersion::get::<Self>()
}
}
};
// Implementation for `GetStorageVersion` when no storage version is passed.
(@impl_get_storage_version
$module:ident<$trait_instance:ident: $trait_name:ident$(<I>, $instance:ident: $instantiable:path)?>;
{ $( $other_where_bounds:tt )* }
) => {
// Implement `GetStorageVersion` for `Pallet`
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::traits::GetStorageVersion
for $module<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
{
fn current_storage_version() -> $crate::traits::StorageVersion {
Default::default()
}
fn on_chain_storage_version() -> $crate::traits::StorageVersion {
$crate::traits::StorageVersion::get::<Self>()
}
}
};
// The main macro expansion that actually renders the module code.
(@imp
@@ -1852,6 +1967,7 @@ macro_rules! decl_module {
{ $( $constants:tt )* }
{ $error_type:ty }
{ $( $integrity_test:tt )* }
{ $( $storage_version:tt )* }
) => {
$crate::__check_reserved_fn_name! { $( $fn_name )* }
@@ -1908,6 +2024,7 @@ macro_rules! decl_module {
{ $( $other_where_bounds )* }
$( $offchain )*
}
$crate::decl_module! {
@impl_deposit_event
$mod_type<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?>;
@@ -1964,6 +2081,13 @@ macro_rules! decl_module {
)*
}
$crate::decl_module! {
@impl_get_storage_version
$mod_type<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?>;
{ $( $other_where_bounds )* }
$( $storage_version )*
}
// Implement weight calculation function for Call
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::dispatch::GetDispatchInfo
for $call_type<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
@@ -1997,6 +2121,27 @@ macro_rules! decl_module {
}
}
// Implement PalletInfoAccess for the module.
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::traits::PalletInfoAccess
for $mod_type<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
{
fn index() -> usize {
<
<$trait_instance as $system::Config>::PalletInfo as $crate::traits::PalletInfo
>::index::<Self>()
.expect("Pallet is part of the runtime because pallet `Config` trait is \
implemented by the runtime")
}
fn name() -> &'static str {
<
<$trait_instance as $system::Config>::PalletInfo as $crate::traits::PalletInfo
>::name::<Self>()
.expect("Pallet is part of the runtime because pallet `Config` trait is \
implemented by the runtime")
}
}
// Implement GetCallName for the Call.
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::dispatch::GetCallName
for $call_type<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
@@ -2023,32 +2168,13 @@ macro_rules! decl_module {
}
}
// Bring `GetPalletVersion` into scope to make it easily usable.
pub use $crate::traits::GetPalletVersion as _;
// Implement `GetPalletVersion` for `Module`
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::traits::GetPalletVersion
for $mod_type<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
{
fn current_version() -> $crate::traits::PalletVersion {
$crate::crate_to_pallet_version!()
}
fn storage_version() -> Option<$crate::traits::PalletVersion> {
let key = $crate::traits::PalletVersion::storage_key::<
<$trait_instance as $system::Config>::PalletInfo, Self
>().expect("Every active pallet has a name in the runtime; qed");
$crate::storage::unhashed::get(&key)
}
}
// Implement `OnGenesis` for `Module`
impl<$trait_instance: $trait_name $(<I>, $instance: $instantiable)?> $crate::traits::OnGenesis
for $mod_type<$trait_instance $(, $instance)?> where $( $other_where_bounds )*
{
fn on_genesis() {
$crate::crate_to_pallet_version!()
.put_into_storage::<<$trait_instance as $system::Config>::PalletInfo, Self>();
let storage_version = <Self as $crate::traits::GetStorageVersion>::current_storage_version();
storage_version.put::<Self>();
}
}