diff --git a/polkadot-parachains/integritee-runtime/src/lib.rs b/polkadot-parachains/integritee-runtime/src/lib.rs index c0470054..ea6b6a03 100644 --- a/polkadot-parachains/integritee-runtime/src/lib.rs +++ b/polkadot-parachains/integritee-runtime/src/lib.rs @@ -25,8 +25,9 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use codec::{Decode, Encode, MaxEncodedLen}; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -use frame_support::traits::{ - ConstBool, EqualPrivilegeOnly, Imbalance, InstanceFilter, OnUnbalanced, +use frame_support::{ + instances::{Instance1, Instance2}, + traits::{ConstBool, EqualPrivilegeOnly, Imbalance, InstanceFilter, OnUnbalanced}, }; pub use opaque::*; use pallet_collective; @@ -825,6 +826,14 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic, migrations_fix::bounties::v4::MigrateToV4, + // Multisig + pallet_multisig::migrations::v1::MigrateToV1, + // Collective + // migration changes the pallet name prefix (back in 2021). no need to touch this. I guess this has been left untouched when we migrated solo to para + // for consistency, we will bruteforce to V4 + // future: v1.6.0 is still at V4. + migrations_fix::collective::v4::MigrateToV4, + migrations_fix::collective::v4::MigrateToV4, ); /// Executive: handles dispatch to the various modules. diff --git a/polkadot-parachains/integritee-runtime/src/migrations_fix.rs b/polkadot-parachains/integritee-runtime/src/migrations_fix.rs index 1a5fde53..0783ca47 100644 --- a/polkadot-parachains/integritee-runtime/src/migrations_fix.rs +++ b/polkadot-parachains/integritee-runtime/src/migrations_fix.rs @@ -140,9 +140,6 @@ pub mod scheduler { } pub mod collective { - // this is necessary because migrations from v0 to v3 are no longer available in the scheduler - // pallet code and migrating is only possible from v3. The strategy here is to empty the agenda - // (has been empty since genesis) use frame_support::traits::OnRuntimeUpgrade; use pallet_collective::*; @@ -151,20 +148,18 @@ pub mod collective { pub mod v4 { use super::*; - use frame_support::pallet_prelude::*; + use frame_support::{pallet_prelude::*, traits::Instance}; use sp_std::vec::Vec; - /// Migrate the scheduler pallet from V0 to V4 without changing storage. the only active schedule has been submitted already in V4 - pub struct MigrateToV4(sp_std::marker::PhantomData); - - impl OnRuntimeUpgrade for MigrateToV4 { + pub struct MigrateToV4, I: 'static>(sp_std::marker::PhantomData<(T, I)>); + impl, I: Instance + 'static> OnRuntimeUpgrade for MigrateToV4 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, sp_runtime::DispatchError> { Ok((0u32).encode()) } fn on_runtime_upgrade() -> Weight { - let onchain_version = Pallet::::on_chain_storage_version(); + let onchain_version = Pallet::::on_chain_storage_version(); if onchain_version >= 3 { log::warn!( target: TARGET, @@ -175,14 +170,14 @@ pub mod collective { return T::DbWeight::get().reads(1) } log::info!(target: TARGET, "migrating from {:?} to 4", onchain_version); - StorageVersion::new(4).put::>(); + StorageVersion::new(4).put::>(); T::DbWeight::get().reads_writes(1, 1) } #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::DispatchError> { - ensure!(StorageVersion::get::>() == 4, "Must upgrade"); + ensure!(StorageVersion::get::>() == 4, "Must upgrade"); Ok(()) } } @@ -304,7 +299,7 @@ pub mod bounties { } #[cfg(feature = "try-runtime")] - fn post_upgrade(state: Vec) -> Result<(), sp_runtime::DispatchError> { + fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::DispatchError> { ensure!(StorageVersion::get::>() == 4, "Must upgrade"); Ok(()) } @@ -326,9 +321,26 @@ pub mod preimage { pub mod v1 { use super::*; - use frame_support::pallet_prelude::*; + use frame_support::{pallet_prelude::*, traits::Currency}; use sp_std::vec::Vec; + const MAX_SIZE: u32 = 4 * 1024 * 1024; + type BalanceOf = + <::Currency as Currency<::AccountId>>::Balance; + + //these are actually the same types as in the current version of the pallet. + #[frame_support::storage_alias] + pub(super) type StatusFor = StorageMap< + Pallet, + Identity, + crate::Hash, + RequestStatus>, + >; + + #[frame_support::storage_alias] + pub(super) type PreimageFor = + StorageMap, Identity, (crate::Hash, u32), BoundedVec>>; + pub struct MigrateToV1(sp_std::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { @@ -336,6 +348,7 @@ pub mod preimage { fn pre_upgrade() -> Result, sp_runtime::DispatchError> { let images = PreimageFor::::iter_values().count() as u32; let status = StatusFor::::iter_values().count() as u32; + log::info!(target: TARGET, "PreImageFor decoded: {}, StatusFor decoded {}", images, status); assert_eq!(images, status); Ok(0u32.encode()) } @@ -358,7 +371,7 @@ pub mod preimage { } #[cfg(feature = "try-runtime")] - fn post_upgrade(state: Vec) -> Result<(), sp_runtime::DispatchError> { + fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::DispatchError> { ensure!(StorageVersion::get::>() == 1, "Must upgrade"); Ok(()) }