Skip to content

Commit

Permalink
clean state_trie_migration from westend
Browse files Browse the repository at this point in the history
  • Loading branch information
cheme committed Feb 17, 2023
1 parent 139aff1 commit b1d55c6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 64 deletions.
4 changes: 0 additions & 4 deletions runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ pallet-session = { git = "https://github.com/paritytech/substrate", branch = "ma
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking-reward-curve = { package = "pallet-staking-reward-curve", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-state-trie-migration = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -99,7 +98,6 @@ xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default
hex-literal = "0.3.4"
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
serde_json = "1.0.81"
remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "master", package = "frame-remote-externalities" }
tokio = { version = "1.24.2", features = ["macros"] }
Expand Down Expand Up @@ -156,7 +154,6 @@ std = [
"pallet-session/std",
"pallet-society/std",
"pallet-staking/std",
"pallet-state-trie-migration/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-treasury/std",
Expand Down Expand Up @@ -257,7 +254,6 @@ try-runtime = [
"pallet-session/try-runtime",
"pallet-society/try-runtime",
"pallet-staking/try-runtime",
"pallet-state-trie-migration/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-treasury/try-runtime",
Expand Down
60 changes: 0 additions & 60 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 @@ -1243,7 +1227,6 @@ impl Get<&'static str> for StakingMigrationV11OldPallet {
///
/// Should be cleared after every release.
pub type Migrations = (
init_state_migration::InitMigrate,
// "Use 2D weights in XCM v3" <https://github.com/paritytech/polkadot/pull/6134>
pallet_xcm::migration::v1::MigrateToV1<Runtime>,
parachains_ump::migration::v1::MigrateToV1<Runtime>,
Expand Down Expand Up @@ -1907,46 +1890,3 @@ mod remote_tests {
ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost));
}
}

mod init_state_migration {
use super::Runtime;
use frame_support::traits::OnRuntimeUpgrade;
use pallet_state_trie_migration::{AutoLimits, MigrationLimits, MigrationProcess};
#[cfg(not(feature = "std"))]
use sp_std::prelude::*;

/// Initialize an automatic migration process.
pub struct InitMigrate;
impl OnRuntimeUpgrade for InitMigrate {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
frame_support::ensure!(
AutoLimits::<Runtime>::get().is_none(),
"Automigration already started."
);
Ok(Default::default())
}

fn on_runtime_upgrade() -> frame_support::weights::Weight {
if MigrationProcess::<Runtime>::get() == Default::default() &&
AutoLimits::<Runtime>::get().is_none()
{
AutoLimits::<Runtime>::put(Some(MigrationLimits { item: 160, size: 204800 }));
log::info!("Automatic trie migration started.");
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(2, 1)
} else {
log::info!("Automatic trie migration not started.");
<Runtime as frame_system::Config>::DbWeight::get().reads(2)
}
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
frame_support::ensure!(
AutoLimits::<Runtime>::get().is_some(),
"Automigration started."
);
Ok(())
}
}
}

0 comments on commit b1d55c6

Please sign in to comment.