mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 21:51:06 +00:00
Ensure all StorageVersions on Rococo/Westend are correct and migration hooks pass (#7251)
* set fastunstake storage version * fix configration migration hooks * set missing rococo versions * remove child bounties version set * future proof this configuration migration * simplify rococo migration * simplify westend version migration * typo * restore missing comments * set configuration storage version correctly * remove redundant preupgrade version check * fix version checks * remove redundant comment
This commit is contained in:
@@ -473,8 +473,20 @@ impl WeightInfo for TestWeightInfo {
|
|||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
/// The current storage version.
|
||||||
|
///
|
||||||
|
/// v0-v1: <https://github.com/paritytech/polkadot/pull/3575>
|
||||||
|
/// v1-v2: <https://github.com/paritytech/polkadot/pull/4420>
|
||||||
|
/// v2-v3: <https://github.com/paritytech/polkadot/pull/6091>
|
||||||
|
/// v3-v4: <https://github.com/paritytech/polkadot/pull/6345>
|
||||||
|
/// v4-v5: <https://github.com/paritytech/polkadot/pull/6937>
|
||||||
|
/// + <https://github.com/paritytech/polkadot/pull/6961>
|
||||||
|
/// + <https://github.com/paritytech/polkadot/pull/6934>
|
||||||
|
/// v5-v6: <https://github.com/paritytech/polkadot/pull/6271> (remove UMP dispatch queue)
|
||||||
|
const STORAGE_VERSION: StorageVersion = StorageVersion::new(6);
|
||||||
|
|
||||||
#[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>(_);
|
||||||
|
|
||||||
|
|||||||
@@ -16,20 +16,7 @@
|
|||||||
|
|
||||||
//! A module that is responsible for migration of storage.
|
//! A module that is responsible for migration of storage.
|
||||||
|
|
||||||
use frame_support::traits::StorageVersion;
|
|
||||||
use primitives::ExecutorParams;
|
use primitives::ExecutorParams;
|
||||||
|
|
||||||
/// The current storage version.
|
|
||||||
///
|
|
||||||
/// v0-v1: <https://github.com/paritytech/polkadot/pull/3575>
|
|
||||||
/// v1-v2: <https://github.com/paritytech/polkadot/pull/4420>
|
|
||||||
/// v2-v3: <https://github.com/paritytech/polkadot/pull/6091>
|
|
||||||
/// v3-v4: <https://github.com/paritytech/polkadot/pull/6345>
|
|
||||||
/// v4-v5: <https://github.com/paritytech/polkadot/pull/6937>
|
|
||||||
/// + <https://github.com/paritytech/polkadot/pull/6961>
|
|
||||||
/// + <https://github.com/paritytech/polkadot/pull/6934>
|
|
||||||
/// v5-v6: <https://github.com/paritytech/polkadot/pull/6271> (remove UMP dispatch queue)
|
|
||||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(6);
|
|
||||||
|
|
||||||
pub mod v5;
|
pub mod v5;
|
||||||
pub mod v6;
|
pub mod v6;
|
||||||
|
|||||||
@@ -262,8 +262,6 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToV5<T> {
|
|||||||
#[cfg(feature = "try-runtime")]
|
#[cfg(feature = "try-runtime")]
|
||||||
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
|
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
|
||||||
log::trace!(target: crate::configuration::LOG_TARGET, "Running pre_upgrade()");
|
log::trace!(target: crate::configuration::LOG_TARGET, "Running pre_upgrade()");
|
||||||
|
|
||||||
ensure!(StorageVersion::get::<Pallet<T>>() == 4, "The migration requires version 4");
|
|
||||||
Ok(Vec::new())
|
Ok(Vec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,8 +283,8 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToV5<T> {
|
|||||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
||||||
log::trace!(target: crate::configuration::LOG_TARGET, "Running post_upgrade()");
|
log::trace!(target: crate::configuration::LOG_TARGET, "Running post_upgrade()");
|
||||||
ensure!(
|
ensure!(
|
||||||
StorageVersion::get::<Pallet<T>>() == 5,
|
StorageVersion::get::<Pallet<T>>() >= 5,
|
||||||
"Storage version should be 5 after the migration"
|
"Storage version should be greater or equal to 5 after the migration"
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToV6<T> {
|
|||||||
#[cfg(feature = "try-runtime")]
|
#[cfg(feature = "try-runtime")]
|
||||||
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
|
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
|
||||||
log::trace!(target: crate::configuration::LOG_TARGET, "Running pre_upgrade()");
|
log::trace!(target: crate::configuration::LOG_TARGET, "Running pre_upgrade()");
|
||||||
|
|
||||||
ensure!(StorageVersion::get::<Pallet<T>>() == 5, "The migration requires version 4");
|
|
||||||
Ok(Vec::new())
|
Ok(Vec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,8 +82,8 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToV6<T> {
|
|||||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
||||||
log::trace!(target: crate::configuration::LOG_TARGET, "Running post_upgrade()");
|
log::trace!(target: crate::configuration::LOG_TARGET, "Running post_upgrade()");
|
||||||
ensure!(
|
ensure!(
|
||||||
StorageVersion::get::<Pallet<T>>() == 6,
|
StorageVersion::get::<Pallet<T>>() >= 6,
|
||||||
"Storage version should be 6 after the migration"
|
"Storage version should be >= 6 after the migration"
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1527,6 +1527,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 = ();
|
||||||
pub type V0941 = (); // Node only release - no migrations.
|
pub type V0941 = (); // Node only release - no migrations.
|
||||||
@@ -1535,8 +1536,91 @@ pub mod migrations {
|
|||||||
pallet_offences::migration::v1::MigrateToV1<Runtime>,
|
pallet_offences::migration::v1::MigrateToV1<Runtime>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Migrations that set `StorageVersion`s we missed to set.
|
||||||
|
///
|
||||||
|
/// It's *possible* that these pallets have not in fact been migrated to the versions being set,
|
||||||
|
/// which we should keep in mind in the future if we notice any strange behavior.
|
||||||
|
/// We opted to not check exactly what on-chain versions each pallet is at, since it would be
|
||||||
|
/// an involved effort, this is testnet, and no one has complained
|
||||||
|
/// (https://github.com/paritytech/polkadot/issues/6657#issuecomment-1552956439).
|
||||||
|
pub struct SetStorageVersions;
|
||||||
|
|
||||||
|
impl OnRuntimeUpgrade for SetStorageVersions {
|
||||||
|
fn on_runtime_upgrade() -> Weight {
|
||||||
|
let mut writes = 0;
|
||||||
|
let mut reads = 0;
|
||||||
|
|
||||||
|
// Council
|
||||||
|
if Council::on_chain_storage_version() < 4 {
|
||||||
|
// Safe to assume Council was created with V4 pallet.
|
||||||
|
StorageVersion::new(4).put::<Council>();
|
||||||
|
writes += 1;
|
||||||
|
}
|
||||||
|
reads += 1;
|
||||||
|
|
||||||
|
// Technical Committee
|
||||||
|
if TechnicalCommittee::on_chain_storage_version() < 4 {
|
||||||
|
StorageVersion::new(4).put::<TechnicalCommittee>();
|
||||||
|
writes += 1;
|
||||||
|
}
|
||||||
|
reads += 1;
|
||||||
|
|
||||||
|
// PhragmenElection
|
||||||
|
if PhragmenElection::on_chain_storage_version() < 4 {
|
||||||
|
StorageVersion::new(4).put::<PhragmenElection>();
|
||||||
|
writes += 1;
|
||||||
|
}
|
||||||
|
reads += 1;
|
||||||
|
|
||||||
|
// TechnicalMembership
|
||||||
|
if TechnicalMembership::on_chain_storage_version() < 4 {
|
||||||
|
StorageVersion::new(4).put::<TechnicalMembership>();
|
||||||
|
writes += 1;
|
||||||
|
}
|
||||||
|
reads += 1;
|
||||||
|
|
||||||
|
// Scheduler
|
||||||
|
if Scheduler::on_chain_storage_version() < 4 {
|
||||||
|
StorageVersion::new(4).put::<Scheduler>();
|
||||||
|
writes += 1;
|
||||||
|
}
|
||||||
|
reads += 1;
|
||||||
|
|
||||||
|
// Bounties
|
||||||
|
if Bounties::on_chain_storage_version() < 4 {
|
||||||
|
StorageVersion::new(4).put::<Bounties>();
|
||||||
|
writes += 1;
|
||||||
|
}
|
||||||
|
reads += 1;
|
||||||
|
|
||||||
|
// Tips
|
||||||
|
if Tips::on_chain_storage_version() < 4 {
|
||||||
|
StorageVersion::new(4).put::<Tips>();
|
||||||
|
writes += 1;
|
||||||
|
}
|
||||||
|
reads += 1;
|
||||||
|
|
||||||
|
// NisCounterpartBalances
|
||||||
|
if NisCounterpartBalances::on_chain_storage_version() < 1 {
|
||||||
|
StorageVersion::new(1).put::<NisCounterpartBalances>();
|
||||||
|
writes += 1;
|
||||||
|
}
|
||||||
|
reads += 1;
|
||||||
|
|
||||||
|
// Crowdloan
|
||||||
|
if Crowdloan::on_chain_storage_version() < 2 {
|
||||||
|
StorageVersion::new(2).put::<Crowdloan>();
|
||||||
|
writes += 1;
|
||||||
|
}
|
||||||
|
reads += 1;
|
||||||
|
|
||||||
|
RocksDbWeight::get().reads_writes(reads, writes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Unreleased migrations. Add new ones here:
|
/// Unreleased migrations. Add new ones here:
|
||||||
pub type Unreleased = (
|
pub type Unreleased = (
|
||||||
|
SetStorageVersions,
|
||||||
// Remove UMP dispatch queue <https://github.com/paritytech/polkadot/pull/6271>
|
// Remove UMP dispatch queue <https://github.com/paritytech/polkadot/pull/6271>
|
||||||
parachains_configuration::migration::v6::MigrateToV6<Runtime>,
|
parachains_configuration::migration::v6::MigrateToV6<Runtime>,
|
||||||
ump_migrations::UpdateUmpLimits,
|
ump_migrations::UpdateUmpLimits,
|
||||||
|
|||||||
@@ -1281,6 +1281,8 @@ pub type Migrations =
|
|||||||
/// 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 frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub type V0940 = (
|
pub type V0940 = (
|
||||||
@@ -1297,8 +1299,23 @@ pub mod migrations {
|
|||||||
pallet_offences::migration::v1::MigrateToV1<Runtime>,
|
pallet_offences::migration::v1::MigrateToV1<Runtime>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Migrations that set `StorageVersion`s we missed to set.
|
||||||
|
pub struct SetStorageVersions;
|
||||||
|
|
||||||
|
impl OnRuntimeUpgrade for SetStorageVersions {
|
||||||
|
fn on_runtime_upgrade() -> Weight {
|
||||||
|
if FastUnstake::on_chain_storage_version() < 1 {
|
||||||
|
StorageVersion::new(1).put::<FastUnstake>();
|
||||||
|
return RocksDbWeight::get().reads_writes(1, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
RocksDbWeight::get().reads(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Unreleased migrations. Add new ones here:
|
/// Unreleased migrations. Add new ones here:
|
||||||
pub type Unreleased = (
|
pub type Unreleased = (
|
||||||
|
SetStorageVersions,
|
||||||
// Remove UMP dispatch queue <https://github.com/paritytech/polkadot/pull/6271>
|
// Remove UMP dispatch queue <https://github.com/paritytech/polkadot/pull/6271>
|
||||||
parachains_configuration::migration::v6::MigrateToV6<Runtime>,
|
parachains_configuration::migration::v6::MigrateToV6<Runtime>,
|
||||||
ump_migrations::UpdateUmpLimits,
|
ump_migrations::UpdateUmpLimits,
|
||||||
|
|||||||
Reference in New Issue
Block a user