From 4efe3bf847baf23eb4cdaf00b00dc094fe12d600 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Thu, 20 Apr 2023 08:57:14 +0000 Subject: [PATCH] Merge pull request #920 from UniqueNetwork/fix/on-runtime-upgrade --- --- a/Cargo.lock +++ b/Cargo.lock @@ -5996,7 +5996,7 @@ [[package]] name = "pallet-app-promotion" -version = "0.1.5" +version = "0.1.6" dependencies = [ "frame-benchmarking", "frame-support", --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -167,6 +167,8 @@ .map(|k| (k, 1 << 100)) .collect(), }, + common: Default::default(), + nonfungible: Default::default(), treasury: Default::default(), tokens: TokensConfig { balances: vec![] }, sudo: SudoConfig { @@ -225,6 +227,8 @@ .expect("WASM binary was not build, please build it!") .to_vec(), }, + common: Default::default(), + nonfungible: Default::default(), balances: BalancesConfig { balances: $endowed_accounts .iter() --- a/pallets/app-promotion/CHANGELOG.md +++ b/pallets/app-promotion/CHANGELOG.md @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file. +## [0.1.6] - 2023-04-19 + +- ### Fixed + +- Useless `on_runtime_upgrade()` has been removed ## [0.1.5] - 2023-02-14 --- a/pallets/app-promotion/Cargo.toml +++ b/pallets/app-promotion/Cargo.toml @@ -9,7 +9,7 @@ license = 'GPLv3' name = 'pallet-app-promotion' repository = 'https://github.com/UniqueNetwork/unique-chain' -version = '0.1.5' +version = '0.1.6' [package.metadata.docs.rs] targets = ['x86_64-unknown-linux-gnu'] --- a/pallets/app-promotion/src/lib.rs +++ b/pallets/app-promotion/src/lib.rs @@ -263,10 +263,6 @@ pub type PreviousCalculatedRecord = StorageValue; - #[pallet::storage] - pub(crate) type UpgradedToReserves = - StorageValue; - #[pallet::hooks] impl Hooks> for Pallet { /// Block overflow is impossible due to the fact that the unstake algorithm in on_initialize @@ -289,12 +285,6 @@ } ::WeightInfo::on_initialize(counter) - } - - fn on_runtime_upgrade() -> Weight { - >::kill(); - - T::DbWeight::get().reads_writes(0, 1) } } --- a/pallets/common/CHANGELOG.md +++ b/pallets/common/CHANGELOG.md @@ -3,7 +3,12 @@ All notable changes to this project will be documented in this file. +## [0.1.14] - 2023-04-19 + +- ### Fixed +- Useless `on_runtime_upgrade()` has been removed + ## [0.1.14] - 2023-03-28 ### Added @@ -82,7 +87,7 @@ However, we don't use prefix removal limits, so upgrade is straightforward -Upstream-Change: https://github.com/paritytech/substrate/pull/11490 +Upstream-Change: - build: Upgrade polkadot to v0.9.25 cdfb9bdc7b205ff1b5134f034ef9973d769e5e6b --- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -420,10 +420,11 @@ #[frame_support::pallet] pub mod pallet { + use core::marker::PhantomData; + use super::*; use dispatch::CollectionDispatch; use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key, traits::StorageVersion}; - use frame_system::pallet_prelude::*; use frame_support::traits::Currency; use up_data_structs::{TokenId, mapping::TokenAddressMapping}; use scale_info::TypeInfo; @@ -479,6 +480,23 @@ } } + #[pallet::genesis_config] + pub struct GenesisConfig(PhantomData); + + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + Self(Default::default()) + } + } + + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) { + StorageVersion::new(1).put::>(); + } + } + impl Pallet { /// Helper function that handles deposit events pub fn deposit_event(event: Event) { @@ -869,15 +887,6 @@ ), QueryKind = OptionQuery, >; - - #[pallet::hooks] - impl Hooks> for Pallet { - fn on_runtime_upgrade() -> Weight { - StorageVersion::new(1).put::>(); - - Weight::zero() - } - } } impl Pallet { --- a/pallets/nonfungible/CHANGELOG.md +++ b/pallets/nonfungible/CHANGELOG.md @@ -3,7 +3,12 @@ All notable changes to this project will be documented in this file. +## [0.1.14] - 2023-04-19 + +- ### Fixed +- Useless `on_runtime_upgrade()` has been removed + ## [0.1.14] - 2023-03-28 ### Fixed @@ -83,7 +88,7 @@ However, we don't use prefix removal limits, so upgrade is straightforward -Upstream-Change: https://github.com/paritytech/substrate/pull/11490 +Upstream-Change: - build: Upgrade polkadot to v0.9.25 cdfb9bdc7b205ff1b5134f034ef9973d769e5e6b --- a/pallets/nonfungible/src/lib.rs +++ b/pallets/nonfungible/src/lib.rs @@ -283,13 +283,20 @@ QueryKind = ValueQuery, >; - /// Upgrade from the old schema to properties. - #[pallet::hooks] - impl Hooks> for Pallet { - fn on_runtime_upgrade() -> Weight { - StorageVersion::new(1).put::>(); + #[pallet::genesis_config] + pub struct GenesisConfig(PhantomData); - Weight::zero() + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + Self(Default::default()) + } + } + + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) { + StorageVersion::new(1).put::>(); } } } -- gitstuff