Skip to content

Commit

Permalink
Add balances pallet migration with no accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn-x2 committed Feb 1, 2023
1 parent 5ea142e commit c1fd840
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
13 changes: 11 additions & 2 deletions runtimes/common/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ use sp_std::marker::PhantomData;

use ctype::{CtypeCreatorOf, CtypeEntryOf};

#[cfg(feature = "try-runtime")]
use sp_std::vec::Vec;
use sp_std::{vec, vec::Vec};

use crate::AccountId;

pub struct AddCTypeBlockNumber<R>(PhantomData<R>);

Expand Down Expand Up @@ -289,3 +290,11 @@ where
Self::migrate()
}
}

// Used for the balances pallet migration.
pub struct EmptyAccountlist;
impl Get<Vec<AccountId>> for EmptyAccountlist {
fn get() -> Vec<AccountId> {
vec![]
}
}
8 changes: 6 additions & 2 deletions runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use runtime_common::{
constants::{self, UnvestedFundsAllowedWithdrawReasons, EXISTENTIAL_DEPOSIT, KILT},
errors::PublicCredentialsApiError,
fees::{ToAuthor, WeightToFee},
migrations::EmptyAccountlist,
pallet_id, AccountId, AuthorityId, Balance, BlockHashCount, BlockLength, BlockNumber, BlockWeights, DidIdentifier,
FeeSplit, Hash, Header, Index, Signature, SlowAdjustingFeeUpdate,
};
Expand Down Expand Up @@ -1069,8 +1070,11 @@ pub type Executive = frame_executive::Executive<
pallet_democracy::migrations::v1::Migration<Runtime>,
// "Scheduler: remove empty agenda on cancel" https://github.com/paritytech/substrate/pull/12989
pallet_scheduler::migration::v4::CleanupAgendas<Runtime>,
// NOT INCLUDED: "API for registering inactive funds" https://github.com/paritytech/substrate/pull/12813
// pallet_balances::migration::MigrateToTrackInactive<...>
// "API for registering inactive funds" https://github.com/paritytech/substrate/pull/12813
// We don't consider any account beyond the treasury (done automatically by the treasury) as having funds
// deactivated.
// TODO: Consider to mark the pure proxy funds as deactivated in the next release.
pallet_balances::migration::MigrateManyToTrackInactive<Runtime, EmptyAccountlist>,
runtime_common::migrations::AddCTypeBlockNumber<Runtime>,
// The migration above must be run as last since it checks that all pallets are using the new StorageVersion
// properly.
Expand Down
8 changes: 6 additions & 2 deletions runtimes/spiritnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ use runtime_common::{
constants::{self, UnvestedFundsAllowedWithdrawReasons, EXISTENTIAL_DEPOSIT, KILT},
errors::PublicCredentialsApiError,
fees::{ToAuthor, WeightToFee},
migrations::EmptyAccountlist,
pallet_id, AccountId, AuthorityId, Balance, BlockHashCount, BlockLength, BlockNumber, BlockWeights, DidIdentifier,
FeeSplit, Hash, Header, Index, Signature, SlowAdjustingFeeUpdate,
};
Expand Down Expand Up @@ -1063,8 +1064,11 @@ pub type Executive = frame_executive::Executive<
pallet_democracy::migrations::v1::Migration<Runtime>,
// "Scheduler: remove empty agenda on cancel" https://github.com/paritytech/substrate/pull/12989
pallet_scheduler::migration::v4::CleanupAgendas<Runtime>,
// NOT INCLUDED: "API for registering inactive funds" https://github.com/paritytech/substrate/pull/12813
// pallet_balances::migration::MigrateToTrackInactive<...>
// "API for registering inactive funds" https://github.com/paritytech/substrate/pull/12813
// We don't consider any account beyond the treasury (done automatically by the treasury) as having funds
// deactivated.
// TODO: Consider to mark the pure proxy funds as deactivated in the next release.
pallet_balances::migration::MigrateManyToTrackInactive<Runtime, EmptyAccountlist>,
runtime_common::migrations::AddCTypeBlockNumber<Runtime>,
// The migration above must be run as last since it checks that all pallets are using the new StorageVersion
// properly.
Expand Down

0 comments on commit c1fd840

Please sign in to comment.