Ensure all StorageVersions on Polkadot/Kusama are correct (#7199)

* Yeah

* Fix all the migrations for Kusama & Polkadot

---------

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
This commit is contained in:
Bastian Köcher
2023-05-17 16:53:01 +02:00
committed by GitHub
parent 750579aab0
commit 676bb648d2
9 changed files with 75 additions and 18 deletions
@@ -446,8 +446,12 @@ pub mod pallet {
type WeightInfo: WeightInfo;
}
/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::pallet]
#[pallet::without_storage_info]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
/// The last pruned session, if any. All data stored by this module
@@ -18,9 +18,6 @@
use frame_support::traits::StorageVersion;
/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
pub mod v1 {
use super::*;
use crate::disputes::{Config, Pallet};
@@ -38,10 +35,10 @@ pub mod v1 {
fn on_runtime_upgrade() -> Weight {
let mut weight: Weight = Weight::zero();
if StorageVersion::get::<Pallet<T>>() < STORAGE_VERSION {
if StorageVersion::get::<Pallet<T>>() < 1 {
log::info!(target: crate::disputes::LOG_TARGET, "Migrating disputes storage to v1");
weight += migrate_to_v1::<T>();
STORAGE_VERSION.put::<Pallet<T>>();
StorageVersion::new(1).put::<Pallet<T>>();
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
} else {
log::info!(
@@ -71,7 +68,7 @@ pub mod v1 {
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
log::trace!(target: crate::disputes::LOG_TARGET, "Running post_upgrade()");
ensure!(
StorageVersion::get::<Pallet<T>>() == STORAGE_VERSION,
StorageVersion::get::<Pallet<T>>() >= 1,
"Storage version should be `1` after the migration"
);
ensure!(
+3 -1
View File
@@ -214,9 +214,11 @@ impl WeightInfo for TestWeightInfo {
pub mod pallet {
use super::*;
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::pallet]
#[pallet::without_storage_info]
#[pallet::storage_version(migration::STORAGE_VERSION)]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pallet::config]
@@ -21,8 +21,6 @@ use frame_support::{
weights::Weight,
};
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
pub mod v1 {
use super::*;