diff --git a/pallets/fellowship/src/migration.rs b/pallets/fellowship/src/migration.rs index 10fcc478..5b725130 100644 --- a/pallets/fellowship/src/migration.rs +++ b/pallets/fellowship/src/migration.rs @@ -103,6 +103,7 @@ pub mod v0 { weight = weight.saturating_add(T::DbWeight::get().reads_writes(2, 1)); } else { log::warn!("Skipping v1, should be removed from Executive"); + log::warn!("on_chain = {:?}, current = {:?}", onchain, current); weight = weight.saturating_add(T::DbWeight::get().reads(1)); } diff --git a/pallets/proposals/src/lib.rs b/pallets/proposals/src/lib.rs index 3d25cb29..057e3f01 100644 --- a/pallets/proposals/src/lib.rs +++ b/pallets/proposals/src/lib.rs @@ -132,7 +132,7 @@ pub mod pallet { type AssetSignerOrigin: EnsureOrigin; } - const STORAGE_VERSION: StorageVersion = StorageVersion::new(6); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(7); #[pallet::pallet] #[pallet::storage_version(STORAGE_VERSION)] diff --git a/pallets/proposals/src/migration.rs b/pallets/proposals/src/migration.rs index 1e04bb71..67b69b6b 100644 --- a/pallets/proposals/src/migration.rs +++ b/pallets/proposals/src/migration.rs @@ -736,7 +736,8 @@ pub mod v7 { let onchain = as GetStorageVersion>::on_chain_storage_version(); ensure!( - ::MaxJuryMembers::get() < u8::MAX as u32, + + <::JurySelector as SelectJury>>::JurySize::get() < u8::MAX as u32, "Max jury members must be smaller than u8" ); @@ -767,9 +768,15 @@ pub mod v7 { weight } + + #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { log::warn!( target: "pallet-proposals", "Running post_upgrade()"); + Projects::::iter().for_each(|(_k, project)|{ + + assert!(project.jury.len() > 0, "jury size must be > 0"); + }); ensure!( Pallet::::current_storage_version() == 7, @@ -793,8 +800,6 @@ pub mod v7 { v5::FundingType::Grant(_) => crate::FundingPath::WaitForFunding, }; - let jury = >>::select_jury(); - let refund_locations: BoundedVec<(Locality>, Percent), T::MaximumContributorsPerProject> = match project.funding_type { v5::FundingType::Proposal => crate::Pallet::::convert_contributions_to_refund_locations(&project.contributions), v5::FundingType::Brief => crate::Pallet::::convert_contributions_to_refund_locations(&project.contributions), @@ -812,6 +817,12 @@ pub mod v7 { }, }; + let jury = match project.funding_type { + v5::FundingType::Grant(_) => project.contributions.keys().cloned().collect::>>(), + v5::FundingType::Brief => >>::select_jury().to_vec(), + _ => >>::select_jury().to_vec(), + }; + let mut new_milestones: BoundedBTreeMilestones = BoundedBTreeMap::new(); project.milestones.iter().for_each(|(_ms_key, ms): (&MilestoneKey, &v6::V6Milestone)| { // assume that if its approved then its been withdrawn. @@ -844,7 +855,7 @@ pub mod v7 { cancelled: project.cancelled, deposit_id: project.deposit_id, refund_locations, - jury, + jury: jury.try_into().expect("contributions bound is larger than jury bound, reduce contribution bound or increase jury bound."), on_creation_funding, refunded_funds: Zero::zero(), }; diff --git a/runtime/imbue-kusama/src/lib.rs b/runtime/imbue-kusama/src/lib.rs index 7d202698..e03f2785 100644 --- a/runtime/imbue-kusama/src/lib.rs +++ b/runtime/imbue-kusama/src/lib.rs @@ -181,12 +181,13 @@ pub mod migrations { use super::*; /// Unreleased migrations. Add new ones here: pub type Unreleased = ( - pallet_proposals::migration::v7::MigrateToV7, + pallet_fellowship::migration::v0::MigrateInitial, pallet_balances::migration::MigrateToTrackInactive, pallet_collator_selection::migration::v1::MigrateToV1, pallet_xcm::migration::v1::VersionUncheckedMigrateToV1, - pallet_fellowship::migration::v0::MigrateInitial, orml_unknown_tokens::Migration, + // PROPOSALS MIGRATION MUST BE RUN AFTER FELLOWSHIP MIGRATION + pallet_proposals::migration::v7::MigrateToV7, ); }