diff --git a/Cargo.lock b/Cargo.lock index 1f5f0c8947eb..f63f3a8c265b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13344,7 +13344,6 @@ dependencies = [ "sp-std", "sp-tracing", "sp-transaction-pool", - "sp-trie", "sp-version", "substrate-wasm-builder", "tiny-keccak", diff --git a/runtime/westend/Cargo.toml b/runtime/westend/Cargo.toml index cb53fa136e97..07c918a50615 100644 --- a/runtime/westend/Cargo.toml +++ b/runtime/westend/Cargo.toml @@ -99,7 +99,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"] } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index d17907bc2683..2b61741344f1 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -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; - type SignedFilter = frame_support::traits::NeverEnsureOrigin; - - // Use same weights as substrate ones. - type WeightInfo = pallet_state_trie_migration::weights::SubstrateWeight; - type MaxKeyLen = MigrationMaxKeyLen; -} - construct_runtime! { pub enum Runtime where Block = Block, @@ -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} = 42, @@ -1243,7 +1227,7 @@ impl Get<&'static str> for StakingMigrationV11OldPallet { /// /// Should be cleared after every release. pub type Migrations = ( - init_state_migration::InitMigrate, + clean_state_migration::CleanMigrate, // "Use 2D weights in XCM v3" pallet_xcm::migration::v1::MigrateToV1, parachains_ump::migration::v1::MigrateToV1, @@ -1926,43 +1910,47 @@ mod remote_tests { } } -mod init_state_migration { +mod clean_state_migration { use super::Runtime; - use frame_support::traits::OnRuntimeUpgrade; - use pallet_state_trie_migration::{AutoLimits, MigrationLimits, MigrationProcess}; + use frame_support::{pallet_prelude::*, storage_alias, traits::OnRuntimeUpgrade}; + use pallet_state_trie_migration::MigrationLimits; + #[cfg(not(feature = "std"))] use sp_std::prelude::*; + #[storage_alias] + type AutoLimits = StorageValue, ValueQuery>; + + // Actual type of value is `MigrationTask`, putting a dummy + // one to avoid the trait constraint on T. + // Since we only use `kill` it is fine. + #[storage_alias] + type MigrationProcess = StorageValue; + + #[storage_alias] + type SignedMigrationMaxLimits = StorageValue; + /// Initialize an automatic migration process. - pub struct InitMigrate; - impl OnRuntimeUpgrade for InitMigrate { + pub struct CleanMigrate; + + impl OnRuntimeUpgrade for CleanMigrate { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, &'static str> { - frame_support::ensure!( - AutoLimits::::get().is_none(), - "Automigration already started." - ); Ok(Default::default()) } fn on_runtime_upgrade() -> frame_support::weights::Weight { - if MigrationProcess::::get() == Default::default() && - AutoLimits::::get().is_none() - { - AutoLimits::::put(Some(MigrationLimits { item: 160, size: 204800 })); - log::info!("Automatic trie migration started."); - ::DbWeight::get().reads_writes(2, 1) - } else { - log::info!("Automatic trie migration not started."); - ::DbWeight::get().reads(2) - } + MigrationProcess::kill(); + AutoLimits::kill(); + SignedMigrationMaxLimits::kill(); + ::DbWeight::get().writes(3) } #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), &'static str> { frame_support::ensure!( - AutoLimits::::get().is_some(), - "Automigration started." + !AutoLimits::exists() && !SignedMigrationMaxLimits::exists(), + "State migration clean.", ); Ok(()) }