90fd044766
- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs) - pallet/ directories → pezpallet/ (4 locations) - Fixed pezpallet.rs self-include recursion bug - Fixed sc-chain-spec hardcoded crate name in derive macro - Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API) - Added BizinikiwiConfig type alias for zombienet tests - Deleted obsolete session state files Verified: pezsnowbridge-pezpallet-*, pezpallet-staking, pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
73 lines
2.8 KiB
Rust
73 lines
2.8 KiB
Rust
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
// This file is part of Pezkuwi.
|
|
|
|
// Pezkuwi 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.
|
|
|
|
// Pezkuwi 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 Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
use super::{Config, MaxPermanentSlots, MaxTemporarySlots, Pezpallet, LOG_TARGET};
|
|
use pezframe_support::traits::{Get, GetStorageVersion, UncheckedOnRuntimeUpgrade};
|
|
|
|
#[cfg(feature = "try-runtime")]
|
|
use alloc::vec::Vec;
|
|
#[cfg(feature = "try-runtime")]
|
|
use pezframe_support::ensure;
|
|
|
|
pub mod v1 {
|
|
use super::*;
|
|
pub struct VersionUncheckedMigrateToV1<T>(core::marker::PhantomData<T>);
|
|
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateToV1<T> {
|
|
#[cfg(feature = "try-runtime")]
|
|
fn pre_upgrade() -> Result<Vec<u8>, pezsp_runtime::TryRuntimeError> {
|
|
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
|
|
ensure!(on_chain_version < 1, "assigned_slots::MigrateToV1 migration can be deleted");
|
|
Ok(Default::default())
|
|
}
|
|
|
|
fn on_runtime_upgrade() -> pezframe_support::weights::Weight {
|
|
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
|
|
if on_chain_version < 1 {
|
|
const MAX_PERMANENT_SLOTS: u32 = 100;
|
|
const MAX_TEMPORARY_SLOTS: u32 = 100;
|
|
|
|
MaxPermanentSlots::<T>::put(MAX_PERMANENT_SLOTS);
|
|
MaxTemporarySlots::<T>::put(MAX_TEMPORARY_SLOTS);
|
|
// Return the weight consumed by the migration.
|
|
T::DbWeight::get().reads_writes(1, 3)
|
|
} else {
|
|
log::info!(target: LOG_TARGET, "MigrateToV1 should be removed");
|
|
T::DbWeight::get().reads(1)
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "try-runtime")]
|
|
fn post_upgrade(_state: Vec<u8>) -> Result<(), pezsp_runtime::TryRuntimeError> {
|
|
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
|
|
ensure!(on_chain_version == 1, "assigned_slots::MigrateToV1 needs to be run");
|
|
assert_eq!(MaxPermanentSlots::<T>::get(), 100);
|
|
assert_eq!(MaxTemporarySlots::<T>::get(), 100);
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
/// [`VersionUncheckedMigrateToV1`] wrapped in a
|
|
/// [`VersionedMigration`](pezframe_support::migrations::VersionedMigration), ensuring the
|
|
/// migration is only performed when on-chain version is 0.
|
|
pub type MigrateToV1<T> = pezframe_support::migrations::VersionedMigration<
|
|
0,
|
|
1,
|
|
VersionUncheckedMigrateToV1<T>,
|
|
Pezpallet<T>,
|
|
<T as pezframe_system::Config>::DbWeight,
|
|
>;
|
|
}
|