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 1 commit
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
Next Next commit
remove old migration code
  • Loading branch information
shawntabrizi committed May 2, 2020
commit c0df5cee0726c55d707ad8cc9cc77e2ea4ee994a
25 changes: 0 additions & 25 deletions frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,6 @@ decl_module! {

fn deposit_event() = default;

fn on_runtime_upgrade() -> Weight {
Self::migrate();

0
}

/// Propose a sensitive action to be taken.
///
/// The dispatch origin of this call must be _Signed_ and the sender must
Expand Down Expand Up @@ -1268,25 +1262,6 @@ decl_module! {
}

impl<T: Trait> Module<T> {
fn migrate() {
use frame_support::{Twox64Concat, migration::{StorageKeyIterator, remove_storage_prefix}};
remove_storage_prefix(b"Democracy", b"VotesOf", &[]);
remove_storage_prefix(b"Democracy", b"VotersFor", &[]);
remove_storage_prefix(b"Democracy", b"Delegations", &[]);
for (who, (end, proposal_hash, threshold, delay))
in StorageKeyIterator::<
ReferendumIndex,
(T::BlockNumber, T::Hash, VoteThreshold, T::BlockNumber),
Twox64Concat,
>::new(b"Democracy", b"ReferendumInfoOf").drain()
{
let status = ReferendumStatus {
end, proposal_hash, threshold, delay, tally: Tally::default()
};
ReferendumInfoOf::<T>::insert(who, ReferendumInfo::Ongoing(status))
}
}

// exposed immutables.

/// Get the amount locked in support of `proposal`; `None` if proposal isn't a valid proposal
Expand Down
8 changes: 0 additions & 8 deletions frame/offences/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
fn deposit_event() = default;

fn on_runtime_upgrade() -> Weight {
Reports::<T>::remove_all();
ConcurrentReportsIndex::<T>::remove_all();
ReportsByKindIndex::remove_all();

0
}

fn on_initialize(now: T::BlockNumber) -> Weight {
// only decode storage if we can actually submit anything again.
if T::OnOffenceHandler::can_report() {
Expand Down
49 changes: 0 additions & 49 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,18 +1246,6 @@ decl_module! {
}
}

fn on_runtime_upgrade() -> Weight {
// For Kusama the type hasn't actually changed as Moment was u64 and was the number of
// millisecond since unix epoch.
StorageVersion::mutate(|v| {
if matches!(v, Releases::V2_0_0) {
Self::migrate_last_reward_to_claimed_rewards();
}
*v = Releases::V3_0_0;
});
0
}

/// Take the origin account as a stash and lock up `value` of its balance. `controller` will
/// be the account that controls it.
///
Expand Down Expand Up @@ -1935,43 +1923,6 @@ decl_module! {
}

impl<T: Trait> Module<T> {
/// Migrate `last_reward` to `claimed_rewards`
pub fn migrate_last_reward_to_claimed_rewards() {
use frame_support::migration::{StorageIterator, put_storage_value};
// Migrate from `last_reward` to `claimed_rewards`.
// We will construct a vector from `current_era - history_depth` to `last_reward`
// for each validator and nominator.
//
// Old Staking Ledger
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
struct OldStakingLedger<AccountId, Balance: HasCompact> {
pub stash: AccountId,
#[codec(compact)]
pub total: Balance,
#[codec(compact)]
pub active: Balance,
pub unlocking: Vec<UnlockChunk<Balance>>,
pub last_reward: Option<EraIndex>,
}
// Current era and history depth
let current_era = Self::current_era().unwrap_or(0);
let history_depth = Self::history_depth();
let last_payout_era = current_era.saturating_sub(history_depth);
// Convert all ledgers to the new format.
for (hash, old_ledger) in StorageIterator::<OldStakingLedger<T::AccountId, BalanceOf<T>>>::new(b"Staking", b"Ledger").drain() {
let last_reward = old_ledger.last_reward.unwrap_or(0);
let new_ledger = StakingLedger {
stash: old_ledger.stash,
total: old_ledger.total,
active: old_ledger.active,
unlocking: old_ledger.unlocking,
claimed_rewards: (last_payout_era..=last_reward).collect(),
};
put_storage_value(b"Staking", b"Ledger", &hash, new_ledger);
}
MigrateEra::put(current_era);
}

/// The total balance that can be slashed from a stash account as of right now.
pub fn slashable_balance_of(stash: &T::AccountId) -> BalanceOf<T> {
Self::bonded(stash).and_then(Self::ledger).map(|l| l.active).unwrap_or_default()
Expand Down
14 changes: 0 additions & 14 deletions frame/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ decl_module! {
*fm = T::FeeMultiplierUpdate::convert(*fm)
});
}

fn on_runtime_upgrade() -> Weight {
// TODO: Remove this code after on-chain upgrade from u32 to u64 weights
use sp_runtime::Fixed64;
use frame_support::migration::take_storage_value;
if let Some(old_next_fee_multiplier) = take_storage_value::<Fixed64>(b"TransactionPayment", b"NextFeeMultiplier", &[]) {
let raw_multiplier = old_next_fee_multiplier.into_inner() as i128;
// Fixed64 used 10^9 precision, where Fixed128 uses 10^18, so we need to add 9 zeros.
let new_raw_multiplier: i128 = raw_multiplier.saturating_mul(1_000_000_000);
let new_next_fee_multiplier: Fixed128 = Fixed128::from_parts(new_raw_multiplier);
NextFeeMultiplier::put(new_next_fee_multiplier);
}
0
}
}
}

Expand Down