diff --git a/substrate/bin/node-template/pallets/template/src/mock.rs b/substrate/bin/node-template/pallets/template/src/mock.rs index 3179b56b22..2ea81ffb45 100644 --- a/substrate/bin/node-template/pallets/template/src/mock.rs +++ b/substrate/bin/node-template/pallets/template/src/mock.rs @@ -40,7 +40,7 @@ impl system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } impl Trait for Test { diff --git a/substrate/bin/node-template/runtime/src/lib.rs b/substrate/bin/node-template/runtime/src/lib.rs index 707799eab4..0414759a5a 100644 --- a/substrate/bin/node-template/runtime/src/lib.rs +++ b/substrate/bin/node-template/runtime/src/lib.rs @@ -162,7 +162,7 @@ impl system::Trait for Runtime { /// This type is being generated by `construct_runtime!`. type ModuleToIndex = ModuleToIndex; /// What to do if a new account is created. - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); /// What to do if an account is fully reaped from the system. type OnKilledAccount = (); /// The data to be stored in an account. diff --git a/substrate/bin/node/runtime/Cargo.toml b/substrate/bin/node/runtime/Cargo.toml index 90ef3833a3..a5fad30837 100644 --- a/substrate/bin/node/runtime/Cargo.toml +++ b/substrate/bin/node/runtime/Cargo.toml @@ -60,8 +60,8 @@ pallet-randomness-collective-flip = { version = "2.0.0-alpha.4", default-feature pallet-recovery = { version = "2.0.0-alpha.4", default-features = false, path = "../../../frame/recovery" } pallet-session = { version = "2.0.0-alpha.4", features = ["historical"], path = "../../../frame/session", default-features = false } pallet-session-benchmarking = { version = "2.0.0-alpha.4", path = "../../../frame/session/benchmarking", default-features = false, optional = true } -pallet-staking = { version = "2.0.0-alpha.4", features = ["migrate"], path = "../../../frame/staking", default-features = false } -pallet-staking-reward-curve = { version = "2.0.0-alpha.4", path = "../../../frame/staking/reward-curve" } +pallet-staking = { version = "2.0.0-alpha.4", default-features = false, path = "../../../frame/staking" } +pallet-staking-reward-curve = { version = "2.0.0-alpha.4", default-features = false, path = "../../../frame/staking/reward-curve" } pallet-sudo = { version = "2.0.0-alpha.4", default-features = false, path = "../../../frame/sudo" } pallet-society = { version = "2.0.0-alpha.4", default-features = false, path = "../../../frame/society" } pallet-timestamp = { version = "2.0.0-alpha.4", default-features = false, path = "../../../frame/timestamp" } @@ -135,10 +135,8 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking", - "pallet-balances/runtime-benchmarks", - "pallet-identity/runtime-benchmarks", - "pallet-session-benchmarking", "pallet-timestamp/runtime-benchmarks", + "pallet-identity/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", - "pallet-staking/runtime-benchmarks", ] diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 5468ee0fb3..b27ba6c9ac 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -82,7 +82,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to 0. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 237, + spec_version: 238, impl_version: 0, apis: RUNTIME_API_VERSIONS, }; @@ -140,7 +140,6 @@ impl frame_system::Trait for Runtime { type Version = Version; type ModuleToIndex = ModuleToIndex; type AccountData = pallet_balances::AccountData; - type MigrateAccount = (Balances, Identity, Democracy, Elections, ImOnline, Recovery, Session, Society, Staking, Vesting); type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/client/consensus/babe/src/aux_schema.rs b/substrate/client/consensus/babe/src/aux_schema.rs index 6f69e65940..3ca2f560d4 100644 --- a/substrate/client/consensus/babe/src/aux_schema.rs +++ b/substrate/client/consensus/babe/src/aux_schema.rs @@ -25,7 +25,7 @@ use sc_client_api::backend::AuxStore; use sp_blockchain::{Result as ClientResult, Error as ClientError}; use sp_runtime::traits::Block as BlockT; use sp_consensus_babe::BabeBlockWeight; -use sc_consensus_epochs::{EpochChangesFor, SharedEpochChanges, migration::EpochChangesForV0}; +use sc_consensus_epochs::{EpochChangesFor, SharedEpochChanges}; use crate::Epoch; const BABE_EPOCH_CHANGES_VERSION: &[u8] = b"babe_epoch_changes_version"; @@ -57,11 +57,7 @@ pub(crate) fn load_epoch_changes( let version = load_decode::<_, u32>(backend, BABE_EPOCH_CHANGES_VERSION)?; let maybe_epoch_changes = match version { - None => load_decode::<_, EpochChangesForV0>( - backend, - BABE_EPOCH_CHANGES_KEY, - )?.map(|v0| v0.migrate()), - Some(BABE_EPOCH_CHANGES_CURRENT_VERSION) => load_decode::<_, EpochChangesFor>( + None | Some(BABE_EPOCH_CHANGES_CURRENT_VERSION) => load_decode::<_, EpochChangesFor>( backend, BABE_EPOCH_CHANGES_KEY, )?, @@ -127,72 +123,3 @@ pub(crate) fn load_block_weight( ) -> ClientResult> { load_decode(backend, block_weight_key(block_hash).as_slice()) } - -#[cfg(test)] -mod test { - use super::*; - use crate::Epoch; - use fork_tree::ForkTree; - use substrate_test_runtime_client; - use sp_core::H256; - use sp_runtime::traits::NumberFor; - use sc_consensus_epochs::{PersistedEpoch, PersistedEpochHeader, EpochHeader}; - use sp_consensus::Error as ConsensusError; - use sc_network_test::Block as TestBlock; - - #[test] - fn load_decode_from_v0_epoch_changes() { - let epoch = Epoch { - start_slot: 0, - authorities: vec![], - randomness: [0; 32], - epoch_index: 1, - duration: 100, - }; - let client = substrate_test_runtime_client::new(); - let mut v0_tree = ForkTree::, _>::new(); - v0_tree.import::<_, ConsensusError>( - Default::default(), - Default::default(), - PersistedEpoch::Regular(epoch), - &|_, _| Ok(false), // Test is single item only so this can be set to false. - ).unwrap(); - - client.insert_aux( - &[(BABE_EPOCH_CHANGES_KEY, - &EpochChangesForV0::::from_raw(v0_tree).encode()[..])], - &[], - ).unwrap(); - - assert_eq!( - load_decode::<_, u32>(&client, BABE_EPOCH_CHANGES_VERSION).unwrap(), - None, - ); - - let epoch_changes = load_epoch_changes::(&client).unwrap(); - - assert!( - epoch_changes.lock() - .tree() - .iter() - .map(|(_, _, epoch)| epoch.clone()) - .collect::>() == - vec![PersistedEpochHeader::Regular(EpochHeader { - start_slot: 0, - end_slot: 100, - })], - ); // PersistedEpochHeader does not implement Debug, so we use assert! directly. - - write_epoch_changes::( - &epoch_changes.lock(), - |values| { - client.insert_aux(values, &[]).unwrap(); - }, - ); - - assert_eq!( - load_decode::<_, u32>(&client, BABE_EPOCH_CHANGES_VERSION).unwrap(), - Some(1), - ); - } -} diff --git a/substrate/client/consensus/epochs/src/lib.rs b/substrate/client/consensus/epochs/src/lib.rs index 001c172b34..d5816d960c 100644 --- a/substrate/client/consensus/epochs/src/lib.rs +++ b/substrate/client/consensus/epochs/src/lib.rs @@ -16,8 +16,6 @@ //! Generic utilities for epoch-based consensus engines. -pub mod migration; - use std::{sync::Arc, ops::Add, collections::BTreeMap, borrow::{Borrow, BorrowMut}}; use parking_lot::Mutex; use codec::{Encode, Decode}; diff --git a/substrate/client/consensus/epochs/src/migration.rs b/substrate/client/consensus/epochs/src/migration.rs deleted file mode 100644 index e4717b5584..0000000000 --- a/substrate/client/consensus/epochs/src/migration.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2019-2020 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . - -//! Migration types for epoch changes. - -use std::collections::BTreeMap; -use codec::{Encode, Decode}; -use fork_tree::ForkTree; -use sp_runtime::traits::{Block as BlockT, NumberFor}; -use crate::{Epoch, EpochChanges, PersistedEpoch, PersistedEpochHeader}; - -/// Legacy definition of epoch changes. -#[derive(Clone, Encode, Decode)] -pub struct EpochChangesV0 { - inner: ForkTree>, -} - -/// Type alias for legacy definition of epoch changes. -pub type EpochChangesForV0 = EpochChangesV0<::Hash, NumberFor, Epoch>; - -impl EpochChangesV0 where - Hash: PartialEq + Ord + Copy, - Number: Ord + Copy, -{ - /// Create a new value of this type from raw. - pub fn from_raw(inner: ForkTree>) -> Self { - Self { inner } - } - - /// Migrate the type into current epoch changes definition. - pub fn migrate(self) -> EpochChanges { - let mut epochs = BTreeMap::new(); - - let inner = self.inner.map(&mut |hash, number, data| { - let header = PersistedEpochHeader::from(&data); - epochs.insert((*hash, *number), data); - header - }); - - EpochChanges { inner, epochs } - } -} diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index af74f90461..838d21a462 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -294,7 +294,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } impl Trait for Test { diff --git a/substrate/frame/aura/src/mock.rs b/substrate/frame/aura/src/mock.rs index b191e1d05d..05a161ee49 100644 --- a/substrate/frame/aura/src/mock.rs +++ b/substrate/frame/aura/src/mock.rs @@ -62,7 +62,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/authority-discovery/src/lib.rs b/substrate/frame/authority-discovery/src/lib.rs index 0479e710c5..8ee4931e48 100644 --- a/substrate/frame/authority-discovery/src/lib.rs +++ b/substrate/frame/authority-discovery/src/lib.rs @@ -158,7 +158,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/authorship/src/lib.rs b/substrate/frame/authorship/src/lib.rs index 1869d408ca..d3c1bf752a 100644 --- a/substrate/frame/authorship/src/lib.rs +++ b/substrate/frame/authorship/src/lib.rs @@ -432,7 +432,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index 8013e0cd45..29e8625419 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -188,12 +188,6 @@ decl_module! { Self::deposit_vrf_output(&vrf_output); } } - - fn on_runtime_upgrade() { - for i in 0..=SegmentIndex::get() { - UnderConstruction::migrate_key_from_blake(i); - } - } } } diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index 63943593b8..2ec083728e 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -65,7 +65,7 @@ impl frame_system::Trait for Test { type MaximumBlockLength = MaximumBlockLength; type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index 6e707caaa1..b83530d635 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -167,7 +167,7 @@ use frame_support::{ Currency, OnKilledAccount, OnUnbalanced, TryDrop, StoredMap, WithdrawReason, WithdrawReasons, LockIdentifier, LockableCurrency, ExistenceRequirement, Imbalance, SignedImbalance, ReservableCurrency, Get, ExistenceRequirement::KeepAlive, - ExistenceRequirement::AllowDeath, IsDeadAccount, BalanceStatus as Status, MigrateAccount, + ExistenceRequirement::AllowDeath, IsDeadAccount, BalanceStatus as Status, } }; use sp_runtime::{ @@ -531,12 +531,6 @@ decl_module! { } } -impl, I: Instance> MigrateAccount for Module { - fn migrate_account(account: &T::AccountId) { - Locks::::migrate_key_from_blake(account); - } -} - impl, I: Instance> Module { // PRIVATE MUTABLES @@ -856,7 +850,7 @@ impl, I: Instance> frame_system::Trait for ElevatedTrait { type AvailableBlockRatio = T::AvailableBlockRatio; type Version = T::Version; type ModuleToIndex = T::ModuleToIndex; - type MigrateAccount = (); type OnNewAccount = T::OnNewAccount; + type OnNewAccount = T::OnNewAccount; type OnKilledAccount = T::OnKilledAccount; type AccountData = T::AccountData; } diff --git a/substrate/frame/balances/src/tests_composite.rs b/substrate/frame/balances/src/tests_composite.rs index 8bf31ec36c..3a5c2178f8 100644 --- a/substrate/frame/balances/src/tests_composite.rs +++ b/substrate/frame/balances/src/tests_composite.rs @@ -66,7 +66,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = super::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/balances/src/tests_local.rs b/substrate/frame/balances/src/tests_local.rs index c6beec0782..861c197212 100644 --- a/substrate/frame/balances/src/tests_local.rs +++ b/substrate/frame/balances/src/tests_local.rs @@ -66,7 +66,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = super::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = Module; } parameter_types! { diff --git a/substrate/frame/benchmarking/src/tests.rs b/substrate/frame/benchmarking/src/tests.rs index 6e837ec241..4327476c4a 100644 --- a/substrate/frame/benchmarking/src/tests.rs +++ b/substrate/frame/benchmarking/src/tests.rs @@ -71,7 +71,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/collective/src/lib.rs b/substrate/frame/collective/src/lib.rs index 30b1b19974..8b46856cbb 100644 --- a/substrate/frame/collective/src/lib.rs +++ b/substrate/frame/collective/src/lib.rs @@ -168,17 +168,6 @@ decl_error! { } } -mod migration { - use super::*; - - pub fn migrate, I: Instance>() { - for p in Proposals::::get().into_iter() { - ProposalOf::::migrate_key_from_blake(&p); - Voting::::migrate_key_from_blake(&p); - } - } -} - // Note: this module is not benchmarked. The weights are obtained based on the similarity of the // executed logic with other democracy function. Note that councillor operations are assigned to the // operational class. @@ -188,10 +177,6 @@ decl_module! { fn deposit_event() = default; - fn on_runtime_upgrade() { - migration::migrate::(); - } - /// Set the collective's membership. /// /// - `new_members`: The new member list. Be nice to the chain and @@ -550,7 +535,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } impl Trait for Test { diff --git a/substrate/frame/contracts/src/tests.rs b/substrate/frame/contracts/src/tests.rs index d05d251b23..165e23e8b8 100644 --- a/substrate/frame/contracts/src/tests.rs +++ b/substrate/frame/contracts/src/tests.rs @@ -116,7 +116,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = Contracts; } impl pallet_balances::Trait for Test { diff --git a/substrate/frame/democracy/src/lib.rs b/substrate/frame/democracy/src/lib.rs index cbc766499f..04aef6fe41 100644 --- a/substrate/frame/democracy/src/lib.rs +++ b/substrate/frame/democracy/src/lib.rs @@ -170,7 +170,6 @@ use frame_system::{self as system, ensure_signed, ensure_root}; mod vote_threshold; pub use vote_threshold::{Approved, VoteThreshold}; -use frame_support::traits::MigrateAccount; const DEMOCRACY_ID: LockIdentifier = *b"democrac"; @@ -584,41 +583,10 @@ decl_error! { } } -impl MigrateAccount for Module { - fn migrate_account(a: &T::AccountId) { - Proxy::::migrate_key_from_blake(a); - Locks::::migrate_key_from_blake(a); - Delegations::::migrate_key_from_blake(a); - for i in LowestUnbaked::get()..ReferendumCount::get() { - VoteOf::::migrate_key_from_blake((i, a)); - } - } -} - -mod migration { - use super::*; - pub fn migrate() { - Blacklist::::remove_all(); - Cancellations::::remove_all(); - for i in LowestUnbaked::get()..ReferendumCount::get() { - VotersFor::::migrate_key_from_blake(i); - ReferendumInfoOf::::migrate_key_from_blake(i); - } - for (p, h, _) in PublicProps::::get().into_iter() { - DepositOf::::migrate_key_from_blake(p); - Preimages::::migrate_key_from_blake(h); - } - } -} - decl_module! { pub struct Module for enum Call where origin: T::Origin { type Error = Error; - fn on_runtime_upgrade() { - migration::migrate::(); - } - /// The minimum period of locking and the period between a proposal being approved and enacted. /// /// It should generally be a little more than the unstake period to ensure that @@ -1639,7 +1607,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index ac85b3047d..54bf801bbd 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -95,7 +95,6 @@ use frame_support::{ }; use sp_phragmen::ExtendedBalance; use frame_system::{self as system, ensure_signed, ensure_root}; -use frame_support::traits::MigrateAccount; const MODULE_ID: LockIdentifier = *b"phrelect"; @@ -474,14 +473,6 @@ decl_event!( } ); -impl MigrateAccount for Module { - fn migrate_account(a: &T::AccountId) { - if StakeOf::::migrate_key_from_blake(a).is_some() { - VotesOf::::migrate_key_from_blake(a); - } - } -} - impl Module { /// Attempts to remove a member `who`. If a runner up exists, it is used as the replacement. /// Otherwise, `Ok(false)` is returned to signal the caller. @@ -825,7 +816,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/elections/src/mock.rs b/substrate/frame/elections/src/mock.rs index 2a5e5fefbd..b82e73d512 100644 --- a/substrate/frame/elections/src/mock.rs +++ b/substrate/frame/elections/src/mock.rs @@ -55,7 +55,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/example-offchain-worker/src/tests.rs b/substrate/frame/example-offchain-worker/src/tests.rs index 5e086aa3a6..9b6a567a17 100644 --- a/substrate/frame/example-offchain-worker/src/tests.rs +++ b/substrate/frame/example-offchain-worker/src/tests.rs @@ -66,7 +66,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/example/src/lib.rs b/substrate/frame/example/src/lib.rs index 62e46e9cb2..d6036b3af8 100644 --- a/substrate/frame/example/src/lib.rs +++ b/substrate/frame/example/src/lib.rs @@ -731,7 +731,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/executive/src/lib.rs b/substrate/frame/executive/src/lib.rs index 8fbcb3bc60..117607d9b6 100644 --- a/substrate/frame/executive/src/lib.rs +++ b/substrate/frame/executive/src/lib.rs @@ -481,7 +481,7 @@ mod tests { type Version = RuntimeVersion; type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/finality-tracker/src/lib.rs b/substrate/frame/finality-tracker/src/lib.rs index 953861dede..c7d5ad30d9 100644 --- a/substrate/frame/finality-tracker/src/lib.rs +++ b/substrate/frame/finality-tracker/src/lib.rs @@ -262,7 +262,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/generic-asset/src/lib.rs b/substrate/frame/generic-asset/src/lib.rs index 29dbe3e781..3cb48ad18a 100644 --- a/substrate/frame/generic-asset/src/lib.rs +++ b/substrate/frame/generic-asset/src/lib.rs @@ -1123,7 +1123,7 @@ impl frame_system::Trait for ElevatedTrait { type Version = T::Version; type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } impl Trait for ElevatedTrait { diff --git a/substrate/frame/generic-asset/src/mock.rs b/substrate/frame/generic-asset/src/mock.rs index 8daca2da38..8db140d90c 100644 --- a/substrate/frame/generic-asset/src/mock.rs +++ b/substrate/frame/generic-asset/src/mock.rs @@ -63,7 +63,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/grandpa/Cargo.toml b/substrate/frame/grandpa/Cargo.toml index 1e64f66a6a..cca1fee0a5 100644 --- a/substrate/frame/grandpa/Cargo.toml +++ b/substrate/frame/grandpa/Cargo.toml @@ -39,4 +39,3 @@ std = [ "pallet-session/std", "pallet-finality-tracker/std", ] -migrate-authorities = [] diff --git a/substrate/frame/grandpa/src/lib.rs b/substrate/frame/grandpa/src/lib.rs index ab8c384dfb..dd0101e5f6 100644 --- a/substrate/frame/grandpa/src/lib.rs +++ b/substrate/frame/grandpa/src/lib.rs @@ -151,13 +151,6 @@ decl_error! { decl_storage! { trait Store for Module as GrandpaFinality { - /// DEPRECATED - /// - /// This used to store the current authority set, which has been migrated to the well-known - /// GRANDPA_AUTHORITIES_KEY unhashed key. - #[cfg(feature = "migrate-authorities")] - pub(crate) Authorities get(fn authorities): AuthorityList; - /// State of the current authority set. State get(fn state): StoredState = StoredState::Live; @@ -184,15 +177,6 @@ decl_storage! { } } -mod migration { - use super::*; - pub fn migrate() { - for i in 0..=CurrentSetId::get() { - SetIdSession::migrate_key_from_blake(i); - } - } -} - decl_module! { pub struct Module for enum Call where origin: T::Origin { type Error = Error; @@ -205,15 +189,6 @@ decl_module! { // FIXME: https://github.com/paritytech/substrate/issues/1112 } - fn on_runtime_upgrade() { - migration::migrate::(); - } - - fn on_initialize() { - #[cfg(feature = "migrate-authorities")] - Self::migrate_authorities(); - } - fn on_finalize(block_number: T::BlockNumber) { // check for scheduled pending authority set changes if let Some(pending_change) = >::get() { @@ -384,13 +359,6 @@ impl Module { Self::set_grandpa_authorities(authorities); } } - - #[cfg(feature = "migrate-authorities")] - fn migrate_authorities() { - if Authorities::exists() { - Self::set_grandpa_authorities(&Authorities::take()); - } - } } impl Module { diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index 24d7feab49..8b94becd5a 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/grandpa/src/tests.rs b/substrate/frame/grandpa/src/tests.rs index ff3841b8d4..19e42a301f 100644 --- a/substrate/frame/grandpa/src/tests.rs +++ b/substrate/frame/grandpa/src/tests.rs @@ -318,21 +318,3 @@ fn time_slot_have_sane_ord() { ]; assert!(FIXTURE.windows(2).all(|f| f[0] < f[1])); } - -#[test] -#[cfg(feature = "migrate-authorities")] -fn authorities_migration() { - use sp_runtime::traits::OnInitialize; - - with_externalities(&mut new_test_ext(vec![]), || { - let authorities = to_authorities(vec![(1, 1), (2, 1), (3, 1)]); - - Authorities::put(authorities.clone()); - assert!(Grandpa::grandpa_authorities().is_empty()); - - Grandpa::on_initialize(1); - - assert!(!Authorities::exists()); - assert_eq!(Grandpa::grandpa_authorities(), authorities); - }); -} diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index d3098dcde2..4cbd8c7a2b 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -77,7 +77,6 @@ use frame_support::{ weights::SimpleDispatchInfo, }; use frame_system::{self as system, ensure_signed, ensure_root}; -use frame_support::traits::MigrateAccount; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; @@ -887,18 +886,6 @@ impl Module { } } -impl MigrateAccount for Module { - fn migrate_account(a: &T::AccountId) { - if IdentityOf::::migrate_key_from_blake(a).is_some() { - if let Some((_, subs)) = SubsOf::::migrate_key_from_blake(a) { - for sub in subs.into_iter() { - SuperOf::::migrate_key_from_blake(sub); - } - } - } - } -} - #[cfg(test)] mod tests { use super::*; @@ -949,7 +936,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/im-online/src/lib.rs b/substrate/frame/im-online/src/lib.rs index 4d40decdfc..a0a16c46f3 100644 --- a/substrate/frame/im-online/src/lib.rs +++ b/substrate/frame/im-online/src/lib.rs @@ -95,7 +95,6 @@ use frame_support::{ }; use frame_system::{self as system, ensure_none}; use frame_system::offchain::SubmitUnsignedTransaction; -use frame_support::traits::MigrateAccount; pub mod sr25519 { mod app_sr25519 { @@ -303,38 +302,12 @@ decl_error! { } } -mod migration { - use super::*; - use frame_support::Blake2_256; - pub fn migrate() { - let current_index = >::current_index(); - let key_count = Keys::::get().len() as AuthIndex; - for i in 0..key_count { - ReceivedHeartbeats::migrate_keys::(current_index, i); - } - } -} - -impl MigrateAccount for Module { - fn migrate_account(a: &T::AccountId) { - use frame_support::Blake2_256; - let current_index = >::current_index(); - if let Ok(v) = a.using_encoded(|mut d| T::ValidatorId::decode(&mut d)) { - AuthoredBlocks::::migrate_keys::(current_index, v); - } - } -} - decl_module! { pub struct Module for enum Call where origin: T::Origin { type Error = Error; fn deposit_event() = default; - fn on_runtime_upgrade() { - migration::migrate::(); - } - fn heartbeat( origin, heartbeat: Heartbeat, diff --git a/substrate/frame/im-online/src/mock.rs b/substrate/frame/im-online/src/mock.rs index e0ee2547bf..78b6409d54 100644 --- a/substrate/frame/im-online/src/mock.rs +++ b/substrate/frame/im-online/src/mock.rs @@ -119,7 +119,7 @@ impl frame_system::Trait for Runtime { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/indices/src/mock.rs b/substrate/frame/indices/src/mock.rs index f5cd1009e6..355b3cc792 100644 --- a/substrate/frame/indices/src/mock.rs +++ b/substrate/frame/indices/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/membership/src/lib.rs b/substrate/frame/membership/src/lib.rs index e9fa5a0630..129f3c4003 100644 --- a/substrate/frame/membership/src/lib.rs +++ b/substrate/frame/membership/src/lib.rs @@ -321,7 +321,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } ord_parameter_types! { diff --git a/substrate/frame/nicks/src/lib.rs b/substrate/frame/nicks/src/lib.rs index ddfd71107f..2ab1789d39 100644 --- a/substrate/frame/nicks/src/lib.rs +++ b/substrate/frame/nicks/src/lib.rs @@ -286,7 +286,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/offences/src/mock.rs b/substrate/frame/offences/src/mock.rs index c617224716..a003ad6915 100644 --- a/substrate/frame/offences/src/mock.rs +++ b/substrate/frame/offences/src/mock.rs @@ -90,7 +90,7 @@ impl frame_system::Trait for Runtime { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/randomness-collective-flip/src/lib.rs b/substrate/frame/randomness-collective-flip/src/lib.rs index 525bbedb40..0ded7dd6b0 100644 --- a/substrate/frame/randomness-collective-flip/src/lib.rs +++ b/substrate/frame/randomness-collective-flip/src/lib.rs @@ -192,7 +192,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/recovery/src/lib.rs b/substrate/frame/recovery/src/lib.rs index d995606e52..d7f5127ee3 100644 --- a/substrate/frame/recovery/src/lib.rs +++ b/substrate/frame/recovery/src/lib.rs @@ -163,7 +163,6 @@ use frame_support::{ traits::{Currency, ReservableCurrency, Get, BalanceStatus}, }; use frame_system::{self as system, ensure_signed, ensure_root}; -use frame_support::traits::MigrateAccount; #[cfg(test)] mod mock; @@ -258,13 +257,6 @@ decl_storage! { } } -impl MigrateAccount for Module { - fn migrate_account(a: &T::AccountId) { - Recoverable::::migrate_key_from_blake(a); - Proxy::::migrate_key_from_blake(a); - } -} - decl_event! { /// Events type. pub enum Event where diff --git a/substrate/frame/recovery/src/mock.rs b/substrate/frame/recovery/src/mock.rs index 3eaba0d6c1..a5b7731c22 100644 --- a/substrate/frame/recovery/src/mock.rs +++ b/substrate/frame/recovery/src/mock.rs @@ -79,7 +79,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/scored-pool/src/mock.rs b/substrate/frame/scored-pool/src/mock.rs index f50e918ee6..a28b789137 100644 --- a/substrate/frame/scored-pool/src/mock.rs +++ b/substrate/frame/scored-pool/src/mock.rs @@ -71,7 +71,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/session/src/historical.rs b/substrate/frame/session/src/historical.rs index 848f6d5599..12b88b347c 100644 --- a/substrate/frame/session/src/historical.rs +++ b/substrate/frame/session/src/historical.rs @@ -67,25 +67,7 @@ decl_storage! { } decl_module! { - pub struct Module for enum Call where origin: T::Origin { - fn on_initialize(_n: T::BlockNumber) { - CachedObsolete::::remove_all(); - } - fn on_runtime_upgrade() { - migration::migrate::(); - } - } -} - -mod migration { - use super::*; - pub fn migrate() { - if let Some((begin, end)) = StoredRange::get() { - for i in begin..end { - HistoricalSessions::::migrate_key_from_blake(i); - } - } - } + pub struct Module for enum Call where origin: T::Origin {} } impl Module { diff --git a/substrate/frame/session/src/lib.rs b/substrate/frame/session/src/lib.rs index 82cacdb516..f4490e50a0 100644 --- a/substrate/frame/session/src/lib.rs +++ b/substrate/frame/session/src/lib.rs @@ -109,7 +109,6 @@ use frame_support::{ensure, decl_module, decl_event, decl_storage, decl_error, C use frame_support::{traits::{Get, FindAuthor, ValidatorRegistration}, Parameter}; use frame_support::dispatch::{self, DispatchResult, DispatchError}; use frame_system::{self as system, ensure_signed}; -use frame_support::traits::MigrateAccount; #[cfg(test)] mod mock; @@ -504,18 +503,6 @@ decl_module! { } } -impl MigrateAccount for Module { - fn migrate_account(a: &T::AccountId) { - if let Some(v) = T::ValidatorIdOf::convert(a.clone()) { - if let Some(keys) = NextKeys::::migrate_key_from_blake(v) { - for id in T::Keys::key_ids() { - KeyOwner::::migrate_key_from_blake((*id, keys.get_raw(*id))); - } - } - } - } -} - impl Module { /// Move on to next session. Register new validator set and session keys. Changes /// to the validator set have a session of delay to take effect. This allows for diff --git a/substrate/frame/session/src/mock.rs b/substrate/frame/session/src/mock.rs index 6a60233222..9d64285b90 100644 --- a/substrate/frame/session/src/mock.rs +++ b/substrate/frame/session/src/mock.rs @@ -179,7 +179,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/society/src/lib.rs b/substrate/frame/society/src/lib.rs index eafd5ec519..03c61ba532 100644 --- a/substrate/frame/society/src/lib.rs +++ b/substrate/frame/society/src/lib.rs @@ -261,7 +261,10 @@ use sp_runtime::{Percent, ModuleId, RuntimeDebug, }; use frame_support::{decl_error, decl_module, decl_storage, decl_event, ensure, dispatch::DispatchResult}; use frame_support::weights::SimpleDispatchInfo; -use frame_support::traits::{Currency, ReservableCurrency, Randomness, Get, ChangeMembers, BalanceStatus, ExistenceRequirement::AllowDeath, MigrateAccount}; +use frame_support::traits::{ + Currency, ReservableCurrency, Randomness, Get, ChangeMembers, BalanceStatus, + ExistenceRequirement::AllowDeath +}; use frame_system::{self as system, ensure_signed, ensure_root}; type BalanceOf = <>::Currency as Currency<::AccountId>>::Balance; @@ -1130,12 +1133,6 @@ decl_event! { } } -impl MigrateAccount for Module { - fn migrate_account(a: &T::AccountId) { - Payouts::::migrate_key_from_blake(a); - } -} - /// Simple ensure origin struct to filter for the founder account. pub struct EnsureFounder(sp_std::marker::PhantomData); impl EnsureOrigin for EnsureFounder { diff --git a/substrate/frame/society/src/mock.rs b/substrate/frame/society/src/mock.rs index b80e0cd2bf..158f139df5 100644 --- a/substrate/frame/society/src/mock.rs +++ b/substrate/frame/society/src/mock.rs @@ -77,7 +77,7 @@ impl frame_system::Trait for Test { type AvailableBlockRatio = AvailableBlockRatio; type Version = (); type ModuleToIndex = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); type AccountData = pallet_balances::AccountData; } diff --git a/substrate/frame/staking/Cargo.toml b/substrate/frame/staking/Cargo.toml index 0bb6c3fd4c..ca21317e5c 100644 --- a/substrate/frame/staking/Cargo.toml +++ b/substrate/frame/staking/Cargo.toml @@ -35,7 +35,6 @@ frame-benchmarking = { version = "2.0.0-alpha.4", path = "../benchmarking" } rand_chacha = { version = "0.2" } [features] -migrate = [] default = ["std"] std = [ "serde", diff --git a/substrate/frame/staking/src/lib.rs b/substrate/frame/staking/src/lib.rs index 312e70963e..4851768074 100644 --- a/substrate/frame/staking/src/lib.rs +++ b/substrate/frame/staking/src/lib.rs @@ -286,7 +286,6 @@ use sp_runtime::{Serialize, Deserialize}; use frame_system::{self as system, ensure_signed, ensure_root}; use sp_phragmen::ExtendedBalance; -use frame_support::traits::MigrateAccount; const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4; pub const MAX_NOMINATIONS: usize = 16; @@ -956,10 +955,6 @@ decl_module! { fn deposit_event() = default; - fn on_runtime_upgrade() { - migrate::(); - } - fn on_finalize() { // Set the start of the first era. if let Some(mut active_era) = Self::active_era() { @@ -1480,30 +1475,6 @@ decl_module! { } } -impl MigrateAccount for Module { - fn migrate_account(a: &T::AccountId) { - if let Some(controller) = Bonded::::migrate_key_from_blake(a) { - Ledger::::migrate_key_from_blake(controller); - Payee::::migrate_key_from_blake(a); - Validators::::migrate_key_from_blake(a); - Nominators::::migrate_key_from_blake(a); - SlashingSpans::::migrate_key_from_blake(a); - } - } -} - -fn migrate() { - if let Some(current_era) = CurrentEra::get() { - let history_depth = HistoryDepth::get(); - for era in current_era.saturating_sub(history_depth)..=current_era { - ErasStartSessionIndex::migrate_key_from_blake(era); - ErasValidatorReward::::migrate_key_from_blake(era); - ErasRewardPoints::::migrate_key_from_blake(era); - ErasTotalStake::::migrate_key_from_blake(era); - } - } -} - impl Module { // PUBLIC IMMUTABLES diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index 381ddf6fa9..8754751629 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -138,7 +138,7 @@ impl frame_system::Trait for Test { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } impl pallet_balances::Trait for Test { diff --git a/substrate/frame/support/src/traits.rs b/substrate/frame/support/src/traits.rs index d36656a740..b25489dbe1 100644 --- a/substrate/frame/support/src/traits.rs +++ b/substrate/frame/support/src/traits.rs @@ -29,13 +29,6 @@ use sp_runtime::{ use crate::dispatch::Parameter; use crate::storage::StorageMap; -/// Migrate a given account. -#[impl_trait_for_tuples::impl_for_tuples(30)] -pub trait MigrateAccount { - /// Migrate the `account`. - fn migrate_account(account: &A); -} - /// An abstraction of a value stored within storage, but possibly as part of a larger composite /// item. pub trait StoredMap { diff --git a/substrate/frame/system/benches/bench.rs b/substrate/frame/system/benches/bench.rs index 03243bbfc4..90a4ad1d34 100644 --- a/substrate/frame/system/benches/bench.rs +++ b/substrate/frame/system/benches/bench.rs @@ -77,7 +77,7 @@ impl system::Trait for Runtime { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index 29167d5b7e..6c30fbd755 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -116,7 +116,7 @@ use frame_support::{ decl_module, decl_event, decl_storage, decl_error, storage, Parameter, ensure, debug, traits::{ Contains, Get, ModuleToIndex, OnNewAccount, OnKilledAccount, IsDeadAccount, Happened, - StoredMap, MigrateAccount, + StoredMap, }, weights::{Weight, DispatchInfo, DispatchClass, SimpleDispatchInfo, FunctionOf}, }; @@ -126,7 +126,6 @@ use codec::{Encode, Decode, FullCodec, EncodeLike}; use sp_io::TestExternalities; pub mod offchain; -mod migration; /// Compute the trie root of a list of extrinsics. pub fn extrinsics_root(extrinsics: &[E]) -> H::Output { @@ -222,9 +221,6 @@ pub trait Trait: 'static + Eq + Clone { /// /// All resources should be cleaned up associated with the given account. type OnKilledAccount: OnKilledAccount; - - /// Migrate an account. - type MigrateAccount: MigrateAccount; } pub type DigestOf = generic::Digest<::Hash>; @@ -460,15 +456,6 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin { type Error = Error; - fn on_runtime_upgrade() { - migration::migrate::(); - - // Remove the old `RuntimeUpgraded` storage entry. - let mut runtime_upgraded_key = sp_io::hashing::twox_128(b"System").to_vec(); - runtime_upgraded_key.extend(&sp_io::hashing::twox_128(b"RuntimeUpgraded")); - sp_io::storage::clear(&runtime_upgraded_key); - } - /// A dispatch that will fill the block weight up to the given ratio. // TODO: This should only be available for testing, rather than in general usage, but // that's not possible at present (since it's within the decl_module macro). @@ -577,21 +564,6 @@ decl_module! { ensure!(account.data == T::AccountData::default(), Error::::NonDefaultComposite); Account::::remove(who); } - - #[weight = FunctionOf( - |(accounts,): (&Vec,)| accounts.len() as u32 * 10_000, - DispatchClass::Normal, - true, - )] - fn migrate_accounts(origin, accounts: Vec) { - let _ = ensure_signed(origin)?; - for a in &accounts { - if Account::::migrate_key_from_blake(a).is_some() { - // Inform other modules about the account. - T::MigrateAccount::migrate_account(a); - } - } - } } } @@ -1570,7 +1542,7 @@ mod tests { type Version = Version; type ModuleToIndex = (); type AccountData = u32; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = RecordKilled; } diff --git a/substrate/frame/system/src/migration.rs b/substrate/frame/system/src/migration.rs deleted file mode 100644 index ece389f4f8..0000000000 --- a/substrate/frame/system/src/migration.rs +++ /dev/null @@ -1,37 +0,0 @@ -use super::*; -use sp_runtime::traits::SaturatedConversion; - -pub fn migrate() { - // Number is current block - we obviously don't know that hash. - // Number - 1 is the parent block, who hash we record in this block, but then that's already - // with the new storage so we don't migrate it. - // Number - 2 is therefore the most recent block's hash that needs migrating. - if Number::::get() > One::one() { - sp_runtime::print("Migrating BlockHash..."); - BlockHash::::migrate_key_from_blake(T::BlockNumber::zero()); - let mut n = Number::::get() - One::one() - One::one(); - while !n.is_zero() { - sp_runtime::print(n.saturated_into::()); - if BlockHash::::migrate_key_from_blake(n).is_none() { - break; - } - n -= One::one(); - } - } - - sp_runtime::print("Migrating Accounts..."); - let mut count = 0u32; - if let Ok(accounts) = Vec::::decode(&mut &include_bytes!("accounts.scale")[..]) { - for a in &accounts { - if Account::::migrate_key_from_blake(a).is_some() { - // Inform other modules about the account. - T::MigrateAccount::migrate_account(a); - count += 1; - if count % 1000 == 0 { - sp_runtime::print(count); - } - } - } - } - sp_runtime::print(count); -} diff --git a/substrate/frame/timestamp/src/lib.rs b/substrate/frame/timestamp/src/lib.rs index 18e3be877b..2a37dfdddb 100644 --- a/substrate/frame/timestamp/src/lib.rs +++ b/substrate/frame/timestamp/src/lib.rs @@ -278,7 +278,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/transaction-payment/src/lib.rs b/substrate/frame/transaction-payment/src/lib.rs index 0306e74edb..a9da383061 100644 --- a/substrate/frame/transaction-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/src/lib.rs @@ -310,7 +310,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } diff --git a/substrate/frame/treasury/src/lib.rs b/substrate/frame/treasury/src/lib.rs index 72f9c508ca..ad3bb419af 100644 --- a/substrate/frame/treasury/src/lib.rs +++ b/substrate/frame/treasury/src/lib.rs @@ -283,22 +283,8 @@ decl_error! { } } -mod migration { - use super::*; - pub fn migrate() { - for i in 0..ProposalCount::get() { - Proposals::::migrate_key_from_blake(i); - } - Reasons::::remove_all(); - } -} - decl_module! { pub struct Module for enum Call where origin: T::Origin { - fn on_runtime_upgrade() { - migration::migrate::(); - } - /// Fraction of a proposal's value that should be bonded in order to place the proposal. /// An accepted proposal gets these back. A rejected proposal does not. const ProposalBond: Permill = T::ProposalBond::get(); @@ -776,7 +762,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/utility/src/lib.rs b/substrate/frame/utility/src/lib.rs index 6ecaadab37..0b60532c3d 100644 --- a/substrate/frame/utility/src/lib.rs +++ b/substrate/frame/utility/src/lib.rs @@ -623,7 +623,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } parameter_types! { diff --git a/substrate/frame/vesting/src/lib.rs b/substrate/frame/vesting/src/lib.rs index 0b670de3b4..94a70b7ef1 100644 --- a/substrate/frame/vesting/src/lib.rs +++ b/substrate/frame/vesting/src/lib.rs @@ -53,7 +53,10 @@ use sp_runtime::{DispatchResult, RuntimeDebug, traits::{ StaticLookup, Zero, AtLeast32Bit, MaybeSerializeDeserialize, Convert }}; use frame_support::{decl_module, decl_event, decl_storage, decl_error, ensure}; -use frame_support::traits::{Currency, LockableCurrency, VestingSchedule, WithdrawReason, LockIdentifier, ExistenceRequirement, Get, MigrateAccount}; +use frame_support::traits::{ + Currency, LockableCurrency, VestingSchedule, WithdrawReason, LockIdentifier, + ExistenceRequirement, Get +}; use frame_support::weights::SimpleDispatchInfo; use frame_system::{self as system, ensure_signed}; @@ -254,12 +257,6 @@ decl_module! { } } -impl MigrateAccount for Module { - fn migrate_account(a: &T::AccountId) { - Vesting::::migrate_key_from_blake(a); - } -} - impl Module { /// (Re)set or remove the module's currency lock on `who`'s account in accordance with their /// current unvested amount. @@ -388,7 +385,7 @@ mod tests { type Version = (); type ModuleToIndex = (); type AccountData = pallet_balances::AccountData; - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); } impl pallet_balances::Trait for Test { diff --git a/substrate/test-utils/runtime/src/lib.rs b/substrate/test-utils/runtime/src/lib.rs index bc5e0070eb..59955cce48 100644 --- a/substrate/test-utils/runtime/src/lib.rs +++ b/substrate/test-utils/runtime/src/lib.rs @@ -391,7 +391,7 @@ impl frame_system::Trait for Runtime { type Version = (); type ModuleToIndex = (); type AccountData = (); - type MigrateAccount = (); type OnNewAccount = (); + type OnNewAccount = (); type OnKilledAccount = (); }