From ea1f7f8babea8d4fd46e185abb97bea4c3274443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 24 Apr 2020 11:47:59 +0200 Subject: [PATCH] Make sure staking migration code runs only for `version = 2_0_0` --- frame/staking/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 34b6a4f795833..d175c26e7aee5 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -1246,8 +1246,12 @@ decl_module! { fn on_runtime_upgrade() -> Weight { // For Kusama the type hasn't actually changed as Moment was u64 and was the number of // millisecond since unix epoch. - StorageVersion::put(Releases::V3_0_0); - Self::migrate_last_reward_to_claimed_rewards(); + StorageVersion::mutate(|v| { + if matches!(v, Releases::V2_0_0) { + Self::migrate_last_reward_to_claimed_rewards(); + } + *v = Releases::V3_0_0; + }); 0 }