Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
ggwpez committed Jan 31, 2025
1 parent 651f5c1 commit 0839abd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
16 changes: 3 additions & 13 deletions integration-tests/ahm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use frame_support::traits::*;
use pallet_rc_migrator::{types::PalletMigrationChecks, RcMigrationStage};
use pallet_rc_migrator::{types::PalletMigrationChecks, MigrationStage, RcMigrationStage};
use std::str::FromStr;

use asset_hub_polkadot_runtime::Runtime as AssetHub;
use polkadot_runtime::Runtime as Polkadot;
Expand All @@ -50,7 +51,7 @@ async fn account_migration_works() {
let mut dmps = Vec::new();

if let Ok(stage) = std::env::var("START_STAGE") {
let stage = state_from_str::<Polkadot>(&stage);
let stage = MigrationStage::from_str(&stage).expect("Invalid start stage");
RcMigrationStage::<Polkadot>::put(stage);
}

Expand Down Expand Up @@ -107,14 +108,3 @@ async fn account_migration_works() {
// some overweight ones.
});
}

pub fn state_from_str<T: pallet_rc_migrator::Config>(
s: &str,
) -> pallet_rc_migrator::MigrationStageOf<T> {
use pallet_rc_migrator::MigrationStage;
match s {
"preimage" => MigrationStage::PreimageMigrationInit,
"referenda" => MigrationStage::ReferendaMigrationInit,
_ => MigrationStage::Pending,
}
}
40 changes: 26 additions & 14 deletions pallets/rc-migrator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ mod weights;
pub use pallet::*;
pub mod scheduler;

use accounts::AccountsMigrator;
use frame_support::{
pallet_prelude::*,
sp_runtime::traits::AccountIdConversion,
Expand All @@ -54,31 +55,28 @@ use frame_support::{
weights::WeightMeter,
};
use frame_system::{pallet_prelude::*, AccountInfo};
use multisig::MultisigMigrator;
use pallet_balances::AccountData;
use polkadot_parachain_primitives::primitives::Id as ParaId;
use polkadot_runtime_common::paras_registrar;
use runtime_parachains::hrmp;
use sp_core::{crypto::Ss58Codec, H256};
use sp_runtime::AccountId32;
use sp_std::prelude::*;
use storage::TransactionOutcome;
use types::AhWeightInfo;
use weights::WeightInfo;
use xcm::prelude::*;

use accounts::AccountsMigrator;
use multisig::MultisigMigrator;
use preimage::{
PreimageChunkMigrator, PreimageLegacyRequestStatusMigrator, PreimageRequestStatusMigrator,
};
use proxy::*;
use referenda::ReferendaStage;
use runtime_parachains::hrmp;
use sp_core::{crypto::Ss58Codec, H256};
use sp_runtime::AccountId32;
use sp_std::prelude::*;
use staking::{
bags_list::{BagsListMigrator, BagsListStage},
fast_unstake::{FastUnstakeMigrator, FastUnstakeStage},
nom_pools::{NomPoolsMigrator, NomPoolsStage},
};
use types::PalletMigration;
use storage::TransactionOutcome;
use types::{AhWeightInfo, PalletMigration};
use weights::WeightInfo;
use xcm::prelude::*;

/// The log target of this pallet.
pub const LOG_TARGET: &str = "runtime::rc-migrator";
Expand Down Expand Up @@ -199,6 +197,22 @@ impl<AccountId, BlockNumber, BagsListScore> MigrationStage<AccountId, BlockNumbe
}
}

#[cfg(feature = "std")]
impl<AccountId, BlockNumber, BagsListScore> std::str::FromStr
for MigrationStage<AccountId, BlockNumber, BagsListScore>
{
type Err = std::string::String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"preimage" => MigrationStage::PreimageMigrationInit,
"referenda" => MigrationStage::ReferendaMigrationInit,
"multisig" => MigrationStage::MultisigMigrationInit,
other => return Err(format!("Unknown migration stage: {}", other)),
})
}
}

type AccountInfoFor<T> =
AccountInfo<<T as frame_system::Config>::Nonce, <T as frame_system::Config>::AccountData>;

Expand Down Expand Up @@ -322,8 +336,6 @@ pub mod pallet {
// TODO: not complete

Self::transition(MigrationStage::AccountsMigrationInit);
// toggle for testing
//Self::transition(MigrationStage::BagsListMigrationInit);
},
MigrationStage::AccountsMigrationInit => {
// TODO: weights
Expand Down

0 comments on commit 0839abd

Please sign in to comment.