Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
360 changes: 180 additions & 180 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions runtime/common/src/crowdloan/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@ use frame_support::{
Twox64Concat,
};

pub struct MigrateToTrackInactive<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactive<T> {
pub struct MigrateToTrackInactiveV2<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactiveV2<T> {
fn on_runtime_upgrade() -> Weight {
let onchain_version = Pallet::<T>::on_chain_storage_version();

if onchain_version == 0 {
if onchain_version == 1 {
let mut translated = 0u64;
for index in Funds::<T>::iter_keys() {
let b = CurrencyOf::<T>::total_balance(&Pallet::<T>::fund_account_id(index.into()));
for item in Funds::<T>::iter_values() {
let b =
CurrencyOf::<T>::total_balance(&Pallet::<T>::fund_account_id(item.fund_index));
CurrencyOf::<T>::deactivate(b);
translated.saturating_inc();
}

StorageVersion::new(1).put::<Pallet<T>>();
StorageVersion::new(2).put::<Pallet<T>>();
log::info!(target: "runtime::crowdloan", "Summed {} funds, storage to version 1", translated);
T::DbWeight::get().reads_writes(translated * 2 + 1, translated * 2 + 1)
} else {
Expand All @@ -46,9 +47,9 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactive<T> {

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, &'static str> {
let total = Funds::<T>::iter_keys()
.map(|index| {
CurrencyOf::<T>::total_balance(&Pallet::<T>::fund_account_id(index.into()))
let total = Funds::<T>::iter_values()
.map(|item| {
CurrencyOf::<T>::total_balance(&Pallet::<T>::fund_account_id(item.fund_index))
})
.fold(BalanceOf::<T>::zero(), |a, i| a.saturating_add(i));
Ok((total, CurrencyOf::<T>::active_issuance()).encode())
Expand Down
2 changes: 0 additions & 2 deletions runtime/common/src/crowdloan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@

pub mod migration;

// TODO: Expose the total amount held.

use crate::{
slot_range::SlotRange,
traits::{Auctioneer, Registrar},
Expand Down
3 changes: 2 additions & 1 deletion runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1481,8 +1481,9 @@ impl Get<&'static str> for StakingMigrationV11OldPallet {
}

pub type Migrations = (
pallet_balances::migration::ResetInactive<Runtime>,
pallet_balances::migration::MigrateToTrackInactive<Runtime, CheckAccount>,
crowdloan::migration::MigrateToTrackInactive<Runtime>,
crowdloan::migration::MigrateToTrackInactiveV2<Runtime>,
pallet_referenda::migration::v1::MigrateV0ToV1<Runtime>,
pallet_referenda::migration::v1::MigrateV0ToV1<
Runtime,
Expand Down
3 changes: 2 additions & 1 deletion runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,9 @@ impl Get<&'static str> for StakingMigrationV11OldPallet {
}

pub type Migrations = (
pallet_balances::migration::ResetInactive<Runtime>,
pallet_balances::migration::MigrateToTrackInactive<Runtime, xcm_config::CheckAccount>,
crowdloan::migration::MigrateToTrackInactive<Runtime>,
crowdloan::migration::MigrateToTrackInactiveV2<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
Expand Down
3 changes: 2 additions & 1 deletion runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,8 +1478,9 @@ pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;

pub type Migrations = (
pallet_balances::migration::ResetInactive<Runtime>,
pallet_balances::migration::MigrateToTrackInactive<Runtime, xcm_config::CheckAccount>,
crowdloan::migration::MigrateToTrackInactive<Runtime>,
crowdloan::migration::MigrateToTrackInactiveV2<Runtime>,
);

/// Executive: handles dispatch to the various modules.
Expand Down
3 changes: 2 additions & 1 deletion runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,9 @@ impl Get<&'static str> for StakingMigrationV11OldPallet {
}

pub type Migrations = (
pallet_balances::migration::ResetInactive<Runtime>,
pallet_balances::migration::MigrateToTrackInactive<Runtime, xcm_config::CheckAccount>,
crowdloan::migration::MigrateToTrackInactive<Runtime>,
crowdloan::migration::MigrateToTrackInactiveV2<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
Expand Down