mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 18:05:41 +00:00
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:
@@ -183,7 +183,7 @@ pub mod pallet {
|
|||||||
use frame_system::{ensure_root, ensure_signed, pallet_prelude::*};
|
use frame_system::{ensure_root, ensure_signed, pallet_prelude::*};
|
||||||
|
|
||||||
/// The current storage version.
|
/// The current storage version.
|
||||||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
|
||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::without_storage_info]
|
#[pallet::without_storage_info]
|
||||||
|
|||||||
@@ -1468,6 +1468,7 @@ pub type Migrations =
|
|||||||
#[allow(deprecated, missing_docs)]
|
#[allow(deprecated, missing_docs)]
|
||||||
pub mod migrations {
|
pub mod migrations {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion};
|
||||||
|
|
||||||
pub type V0940 = (
|
pub type V0940 = (
|
||||||
pallet_nomination_pools::migration::v4::MigrateToV4<
|
pallet_nomination_pools::migration::v4::MigrateToV4<
|
||||||
@@ -1484,7 +1485,29 @@ pub mod migrations {
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// Unreleased migrations. Add new ones here:
|
/// Unreleased migrations. Add new ones here:
|
||||||
pub type Unreleased = ();
|
pub type Unreleased = SetStorageVersions;
|
||||||
|
|
||||||
|
/// Migrations that set `StorageVersion`s we missed to set.
|
||||||
|
pub struct SetStorageVersions;
|
||||||
|
|
||||||
|
impl OnRuntimeUpgrade for SetStorageVersions {
|
||||||
|
fn on_runtime_upgrade() -> Weight {
|
||||||
|
// The `NisCounterpartBalances` pallet was added to the chain after/with the migration.
|
||||||
|
// So, the migration never needed to be executed, but we also did not set the proper `StorageVersion`.
|
||||||
|
let storage_version = NisCounterpartBalances::on_chain_storage_version();
|
||||||
|
if storage_version < 1 {
|
||||||
|
StorageVersion::new(1).put::<NisCounterpartBalances>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Was missed as part of: `runtime_common::session::migration::ClearOldSessionStorage<Runtime>`.
|
||||||
|
let storage_version = Historical::on_chain_storage_version();
|
||||||
|
if storage_version < 1 {
|
||||||
|
StorageVersion::new(1).put::<Historical>();
|
||||||
|
}
|
||||||
|
|
||||||
|
RocksDbWeight::get().reads_writes(2, 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unchecked extrinsic type as expected by this runtime.
|
/// Unchecked extrinsic type as expected by this runtime.
|
||||||
|
|||||||
@@ -446,8 +446,12 @@ pub mod pallet {
|
|||||||
type WeightInfo: WeightInfo;
|
type WeightInfo: WeightInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The current storage version.
|
||||||
|
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::without_storage_info]
|
#[pallet::without_storage_info]
|
||||||
|
#[pallet::storage_version(STORAGE_VERSION)]
|
||||||
pub struct Pallet<T>(_);
|
pub struct Pallet<T>(_);
|
||||||
|
|
||||||
/// The last pruned session, if any. All data stored by this module
|
/// The last pruned session, if any. All data stored by this module
|
||||||
|
|||||||
@@ -18,9 +18,6 @@
|
|||||||
|
|
||||||
use frame_support::traits::StorageVersion;
|
use frame_support::traits::StorageVersion;
|
||||||
|
|
||||||
/// The current storage version.
|
|
||||||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
|
||||||
|
|
||||||
pub mod v1 {
|
pub mod v1 {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::disputes::{Config, Pallet};
|
use crate::disputes::{Config, Pallet};
|
||||||
@@ -38,10 +35,10 @@ pub mod v1 {
|
|||||||
fn on_runtime_upgrade() -> Weight {
|
fn on_runtime_upgrade() -> Weight {
|
||||||
let mut weight: Weight = Weight::zero();
|
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");
|
log::info!(target: crate::disputes::LOG_TARGET, "Migrating disputes storage to v1");
|
||||||
weight += migrate_to_v1::<T>();
|
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));
|
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));
|
||||||
} else {
|
} else {
|
||||||
log::info!(
|
log::info!(
|
||||||
@@ -71,7 +68,7 @@ pub mod v1 {
|
|||||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
|
fn post_upgrade(_state: Vec<u8>) -> Result<(), &'static str> {
|
||||||
log::trace!(target: crate::disputes::LOG_TARGET, "Running post_upgrade()");
|
log::trace!(target: crate::disputes::LOG_TARGET, "Running post_upgrade()");
|
||||||
ensure!(
|
ensure!(
|
||||||
StorageVersion::get::<Pallet<T>>() == STORAGE_VERSION,
|
StorageVersion::get::<Pallet<T>>() >= 1,
|
||||||
"Storage version should be `1` after the migration"
|
"Storage version should be `1` after the migration"
|
||||||
);
|
);
|
||||||
ensure!(
|
ensure!(
|
||||||
|
|||||||
@@ -214,9 +214,11 @@ impl WeightInfo for TestWeightInfo {
|
|||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::without_storage_info]
|
#[pallet::without_storage_info]
|
||||||
#[pallet::storage_version(migration::STORAGE_VERSION)]
|
#[pallet::storage_version(STORAGE_VERSION)]
|
||||||
pub struct Pallet<T>(_);
|
pub struct Pallet<T>(_);
|
||||||
|
|
||||||
#[pallet::config]
|
#[pallet::config]
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ use frame_support::{
|
|||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
|
||||||
|
|
||||||
pub mod v1 {
|
pub mod v1 {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|||||||
@@ -1437,13 +1437,24 @@ impl Get<Perbill> for NominationPoolsMigrationV4OldPallet {
|
|||||||
///
|
///
|
||||||
/// This contains the combined migrations of the last 10 releases. It allows to skip runtime
|
/// This contains the combined migrations of the last 10 releases. It allows to skip runtime
|
||||||
/// upgrades in case governance decides to do so. THE ORDER IS IMPORTANT.
|
/// upgrades in case governance decides to do so. THE ORDER IS IMPORTANT.
|
||||||
pub type Migrations =
|
pub type Migrations = (
|
||||||
(migrations::V0940, migrations::V0941, migrations::V0942, migrations::Unreleased);
|
migrations::V0938,
|
||||||
|
migrations::V0940,
|
||||||
|
migrations::V0941,
|
||||||
|
migrations::V0942,
|
||||||
|
migrations::Unreleased,
|
||||||
|
);
|
||||||
|
|
||||||
/// The runtime migrations per release.
|
/// The runtime migrations per release.
|
||||||
#[allow(deprecated, missing_docs)]
|
#[allow(deprecated, missing_docs)]
|
||||||
pub mod migrations {
|
pub mod migrations {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion};
|
||||||
|
|
||||||
|
pub type V0938 = (
|
||||||
|
pallet_xcm::migration::v1::MigrateToV1<Runtime>,
|
||||||
|
parachains_ump::migration::v1::MigrateToV1<Runtime>,
|
||||||
|
);
|
||||||
|
|
||||||
pub type V0940 = (
|
pub type V0940 = (
|
||||||
pallet_nomination_pools::migration::v4::MigrateToV4<
|
pallet_nomination_pools::migration::v4::MigrateToV4<
|
||||||
@@ -1460,7 +1471,29 @@ pub mod migrations {
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// Unreleased migrations. Add new ones here:
|
/// Unreleased migrations. Add new ones here:
|
||||||
pub type Unreleased = ();
|
pub type Unreleased = SetStorageVersions;
|
||||||
|
|
||||||
|
/// Migrations that set `StorageVersion`s we missed to set.
|
||||||
|
pub struct SetStorageVersions;
|
||||||
|
|
||||||
|
impl OnRuntimeUpgrade for SetStorageVersions {
|
||||||
|
fn on_runtime_upgrade() -> Weight {
|
||||||
|
// `Referenda` pallet was added on chain after the migration to version `1` was added.
|
||||||
|
// Thus, it never required the migration and we just missed to set the correct `StorageVersion`.
|
||||||
|
let storage_version = Referenda::on_chain_storage_version();
|
||||||
|
if storage_version < 1 {
|
||||||
|
StorageVersion::new(1).put::<Referenda>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Was missed as part of: `runtime_common::session::migration::ClearOldSessionStorage<Runtime>`.
|
||||||
|
let storage_version = Historical::on_chain_storage_version();
|
||||||
|
if storage_version < 1 {
|
||||||
|
StorageVersion::new(1).put::<Historical>();
|
||||||
|
}
|
||||||
|
|
||||||
|
RocksDbWeight::get().reads_writes(2, 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unchecked extrinsic type as expected by this runtime.
|
/// Unchecked extrinsic type as expected by this runtime.
|
||||||
|
|||||||
@@ -162,8 +162,10 @@ pub mod pallet {
|
|||||||
pub const CurrentXcmVersion: u32 = XCM_VERSION;
|
pub const CurrentXcmVersion: u32 = XCM_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||||
|
|
||||||
#[pallet::pallet]
|
#[pallet::pallet]
|
||||||
#[pallet::storage_version(migration::STORAGE_VERSION)]
|
#[pallet::storage_version(STORAGE_VERSION)]
|
||||||
#[pallet::without_storage_info]
|
#[pallet::without_storage_info]
|
||||||
pub struct Pallet<T>(_);
|
pub struct Pallet<T>(_);
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ use frame_support::{
|
|||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
|
||||||
|
|
||||||
const DEFAULT_PROOF_SIZE: u64 = 64 * 1024;
|
const DEFAULT_PROOF_SIZE: u64 = 64 * 1024;
|
||||||
|
|
||||||
pub mod v1 {
|
pub mod v1 {
|
||||||
@@ -51,7 +49,7 @@ pub mod v1 {
|
|||||||
VersionNotifyTargets::<T>::translate_values(translate);
|
VersionNotifyTargets::<T>::translate_values(translate);
|
||||||
|
|
||||||
log::info!("v1 applied successfully");
|
log::info!("v1 applied successfully");
|
||||||
STORAGE_VERSION.put::<Pallet<T>>();
|
StorageVersion::new(1).put::<Pallet<T>>();
|
||||||
|
|
||||||
weight.saturating_add(T::DbWeight::get().writes(1))
|
weight.saturating_add(T::DbWeight::get().writes(1))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user