fix: Complete snowbridge pezpallet rebrand and critical bug fixes
- 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
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! All migrations of this pallet.
|
||||
//! All migrations of this pezpallet.
|
||||
|
||||
/// Migration to unreserve all pallet funds.
|
||||
/// Migration to unreserve all pezpallet funds.
|
||||
pub mod unlock_and_unreserve_all_funds;
|
||||
/// Version 3.
|
||||
pub mod v3;
|
||||
|
||||
+16
-16
@@ -16,7 +16,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
//! A migration that unreserves all deposit and unlocks all stake held in the context of this
|
||||
//! pallet.
|
||||
//! pezpallet.
|
||||
|
||||
use alloc::{collections::btree_map::BTreeMap, vec::Vec};
|
||||
use core::iter::Sum;
|
||||
@@ -41,14 +41,14 @@ pub trait UnlockConfig: 'static {
|
||||
type AccountId: Parameter + Ord;
|
||||
/// The currency type used in the runtime.
|
||||
///
|
||||
/// Should match the currency type previously used for the pallet, if applicable.
|
||||
/// Should match the currency type previously used for the pezpallet, if applicable.
|
||||
type Currency: LockableCurrency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
|
||||
/// The name of the pallet as previously configured in
|
||||
/// The name of the pezpallet as previously configured in
|
||||
/// [`construct_runtime!`](pezframe_support::construct_runtime).
|
||||
type PalletName: Get<&'static str>;
|
||||
/// The maximum number of votes per voter as configured previously in the previous runtime.
|
||||
type MaxVotesPerVoter: Get<u32>;
|
||||
/// Identifier for the elections-phragmen pallet's lock, as previously configured in the
|
||||
/// Identifier for the elections-phragmen pezpallet's lock, as previously configured in the
|
||||
/// runtime.
|
||||
type PalletId: Get<LockIdentifier>;
|
||||
/// The DB weight as configured in the runtime to calculate the correct weight.
|
||||
@@ -86,18 +86,18 @@ type Voting<T: UnlockConfig> = StorageMap<
|
||||
>;
|
||||
|
||||
/// A migration that unreserves all deposit and unlocks all stake held in the context of this
|
||||
/// pallet.
|
||||
/// pezpallet.
|
||||
///
|
||||
/// Useful to prevent funds from being locked up when the pallet is being deprecated.
|
||||
/// Useful to prevent funds from being locked up when the pezpallet is being deprecated.
|
||||
///
|
||||
/// The pallet should be made inoperable before this migration is run.
|
||||
/// The pezpallet should be made inoperable before this migration is run.
|
||||
///
|
||||
/// (See also [`RemovePallet`][pezframe_support::migrations::RemovePallet])
|
||||
pub struct UnlockAndUnreserveAllFunds<T: UnlockConfig>(core::marker::PhantomData<T>);
|
||||
|
||||
impl<T: UnlockConfig> UnlockAndUnreserveAllFunds<T> {
|
||||
/// Calculates and returns the total amounts deposited and staked by each account in the context
|
||||
/// of this pallet.
|
||||
/// of this pezpallet.
|
||||
///
|
||||
/// The deposited and staked amounts are returned in two separate `BTreeMap` collections.
|
||||
///
|
||||
@@ -177,20 +177,20 @@ where
|
||||
/// checks the integrity of deposited and reserved balances.
|
||||
///
|
||||
/// Steps:
|
||||
/// 1. Gets the deposited and staked balances for each account stored in this pallet.
|
||||
/// 1. Gets the deposited and staked balances for each account stored in this pezpallet.
|
||||
/// 2. Collects actual pre-migration locked and reserved balances for each account.
|
||||
/// 3. Checks the integrity of the deposited and reserved balances.
|
||||
/// 4. Prints summary statistics about the state to be migrated.
|
||||
/// 5. Encodes and returns pre-migration data to be used in post_upgrade.
|
||||
///
|
||||
/// Fails with a `TryRuntimeError` if there's a discrepancy between the amount
|
||||
/// reported as staked by the pallet and the amount actually locked in `Balances`.
|
||||
/// reported as staked by the pezpallet and the amount actually locked in `Balances`.
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, pezsp_runtime::TryRuntimeError> {
|
||||
use alloc::collections::btree_set::BTreeSet;
|
||||
use codec::Encode;
|
||||
|
||||
// Get staked and deposited balances as reported by this pallet.
|
||||
// Get staked and deposited balances as reported by this pezpallet.
|
||||
let (account_deposited_sums, account_staked_sums, _) =
|
||||
Self::get_account_deposited_and_staked_sums();
|
||||
|
||||
@@ -206,7 +206,7 @@ where
|
||||
.collect();
|
||||
|
||||
// Total deposited for each account *should* be less than or equal to the total reserved,
|
||||
// however this does not hold for all cases due to bugs in the reserve logic of this pallet.
|
||||
// however this does not hold for all cases due to bugs in the reserve logic of this pezpallet.
|
||||
let bugged_deposits = all_accounts
|
||||
.iter()
|
||||
.filter(|account| {
|
||||
@@ -241,11 +241,11 @@ where
|
||||
/// Executes the migration.
|
||||
///
|
||||
/// Steps:
|
||||
/// 1. Retrieves the deposit and stake amounts from the pallet.
|
||||
/// 1. Retrieves the deposit and stake amounts from the pezpallet.
|
||||
/// 2. Unreserves the deposited funds for each account.
|
||||
/// 3. Unlocks the staked funds for each account.
|
||||
fn on_runtime_upgrade() -> pezframe_support::weights::Weight {
|
||||
// Get staked and deposited balances as reported by this pallet.
|
||||
// Get staked and deposited balances as reported by this pezpallet.
|
||||
let (account_deposited_sums, account_staked_sums, initial_reads) =
|
||||
Self::get_account_deposited_and_staked_sums();
|
||||
|
||||
@@ -290,7 +290,7 @@ where
|
||||
BTreeMap::<T::AccountId, BalanceOf<T>>::decode(&mut &account_reserved_before_bytes[..])
|
||||
.map_err(|_| "Failed to decode account_reserved_before_bytes")?;
|
||||
|
||||
// Get deposited balances as reported by this pallet.
|
||||
// Get deposited balances as reported by this pezpallet.
|
||||
let (account_deposited_sums, _, _) = Self::get_account_deposited_and_staked_sums();
|
||||
|
||||
// Check that the reserved balance is reduced by the expected deposited amount.
|
||||
@@ -300,7 +300,7 @@ where
|
||||
.get(&account)
|
||||
.unwrap_or(&Zero::zero())
|
||||
// .min here to handle bugged deposits where actual_reserved_before is less than the
|
||||
// amount the pallet reports is reserved
|
||||
// amount the pezpallet reports is reserved
|
||||
.min(&actual_reserved_before);
|
||||
let expected_reserved_after =
|
||||
actual_reserved_before.saturating_sub(expected_amount_deducted);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
//! Migrations to version [`3.0.0`], as denoted by the changelog.
|
||||
|
||||
use super::super::LOG_TARGET;
|
||||
use crate::{Config, Pallet};
|
||||
use crate::{Config, Pezpallet};
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode, FullCodec};
|
||||
use pezframe_support::{
|
||||
@@ -51,25 +51,25 @@ pub trait V2ToV3 {
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
type Candidates<V, T: Config> =
|
||||
StorageValue<Pallet<T>, Vec<(<V as V2ToV3>::AccountId, <V as V2ToV3>::Balance)>, ValueQuery>;
|
||||
StorageValue<Pezpallet<T>, Vec<(<V as V2ToV3>::AccountId, <V as V2ToV3>::Balance)>, ValueQuery>;
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
type Members<V, T: Config> = StorageValue<
|
||||
Pallet<T>,
|
||||
Pezpallet<T>,
|
||||
Vec<SeatHolder<<V as V2ToV3>::AccountId, <V as V2ToV3>::Balance>>,
|
||||
ValueQuery,
|
||||
>;
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
type RunnersUp<V, T: Config> = StorageValue<
|
||||
Pallet<T>,
|
||||
Pezpallet<T>,
|
||||
Vec<SeatHolder<<V as V2ToV3>::AccountId, <V as V2ToV3>::Balance>>,
|
||||
ValueQuery,
|
||||
>;
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
type Voting<V, T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Pezpallet<T>,
|
||||
Twox64Concat,
|
||||
<V as V2ToV3>::AccountId,
|
||||
Voter<<V as V2ToV3>::AccountId, <V as V2ToV3>::Balance>,
|
||||
@@ -88,7 +88,7 @@ pub fn apply<V: V2ToV3, T: Config>(
|
||||
old_voter_bond: V::Balance,
|
||||
old_candidacy_bond: V::Balance,
|
||||
) -> Weight {
|
||||
let storage_version = StorageVersion::get::<Pallet<T>>();
|
||||
let storage_version = StorageVersion::get::<Pezpallet<T>>();
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"Running migration for elections-phragmen with storage version {:?}",
|
||||
@@ -101,7 +101,7 @@ pub fn apply<V: V2ToV3, T: Config>(
|
||||
migrate_runners_up_to_recorded_deposit::<V, T>(old_candidacy_bond);
|
||||
migrate_members_to_recorded_deposit::<V, T>(old_candidacy_bond);
|
||||
|
||||
StorageVersion::new(3).put::<Pallet<T>>();
|
||||
StorageVersion::new(3).put::<Pezpallet<T>>();
|
||||
|
||||
Weight::MAX
|
||||
} else {
|
||||
|
||||
@@ -26,7 +26,7 @@ use pezframe_support::{
|
||||
/// The old prefix.
|
||||
pub const OLD_PREFIX: &[u8] = b"PhragmenElection";
|
||||
|
||||
/// Migrate the entire storage of this pallet to a new prefix.
|
||||
/// Migrate the entire storage of this pezpallet to a new prefix.
|
||||
///
|
||||
/// This new prefix must be the same as the one set in construct_runtime. For safety, use
|
||||
/// `PalletInfo` to get it, as:
|
||||
@@ -37,11 +37,11 @@ pub fn migrate<T: crate::Config, N: AsRef<str>>(new_pallet_name: N) -> Weight {
|
||||
if new_pallet_name.as_ref().as_bytes() == OLD_PREFIX {
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"New pallet name is equal to the old prefix. No migration needs to be done.",
|
||||
"New pezpallet name is equal to the old prefix. No migration needs to be done.",
|
||||
);
|
||||
return Weight::zero();
|
||||
}
|
||||
let storage_version = StorageVersion::get::<crate::Pallet<T>>();
|
||||
let storage_version = StorageVersion::get::<crate::Pezpallet<T>>();
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"Running migration to v4 for elections-phragmen with storage version {:?}",
|
||||
@@ -55,7 +55,7 @@ pub fn migrate<T: crate::Config, N: AsRef<str>>(new_pallet_name: N) -> Weight {
|
||||
new_pallet_name.as_ref().as_bytes(),
|
||||
);
|
||||
|
||||
StorageVersion::new(4).put::<crate::Pallet<T>>();
|
||||
StorageVersion::new(4).put::<crate::Pezpallet<T>>();
|
||||
|
||||
<T as pezframe_system::Config>::BlockWeights::get().max_block
|
||||
} else {
|
||||
@@ -93,7 +93,7 @@ pub fn pre_migration<T: crate::Config, N: AsRef<str>>(new: N) {
|
||||
pezsp_core::hexdisplay::HexDisplay::from(&pezsp_io::storage::next_key(new.as_bytes()).unwrap())
|
||||
);
|
||||
// ensure storage version is 3.
|
||||
assert_eq!(StorageVersion::get::<crate::Pallet<T>>(), 3);
|
||||
assert_eq!(StorageVersion::get::<crate::Pezpallet<T>>(), 3);
|
||||
}
|
||||
|
||||
/// Some checks for after migration. This can be linked to
|
||||
@@ -103,5 +103,5 @@ pub fn pre_migration<T: crate::Config, N: AsRef<str>>(new: N) {
|
||||
pub fn post_migration<T: crate::Config>() {
|
||||
log::info!("post-migration elections-phragmen");
|
||||
// ensure we've been updated to v4 by the automatic write of crate version -> storage version.
|
||||
assert_eq!(StorageVersion::get::<crate::Pallet<T>>(), 4);
|
||||
assert_eq!(StorageVersion::get::<crate::Pezpallet<T>>(), 4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user