Skip to content

Commit

Permalink
use storage_alias
Browse files Browse the repository at this point in the history
  • Loading branch information
cheme committed Feb 17, 2023
1 parent 0d0ef73 commit 5289745
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1097,19 +1097,6 @@ parameter_types! {
pub const MigrationMaxKeyLen: u32 = 512;
}

impl pallet_state_trie_migration::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type SignedDepositPerItem = MigrationSignedDepositPerItem;
type SignedDepositBase = MigrationSignedDepositBase;
type ControlOrigin = EnsureRoot<AccountId>;
type SignedFilter = frame_support::traits::NeverEnsureOrigin<AccountId>;

// Use same weights as substrate ones.
type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight<Runtime>;
type MaxKeyLen = MigrationMaxKeyLen;
}

construct_runtime! {
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -1178,9 +1165,6 @@ construct_runtime! {
// Fast unstake pallet: extension to staking.
FastUnstake: pallet_fast_unstake = 30,

// State trie migration pallet, only temporary.
StateTrieMigration: pallet_state_trie_migration = 35,

// Parachains pallets. Start indices at 40 to leave room.
ParachainsOrigin: parachains_origin::{Pallet, Origin} = 41,
Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 42,
Expand Down Expand Up @@ -1910,13 +1894,24 @@ mod remote_tests {

mod clean_state_migration {
use super::Runtime;
use frame_support::traits::OnRuntimeUpgrade;
use pallet_state_trie_migration::{AutoLimits, MigrationProcess, SignedMigrationMaxLimits};
use frame_support::{pallet_prelude::*, storage_alias, traits::OnRuntimeUpgrade};
use pallet_state_trie_migration::{Config, MigrationLimits, MigrationTask, Pallet};

#[cfg(not(feature = "std"))]
use sp_std::prelude::*;

#[storage_alias]
type AutoLimits<T> = StorageValue<Pallet<T>, Option<MigrationLimits>, ValueQuery>;

#[storage_alias]
type MigrationProcess<T> = StorageValue<Pallet<T>, MigrationTask<T>, ValueQuery>;

#[storage_alias]
type SignedMigrationMaxLimits<T> = StorageValue<Pallet<T>, MigrationLimits, OptionQuery>;

/// Initialize an automatic migration process.
pub struct CleanMigrate;

impl OnRuntimeUpgrade for CleanMigrate {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
Expand All @@ -1933,9 +1928,7 @@ mod clean_state_migration {
#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
frame_support::ensure!(
!MigrationProcess::<Runtime>::exists() &&
!AutoLimits::<Runtime>::exists() &&
!SignedMigrationMaxLimits::<Runtime>::exists(),
!AutoLimits::<Runtime>::exists() && !SignedMigrationMaxLimits::<Runtime>::exists(),
"State migration clean.",
);
Ok(())
Expand Down

0 comments on commit 5289745

Please sign in to comment.