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

Commit

Permalink
Remove lingering runtime upgrades (#6476)
Browse files Browse the repository at this point in the history
* Remove lingering runtime upgrades

* remove unused warnings

* remove tests
  • Loading branch information
shawntabrizi authored Jun 23, 2020
1 parent fed834c commit cf7432a
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 173 deletions.
17 changes: 0 additions & 17 deletions frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ use sp_runtime::{
use codec::{Encode, Decode, Input};
use frame_support::{
decl_module, decl_storage, decl_event, decl_error, ensure, Parameter,
storage::IterableStorageMap,
weights::{Weight, DispatchClass},
traits::{
Currency, ReservableCurrency, LockableCurrency, WithdrawReason, LockIdentifier, Get,
Expand Down Expand Up @@ -602,22 +601,6 @@ decl_module! {

fn deposit_event() = default;

fn on_runtime_upgrade() -> Weight {
if let None = StorageVersion::get() {
StorageVersion::put(Releases::V1);

DepositOf::<T>::translate::<
(BalanceOf<T>, Vec<T::AccountId>), _
>(|_, (balance, accounts)| {
Some((accounts, balance))
});

T::MaximumBlockWeight::get()
} else {
T::DbWeight::get().reads(1)
}
}

/// Propose a sensitive action to be taken.
///
/// The dispatch origin of this call must be _Signed_ and the sender must
Expand Down
1 change: 0 additions & 1 deletion frame/democracy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ mod preimage;
mod public_proposals;
mod scheduling;
mod voting;
mod migration;
mod decoders;

const AYE: Vote = Vote { aye: true, conviction: Conviction::None };
Expand Down
45 changes: 0 additions & 45 deletions frame/democracy/src/tests/migration.rs

This file was deleted.

12 changes: 1 addition & 11 deletions frame/indices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use sp_runtime::traits::{
StaticLookup, Member, LookupError, Zero, Saturating, AtLeast32Bit
};
use frame_support::{Parameter, decl_module, decl_error, decl_event, decl_storage, ensure};
use frame_support::dispatch::{DispatchResult, Weight};
use frame_support::dispatch::DispatchResult;
use frame_support::traits::{Currency, ReservableCurrency, Get, BalanceStatus::Reserved};
use frame_support::weights::constants::WEIGHT_PER_MICROS;
use frame_system::{ensure_signed, ensure_root};
Expand Down Expand Up @@ -104,16 +104,6 @@ decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system = frame_system {
fn deposit_event() = default;

fn on_runtime_upgrade() -> Weight {
use frame_support::migration::{StorageIterator, put_storage_value};
for (key, value) in StorageIterator::<
(T::AccountId, BalanceOf<T>)
>::new(b"Indices", b"Accounts").drain() {
put_storage_value(b"Indices", b"Accounts", &key, (value.0, value.1, false));
}
1_000_000_000
}

/// Assign an previously unassigned index.
///
/// Payment: `Deposit` is reserved from the sender account.
Expand Down
11 changes: 0 additions & 11 deletions frame/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,6 @@ decl_module! {
/// Deposit one of this module's events by using the default implementation.
fn deposit_event() = default;

fn on_runtime_upgrade() -> Weight {
// Utility.Multisigs -> Multisig.Multisigs
use frame_support::migration::{StorageIterator, put_storage_value};
for (key, value) in StorageIterator::<
Multisig<T::BlockNumber, BalanceOf<T>, T::AccountId>
>::new(b"Utility", b"Multisigs").drain() {
put_storage_value(b"Multisig", b"Multisigs", &key, value);
}
1_000_000_000
}

/// Immediately dispatch a multi-signature call using a single approval from the caller.
///
/// The dispatch origin for this call must be _Signed_.
Expand Down
28 changes: 3 additions & 25 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,9 +1278,9 @@ decl_module! {
/// Number of eras that staked funds must remain bonded for.
const BondingDuration: EraIndex = T::BondingDuration::get();

/// Number of eras that slashes are deferred by, after computation.
/// Number of eras that slashes are deferred by, after computation.
///
/// This should be less than the bonding duration.
/// This should be less than the bonding duration.
/// Set to 0 if slashes should be applied immediately, without opportunity for
/// intervention.
const SlashDeferDuration: EraIndex = T::SlashDeferDuration::get();
Expand All @@ -1294,7 +1294,7 @@ decl_module! {
/// length of a session will be pointless.
const ElectionLookahead: T::BlockNumber = T::ElectionLookahead::get();

/// Maximum number of balancing iterations to run in the offchain submission.
/// Maximum number of balancing iterations to run in the offchain submission.
///
/// If set to 0, balance_solution will not be executed at all.
const MaxIterations: u32 = T::MaxIterations::get();
Expand All @@ -1312,28 +1312,6 @@ decl_module! {

fn deposit_event() = default;

fn on_runtime_upgrade() -> Weight {
#[allow(dead_code)]
mod inner {
pub struct Module<T>(sp_std::marker::PhantomData<T>);
frame_support::decl_storage! {
trait Store for Module<T: super::Trait> as Staking {
pub MigrateEra: Option<super::EraIndex>;
}
}
}

if let Releases::V3_0_0 = StorageVersion::get() {
StorageVersion::put(Releases::V4_0_0);
inner::MigrateEra::kill();

T::DbWeight::get().reads_writes(1, 1)
} else {
T::DbWeight::get().reads(1)
}
}


/// sets `ElectionStatus` to `Open(now)` where `now` is the block number at which the
/// election window has opened, if we are at the last session and less blocks than
/// `T::ElectionLookahead` is remaining until the next new session schedule. The offchain
Expand Down
63 changes: 0 additions & 63 deletions frame/transaction-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,38 +230,6 @@ decl_module! {
).unwrap(),
);
}

fn on_runtime_upgrade() -> Weight {
use frame_support::migration::take_storage_value;
use sp_std::convert::TryInto;
use frame_support::debug::native::error;

type OldMultiplier = sp_runtime::FixedI128;
type OldInner = <OldMultiplier as FixedPointNumber>::Inner;
type Inner = <Multiplier as FixedPointNumber>::Inner;

if let Releases::V1Ancient = StorageVersion::get() {
StorageVersion::put(Releases::V2);

if let Some(old) = take_storage_value::<OldMultiplier>(
b"TransactionPayment",
b"NextFeeMultiplier",
&[],
) {
let inner = old.into_inner();
let new_inner = <OldInner as TryInto<Inner>>::try_into(inner)
.unwrap_or_default();
let new = Multiplier::from_inner(new_inner);
NextFeeMultiplier::put(new);
T::DbWeight::get().reads_writes(1, 1)
} else {
error!("transaction-payment migration failed.");
T::DbWeight::get().reads(1)
}
} else {
T::DbWeight::get().reads(1)
}
}
}
}

Expand Down Expand Up @@ -740,37 +708,6 @@ mod tests {
PostDispatchInfo { actual_weight: None, }
}

#[test]
fn migration_to_v2_works() {
use sp_runtime::FixedI128;
use frame_support::traits::OnRuntimeUpgrade;

let with_old_multiplier = |mul: FixedI128, expected: FixedU128| {
ExtBuilder::default().build().execute_with(|| {
frame_support::migration::put_storage_value(
b"TransactionPayment",
b"NextFeeMultiplier",
&[],
mul,
);

assert_eq!(StorageVersion::get(), Releases::V1Ancient);

TransactionPayment::on_runtime_upgrade();

assert_eq!(StorageVersion::get(), Releases::V2);
assert_eq!(NextFeeMultiplier::get(), expected);
})
};

with_old_multiplier(FixedI128::saturating_from_integer(-1), FixedU128::zero());
with_old_multiplier(FixedI128::saturating_from_rational(-1, 2), FixedU128::zero());
with_old_multiplier(
FixedI128::saturating_from_rational(1, 2),
FixedU128::saturating_from_rational(1, 2),
);
}

#[test]
fn signed_extension_transaction_payment_work() {
ExtBuilder::default()
Expand Down

0 comments on commit cf7432a

Please sign in to comment.