Skip to content

Commit

Permalink
chore: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wangminqi committed Dec 27, 2024
1 parent a89868d commit 569742f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 50 deletions.
2 changes: 1 addition & 1 deletion parachain/runtime/paseo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub type Executive = frame_executive::Executive<
// it was reverse order before.
// See the comment before collation related pallets too.
AllPalletsWithSystem,
migration::MigrateStorageVersionPatch<Runtime>,
migration::Migrations<Runtime>,
>;

impl fp_self_contained::SelfContainedCall for RuntimeCall {
Expand Down
63 changes: 14 additions & 49 deletions parachain/runtime/paseo/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,17 @@
// In try-runtime, current implementation, the storage version is not checked,
// Pallet version is used instead.

use frame_support::traits::OnRuntimeUpgrade;
use sp_std::marker::PhantomData;

pub struct MigrateStorageVersionPatch<T>(PhantomData<T>);
impl<T> OnRuntimeUpgrade for MigrateStorageVersionPatch<T>
where
T: frame_system::Config
+ cumulus_pallet_xcmp_queue::Config
+ cumulus_pallet_xcmp_queue::migration::v5::V5Config,
{
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<alloc::vec::Vec<u8>, sp_runtime::TryRuntimeError> {
// Only checking the lowest storage version
let xcmp_queue_storage_version_check =
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4::<T>::pre_upgrade()?;

Ok(VersionedPostUpgradeData::MigrationExecuted(Inner::pre_upgrade()?).encode())
}

fn on_runtime_upgrade() -> frame_support::weights::Weight {
let mut weight = frame_support::weights::Weight::from_parts(0, 0);
// V3 to V4
// XCMP QueueConfig has different default value
// Migration targeting at changing storage value to new default value if old value matched
// Our current Paseo setting has already hard-coded
// This migration should have no effect except bumping storage version
weight +=
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4::<T>::on_runtime_upgrade();
// V4 to V5
// Did nothing to storage
// Just checking MaxActiveOutboundChannels is not exceeded
// Our current Paseo Storage is 0
// This migration should have no effect except bumping storage version
weight +=
cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5::<T>::on_runtime_upgrade();

weight
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(
versioned_post_upgrade_data_bytes: alloc::vec::Vec<u8>,
) -> Result<(), sp_runtime::TryRuntimeError> {
// Only checking the lowest storage version
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4::<T>::post_upgrade(
versioned_post_upgrade_data_bytes,
)
}
}
pub type Migrations<Runtime> = (
// V3 to V4
// XCMP QueueConfig has different default value
// Migration targeting at changing storage value to new default value if old value matched
// Our current Paseo setting has already hard-coded
// This migration should have no effect except bumping storage version
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
// V4 to V5
// Did nothing to storage
// Just checking MaxActiveOutboundChannels is not exceeded
// Our current Paseo Storage is 0
// This migration should have no effect except bumping storage version
cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5<Runtime>,
);

0 comments on commit 569742f

Please sign in to comment.