Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[frame/im-online] remove ensure from pre_upgrade #14401

Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 11 additions & 2 deletions frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,17 @@ where

log::info!(target: LOG_TARGET, "Total accounts: {:?}", all_accounts.len());
log::info!(target: LOG_TARGET, "Total stake to unlock: {:?}", total_stake_to_unlock);
log::info!(target: LOG_TARGET, "Total deposit to unreserve: {:?}", total_deposits_to_unreserve);
log::info!(target: LOG_TARGET, "Bugged deposits: {}/{}", bugged_deposits, account_deposits.len());
log::info!(
target: LOG_TARGET,
"Total deposit to unreserve: {:?}",
total_deposits_to_unreserve
);
log::info!(
target: LOG_TARGET,
"Bugged deposits: {}/{}",
bugged_deposits,
account_deposits.len()
);

Ok(account_reserved_before.encode())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,20 @@ where
let total_stake_to_unlock = account_staked_sums.clone().into_values().sum::<BalanceOf<T>>();
let total_deposits_to_unreserve =
account_deposited_sums.clone().into_values().sum::<BalanceOf<T>>();
log::info!(target: LOG_TARGET, "Total accounts: {:?}", all_accounts.len());
log::info!(target: LOG_TARGET, "Total accounts: {:?}", all_accounts.len());
log::info!(target: LOG_TARGET, "Total stake to unlock: {:?}", total_stake_to_unlock);
log::info!(target: LOG_TARGET, "Total deposit to unreserve: {:?}", total_deposits_to_unreserve);
log::info!(
target: LOG_TARGET,
"Total deposit to unreserve: {:?}",
total_deposits_to_unreserve
);
if bugged_deposits > 0 {
log::warn!(target: LOG_TARGET, "Bugged deposits: {}/{}", bugged_deposits, all_accounts.len());
log::warn!(
target: LOG_TARGET,
"Bugged deposits: {}/{}",
bugged_deposits,
all_accounts.len()
);
}

Ok(account_reserved_before.encode())
Expand Down
4 changes: 1 addition & 3 deletions frame/im-online/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ pub mod v1 {
impl<T: Config> OnRuntimeUpgrade for Migration<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
ensure!(StorageVersion::get::<Pallet<T>>() == 0, "can only upgrade from version 0");

let count = v0::ReceivedHeartbeats::<T>::iter().count();
log::info!(target: TARGET, "Migrating {} received heartbeats", count);

Expand Down Expand Up @@ -111,7 +109,7 @@ pub mod v1 {
old_received_heartbeats
);
}
ensure!(StorageVersion::get::<Pallet<T>>() == 1, "must upgrade");
ensure!(StorageVersion::get::<Pallet<T>>() >= 1, "must upgrade");

Ok(())
}
Expand Down