From cc59e2232c5189b87495f4a54586b9bba0b7ecd8 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Tue, 25 Jul 2023 21:37:25 +0700 Subject: [PATCH 01/11] init on-chain storage version --- frame/executive/src/lib.rs | 9 +++- .../procedural/src/pallet/expand/hooks.rs | 45 +++++++++++++++++++ frame/support/src/traits/hooks.rs | 45 +++++++++++++++++++ frame/support/src/traits/metadata.rs | 17 +++++++ 4 files changed, 114 insertions(+), 2 deletions(-) diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 4e24717a39e93..b5c9ee7c20fde 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -364,7 +364,9 @@ where )?; } - let weight = + let before_all_weight = + <(COnRuntimeUpgrade, AllPalletsWithSystem) as OnRuntimeUpgrade>::before_all(); + let try_on_runtime_upgrade_weight = <(COnRuntimeUpgrade, AllPalletsWithSystem) as OnRuntimeUpgrade>::try_on_runtime_upgrade( checks.pre_and_post(), )?; @@ -379,7 +381,7 @@ where )?; } - Ok(weight) + Ok(before_all_weight.saturating_add(try_on_runtime_upgrade_weight)) } } @@ -408,7 +410,10 @@ where { /// Execute all `OnRuntimeUpgrade` of this runtime, and return the aggregate weight. pub fn execute_on_runtime_upgrade() -> Weight { + let before_all_weight = + <(COnRuntimeUpgrade, AllPalletsWithSystem) as OnRuntimeUpgrade>::before_all(); <(COnRuntimeUpgrade, AllPalletsWithSystem) as OnRuntimeUpgrade>::on_runtime_upgrade() + .saturating_add(before_all_weight) } /// Start the execution of a particular block. diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index d2d2b2967fafb..bde971581f53c 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -35,6 +35,31 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { let pallet_ident = &def.pallet_struct.pallet; let frame_system = &def.frame_system; + let initialize_on_chain_storage_version = if let Some(current_version) = + def.pallet_struct.storage_version.as_ref() + { + quote::quote! { + #frame_support::log::info!( + target: #frame_support::LOG_TARGET, + "🐥 Pallet {:?} has no on-chain storage version. Initializing the on-chain storage version to match the storage version defined in the pallet: {:?}", + pallet_name, + #current_version + ); + #current_version.put::(); + } + } else { + quote::quote! { + let default_version = #frame_support::traits::StorageVersion::new(0); + #frame_support::log::info!( + target: #frame_support::LOG_TARGET, + "🐥 Pallet {:?} has no on-chain storage version. The pallet has not defined storage version, so the on-chain version is being initialized to {:?}.", + pallet_name, + default_version, + ); + default_version.put::(); + } + }; + let log_runtime_upgrade = if has_runtime_upgrade { // a migration is defined here. quote::quote! { @@ -190,6 +215,26 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { #frame_support::traits::OnRuntimeUpgrade for #pallet_ident<#type_use_gen> #where_clause { + fn before_all() -> Weight { + #frame_support::sp_tracing::enter_span!( + #frame_support::sp_tracing::trace_span!("before_all") + ); + + // Check if the on-chain version has been set yet + let exists = #frame_support::traits::StorageVersion::exists::(); + if !exists { + let pallet_name = < + ::PalletInfo + as + #frame_support::traits::PalletInfo + >::name::().unwrap_or(""); + #initialize_on_chain_storage_version + Weight::zero() // TODO: Return weight of 1 read 1 write + } else { + Weight::zero() // TODO: Return weight of 1 read + } + } + fn on_runtime_upgrade() -> #frame_support::weights::Weight { #frame_support::sp_tracing::enter_span!( #frame_support::sp_tracing::trace_span!("on_runtime_update") diff --git a/frame/support/src/traits/hooks.rs b/frame/support/src/traits/hooks.rs index 3f9c6b1507d39..42eb29cea9cb5 100644 --- a/frame/support/src/traits/hooks.rs +++ b/frame/support/src/traits/hooks.rs @@ -101,7 +101,46 @@ pub trait OnGenesis { /// See [`Hooks::on_runtime_upgrade`]. pub trait OnRuntimeUpgrade { + /// Advanced lifecycle hook called for all pallets and custom migrations before any other + /// [`OnRuntimeUpgrade`] hooks. + /// + /// Sometimes it is useful to have some logic execute prior to any other [`OnRuntimeUpgrade`] + /// hooks being called, which [`OnRuntimeUpgrade::before_all`] allows for. + /// + /// When the Executive pallet executes runtime upgrades, hooks are called in this order: + /// 1. [`OnRuntimeUpgrade::before_all`] for all custom migrations + /// 2. [`OnRuntimeUpgrade::before_all`] for all pallet migrations + /// 3. For each custom migration: + /// 1. [`OnRuntimeUpgrade::pre_upgrade`] + /// 2. [`OnRuntimeUpgrade::on_runtime_upgrade`] + /// 3. [`OnRuntimeUpgrade::post_upgrade`] + /// 4. For each pallet: + /// 1. [`OnRuntimeUpgrade::pre_upgrade`] + /// 2. [`OnRuntimeUpgrade::on_runtime_upgrade`] + /// 3. [`OnRuntimeUpgrade::post_upgrade`] + /// + /// An example of when this hook is useful is initializing the on-chain storage version of a + /// pallet when it is added to the runtime in a way which will not break + /// [`OnRuntimeUpgrade::post_upgrade`] checks. + /// + /// This is an advanced hook unlikely to be needed in most [`OnRuntimeUpgrade`] implementations, + /// you can probably ignore it. + /// + /// Returns the non-negotiable weight consumed by the checks. + fn before_all() -> Weight { + Weight::zero() + } + /// See [`Hooks::on_runtime_upgrade`]. + /// Perform a module upgrade. + /// + /// # Warning + /// + /// This function will be called before we initialized any runtime state, aka `on_initialize` + /// wasn't called yet. So, information like the block number and any other + /// block local data are not accessible. + /// + /// Return the non-negotiable weight consumed for runtime upgrade. fn on_runtime_upgrade() -> Weight { Weight::zero() } @@ -145,6 +184,12 @@ pub trait OnRuntimeUpgrade { #[cfg_attr(all(feature = "tuples-96", not(feature = "tuples-128")), impl_for_tuples(96))] #[cfg_attr(feature = "tuples-128", impl_for_tuples(128))] impl OnRuntimeUpgrade for Tuple { + fn before_all() -> Weight { + let mut weight = Weight::zero(); + for_tuples!( #( weight = weight.saturating_add(Tuple::before_all()); )* ); + weight + } + fn on_runtime_upgrade() -> Weight { let mut weight = Weight::zero(); for_tuples!( #( weight = weight.saturating_add(Tuple::on_runtime_upgrade()); )* ); diff --git a/frame/support/src/traits/metadata.rs b/frame/support/src/traits/metadata.rs index 85d8f9a5a74e0..c671fe536d295 100644 --- a/frame/support/src/traits/metadata.rs +++ b/frame/support/src/traits/metadata.rs @@ -218,6 +218,23 @@ impl StorageVersion { crate::storage::unhashed::get_or_default(&key) } + + /// Returns if the storage key for the given pallet exists in storage. + /// + /// See [`STORAGE_VERSION_STORAGE_KEY_POSTFIX`] on how this key is built. + /// + /// # Panics + /// + /// This function will panic iff `Pallet` can not be found by `PalletInfo`. + /// In a runtime that is put together using + /// [`construct_runtime!`](crate::construct_runtime) this should never happen. + /// + /// It will also panic if this function isn't executed in an externalities + /// provided environment. + pub fn exists() -> bool { + let key = Self::storage_key::

(); + crate::storage::unhashed::exists(&key) + } } impl PartialEq for StorageVersion { From b56c7cde88d36631a5a94cd5e69aaa8bda9b39cd Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Tue, 25 Jul 2023 21:39:00 +0700 Subject: [PATCH 02/11] fix comment --- frame/support/src/traits/hooks.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/frame/support/src/traits/hooks.rs b/frame/support/src/traits/hooks.rs index 42eb29cea9cb5..028e140ce9659 100644 --- a/frame/support/src/traits/hooks.rs +++ b/frame/support/src/traits/hooks.rs @@ -132,15 +132,6 @@ pub trait OnRuntimeUpgrade { } /// See [`Hooks::on_runtime_upgrade`]. - /// Perform a module upgrade. - /// - /// # Warning - /// - /// This function will be called before we initialized any runtime state, aka `on_initialize` - /// wasn't called yet. So, information like the block number and any other - /// block local data are not accessible. - /// - /// Return the non-negotiable weight consumed for runtime upgrade. fn on_runtime_upgrade() -> Weight { Weight::zero() } From 0cfa0b86f09e40b214ee3fa4c73341859e9adf31 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 26 Jul 2023 13:48:36 +0700 Subject: [PATCH 03/11] refactor pallet_name repetition --- .../procedural/src/pallet/expand/hooks.rs | 61 ++++++------------- 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index bde971581f53c..6365ede3e9dd2 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -34,6 +34,13 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { let type_use_gen = &def.type_use_generics(span); let pallet_ident = &def.pallet_struct.pallet; let frame_system = &def.frame_system; + let pallet_name = quote::quote! { + < + ::PalletInfo + as + #frame_support::traits::PalletInfo + >::name::().unwrap_or("") + }; let initialize_on_chain_storage_version = if let Some(current_version) = def.pallet_struct.storage_version.as_ref() @@ -42,21 +49,18 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { #frame_support::log::info!( target: #frame_support::LOG_TARGET, "🐥 Pallet {:?} has no on-chain storage version. Initializing the on-chain storage version to match the storage version defined in the pallet: {:?}", - pallet_name, + #pallet_name, #current_version ); #current_version.put::(); } } else { quote::quote! { - let default_version = #frame_support::traits::StorageVersion::new(0); - #frame_support::log::info!( + #frame_support::log::debug!( target: #frame_support::LOG_TARGET, - "🐥 Pallet {:?} has no on-chain storage version. The pallet has not defined storage version, so the on-chain version is being initialized to {:?}.", - pallet_name, - default_version, + "🐥 Pallet {:?} has no on-chain storage version, but the pallet has no defined storage version so the on-chain version will not be initialized and implicitly remain 0.", + #pallet_name ); - default_version.put::(); } }; @@ -67,7 +71,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { target: #frame_support::LOG_TARGET, "⚠️ {} declares internal migrations (which *might* execute). \ On-chain `{:?}` vs current storage version `{:?}`", - pallet_name, + #pallet_name, ::on_chain_storage_version(), ::current_storage_version(), ); @@ -78,21 +82,16 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { #frame_support::log::debug!( target: #frame_support::LOG_TARGET, "✅ no migration for {}", - pallet_name, + #pallet_name, ); } }; let log_try_state = quote::quote! { - let pallet_name = < - ::PalletInfo - as - #frame_support::traits::PalletInfo - >::name::().expect("No name found for the pallet! This usually means that the pallet wasn't added to `construct_runtime!`."); #frame_support::log::debug!( target: #frame_support::LOG_TARGET, "🩺 try-state pallet {:?}", - pallet_name, + #pallet_name, ); }; @@ -116,16 +115,10 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { let current_version = ::current_storage_version(); if on_chain_version != current_version { - let pallet_name = < - ::PalletInfo - as - #frame_support::traits::PalletInfo - >::name::().unwrap_or(""); - #frame_support::log::error!( target: #frame_support::LOG_TARGET, "{}: On chain storage version {:?} doesn't match current storage version {:?}.", - pallet_name, + #pallet_name, on_chain_version, current_version, ); @@ -138,17 +131,11 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { let on_chain_version = ::on_chain_storage_version(); if on_chain_version != #frame_support::traits::StorageVersion::new(0) { - let pallet_name = < - ::PalletInfo - as - #frame_support::traits::PalletInfo - >::name::().unwrap_or(""); - #frame_support::log::error!( target: #frame_support::LOG_TARGET, "{}: On chain storage version {:?} is set to non zero, \ while the pallet is missing the `#[pallet::storage_version(VERSION)]` attribute.", - pallet_name, + #pallet_name, on_chain_version, ); @@ -215,7 +202,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { #frame_support::traits::OnRuntimeUpgrade for #pallet_ident<#type_use_gen> #where_clause { - fn before_all() -> Weight { + fn before_all() -> #frame_support::weights::Weight { #frame_support::sp_tracing::enter_span!( #frame_support::sp_tracing::trace_span!("before_all") ); @@ -223,15 +210,10 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { // Check if the on-chain version has been set yet let exists = #frame_support::traits::StorageVersion::exists::(); if !exists { - let pallet_name = < - ::PalletInfo - as - #frame_support::traits::PalletInfo - >::name::().unwrap_or(""); #initialize_on_chain_storage_version - Weight::zero() // TODO: Return weight of 1 read 1 write + ::DbWeight::get().reads_writes(1, 1) } else { - Weight::zero() // TODO: Return weight of 1 read + ::DbWeight::get().reads(1) } } @@ -241,11 +223,6 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { ); // log info about the upgrade. - let pallet_name = < - ::PalletInfo - as - #frame_support::traits::PalletInfo - >::name::().unwrap_or(""); #log_runtime_upgrade < From 7083af8d7336f63e946831b31a4cc35885c2fb5d Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 26 Jul 2023 14:00:20 +0700 Subject: [PATCH 04/11] use frame_support::traits::Get --- frame/support/procedural/src/pallet/expand/hooks.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index 6365ede3e9dd2..dac53bbd5a67f 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -203,6 +203,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { for #pallet_ident<#type_use_gen> #where_clause { fn before_all() -> #frame_support::weights::Weight { + use #frame_support::traits::Get; #frame_support::sp_tracing::enter_span!( #frame_support::sp_tracing::trace_span!("before_all") ); From 3e9ae525694f4b7e7fd55cdf57ea7dd6aa6a8b3f Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 26 Jul 2023 14:06:01 +0700 Subject: [PATCH 05/11] init on-chain versions for pallet without a current version --- frame/support/procedural/src/pallet/expand/hooks.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index dac53bbd5a67f..464cc02fd0621 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -56,10 +56,12 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { } } else { quote::quote! { - #frame_support::log::debug!( + let default_version = #frame_support::traits::StorageVersion::new(0); + #frame_support::log::info!( target: #frame_support::LOG_TARGET, - "🐥 Pallet {:?} has no on-chain storage version, but the pallet has no defined storage version so the on-chain version will not be initialized and implicitly remain 0.", - #pallet_name + "🐥 Pallet {:?} has no on-chain storage version. The pallet has not defined storage version, so the on-chain version is being initialized to {:?}.", + #pallet_name, + default_version ); } }; From 06ab2627647357bcae3239011cf195a290edb6ac Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 26 Jul 2023 15:11:34 +0700 Subject: [PATCH 06/11] add tests --- frame/support/test/tests/pallet.rs | 54 +++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 99010ffc8dbdf..81b3b29694da0 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -2110,6 +2110,54 @@ fn test_storage_alias() { }) } +#[test] +fn pallet_on_chain_storage_version_initializes_correctly() { + type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, + >; + + // Simple example of a pallet with current version 10 being added to the runtime for the first + // time. + TestExternalities::default().execute_with(|| { + let current_version = Example::current_storage_version(); + + // Check the on-chain storage version initially is not set and does not match the current + // version. + let on_chain_version_before = StorageVersion::get::(); + assert_eq!(StorageVersion::exists::(), false); + assert_ne!(on_chain_version_before, current_version); + + // OnRuntimeUpgrade calls pallet `before_all` hook which initializes the storage version. + Executive::execute_on_runtime_upgrade(); + + // Check that the storage version was initialized to the current version + let on_chain_version_after = StorageVersion::get::(); + assert_eq!(on_chain_version_after, current_version); + }); + + // Pallet with no current storage version should have the on-chain version initialized to 0. + TestExternalities::default().execute_with(|| { + // Example4 current_storage_version is NoStorageVersionSet. + + // Check the storage version is not set and implicitly 0. + let on_chain_version_before = StorageVersion::get::(); + assert_eq!(StorageVersion::exists::(), false); + assert_eq!(on_chain_version_before, StorageVersion::new(0)); + + // OnRuntimeUpgrade calls pallet `before_all` hook which initializes the storage version. + Executive::execute_on_runtime_upgrade(); + + // Check that the storage version now exists and was initialized to 0. + let on_chain_version_after = StorageVersion::get::(); + assert_eq!(StorageVersion::exists::(), true); + assert_eq!(on_chain_version_after, StorageVersion::new(0)); + }); +} + #[cfg(feature = "try-runtime")] #[test] fn post_runtime_upgrade_detects_storage_version_issues() { @@ -2163,7 +2211,11 @@ fn post_runtime_upgrade_detects_storage_version_issues() { TestExternalities::default().execute_with(|| { // Call `on_genesis` to put the storage version of `Example` into the storage. - Example::on_genesis(); + // Example::on_genesis(); + + // Set the on-chain version to something different to the current version + StorageVersion::new(100).put::(); + // The version isn't changed, we should detect it. assert!( Executive::try_runtime_upgrade(UpgradeCheckSelect::PreAndPost).unwrap_err() == From b8e1310a58be9635dc1e6a48fea49385f180c121 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 26 Jul 2023 15:13:49 +0700 Subject: [PATCH 07/11] fix test --- frame/support/test/tests/pallet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 81b3b29694da0..6b3c4ee98cb90 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -2211,7 +2211,7 @@ fn post_runtime_upgrade_detects_storage_version_issues() { TestExternalities::default().execute_with(|| { // Call `on_genesis` to put the storage version of `Example` into the storage. - // Example::on_genesis(); + Example::on_genesis(); // Set the on-chain version to something different to the current version StorageVersion::new(100).put::(); From 424455ba870af7b65afcf5b3b7f7f836b65e2db4 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 26 Jul 2023 15:22:31 +0700 Subject: [PATCH 08/11] put the default version --- frame/support/procedural/src/pallet/expand/hooks.rs | 1 + frame/support/test/tests/pallet.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index 464cc02fd0621..95ee579191f71 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -63,6 +63,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { #pallet_name, default_version ); + default_version.put::(); } }; diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 6b3c4ee98cb90..73185245b64f8 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -2153,7 +2153,7 @@ fn pallet_on_chain_storage_version_initializes_correctly() { // Check that the storage version now exists and was initialized to 0. let on_chain_version_after = StorageVersion::get::(); - assert_eq!(StorageVersion::exists::(), true); + assert_eq!(StorageVersion::exists::(), true); assert_eq!(on_chain_version_after, StorageVersion::new(0)); }); } From 6f679512217076700d27dcde732c0ccb667e8473 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 26 Jul 2023 17:58:39 +0700 Subject: [PATCH 09/11] kick ci --- frame/executive/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index b5c9ee7c20fde..3e3cc317bbbbf 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -1,7 +1,7 @@ // This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: Apache-2. 0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From aa0aa802b8450526b6bfeafca518c5ae84f9fd34 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 26 Jul 2023 17:59:59 +0700 Subject: [PATCH 10/11] kick ci --- frame/executive/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 3e3cc317bbbbf..b5c9ee7c20fde 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -1,7 +1,7 @@ // This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2. 0 +// SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From ab5199653db1bd2e0ca3e4c750515ff0028e8052 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Sun, 20 Aug 2023 16:38:18 +1000 Subject: [PATCH 11/11] Update frame/support/procedural/src/pallet/expand/hooks.rs Co-authored-by: Keith Yeung --- frame/support/procedural/src/pallet/expand/hooks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index 95ee579191f71..d4de5dab312e6 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -43,7 +43,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { }; let initialize_on_chain_storage_version = if let Some(current_version) = - def.pallet_struct.storage_version.as_ref() + &def.pallet_struct.storage_version { quote::quote! { #frame_support::log::info!(