From 984ac1134afda2af30a7ce526fa27e597ce86fee Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Tue, 20 Jun 2023 13:37:27 +0200 Subject: [PATCH 01/33] fix society v2 migration --- frame/society/src/lib.rs | 4 ++-- frame/society/src/migrations.rs | 39 ++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 6f42ae00f287d..98967f7f12314 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -466,12 +466,12 @@ pub struct GroupParams { pub type GroupParamsFor = GroupParams>; +pub(crate) const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); + #[frame_support::pallet] pub mod pallet { use super::*; - const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); - #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] #[pallet::without_storage_info] diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index bd590f9b18770..6c3753759d09c 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -40,24 +40,32 @@ impl< { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { - ensure!(can_migrate::(), "pallet_society: already upgraded"); - - let current = Pallet::::current_storage_version(); - let onchain = Pallet::::on_chain_storage_version(); - ensure!(onchain == 0 && current == 2, "pallet_society: invalid version"); + log::info!(target: TARGET, "pre_upgrade"); + if !can_migrate::() { + log::warn!( + target: TARGET, + "Already migrated", + ); + } Ok((old::Candidates::::get(), old::Members::::get()).encode()) } fn on_runtime_upgrade() -> Weight { - let current = Pallet::::current_storage_version(); let onchain = Pallet::::on_chain_storage_version(); - if current == 2 && onchain == 0 { - from_original::(&mut PastPayouts::get()) - } else { + if onchain < 2 { log::info!( - "Running migration with current storage version {:?} / onchain {:?}", - current, + target: TARGET, + "Running migration against onchain version {:?}", + onchain + ); + let weight = from_original::(&mut PastPayouts::get()); + crate::STORAGE_VERSION.put::>(); + weight + } else { + log::warn!( + target: TARGET, + "Migration is a noop. onchain version: {:?}", onchain ); T::DbWeight::get().reads(1) @@ -86,7 +94,7 @@ impl< assert_eq!(members, old_members); ensure!( - Pallet::::on_chain_storage_version() == 2, + Pallet::::on_chain_storage_version() >= 2, "The onchain version must be updated after the migration." ); @@ -196,9 +204,10 @@ pub fn assert_internal_consistency, I: Instance + 'static>() { for (who, record) in members.iter() { assert_eq!(MemberByIndex::::get(record.index).as_ref(), Some(who)); } - if let Some(founder) = Founder::::get() { - assert_eq!(Members::::get(founder).expect("founder is member").index, 0); - } + // TODO: This panics if uncommented -- FIXME + // if let Some(founder) = Founder::::get() { + // assert_eq!(Members::::get(founder).expect("founder is member").index, 0); + // } if let Some(head) = Head::::get() { assert!(Members::::contains_key(head)); } From d67ae41f0e51aa2994bb32583f1a01eb0788bf63 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:15:48 +0200 Subject: [PATCH 02/33] Update frame/society/src/migrations.rs --- frame/society/src/migrations.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 6c3753759d09c..1744fb61f0712 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -42,10 +42,7 @@ impl< fn pre_upgrade() -> Result, TryRuntimeError> { log::info!(target: TARGET, "pre_upgrade"); if !can_migrate::() { - log::warn!( - target: TARGET, - "Already migrated", - ); + log::warn!(target: TARGET, "Already migrated"); } Ok((old::Candidates::::get(), old::Members::::get()).encode()) From 93cca301444b498a28637664554a22ca59ce9e93 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 22 Jun 2023 08:19:09 +1000 Subject: [PATCH 03/33] Update frame/society/src/migrations.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/society/src/migrations.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 1744fb61f0712..bb5ad57ee3507 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -40,7 +40,6 @@ impl< { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { - log::info!(target: TARGET, "pre_upgrade"); if !can_migrate::() { log::warn!(target: TARGET, "Already migrated"); } From e7b08e16dfdb2439e1a6157e0cf0ceb5d1b75c2b Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 22 Jun 2023 19:05:51 +1000 Subject: [PATCH 04/33] Update frame/society/src/migrations.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/society/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index bb5ad57ee3507..251f2e74dc3ee 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -41,7 +41,7 @@ impl< #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { if !can_migrate::() { - log::warn!(target: TARGET, "Already migrated"); + log::warn!(target: TARGET, "pallet_society::MigrateToV2: Already migrated"); } Ok((old::Candidates::::get(), old::Members::::get()).encode()) From 81725a29745ca7af2c6da4442c2d82c62f50e8d5 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Sun, 2 Jul 2023 14:19:06 +0200 Subject: [PATCH 05/33] update for versioned upgrade --- frame/society/src/migrations.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 251f2e74dc3ee..c13a11d075030 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -40,9 +40,11 @@ impl< { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { - if !can_migrate::() { - log::warn!(target: TARGET, "pallet_society::MigrateToV2: Already migrated"); - } + ensure!(can_migrate::(), "pallet_society: already upgraded"); + + let current = Pallet::::current_storage_version(); + let onchain = Pallet::::on_chain_storage_version(); + ensure!(onchain == 0 && current == 2, "pallet_society: invalid version"); Ok((old::Candidates::::get(), old::Members::::get()).encode()) } @@ -90,7 +92,7 @@ impl< assert_eq!(members, old_members); ensure!( - Pallet::::on_chain_storage_version() >= 2, + Pallet::::on_chain_storage_version() == 2, "The onchain version must be updated after the migration." ); From ab2aa97e595542edb98a267ea1824a847a9798c5 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Sun, 2 Jul 2023 23:54:19 +0200 Subject: [PATCH 06/33] fix society v2 migration --- frame/society/Cargo.toml | 2 +- frame/society/src/migrations.rs | 45 ++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/frame/society/Cargo.toml b/frame/society/Cargo.toml index 2ef5dfad78c6e..d416e3431f649 100644 --- a/frame/society/Cargo.toml +++ b/frame/society/Cargo.toml @@ -24,7 +24,7 @@ sp-io = { version = "23.0.0", default-features = false, path = "../../primitives sp-arithmetic = { version = "16.0.0", default-features = false, path = "../../primitives/arithmetic" } sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } -frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } +frame-support = { version = "4.0.0-dev", default-features = false, path = "../support", features=["experimental"] } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } [dev-dependencies] diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index c13a11d075030..61f841abebd14 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -19,7 +19,10 @@ use super::*; use codec::{Decode, Encode}; -use frame_support::traits::{Instance, OnRuntimeUpgrade}; +use frame_support::{ + migrations::VersionedRuntimeUpgrade, + traits::{Instance, OnRuntimeUpgrade}, +}; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; @@ -28,7 +31,7 @@ use sp_runtime::TryRuntimeError; const TARGET: &'static str = "runtime::society::migration"; /// This migration moves all the state to v2 of Society. -pub struct MigrateToV2, I: 'static, PastPayouts>( +pub struct VersionUncheckedMigrateToV2, I: 'static, PastPayouts>( sp_std::marker::PhantomData<(T, I, PastPayouts)>, ); @@ -36,7 +39,7 @@ impl< T: Config, I: Instance + 'static, PastPayouts: Get::AccountId, BalanceOf)>>, - > OnRuntimeUpgrade for MigrateToV2 + > OnRuntimeUpgrade for VersionUncheckedMigrateToV2 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { @@ -101,6 +104,14 @@ impl< } } +pub type VersionCheckedMigrateToV2 = VersionedRuntimeUpgrade< + 0, + 2, + VersionUncheckedMigrateToV2, + Pallet, + ::DbWeight, +>; + pub(crate) mod old { use super::*; use frame_support::storage_alias; @@ -202,10 +213,9 @@ pub fn assert_internal_consistency, I: Instance + 'static>() { for (who, record) in members.iter() { assert_eq!(MemberByIndex::::get(record.index).as_ref(), Some(who)); } - // TODO: This panics if uncommented -- FIXME - // if let Some(founder) = Founder::::get() { - // assert_eq!(Members::::get(founder).expect("founder is member").index, 0); - // } + if let Some(founder) = Founder::::get() { + assert_eq!(Members::::get(founder).expect("founder is member").index, 0); + } if let Some(head) = Head::::get() { assert!(Members::::contains_key(head)); } @@ -288,6 +298,27 @@ pub fn from_original, I: Instance + 'static>( let record = MemberRecord { index: member_count, rank: 0, strikes, vouching }; Members::::insert(&member, record); MemberByIndex::::insert(member_count, &member); + + // The founder must be the first member in Society V2. If we find the founder not in index + // zero, we swap it with the first member. + if member == Founder::::get().expect("founder is always set; qed") && member_count > 0 + { + let member_to_swap = MemberByIndex::::get(0) + .expect("member_count > 0, we must have at least 1 member; qed"); + // Swap the founder with the first member in MemberByIndex. + MemberByIndex::::swap(0, member_count); + // Update the indicies of the swapped member MemberRecords. + Members::::mutate(&member, |m| { + if let Some(member) = m { + member.index = 0; + } + }); + Members::::mutate(&member_to_swap, |m| { + if let Some(member) = m { + member.index = member_count; + } + }); + } member_count.saturating_inc(); } MemberCount::::put(member_count); From 61af5d9b4e44d05abc5b2f5e50d10f0a2e35c1d3 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 3 Jul 2023 10:59:04 +0200 Subject: [PATCH 07/33] remove references to members being sorted from commnets --- frame/society/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 98967f7f12314..1d3fd73aa09d8 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -1681,8 +1681,8 @@ impl, I: 'static> Pallet { bids.iter().any(|bid| bid.who == *who) } - /// Add a member to the sorted members list. If the user is already a member, do nothing. - /// Can fail when `MaxMember` limit is reached, but in that case it has no side-effects. + /// Add a member to the members list. If the user is already a member, do nothing. Can fail when + /// `MaxMember` limit is reached, but in that case it has no side-effects. /// /// Set the `payouts` for the member. NOTE: This *WILL NOT RESERVE THE FUNDS TO MAKE THE /// PAYOUT*. Only set this to be non-empty if you already have the funds reserved in the Payouts @@ -1703,7 +1703,7 @@ impl, I: 'static> Pallet { Ok(()) } - /// Add a member back to the sorted members list, setting their `rank` and `payouts`. + /// Add a member back to the members list, setting their `rank` and `payouts`. /// /// Can fail when `MaxMember` limit is reached, but in that case it has no side-effects. /// @@ -1713,8 +1713,8 @@ impl, I: 'static> Pallet { Self::insert_member(who, rank) } - /// Add a member to the sorted members list. If the user is already a member, do nothing. - /// Can fail when `MaxMember` limit is reached, but in that case it has no side-effects. + /// Add a member to the members list. If the user is already a member, do nothing. Can fail when + /// `MaxMember` limit is reached, but in that case it has no side-effects. fn add_new_member(who: &T::AccountId, rank: Rank) -> DispatchResult { Self::insert_member(who, rank) } From 46913c33fde001f5dc59ae753876caf01a51a6a6 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 3 Jul 2023 10:59:49 +0200 Subject: [PATCH 08/33] fix type --- frame/support/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index 889439907efd2..b73dcfa19c8af 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -78,7 +78,7 @@ pub struct VersionedRuntimeUpgrade), + MigrationExecuted(sp_std::vec::Vec), /// This migration is a noop, do not run post_upgrade checks. Noop, } From 8cce5906565c4bf6eb36313c62613b43a392010c Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 3 Jul 2023 13:26:32 +0200 Subject: [PATCH 09/33] fix can_migrate check --- frame/society/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 61f841abebd14..c99a05e538a4c 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -198,7 +198,7 @@ pub(crate) mod old { } pub fn can_migrate, I: Instance + 'static>() -> bool { - old::Members::::exists() + Members::::iter().next().is_none() } /// Will panic if there are any inconsistencies in the pallet's state or old keys remaining. From 88e08369dd85525a42476c4e693de1565ac2e67a Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 3 Jul 2023 15:45:45 +0200 Subject: [PATCH 10/33] add sanity log --- frame/society/src/migrations.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index c99a05e538a4c..f8fdbd1d94999 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -311,11 +311,15 @@ pub fn from_original, I: Instance + 'static>( Members::::mutate(&member, |m| { if let Some(member) = m { member.index = 0; + } else { + log::error!("Member somehow disapeared from storage after it was inserted") } }); Members::::mutate(&member_to_swap, |m| { if let Some(member) = m { member.index = member_count; + } else { + log::error!("Member somehow disapeared from storage after it was queried") } }); } From af97daafee878efd8b571bac52eabf04f93dcca3 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 3 Jul 2023 17:02:27 +0200 Subject: [PATCH 11/33] fix sanity check --- frame/society/src/migrations.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index f8fdbd1d94999..0931811ce9ac4 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -253,9 +253,9 @@ pub fn assert_internal_consistency, I: Instance + 'static>() { pub fn from_original, I: Instance + 'static>( past_payouts: &mut [(::AccountId, BalanceOf)], ) -> Weight { - // First check that this is the original state layout. This is easy since the original layout - // contained the Members value, and this value no longer exists in the new layout. - if !old::Members::::exists() { + // First check that this is the original state layout. This is easy since the new layout + // contains a new Members value, which did not exist in the old layout. + if Members::::iter().next().is_some() { log::warn!(target: TARGET, "Skipping MigrateToV2 migration since it appears unapplicable"); // Already migrated or no data to migrate: Bail. return T::DbWeight::get().reads(1) From 0b4abd893fa592988c07afc5900900c49ea929f1 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 3 Jul 2023 17:23:44 +0200 Subject: [PATCH 12/33] kick ci --- frame/society/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 0931811ce9ac4..83a5c3abc485e 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -257,7 +257,7 @@ pub fn from_original, I: Instance + 'static>( // contains a new Members value, which did not exist in the old layout. if Members::::iter().next().is_some() { log::warn!(target: TARGET, "Skipping MigrateToV2 migration since it appears unapplicable"); - // Already migrated or no data to migrate: Bail. + // Already migrated or no data to migrate: Bail . return T::DbWeight::get().reads(1) } From 400304c5e72493fefc93632d5c293e8b5458cb64 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 3 Jul 2023 17:23:53 +0200 Subject: [PATCH 13/33] kick ci --- frame/society/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 83a5c3abc485e..0931811ce9ac4 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -257,7 +257,7 @@ pub fn from_original, I: Instance + 'static>( // contains a new Members value, which did not exist in the old layout. if Members::::iter().next().is_some() { log::warn!(target: TARGET, "Skipping MigrateToV2 migration since it appears unapplicable"); - // Already migrated or no data to migrate: Bail . + // Already migrated or no data to migrate: Bail. return T::DbWeight::get().reads(1) } From afd9e9363160efe06a81193be226d238540313d1 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 3 Jul 2023 18:29:44 +0200 Subject: [PATCH 14/33] run tests with --experimental flag --- scripts/ci/gitlab/pipeline/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index 2e5495cb82a3e..dc41895b3a16e 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -155,21 +155,21 @@ node-bench-regression-guard: --compare-with artifacts/benches/$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA" after_script: [""] -cargo-check-try-runtime: +cargo-check-try-runtime-and-experimental: stage: test extends: - .docker-env - .test-refs script: - rusty-cachier snapshot create - - time cargo check --locked --features try-runtime + - time cargo check --locked --features try-runtime,experimental - rusty-cachier cache upload test-deterministic-wasm: stage: test # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs needs: - - job: cargo-check-try-runtime + - job: cargo-check-try-runtime-and-experimental artifacts: false extends: - .docker-env @@ -221,7 +221,7 @@ test-linux-stable: --locked --release --verbose - --features runtime-benchmarks,try-runtime + --features runtime-benchmarks,try-runtime,experimental --manifest-path ./bin/node/cli/Cargo.toml --partition count:${CI_NODE_INDEX}/${CI_NODE_TOTAL} # we need to update cache only from one job @@ -258,8 +258,8 @@ test-frame-support: script: - rusty-cachier snapshot create - cat /cargo_target_dir/debug/.fingerprint/memory_units-759eddf317490d2b/lib-memory_units.json || true - - time cargo test --verbose --locked -p frame-support-test --features=frame-feature-testing,no-metadata-docs,try-runtime --manifest-path ./frame/support/test/Cargo.toml - - time cargo test --verbose --locked -p frame-support-test --features=frame-feature-testing,frame-feature-testing-2,no-metadata-docs,try-runtime --manifest-path ./frame/support/test/Cargo.toml + - time cargo test --verbose --locked -p frame-support-test --features=frame-feature-testing,no-metadata-docs,try-runtime,experimental --manifest-path ./frame/support/test/Cargo.toml + - time cargo test --verbose --locked -p frame-support-test --features=frame-feature-testing,frame-feature-testing-2,no-metadata-docs,try-runtime,experimental --manifest-path ./frame/support/test/Cargo.toml - SUBSTRATE_TEST_TIMEOUT=1 time cargo test -p substrate-test-utils --release --verbose --locked -- --ignored timeout - cat /cargo_target_dir/debug/.fingerprint/memory_units-759eddf317490d2b/lib-memory_units.json || true - rusty-cachier cache upload From e1f3c010f68c340bf69ba4f5e49d64d141aa34e7 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Tue, 4 Jul 2023 16:06:21 +0200 Subject: [PATCH 15/33] versioned migration cleanup --- frame/society/src/migrations.rs | 10 +++++----- frame/support/src/migrations.rs | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 0931811ce9ac4..1ea408740cf79 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -104,12 +104,12 @@ impl< } } -pub type VersionCheckedMigrateToV2 = VersionedRuntimeUpgrade< +pub type VersionCheckedMigrateToV2 = VersionedRuntimeUpgrade< 0, 2, - VersionUncheckedMigrateToV2, - Pallet, - ::DbWeight, + VersionUncheckedMigrateToV2, + crate::pallet::Pallet, + ::DbWeight, >; pub(crate) mod old { @@ -255,7 +255,7 @@ pub fn from_original, I: Instance + 'static>( ) -> Weight { // First check that this is the original state layout. This is easy since the new layout // contains a new Members value, which did not exist in the old layout. - if Members::::iter().next().is_some() { + if !can_migrate::() { log::warn!(target: TARGET, "Skipping MigrateToV2 migration since it appears unapplicable"); // Already migrated or no data to migrate: Bail. return T::DbWeight::get().reads(1) diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index b73dcfa19c8af..e59700be6dd84 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -24,12 +24,6 @@ use sp_core::Get; use sp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult}; use sp_std::marker::PhantomData; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; - -#[cfg(feature = "experimental")] -use crate::traits::OnRuntimeUpgrade; - /// Make it easier to write versioned runtime upgrades. /// /// [`VersionedRuntimeUpgrade`] allows developers to write migrations without worrying about @@ -57,13 +51,19 @@ use crate::traits::OnRuntimeUpgrade; /// // OnRuntimeUpgrade implementation... /// } /// -/// pub type VersionCheckedMigrateV5ToV6 = -/// VersionedRuntimeUpgrade<5, 6, VersionUncheckedMigrateV5ToV6, Pallet, DbWeight>; +/// pub type VersionCheckedMigrateV5ToV6 = +/// VersionedRuntimeUpgrade< +/// 5, +/// 6, +/// VersionUncheckedMigrateV5ToV6, +/// crate::pallet::Pallet, +/// ::DbWeight +/// >; /// /// // Migrations tuple to pass to the Executive pallet: /// pub type Migrations = ( /// // other migrations... -/// VersionCheckedMigrateV5ToV6, +/// VersionCheckedMigrateV5ToV6, /// // other migrations... /// ); /// ``` @@ -93,16 +93,16 @@ pub enum VersionedPostUpgradeData { impl< const FROM: u16, const TO: u16, - Inner: OnRuntimeUpgrade, + Inner: crate::traits::OnRuntimeUpgrade, Pallet: GetStorageVersion + PalletInfoAccess, DbWeight: Get, - > OnRuntimeUpgrade for VersionedRuntimeUpgrade + > crate::traits::OnRuntimeUpgrade for VersionedRuntimeUpgrade { /// Executes pre_upgrade if the migration will run, and wraps the pre_upgrade bytes in /// [`VersionedPostUpgradeData`] before passing them to post_upgrade, so it knows whether the /// migration ran or not. #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { use codec::Encode; let on_chain_version = Pallet::on_chain_storage_version(); if on_chain_version == FROM { @@ -152,7 +152,7 @@ impl< /// the migration ran, and [`VersionedPostUpgradeData::Noop`] otherwise. #[cfg(feature = "try-runtime")] fn post_upgrade( - versioned_post_upgrade_data_bytes: Vec, + versioned_post_upgrade_data_bytes: sp_std::vec::Vec, ) -> Result<(), sp_runtime::TryRuntimeError> { use codec::DecodeAll; match ::decode_all(&mut &versioned_post_upgrade_data_bytes[..]) @@ -321,7 +321,7 @@ impl, DbWeight: Get> frame_support::traits } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { use crate::storage::unhashed::contains_prefixed_key; let hashed_prefix = twox_128(P::get().as_bytes()); @@ -332,11 +332,11 @@ impl, DbWeight: Get> frame_support::traits P::get() ), }; - Ok(Vec::new()) + Ok(sp_std::vec::Vec::new()) } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + fn post_upgrade(_state: sp_std::vec::Vec) -> Result<(), sp_runtime::TryRuntimeError> { use crate::storage::unhashed::contains_prefixed_key; let hashed_prefix = twox_128(P::get().as_bytes()); From 568440bc0bc9ae9b6ff036dfd77a4d4bd7d4d10a Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Tue, 4 Jul 2023 16:14:32 +0200 Subject: [PATCH 16/33] revert pipeline change --- scripts/ci/gitlab/pipeline/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index dc41895b3a16e..2e5495cb82a3e 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -155,21 +155,21 @@ node-bench-regression-guard: --compare-with artifacts/benches/$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA" after_script: [""] -cargo-check-try-runtime-and-experimental: +cargo-check-try-runtime: stage: test extends: - .docker-env - .test-refs script: - rusty-cachier snapshot create - - time cargo check --locked --features try-runtime,experimental + - time cargo check --locked --features try-runtime - rusty-cachier cache upload test-deterministic-wasm: stage: test # this is an artificial job dependency, for pipeline optimization using GitLab's DAGs needs: - - job: cargo-check-try-runtime-and-experimental + - job: cargo-check-try-runtime artifacts: false extends: - .docker-env @@ -221,7 +221,7 @@ test-linux-stable: --locked --release --verbose - --features runtime-benchmarks,try-runtime,experimental + --features runtime-benchmarks,try-runtime --manifest-path ./bin/node/cli/Cargo.toml --partition count:${CI_NODE_INDEX}/${CI_NODE_TOTAL} # we need to update cache only from one job @@ -258,8 +258,8 @@ test-frame-support: script: - rusty-cachier snapshot create - cat /cargo_target_dir/debug/.fingerprint/memory_units-759eddf317490d2b/lib-memory_units.json || true - - time cargo test --verbose --locked -p frame-support-test --features=frame-feature-testing,no-metadata-docs,try-runtime,experimental --manifest-path ./frame/support/test/Cargo.toml - - time cargo test --verbose --locked -p frame-support-test --features=frame-feature-testing,frame-feature-testing-2,no-metadata-docs,try-runtime,experimental --manifest-path ./frame/support/test/Cargo.toml + - time cargo test --verbose --locked -p frame-support-test --features=frame-feature-testing,no-metadata-docs,try-runtime --manifest-path ./frame/support/test/Cargo.toml + - time cargo test --verbose --locked -p frame-support-test --features=frame-feature-testing,frame-feature-testing-2,no-metadata-docs,try-runtime --manifest-path ./frame/support/test/Cargo.toml - SUBSTRATE_TEST_TIMEOUT=1 time cargo test -p substrate-test-utils --release --verbose --locked -- --ignored timeout - cat /cargo_target_dir/debug/.fingerprint/memory_units-759eddf317490d2b/lib-memory_units.json || true - rusty-cachier cache upload From 2897ad5f0f095061fb15004269de0967f174694f Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Tue, 4 Jul 2023 19:13:34 +0200 Subject: [PATCH 17/33] use defensive! --- frame/society/src/migrations.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 1ea408740cf79..b29beffb3c455 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -312,14 +312,18 @@ pub fn from_original, I: Instance + 'static>( if let Some(member) = m { member.index = 0; } else { - log::error!("Member somehow disapeared from storage after it was inserted") + frame_support::defensive!( + "Member somehow disapeared from storage after it was inserted" + ) } }); Members::::mutate(&member_to_swap, |m| { if let Some(member) = m { member.index = member_count; } else { - log::error!("Member somehow disapeared from storage after it was queried") + frame_support::defensive!( + "Member somehow disapeared from storage after it was queried" + ) } }); } From 039d3e12cb24cdaef016d1d05198c188ca4e3e39 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 5 Jul 2023 02:27:31 +0200 Subject: [PATCH 18/33] semicolons --- frame/society/src/migrations.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index b29beffb3c455..32b449257dd72 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -314,7 +314,7 @@ pub fn from_original, I: Instance + 'static>( } else { frame_support::defensive!( "Member somehow disapeared from storage after it was inserted" - ) + ); } }); Members::::mutate(&member_to_swap, |m| { @@ -323,7 +323,7 @@ pub fn from_original, I: Instance + 'static>( } else { frame_support::defensive!( "Member somehow disapeared from storage after it was queried" - ) + ); } }); } From f17bf46a2c7ad1153be9bda372b6353db41f0a27 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 6 Jul 2023 16:06:31 +0200 Subject: [PATCH 19/33] defensive and doc comment --- frame/society/src/migrations.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 32b449257dd72..c424d2a01eb4f 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -20,8 +20,9 @@ use super::*; use codec::{Decode, Encode}; use frame_support::{ + defensive, migrations::VersionedRuntimeUpgrade, - traits::{Instance, OnRuntimeUpgrade}, + traits::{DefensiveOption, Instance, OnRuntimeUpgrade}, }; #[cfg(feature = "try-runtime")] @@ -60,9 +61,16 @@ impl< "Running migration against onchain version {:?}", onchain ); - let weight = from_original::(&mut PastPayouts::get()); - crate::STORAGE_VERSION.put::>(); - weight + match from_original::(&mut PastPayouts::get()) { + Ok(weight) => { + crate::STORAGE_VERSION.put::>(); + weight + }, + Err(msg) => { + defensive!(msg); + T::DbWeight::get().reads(1) + }, + } } else { log::warn!( target: TARGET, @@ -104,6 +112,8 @@ impl< } } +/// [`VersionUncheckedMigrateToV2`] wrapped in [`VersionedRuntimeUpgrade`], ensuring the migration +/// is only performed when required. pub type VersionCheckedMigrateToV2 = VersionedRuntimeUpgrade< 0, 2, @@ -252,13 +262,13 @@ pub fn assert_internal_consistency, I: Instance + 'static>() { pub fn from_original, I: Instance + 'static>( past_payouts: &mut [(::AccountId, BalanceOf)], -) -> Weight { +) -> Result { // First check that this is the original state layout. This is easy since the new layout // contains a new Members value, which did not exist in the old layout. if !can_migrate::() { log::warn!(target: TARGET, "Skipping MigrateToV2 migration since it appears unapplicable"); // Already migrated or no data to migrate: Bail. - return T::DbWeight::get().reads(1) + return Ok(T::DbWeight::get().reads(1)) } // Migrate Bids from old::Bids (just a trunctation). @@ -301,10 +311,11 @@ pub fn from_original, I: Instance + 'static>( // The founder must be the first member in Society V2. If we find the founder not in index // zero, we swap it with the first member. - if member == Founder::::get().expect("founder is always set; qed") && member_count > 0 + if member == Founder::::get().defensive_ok_or("founder must always be set")? && + member_count > 0 { let member_to_swap = MemberByIndex::::get(0) - .expect("member_count > 0, we must have at least 1 member; qed"); + .defensive_ok_or("member_count > 0, we must have at least 1 member")?; // Swap the founder with the first member in MemberByIndex. MemberByIndex::::swap(0, member_count); // Update the indicies of the swapped member MemberRecords. @@ -363,7 +374,7 @@ pub fn from_original, I: Instance + 'static>( old::Defender::::kill(); let _ = old::DefenderVotes::::clear(u32::MAX, None); - T::BlockWeights::get().max_block + Ok(T::BlockWeights::get().max_block) } pub fn from_raw_past_payouts, I: Instance + 'static>( From b07294acacc5bc155eaca8d51d3ec884459e0850 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 6 Jul 2023 16:13:02 +0200 Subject: [PATCH 20/33] address pr comment --- frame/society/src/migrations.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index c424d2a01eb4f..91f0eacd74927 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -72,11 +72,7 @@ impl< }, } } else { - log::warn!( - target: TARGET, - "Migration is a noop. onchain version: {:?}", - onchain - ); + defensive!("Unexpected onchain version: {:?}. Expected 0."); T::DbWeight::get().reads(1) } } From a769e385b5fdedd8d2add26a5b7e035ad4765617 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 6 Jul 2023 16:21:46 +0200 Subject: [PATCH 21/33] feature gate the versioned migration --- frame/society/Cargo.toml | 5 ++++- frame/society/src/migrations.rs | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/frame/society/Cargo.toml b/frame/society/Cargo.toml index d416e3431f649..073c1363ee70a 100644 --- a/frame/society/Cargo.toml +++ b/frame/society/Cargo.toml @@ -24,7 +24,7 @@ sp-io = { version = "23.0.0", default-features = false, path = "../../primitives sp-arithmetic = { version = "16.0.0", default-features = false, path = "../../primitives/arithmetic" } sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } -frame-support = { version = "4.0.0-dev", default-features = false, path = "../support", features=["experimental"] } +frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } [dev-dependencies] @@ -35,6 +35,9 @@ sp-io = { version = "23.0.0", path = "../../primitives/io" } [features] default = ["std"] +experimental = [ + "frame-support/experimental" +] std = [ "codec/std", "frame-benchmarking?/std", diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 91f0eacd74927..59195d6190b34 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -21,7 +21,6 @@ use super::*; use codec::{Decode, Encode}; use frame_support::{ defensive, - migrations::VersionedRuntimeUpgrade, traits::{DefensiveOption, Instance, OnRuntimeUpgrade}, }; @@ -109,14 +108,16 @@ impl< } /// [`VersionUncheckedMigrateToV2`] wrapped in [`VersionedRuntimeUpgrade`], ensuring the migration -/// is only performed when required. -pub type VersionCheckedMigrateToV2 = VersionedRuntimeUpgrade< - 0, - 2, - VersionUncheckedMigrateToV2, - crate::pallet::Pallet, - ::DbWeight, ->; +/// is only performed when on-chain version is 0. +#[cfg(feature = "experimental")] +pub type VersionCheckedMigrateToV2 = + frame_support::migrations::VersionedRuntimeUpgrade< + 0, + 2, + VersionUncheckedMigrateToV2, + crate::pallet::Pallet, + ::DbWeight, + >; pub(crate) mod old { use super::*; From b039f09a9f1d6702fd199bcb7f220592d024c97b Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 6 Jul 2023 16:32:01 +0200 Subject: [PATCH 22/33] defensive_unwrap_or --- frame/society/src/migrations.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 59195d6190b34..0a4cc677b93ee 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -21,7 +21,7 @@ use super::*; use codec::{Decode, Encode}; use frame_support::{ defensive, - traits::{DefensiveOption, Instance, OnRuntimeUpgrade}, + traits::{Defensive, DefensiveOption, Instance, OnRuntimeUpgrade}, }; #[cfg(feature = "try-runtime")] @@ -60,16 +60,7 @@ impl< "Running migration against onchain version {:?}", onchain ); - match from_original::(&mut PastPayouts::get()) { - Ok(weight) => { - crate::STORAGE_VERSION.put::>(); - weight - }, - Err(msg) => { - defensive!(msg); - T::DbWeight::get().reads(1) - }, - } + from_original::(&mut PastPayouts::get()).defensive_unwrap_or(Weight::MAX) } else { defensive!("Unexpected onchain version: {:?}. Expected 0."); T::DbWeight::get().reads(1) From f344dcbe961fd7154186a7b83d772c5bc6954c71 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 6 Jul 2023 16:47:16 +0200 Subject: [PATCH 23/33] fix test --- frame/society/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/society/src/tests.rs b/frame/society/src/tests.rs index 4a90ad52112d8..ea2afef3b32b5 100644 --- a/frame/society/src/tests.rs +++ b/frame/society/src/tests.rs @@ -77,7 +77,7 @@ fn migration_works() { .collect::>(); old::Bids::::put(bids); - migrations::from_original::(&mut [][..]); + migrations::from_original::(&mut [][..]).expect("migration failed"); migrations::assert_internal_consistency::(); assert_eq!( From 93d7ae42927e7cb9357792ce25f54c6df949e833 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 6 Jul 2023 17:23:13 +0200 Subject: [PATCH 24/33] fix doc comment --- frame/society/src/migrations.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 0a4cc677b93ee..46cc910d1ed31 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -98,8 +98,9 @@ impl< } } -/// [`VersionUncheckedMigrateToV2`] wrapped in [`VersionedRuntimeUpgrade`], ensuring the migration -/// is only performed when on-chain version is 0. +/// [`VersionUncheckedMigrateToV2`] wrapped in a +/// [`frame_support::migrations::VersionedRuntimeUpgrade`], ensuring the migration is only performed +/// when on-chain version is 0. #[cfg(feature = "experimental")] pub type VersionCheckedMigrateToV2 = frame_support::migrations::VersionedRuntimeUpgrade< From 803d114825994ad2e111b93b7c2f337bca9a66f5 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Thu, 6 Jul 2023 17:45:40 +0200 Subject: [PATCH 25/33] change defensive to a log warning --- frame/society/src/migrations.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 46cc910d1ed31..b4f48e507b49d 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -19,10 +19,7 @@ use super::*; use codec::{Decode, Encode}; -use frame_support::{ - defensive, - traits::{Defensive, DefensiveOption, Instance, OnRuntimeUpgrade}, -}; +use frame_support::traits::{Defensive, DefensiveOption, Instance, OnRuntimeUpgrade}; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; @@ -62,7 +59,7 @@ impl< ); from_original::(&mut PastPayouts::get()).defensive_unwrap_or(Weight::MAX) } else { - defensive!("Unexpected onchain version: {:?}. Expected 0."); + log::warn!("Unexpected onchain version: {:?} (expected 0)", onchain); T::DbWeight::get().reads(1) } } From e1c25999bb2ddf8a0c1b18af063ce94ca973ed6a Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Fri, 7 Jul 2023 12:01:07 +0400 Subject: [PATCH 26/33] remove can_migrate anti-pattern --- frame/society/src/migrations.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index b4f48e507b49d..404b1e5fd2cb9 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -40,8 +40,6 @@ impl< { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { - ensure!(can_migrate::(), "pallet_society: already upgraded"); - let current = Pallet::::current_storage_version(); let onchain = Pallet::::on_chain_storage_version(); ensure!(onchain == 0 && current == 2, "pallet_society: invalid version"); @@ -193,10 +191,6 @@ pub(crate) mod old { StorageMap, Twox64Concat, ::AccountId, Vote>; } -pub fn can_migrate, I: Instance + 'static>() -> bool { - Members::::iter().next().is_none() -} - /// Will panic if there are any inconsistencies in the pallet's state or old keys remaining. pub fn assert_internal_consistency, I: Instance + 'static>() { // Check all members are valid data. @@ -249,14 +243,6 @@ pub fn assert_internal_consistency, I: Instance + 'static>() { pub fn from_original, I: Instance + 'static>( past_payouts: &mut [(::AccountId, BalanceOf)], ) -> Result { - // First check that this is the original state layout. This is easy since the new layout - // contains a new Members value, which did not exist in the old layout. - if !can_migrate::() { - log::warn!(target: TARGET, "Skipping MigrateToV2 migration since it appears unapplicable"); - // Already migrated or no data to migrate: Bail. - return Ok(T::DbWeight::get().reads(1)) - } - // Migrate Bids from old::Bids (just a trunctation). Bids::::put(BoundedVec::<_, T::MaxBids>::truncate_from(old::Bids::::take())); From 1f9e5febc1f481afa6e822350836bc2ae0253bfb Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Sat, 8 Jul 2023 01:37:42 +1000 Subject: [PATCH 27/33] Update frame/society/Cargo.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/society/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/society/Cargo.toml b/frame/society/Cargo.toml index 073c1363ee70a..7f3e55e339fe0 100644 --- a/frame/society/Cargo.toml +++ b/frame/society/Cargo.toml @@ -35,6 +35,7 @@ sp-io = { version = "23.0.0", path = "../../primitives/io" } [features] default = ["std"] +# Enable `VersionedRuntimeUpgrade` for the migrations that is currently still experimental. experimental = [ "frame-support/experimental" ] From 87b3ee1d7dbf474a7c9cfa99d9e0efeaad477ce4 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Tue, 11 Jul 2023 10:36:09 +0800 Subject: [PATCH 28/33] add experimental feature warning to doc comment --- frame/support/src/migrations.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index e59700be6dd84..6e82ad86f0aea 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -24,6 +24,9 @@ use sp_core::Get; use sp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult}; use sp_std::marker::PhantomData; +/// EXPERIMENTAL FEATURE WARNING: This feature is experimental and its API should be considered +/// unstable. +/// /// Make it easier to write versioned runtime upgrades. /// /// [`VersionedRuntimeUpgrade`] allows developers to write migrations without worrying about From 28c36cc0430d41f8ce23f4c28f163e9c67310edb Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 12 Jul 2023 21:25:50 +0700 Subject: [PATCH 29/33] update doc comment --- frame/support/src/migrations.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index 6e82ad86f0aea..9ba22d3e15404 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -24,8 +24,7 @@ use sp_core::Get; use sp_io::{hashing::twox_128, storage::clear_prefix, KillStorageResult}; use sp_std::marker::PhantomData; -/// EXPERIMENTAL FEATURE WARNING: This feature is experimental and its API should be considered -/// unstable. +/// EXPERIMENTAL: The API of this feature may change. /// /// Make it easier to write versioned runtime upgrades. /// From 346190029730c86865861b2b06f26962b0c143be Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 12 Jul 2023 22:01:01 +0700 Subject: [PATCH 30/33] bump ci --- frame/support/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index 9ba22d3e15404..25182be637fee 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -26,7 +26,7 @@ use sp_std::marker::PhantomData; /// EXPERIMENTAL: The API of this feature may change. /// -/// Make it easier to write versioned runtime upgrades. +/// Make it easier to write versioned runtime upgrades . /// /// [`VersionedRuntimeUpgrade`] allows developers to write migrations without worrying about /// checking and setting storage versions. Instead, the developer wraps their migration in this From 5b6b1a1af5ed5add58876556b87e0cc50d38b881 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 12 Jul 2023 22:01:14 +0700 Subject: [PATCH 31/33] kick ci --- frame/support/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/migrations.rs b/frame/support/src/migrations.rs index 25182be637fee..9ba22d3e15404 100644 --- a/frame/support/src/migrations.rs +++ b/frame/support/src/migrations.rs @@ -26,7 +26,7 @@ use sp_std::marker::PhantomData; /// EXPERIMENTAL: The API of this feature may change. /// -/// Make it easier to write versioned runtime upgrades . +/// Make it easier to write versioned runtime upgrades. /// /// [`VersionedRuntimeUpgrade`] allows developers to write migrations without worrying about /// checking and setting storage versions. Instead, the developer wraps their migration in this From b0f08e0e57c296f3ae26f1855978902250569bbb Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 12 Jul 2023 22:45:29 +0700 Subject: [PATCH 32/33] kick ci --- frame/society/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 404b1e5fd2cb9..5e036c18ac886 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -95,7 +95,7 @@ impl< /// [`VersionUncheckedMigrateToV2`] wrapped in a /// [`frame_support::migrations::VersionedRuntimeUpgrade`], ensuring the migration is only performed -/// when on-chain version is 0. +/// when on-chain version is 0 . #[cfg(feature = "experimental")] pub type VersionCheckedMigrateToV2 = frame_support::migrations::VersionedRuntimeUpgrade< From 20083ca8d46bef1ae70e67af278108f8b825e346 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Wed, 12 Jul 2023 22:45:42 +0700 Subject: [PATCH 33/33] kick ci --- frame/society/src/migrations.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/society/src/migrations.rs b/frame/society/src/migrations.rs index 5e036c18ac886..404b1e5fd2cb9 100644 --- a/frame/society/src/migrations.rs +++ b/frame/society/src/migrations.rs @@ -95,7 +95,7 @@ impl< /// [`VersionUncheckedMigrateToV2`] wrapped in a /// [`frame_support::migrations::VersionedRuntimeUpgrade`], ensuring the migration is only performed -/// when on-chain version is 0 . +/// when on-chain version is 0. #[cfg(feature = "experimental")] pub type VersionCheckedMigrateToV2 = frame_support::migrations::VersionedRuntimeUpgrade<