mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Remove Executed Migrations (#7495)
* Polkadot is at .42 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Kusama is on .43 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Westend is at .43 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rococo is at .42 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Make UMP limits migration more idempotentish Already 100% idempotent per design, but not it wont try to schedule an unneeded upgrade. Note that the case that the new upgrade is already scheduled is not checked. In that case it will still upgrade the same thing again, but should be no problem. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Clippy Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Delete old migration code Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove old tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Polkadot is at .43 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove a ton of shit Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove more Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove unused code Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Rococo is NOT yet at .43, but remove anyway Rococo is the only runtime that is not yet at .43, but keeping the migration code just for it is not worth it since devops can just apply it at any time. Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Remove old test Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: parity-processbot <>
This commit is contained in:
committed by
GitHub
parent
a1eadbff3b
commit
3bbb336ea7
@@ -27,7 +27,6 @@ pub mod impls;
|
||||
pub mod paras_registrar;
|
||||
pub mod paras_sudo_wrapper;
|
||||
pub mod purchase;
|
||||
pub mod session;
|
||||
pub mod slot_range;
|
||||
pub mod slots;
|
||||
pub mod traits;
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use frame_support::{
|
||||
storage::storage_prefix,
|
||||
traits::{Get, OnRuntimeUpgrade},
|
||||
weights::Weight,
|
||||
};
|
||||
use pallet_session::Config;
|
||||
use sp_io::{storage::clear_prefix, KillStorageResult};
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
/// This migration clears everything under `Session::HistoricalSessions`
|
||||
/// and `Session::StoredRange` that were not cleared when
|
||||
/// the pallet was moved to its new prefix (`Historical`)
|
||||
pub struct ClearOldSessionStorage<T>(sp_std::marker::PhantomData<T>);
|
||||
impl<T: Config> OnRuntimeUpgrade for ClearOldSessionStorage<T> {
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
let prefix = storage_prefix(b"Session", b"StoredRange");
|
||||
let keys_removed_stored_range = match clear_prefix(&prefix, None) {
|
||||
KillStorageResult::AllRemoved(value) => value,
|
||||
KillStorageResult::SomeRemaining(value) => {
|
||||
log::error!(
|
||||
"`clear_prefix` failed to remove all keys. THIS SHOULD NEVER HAPPEN! 🚨",
|
||||
);
|
||||
value
|
||||
},
|
||||
} as u64;
|
||||
|
||||
let prefix = storage_prefix(b"Session", b"HistoricalSessions");
|
||||
let keys_removed_historical_sessions = match clear_prefix(&prefix, None) {
|
||||
KillStorageResult::AllRemoved(value) => value,
|
||||
KillStorageResult::SomeRemaining(value) => {
|
||||
log::error!(
|
||||
"`clear_prefix` failed to remove all keys. THIS SHOULD NEVER HAPPEN! 🚨",
|
||||
);
|
||||
value
|
||||
},
|
||||
} as u64;
|
||||
|
||||
let keys_removed = keys_removed_stored_range + keys_removed_historical_sessions;
|
||||
log::info!("Removed {} keys 🧹", keys_removed);
|
||||
|
||||
T::DbWeight::get().reads_writes(keys_removed, keys_removed)
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod migration;
|
||||
Reference in New Issue
Block a user