From 1d4c28e69ca540513c13046ef727a27553fa6587 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Mon, 25 Nov 2024 18:18:20 +0800 Subject: [PATCH] Release `koi-6800` (#1629) * Bump storage version * Bump spec ver --- pallet/staking/src/lib.rs | 28 +++++++++++++++++++++++++--- runtime/koi/src/lib.rs | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/pallet/staking/src/lib.rs b/pallet/staking/src/lib.rs index 057f24adb..6c9451604 100644 --- a/pallet/staking/src/lib.rs +++ b/pallet/staking/src/lib.rs @@ -40,6 +40,20 @@ pub mod migration { where T: Config, { + let ver = StorageVersion::get::>(); + let (mut r, mut w) = (1, 0); + + if ver != 2 { + log::warn!( + "\ + [pallet::staking] skipping v2 to v3 migration: executed on wrong storage version.\ + Expected version 2, found {ver:?}\ + ", + ); + + return (r, w); + } + fn clear(item: &[u8], r: &mut u64, w: &mut u64) { let res = migration::clear_storage_prefix(PALLET, item, &[], None, None); @@ -47,8 +61,6 @@ pub mod migration { *w += res.backend as u64; } - let rw @ (mut r, mut w) = (1, 1); - clear(b"Collators", &mut r, &mut w); clear(b"Nominators", &mut r, &mut w); clear(b"ExposureCacheStates", &mut r, &mut w); @@ -69,9 +81,16 @@ pub mod migration { )>(PALLET, b"AuthoredBlocksCount", &[]) { >::put(abc); + + r += 1; + w += 1; } - rw + StorageVersion::new(3).put::>(); + + w += 1; + + (r, w) } pub fn post_check() @@ -138,6 +157,8 @@ pub mod pallet { // darwinia use crate::*; + const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); + #[pallet::config] pub trait Config: frame_system::Config { /// Override the [`frame_system::Config::RuntimeEvent`]. @@ -256,6 +277,7 @@ pub mod pallet { } #[pallet::pallet] + #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); #[pallet::hooks] impl Hooks> for Pallet { diff --git a/runtime/koi/src/lib.rs b/runtime/koi/src/lib.rs index bbb65b86c..ca564b848 100644 --- a/runtime/koi/src/lib.rs +++ b/runtime/koi/src/lib.rs @@ -80,7 +80,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { spec_name: sp_runtime::create_runtime_str!("Darwinia Koi"), impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), authoring_version: 0, - spec_version: 6_7_2_0, + spec_version: 6_8_0_0, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 0,