From e93b7af003ffbce1a04c804ce2a5009e32e74572 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Tue, 2 Apr 2024 21:09:17 +0800 Subject: [PATCH] Release `pango-6611` (#1467) * Release `pango-6611` * Fix migration --- runtime/crab/src/migration.rs | 22 ++++++++++++++++++++-- runtime/darwinia/src/migration.rs | 22 ++++++++++++++++++++-- runtime/pangolin/src/lib.rs | 2 +- runtime/pangolin/src/migration.rs | 22 ++++++++++++++++++++-- 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/runtime/crab/src/migration.rs b/runtime/crab/src/migration.rs index 59dc369f0..d30cb86e1 100644 --- a/runtime/crab/src/migration.rs +++ b/runtime/crab/src/migration.rs @@ -27,16 +27,28 @@ pub struct CustomOnRuntimeUpgrade; impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::DispatchError> { + log::info!("pre"); + assert!(Balances::free_balance(ROOT) != 0); + >::iter().for_each(|(k, v)| { + log::info!("{k:?}"); + log::info!("{v:?}"); + }); + Ok(Vec::new()) } #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::DispatchError> { + log::info!("post"); + assert!(Balances::free_balance(ROOT) == 0); - >::iter_values().for_each(|v| { + >::iter().for_each(|(k, v)| { + log::info!("{k:?}"); + log::info!("{v:?}"); + assert!(!v.is_empty()); }); @@ -87,7 +99,13 @@ fn migrate() -> frame_support::weights::Weight { }); if changed { - >::insert(k, v); + if v.is_empty() { + // Clear the storage entry if the vector is empty. + + >::remove(k); + } else { + >::insert(k, v); + } w += 1; } diff --git a/runtime/darwinia/src/migration.rs b/runtime/darwinia/src/migration.rs index 494f838de..a1d82a14d 100644 --- a/runtime/darwinia/src/migration.rs +++ b/runtime/darwinia/src/migration.rs @@ -27,16 +27,28 @@ pub struct CustomOnRuntimeUpgrade; impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::DispatchError> { + log::info!("pre"); + assert!(migration::have_storage_value(b"EcdsaAuthority", b"Authorities", &[])); + >::iter().for_each(|(k, v)| { + log::info!("{k:?}"); + log::info!("{v:?}"); + }); + Ok(Vec::new()) } #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::DispatchError> { + log::info!("post"); + assert!(!migration::have_storage_value(b"EcdsaAuthority", b"Authorities", &[])); - >::iter_values().for_each(|v| { + >::iter().for_each(|(k, v)| { + log::info!("{k:?}"); + log::info!("{v:?}"); + assert!(!v.is_empty()); }); @@ -86,7 +98,13 @@ fn migrate() -> frame_support::weights::Weight { }); if changed { - >::insert(k, v); + if v.is_empty() { + // Clear the storage entry if the vector is empty. + + >::remove(k); + } else { + >::insert(k, v); + } w += 1; } diff --git a/runtime/pangolin/src/lib.rs b/runtime/pangolin/src/lib.rs index 5e95e43f2..3cf424bb8 100644 --- a/runtime/pangolin/src/lib.rs +++ b/runtime/pangolin/src/lib.rs @@ -75,7 +75,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { spec_name: sp_runtime::create_runtime_str!("Pangolin2"), impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), authoring_version: 0, - spec_version: 6_6_1_0, + spec_version: 6_6_1_1, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 0, diff --git a/runtime/pangolin/src/migration.rs b/runtime/pangolin/src/migration.rs index 8ed409989..786f2f1d8 100644 --- a/runtime/pangolin/src/migration.rs +++ b/runtime/pangolin/src/migration.rs @@ -27,12 +27,24 @@ pub struct CustomOnRuntimeUpgrade; impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::DispatchError> { + log::info!("pre"); + + >::iter().for_each(|(k, v)| { + log::info!("{k:?}"); + log::info!("{v:?}"); + }); + Ok(Vec::new()) } #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::DispatchError> { - >::iter_values().for_each(|v| { + log::info!("post"); + + >::iter().for_each(|(k, v)| { + log::info!("{k:?}"); + log::info!("{v:?}"); + assert!(!v.is_empty()); }); @@ -82,7 +94,13 @@ fn migrate() -> frame_support::weights::Weight { }); if changed { - >::insert(k, v); + if v.is_empty() { + // Clear the storage entry if the vector is empty. + + >::remove(k); + } else { + >::insert(k, v); + } w += 1; }