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:
2025-12-16 09:57:23 +03:00
parent eea003e14d
commit 3139ffa25e
3022 changed files with 42157 additions and 23579 deletions
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME nomination pools pallet"
description = "FRAME nomination pools pezpallet"
documentation = "https://docs.rs/pezpallet-nomination-pools"
[lints]
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME nomination pools pallet benchmarking"
description = "FRAME nomination pools pezpallet benchmarking"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-nomination-pools-benchmarking"
@@ -34,7 +34,7 @@ use pezpallet_nomination_pools::{
BalanceOf, BondExtra, BondedPoolInner, BondedPools, ClaimPermission, ClaimPermissions,
Commission, CommissionChangeRate, CommissionClaimPermission, ConfigOp, GlobalMaxCommission,
MaxPoolMembers, MaxPoolMembersPerPool, MaxPools, Metadata, MinCreateBond, MinJoinBond,
Pallet as Pools, PoolId, PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage,
Pezpallet as Pools, PoolId, PoolMembers, PoolRoles, PoolState, RewardPools, SubPoolsStorage,
};
use pezpallet_staking::MaxNominationsOf;
use pezsp_runtime::{
@@ -58,7 +58,7 @@ pub trait Config:
{
}
pub struct Pallet<T: Config>(Pools<T>);
pub struct Pezpallet<T: Config>(Pools<T>);
fn create_funded_user_with_balance<T: pezpallet_nomination_pools::Config>(
string: &'static str,
@@ -136,7 +136,7 @@ fn migrate_to_transfer_stake<T: Config>(pool_id: PoolId) {
// Note: we didn't require ED until pezpallet-staking migrated from locks to holds.
let _ = CurrencyOf::<T>::mint_into(&pool_acc, CurrencyOf::<T>::minimum_balance());
pezpallet_staking::Pallet::<T>::migrate_to_direct_staker(&pool_acc);
pezpallet_staking::Pezpallet::<T>::migrate_to_direct_staker(&pool_acc);
}
fn vote_to_balance<T: pezpallet_nomination_pools::Config>(
@@ -215,7 +215,7 @@ impl<T: Config> ListScenario<T> {
vec![account("random_validator", 0, USER_SEED)],
)?;
let weight_of = pezpallet_staking::Pallet::<T>::weight_of_fn();
let weight_of = pezpallet_staking::Pezpallet::<T>::weight_of_fn();
assert_eq!(vote_to_balance::<T>(weight_of(&pool_origin1)).unwrap(), origin_weight);
assert_eq!(vote_to_balance::<T>(weight_of(&pool_origin2)).unwrap(), origin_weight);
assert_eq!(vote_to_balance::<T>(weight_of(&pool_dest1)).unwrap(), dest_weight);
@@ -254,7 +254,7 @@ impl<T: Config> ListScenario<T> {
Pools::<T>::join(RuntimeOrigin::Signed(joiner.clone()).into(), amount, 1).unwrap();
// check that the vote weight is still the same as the original bonded
let weight_of = pezpallet_staking::Pallet::<T>::weight_of_fn();
let weight_of = pezpallet_staking::Pezpallet::<T>::weight_of_fn();
assert_eq!(vote_to_balance::<T>(weight_of(&self.origin1)).unwrap(), original_bonded);
// check the member was added correctly
@@ -992,7 +992,7 @@ mod benchmarks {
Some(deposit_amount),
);
// ugly type conversion between balances of pallet staking and pools (which really are same
// ugly type conversion between balances of pezpallet staking and pools (which really are same
// type). Maybe there is a better way?
let slash_amount: u128 = deposit_amount.into() / 2;
@@ -1173,5 +1173,5 @@ mod benchmarks {
assert_eq!(PoolMembers::<T>::get(&depositor).unwrap().total_balance(), deposit_amount);
}
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Runtime);
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(), crate::mock::Runtime);
}
@@ -81,7 +81,7 @@ impl pezpallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = pezpallet_timestamp::Pallet<Self>;
type UnixTime = pezpallet_timestamp::Pezpallet<Self>;
type AdminOrigin = pezframe_system::EnsureRoot<Self::AccountId>;
type EraPayout = pezpallet_staking::ConvertCurve<RewardCurve>;
type ElectionProvider =
@@ -31,8 +31,8 @@ use honggfuzz::fuzz;
use pezpallet_nomination_pools::{
log,
mock::*,
pallet as pools,
pallet::{BondedPools, Call as PoolsCall, Event as PoolsEvents, PoolMembers},
pezpallet as pools,
pezpallet::{BondedPools, Call as PoolsCall, Event as PoolsEvents, PoolMembers},
BondExtra, BondedPool, GlobalMaxCommission, LastPoolId, MaxPoolMembers, MaxPoolMembersPerPool,
MaxPools, MinCreateBond, MinJoinBond, PoolId,
};
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Runtime API for nomination-pools FRAME pallet"
description = "Runtime API for nomination-pools FRAME pezpallet"
readme = "README.md"
documentation = "https://docs.rs/pezpallet-nomination-pools-runtime-api"
@@ -1,3 +1,3 @@
Runtime API definition for nomination-pools pallet.
Runtime API definition for nomination-pools pezpallet.
License: Apache-2.0
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Runtime API definition for nomination-pools pallet.
//! Runtime API definition for nomination-pools pezpallet.
//! Currently supports only one rpc endpoint.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -361,7 +361,7 @@ impl<T: Config, Staking: StakingInterface<Balance = BalanceOf<T>, AccountId = T:
///
/// This is the newer staking strategy used by pools. Once switched to this and migrated, ideally
/// the `TransferStake` strategy should not be used. Or a separate migration would be required for
/// it which is not provided by this pallet.
/// it which is not provided by this pezpallet.
///
/// Use [`migration::unversioned::DelegationStakeMigration`] to migrate to this strategy.
pub struct DelegateStake<T: Config, Staking: StakingInterface, Delegation: DelegationInterface>(
+140 -140
View File
@@ -17,7 +17,7 @@
//! # Nomination Pools for Staking Delegation
//!
//! A pallet that allows members to delegate their stake to nominating pools. A nomination pool acts
//! A pezpallet that allows members to delegate their stake to nominating pools. A nomination pool acts
//! as nominator and nominates validators on the members' behalf.
//!
//! # Index
@@ -172,7 +172,7 @@
//!
//! ## Implementor's Guide
//!
//! Some notes and common mistakes that wallets/apps wishing to implement this pallet should be
//! Some notes and common mistakes that wallets/apps wishing to implement this pezpallet should be
//! aware of:
//!
//!
@@ -325,7 +325,7 @@
//! ### Slashing
//!
//! This section assumes that the slash computation is executed by
//! `pezpallet_staking::StakingLedger::slash`, which passes the information to this pallet via
//! `pezpallet_staking::StakingLedger::slash`, which passes the information to this pezpallet via
//! [`pezsp_staking::OnStakingUpdate::on_slash`].
//!
//! Unbonding pools need to be slashed to ensure all nominators whom where in the bonded pool while
@@ -382,7 +382,7 @@ use pezsp_staking::{EraIndex, StakingInterface};
#[cfg(any(feature = "try-runtime", feature = "fuzzing", test, debug_assertions))]
use pezsp_runtime::TryRuntimeError;
/// The log target of this pallet.
/// The log target of this pezpallet.
pub const LOG_TARGET: &str = "runtime::nomination-pools";
// syntactic sugar for logging.
#[macro_export]
@@ -390,7 +390,7 @@ macro_rules! log {
($level:tt, $patter:expr $(, $values:expr)* $(,)?) => {
log::$level!(
target: $crate::LOG_TARGET,
concat!("[{:?}] 🏊‍♂️ ", $patter), <pezframe_system::Pallet<T>>::block_number() $(, $values)*
concat!("[{:?}] 🏊‍♂️ ", $patter), <pezframe_system::Pezpallet<T>>::block_number() $(, $values)*
)
};
}
@@ -404,7 +404,7 @@ pub mod adapter;
pub mod migration;
pub mod weights;
pub use pallet::*;
pub use pezpallet::*;
use pezsp_runtime::traits::BlockNumberProvider;
pub use weights::WeightInfo;
@@ -421,7 +421,7 @@ pub type BlockNumberFor<T> =
pub const POINTS_TO_BALANCE_INIT_RATIO: u32 = 1;
/// Possible operations on the configuration values of this pallet.
/// Possible operations on the configuration values of this pezpallet.
#[derive(
Encode,
Decode,
@@ -916,7 +916,7 @@ impl<T: Config> Commission<T> {
if updated_current {
if let Some((_, payee)) = self.current.as_ref() {
Pallet::<T>::deposit_event(Event::<T>::PoolCommissionUpdated {
Pezpallet::<T>::deposit_event(Event::<T>::PoolCommissionUpdated {
pool_id,
current: Some((new_max, payee.clone())),
});
@@ -1048,12 +1048,12 @@ impl<T: Config> BondedPool<T> {
/// Get the bonded account id of this pool.
fn bonded_account(&self) -> T::AccountId {
Pallet::<T>::generate_bonded_account(self.id)
Pezpallet::<T>::generate_bonded_account(self.id)
}
/// Get the reward account id of this pool.
fn reward_account(&self) -> T::AccountId {
Pallet::<T>::generate_reward_account(self.id)
Pezpallet::<T>::generate_reward_account(self.id)
}
/// Consume self and put into storage.
@@ -1071,7 +1071,7 @@ impl<T: Config> BondedPool<T> {
/// This is often used for bonding and issuing new funds into the pool.
fn balance_to_point(&self, new_funds: BalanceOf<T>) -> BalanceOf<T> {
let bonded_balance = T::StakeAdapter::active_stake(Pool::from(self.bonded_account()));
Pallet::<T>::balance_to_point(bonded_balance, self.points, new_funds)
Pezpallet::<T>::balance_to_point(bonded_balance, self.points, new_funds)
}
/// Convert the given number of points to balance given the current pool state.
@@ -1079,7 +1079,7 @@ impl<T: Config> BondedPool<T> {
/// This is often used for unbonding.
fn points_to_balance(&self, points: BalanceOf<T>) -> BalanceOf<T> {
let bonded_balance = T::StakeAdapter::active_stake(Pool::from(self.bonded_account()));
Pallet::<T>::point_to_balance(bonded_balance, self.points, points)
Pezpallet::<T>::point_to_balance(bonded_balance, self.points, points)
}
/// Issue points to [`Self`] for `new_funds`.
@@ -1249,7 +1249,7 @@ impl<T: Config> BondedPool<T> {
is_full_unbond ||
balance_after_unbond >=
if is_depositor {
Pallet::<T>::depositor_min_bond()
Pezpallet::<T>::depositor_min_bond()
} else {
MinJoinBond::<T>::get()
},
@@ -1340,7 +1340,7 @@ impl<T: Config> BondedPool<T> {
fn set_state(&mut self, state: PoolState) {
if self.state != state {
self.state = state;
Pallet::<T>::deposit_event(Event::<T>::StateChanged {
Pezpallet::<T>::deposit_event(Event::<T>::StateChanged {
pool_id: self.id,
new_state: state,
});
@@ -1515,7 +1515,7 @@ impl<T: Config> RewardPool<T> {
/// This is sum of all the rewards that are claimable by pool members.
fn current_balance(id: PoolId) -> BalanceOf<T> {
T::Currency::reducible_balance(
&Pallet::<T>::generate_reward_account(id),
&Pezpallet::<T>::generate_reward_account(id),
Preservation::Expendable,
Fortitude::Polite,
)
@@ -1546,11 +1546,11 @@ pub struct UnbondPool<T: Config> {
impl<T: Config> UnbondPool<T> {
fn balance_to_point(&self, new_funds: BalanceOf<T>) -> BalanceOf<T> {
Pallet::<T>::balance_to_point(self.balance, self.points, new_funds)
Pezpallet::<T>::balance_to_point(self.balance, self.points, new_funds)
}
fn point_to_balance(&self, points: BalanceOf<T>) -> BalanceOf<T> {
Pallet::<T>::point_to_balance(self.balance, self.points, points)
Pezpallet::<T>::point_to_balance(self.balance, self.points, points)
}
/// Issue the equivalent points of `new_funds` into self.
@@ -1652,8 +1652,8 @@ impl<T: Config> Get<u32> for TotalUnbondingPools<T> {
}
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::traits::StorageVersion;
use pezframe_system::pezpallet_prelude::{
@@ -1664,17 +1664,17 @@ pub mod pallet {
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(8);
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: weights::WeightInfo;
/// The currency type used for nomination pool.
@@ -1698,8 +1698,8 @@ pub mod pallet {
/// prevented via a reasonable `MaxPointsToBalance`), for many many years to come.
type RewardCounter: FixedPointNumber + MaxEncodedLen + TypeInfo + Default + codec::FullCodec;
/// The nomination pool's pallet id.
#[pallet::constant]
/// The nomination pool's pezpallet id.
#[pezpallet::constant]
type PalletId: Get<pezframe_support::PalletId>;
/// The maximum pool points-to-balance ratio that an `open` pool can have.
@@ -1714,11 +1714,11 @@ pub mod pallet {
///
/// For a value of 10, the threshold would be a pool points-to-balance ratio of 10:1.
/// Such a scenario would also be the equivalent of the pool being 90% slashed.
#[pallet::constant]
#[pezpallet::constant]
type MaxPointsToBalance: Get<u8>;
/// The maximum number of simultaneous unbonding chunks that can exist per member.
#[pallet::constant]
#[pezpallet::constant]
type MaxUnbonding: Get<u32>;
/// Infallible method for converting `Currency::Balance` to `U256`.
@@ -1745,7 +1745,7 @@ pub mod pallet {
/// The origin that can manage pool configurations.
type AdminOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// Provider for the block number. Normally this is the `pezframe_system` pallet.
/// Provider for the block number. Normally this is the `pezframe_system` pezpallet.
type BlockNumberProvider: BlockNumberProvider;
/// Restrict some accounts from participating in a nomination pool.
@@ -1757,11 +1757,11 @@ pub mod pallet {
/// This might be lower but never higher than the sum of `total_balance` of all [`PoolMembers`]
/// because calling `pool_withdraw_unbonded` might decrease the total stake of the pool's
/// `bonded_account` without adjusting the pezpallet-internal `UnbondingPool`'s.
#[pallet::storage]
#[pezpallet::storage]
pub type TotalValueLocked<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
/// Minimum amount to bond to join a pool.
#[pallet::storage]
#[pezpallet::storage]
pub type MinJoinBond<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
/// Minimum bond required to create a pool.
@@ -1771,76 +1771,76 @@ pub mod pallet {
///
/// This is the value that will always exist in the staking ledger of the pool bonded account
/// while all other accounts leave.
#[pallet::storage]
#[pezpallet::storage]
pub type MinCreateBond<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
/// Maximum number of nomination pools that can exist. If `None`, then an unbounded number of
/// pools can exist.
#[pallet::storage]
#[pezpallet::storage]
pub type MaxPools<T: Config> = StorageValue<_, u32, OptionQuery>;
/// Maximum number of members that can exist in the system. If `None`, then the count
/// members are not bound on a system wide basis.
#[pallet::storage]
#[pezpallet::storage]
pub type MaxPoolMembers<T: Config> = StorageValue<_, u32, OptionQuery>;
/// Maximum number of members that may belong to pool. If `None`, then the count of
/// members is not bound on a per pool basis.
#[pallet::storage]
#[pezpallet::storage]
pub type MaxPoolMembersPerPool<T: Config> = StorageValue<_, u32, OptionQuery>;
/// The maximum commission that can be charged by a pool. Used on commission payouts to bound
/// pool commissions that are > `GlobalMaxCommission`, necessary if a future
/// `GlobalMaxCommission` is lower than some current pool commissions.
#[pallet::storage]
#[pezpallet::storage]
pub type GlobalMaxCommission<T: Config> = StorageValue<_, Perbill, OptionQuery>;
/// Active members.
///
/// TWOX-NOTE: SAFE since `AccountId` is a secure hash.
#[pallet::storage]
#[pezpallet::storage]
pub type PoolMembers<T: Config> =
CountedStorageMap<_, Twox64Concat, T::AccountId, PoolMember<T>>;
/// Storage for bonded pools.
// To get or insert a pool see [`BondedPool::get`] and [`BondedPool::put`]
#[pallet::storage]
#[pezpallet::storage]
pub type BondedPools<T: Config> =
CountedStorageMap<_, Twox64Concat, PoolId, BondedPoolInner<T>>;
/// Reward pools. This is where there rewards for each pool accumulate. When a members payout is
/// claimed, the balance comes out of the reward pool. Keyed by the bonded pools account.
#[pallet::storage]
#[pezpallet::storage]
pub type RewardPools<T: Config> = CountedStorageMap<_, Twox64Concat, PoolId, RewardPool<T>>;
/// Groups of unbonding pools. Each group of unbonding pools belongs to a
/// bonded pool, hence the name sub-pools. Keyed by the bonded pools account.
#[pallet::storage]
#[pezpallet::storage]
pub type SubPoolsStorage<T: Config> = CountedStorageMap<_, Twox64Concat, PoolId, SubPools<T>>;
/// Metadata for the pool.
#[pallet::storage]
#[pezpallet::storage]
pub type Metadata<T: Config> =
CountedStorageMap<_, Twox64Concat, PoolId, BoundedVec<u8, T::MaxMetadataLen>, ValueQuery>;
/// Ever increasing number of all pools created so far.
#[pallet::storage]
#[pezpallet::storage]
pub type LastPoolId<T: Config> = StorageValue<_, u32, ValueQuery>;
/// A reverse lookup from the pool's account id to its id.
///
/// This is only used for slashing and on automatic withdraw update. In all other instances, the
/// pool id is used, and the accounts are deterministically derived from it.
#[pallet::storage]
#[pezpallet::storage]
pub type ReversePoolIdLookup<T: Config> =
CountedStorageMap<_, Twox64Concat, T::AccountId, PoolId, OptionQuery>;
/// Map from a pool member account to their opted claim permission.
#[pallet::storage]
#[pezpallet::storage]
pub type ClaimPermissions<T: Config> =
StorageMap<_, Twox64Concat, T::AccountId, ClaimPermission, ValueQuery>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub min_join_bond: BalanceOf<T>,
pub min_create_bond: BalanceOf<T>,
@@ -1863,7 +1863,7 @@ pub mod pallet {
}
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
MinJoinBond::<T>::put(self.min_join_bond);
@@ -1884,9 +1884,9 @@ pub mod pallet {
}
}
/// Events of this pallet.
#[pallet::event]
#[pallet::generate_deposit(pub(crate) fn deposit_event)]
/// Events of this pezpallet.
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(crate) fn deposit_event)]
pub enum Event<T: Config> {
/// A pool has been created.
Created { depositor: T::AccountId, pool_id: PoolId },
@@ -1985,7 +1985,7 @@ pub mod pallet {
},
}
#[pallet::error]
#[pezpallet::error]
#[cfg_attr(test, derive(PartialEq))]
pub enum Error<T> {
/// A (bonded) pool id does not exist.
@@ -2008,7 +2008,7 @@ pub mod pallet {
CannotWithdrawAny,
/// The amount does not meet the minimum bond to either join or create a pool.
///
/// The depositor can never unbond to a value less than `Pallet::depositor_min_bond`. The
/// The depositor can never unbond to a value less than `Pezpallet::depositor_min_bond`. The
/// caller does not have nominating permissions for the pool. Members can never unbond to a
/// value below `MinJoinBond`.
MinimumBondNotMet,
@@ -2068,7 +2068,7 @@ pub mod pallet {
AlreadyMigrated,
/// The pool or member delegation has not migrated yet to delegate stake.
NotMigrated,
/// This call is not allowed in the current state of the pallet.
/// This call is not allowed in the current state of the pezpallet.
NotSupported,
/// Account is restricted from participation in pools. This may happen if the account is
/// staking in another way already.
@@ -2103,15 +2103,15 @@ pub mod pallet {
}
/// A reason for freezing funds.
#[pallet::composite_enum]
#[pezpallet::composite_enum]
pub enum FreezeReason {
/// Pool reward account is restricted from going below Existential Deposit.
#[codec(index = 0)]
PoolMinBalance,
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Stake funds with a pool. The amount to bond is delegated (or transferred based on
/// [`adapter::StakeStrategyType`]) from the member to the pool account and immediately
/// increases the pool's bond.
@@ -2128,11 +2128,11 @@ pub mod pallet {
/// * This call will *not* dust the member account, so the member must have at least
/// `existential deposit + amount` in their account.
/// * Only a pool with [`PoolState::Open`] can be joined
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::join())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::join())]
pub fn join(
origin: OriginFor<T>,
#[pallet::compact] amount: BalanceOf<T>,
#[pezpallet::compact] amount: BalanceOf<T>,
pool_id: PoolId,
) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -2196,8 +2196,8 @@ pub mod pallet {
// NOTE: this transaction is implemented with the sole purpose of readability and
// correctness, not optimization. We read/write several storage items multiple times instead
// of just once, in the spirit reusing code.
#[pallet::call_index(1)]
#[pallet::weight(
#[pezpallet::call_index(1)]
#[pezpallet::weight(
T::WeightInfo::bond_extra_transfer()
.max(T::WeightInfo::bond_extra_other())
)]
@@ -2221,8 +2221,8 @@ pub mod pallet {
/// members in the pools stake. Rewards do not "expire".
///
/// See `claim_payout_other` to claim rewards on behalf of some `other` pool member.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::claim_payout())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::claim_payout())]
pub fn claim_payout(origin: OriginFor<T>) -> DispatchResult {
let signer = ensure_signed(origin)?;
// ensure signer is not in an un-migrated state.
@@ -2265,12 +2265,12 @@ pub mod pallet {
/// are available). However, it may not be possible to release the current unlocking chunks,
/// in which case, the result of this call will likely be the `NoMoreChunks` error from the
/// staking system.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::unbond())]
#[pezpallet::call_index(3)]
#[pezpallet::weight(T::WeightInfo::unbond())]
pub fn unbond(
origin: OriginFor<T>,
member_account: AccountIdLookupOf<T>,
#[pallet::compact] unbonding_points: BalanceOf<T>,
#[pezpallet::compact] unbonding_points: BalanceOf<T>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
let member_account = T::Lookup::lookup(member_account)?;
@@ -2355,8 +2355,8 @@ pub mod pallet {
/// can be cleared by withdrawing. In the case there are too many unlocking chunks, the user
/// would probably see an error like `NoMoreChunks` emitted from the staking system when
/// they attempt to unbond.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::pool_withdraw_unbonded(*num_slashing_spans))]
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::WeightInfo::pool_withdraw_unbonded(*num_slashing_spans))]
pub fn pool_withdraw_unbonded(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -2401,8 +2401,8 @@ pub mod pallet {
/// - If the pool has any pending slash, we also try to slash the member before letting them
/// withdraw. This calculation adds some weight overhead and is only defensive. In reality,
/// pool slashes must have been already applied via permissionless [`Call::apply_slash`].
#[pallet::call_index(5)]
#[pallet::weight(
#[pezpallet::call_index(5)]
#[pezpallet::weight(
T::WeightInfo::withdraw_unbonded_kill(*num_slashing_spans)
)]
pub fn withdraw_unbonded(
@@ -2467,13 +2467,13 @@ pub mod pallet {
if stash_killed {
// Maybe an extra consumer left on the pool account, if so, remove it.
if pezframe_system::Pallet::<T>::consumers(&pool_account) == 1 {
pezframe_system::Pallet::<T>::dec_consumers(&pool_account);
if pezframe_system::Pezpallet::<T>::consumers(&pool_account) == 1 {
pezframe_system::Pezpallet::<T>::dec_consumers(&pool_account);
}
// Note: This is not pretty, but we have to do this because of a bug where old pool
// accounts might have had an extra consumer increment. We know at this point no
// other pallet should depend on pool account so safe to do this.
// other pezpallet should depend on pool account so safe to do this.
// Refer to following issues:
// - https://github.com/pezkuwichain/pezkuwi-sdk/issues/135
// - https://github.com/pezkuwichain/pezkuwi-sdk/issues/116
@@ -2554,7 +2554,7 @@ pub mod pallet {
});
if member_account == bonded_pool.roles.depositor {
Pallet::<T>::dissolve_pool(bonded_pool);
Pezpallet::<T>::dissolve_pool(bonded_pool);
Weight::default()
} else {
bonded_pool.dec_members().put();
@@ -2588,11 +2588,11 @@ pub mod pallet {
///
/// In addition to `amount`, the caller will transfer the existential deposit; so the caller
/// needs at have at least `amount + existential_deposit` transferable.
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::create())]
#[pezpallet::call_index(6)]
#[pezpallet::weight(T::WeightInfo::create())]
pub fn create(
origin: OriginFor<T>,
#[pallet::compact] amount: BalanceOf<T>,
#[pezpallet::compact] amount: BalanceOf<T>,
root: AccountIdLookupOf<T>,
nominator: AccountIdLookupOf<T>,
bouncer: AccountIdLookupOf<T>,
@@ -2613,11 +2613,11 @@ pub mod pallet {
///
/// same as `create` with the inclusion of
/// * `pool_id` - `A valid PoolId.
#[pallet::call_index(7)]
#[pallet::weight(T::WeightInfo::create())]
#[pezpallet::call_index(7)]
#[pezpallet::weight(T::WeightInfo::create())]
pub fn create_with_pool_id(
origin: OriginFor<T>,
#[pallet::compact] amount: BalanceOf<T>,
#[pezpallet::compact] amount: BalanceOf<T>,
root: AccountIdLookupOf<T>,
nominator: AccountIdLookupOf<T>,
bouncer: AccountIdLookupOf<T>,
@@ -2643,8 +2643,8 @@ pub mod pallet {
///
/// In addition to a `root` or `nominator` role of `origin`, the pool's depositor needs to
/// have at least `depositor_min_bond` in the pool to start nominating.
#[pallet::call_index(8)]
#[pallet::weight(T::WeightInfo::nominate(validators.len() as u32))]
#[pezpallet::call_index(8)]
#[pezpallet::weight(T::WeightInfo::nominate(validators.len() as u32))]
pub fn nominate(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -2680,8 +2680,8 @@ pub mod pallet {
/// 1. signed by the bouncer, or the root role of the pool,
/// 2. if the pool conditions to be open are NOT met (as described by `ok_to_be_open`), and
/// then the state of the pool can be permissionlessly changed to `Destroying`.
#[pallet::call_index(9)]
#[pallet::weight(T::WeightInfo::set_state())]
#[pezpallet::call_index(9)]
#[pezpallet::weight(T::WeightInfo::set_state())]
pub fn set_state(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -2711,8 +2711,8 @@ pub mod pallet {
///
/// The dispatch origin of this call must be signed by the bouncer, or the root role of the
/// pool.
#[pallet::call_index(10)]
#[pallet::weight(T::WeightInfo::set_metadata(metadata.len() as u32))]
#[pezpallet::call_index(10)]
#[pezpallet::weight(T::WeightInfo::set_metadata(metadata.len() as u32))]
pub fn set_metadata(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -2748,8 +2748,8 @@ pub mod pallet {
/// * `max_members` - Set [`MaxPoolMembers`].
/// * `max_members_per_pool` - Set [`MaxPoolMembersPerPool`].
/// * `global_max_commission` - Set [`GlobalMaxCommission`].
#[pallet::call_index(11)]
#[pallet::weight(T::WeightInfo::set_configs())]
#[pezpallet::call_index(11)]
#[pezpallet::weight(T::WeightInfo::set_configs())]
pub fn set_configs(
origin: OriginFor<T>,
min_join_bond: ConfigOp<BalanceOf<T>>,
@@ -2797,8 +2797,8 @@ pub mod pallet {
///
/// It emits an event, notifying UIs of the role change. This event is quite relevant to
/// most pool members and they should be informed of changes to pool roles.
#[pallet::call_index(12)]
#[pallet::weight(T::WeightInfo::update_roles())]
#[pezpallet::call_index(12)]
#[pezpallet::weight(T::WeightInfo::update_roles())]
pub fn update_roles(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -2849,7 +2849,7 @@ pub mod pallet {
/// Chill on behalf of the pool.
///
/// The dispatch origin of this call can be signed by the pool nominator or the pool
/// root role, same as [`Pallet::nominate`].
/// root role, same as [`Pezpallet::nominate`].
///
/// This directly forwards the call to an implementation of `StakingInterface` (e.g.,
/// `pezpallet-staking`) through [`Config::StakeAdapter`], on behalf of the bonded pool.
@@ -2863,8 +2863,8 @@ pub mod pallet {
///
/// # Conditions for permissioned dispatch:
/// * The caller is the pool's nominator or root.
#[pallet::call_index(13)]
#[pallet::weight(T::WeightInfo::chill())]
#[pezpallet::call_index(13)]
#[pezpallet::weight(T::WeightInfo::chill())]
pub fn chill(origin: OriginFor<T>, pool_id: PoolId) -> DispatchResult {
let who = ensure_signed(origin)?;
let bonded_pool = BondedPool::<T>::get(pool_id).ok_or(Error::<T>::PoolNotFound)?;
@@ -2895,8 +2895,8 @@ pub mod pallet {
/// In the case of `origin != other`, `origin` can only bond extra pending rewards of
/// `other` members assuming set_claim_permission for the given member is
/// `PermissionlessCompound` or `PermissionlessAll`.
#[pallet::call_index(14)]
#[pallet::weight(
#[pezpallet::call_index(14)]
#[pezpallet::weight(
T::WeightInfo::bond_extra_transfer()
.max(T::WeightInfo::bond_extra_other())
)]
@@ -2923,8 +2923,8 @@ pub mod pallet {
///
/// * `origin` - Member of a pool.
/// * `permission` - The permission to be applied.
#[pallet::call_index(15)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
#[pezpallet::call_index(15)]
#[pezpallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn set_claim_permission(
origin: OriginFor<T>,
permission: ClaimPermission,
@@ -2954,8 +2954,8 @@ pub mod pallet {
///
/// Pool member `other` must have a `PermissionlessWithdraw` or `PermissionlessAll` claim
/// permission for this call to be successful.
#[pallet::call_index(16)]
#[pallet::weight(T::WeightInfo::claim_payout())]
#[pezpallet::call_index(16)]
#[pezpallet::weight(T::WeightInfo::claim_payout())]
pub fn claim_payout_other(origin: OriginFor<T>, other: T::AccountId) -> DispatchResult {
let signer = ensure_signed(origin)?;
// ensure member is not in an un-migrated state.
@@ -2973,8 +2973,8 @@ pub mod pallet {
/// tuple. Where a `current` of `None` is provided, any current commission will be removed.
///
/// - If a `None` is supplied to `new_commission`, existing commission will be removed.
#[pallet::call_index(17)]
#[pallet::weight(T::WeightInfo::set_commission())]
#[pezpallet::call_index(17)]
#[pezpallet::weight(T::WeightInfo::set_commission())]
pub fn set_commission(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -3012,8 +3012,8 @@ pub mod pallet {
/// - Initial max can be set to any `Perbill`, and only smaller values thereafter.
/// - Current commission will be lowered in the event it is higher than a new max
/// commission.
#[pallet::call_index(18)]
#[pallet::weight(T::WeightInfo::set_commission_max())]
#[pezpallet::call_index(18)]
#[pezpallet::weight(T::WeightInfo::set_commission_max())]
pub fn set_commission_max(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -3037,8 +3037,8 @@ pub mod pallet {
///
/// Initial change rate is not bounded, whereas subsequent updates can only be more
/// restrictive than the current.
#[pallet::call_index(19)]
#[pallet::weight(T::WeightInfo::set_commission_change_rate())]
#[pezpallet::call_index(19)]
#[pezpallet::weight(T::WeightInfo::set_commission_change_rate())]
pub fn set_commission_change_rate(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -3076,8 +3076,8 @@ pub mod pallet {
///
/// Pending commissions are paid out and added to the total claimed commission.
/// The total pending commission is reset to zero.
#[pallet::call_index(20)]
#[pallet::weight(T::WeightInfo::claim_commission())]
#[pezpallet::call_index(20)]
#[pezpallet::weight(T::WeightInfo::claim_commission())]
pub fn claim_commission(origin: OriginFor<T>, pool_id: PoolId) -> DispatchResult {
let who = ensure_signed(origin)?;
// ensure pool is not in an un-migrated state.
@@ -3093,8 +3093,8 @@ pub mod pallet {
/// insufficient to cover the ED deficit of the pool or vice-versa where there is excess
/// deposit to the pool. This call allows anyone to adjust the ED deposit of the
/// pool by either topping up the deficit or claiming the excess.
#[pallet::call_index(21)]
#[pallet::weight(T::WeightInfo::adjust_pool_deposit())]
#[pezpallet::call_index(21)]
#[pezpallet::weight(T::WeightInfo::adjust_pool_deposit())]
pub fn adjust_pool_deposit(origin: OriginFor<T>, pool_id: PoolId) -> DispatchResult {
let who = ensure_signed(origin)?;
// ensure pool is not in an un-migrated state.
@@ -3107,8 +3107,8 @@ pub mod pallet {
///
/// Determines who can claim the pool's pending commission. Only the `Root` role of the pool
/// is able to configure commission claim permissions.
#[pallet::call_index(22)]
#[pallet::weight(T::WeightInfo::set_commission_claim_permission())]
#[pezpallet::call_index(22)]
#[pezpallet::weight(T::WeightInfo::set_commission_claim_permission())]
pub fn set_commission_claim_permission(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -3133,15 +3133,15 @@ pub mod pallet {
/// Apply a pending slash on a member.
///
/// Fails unless [`crate::pallet::Config::StakeAdapter`] is of strategy type:
/// Fails unless [`crate::pezpallet::Config::StakeAdapter`] is of strategy type:
/// [`adapter::StakeStrategyType::Delegate`].
///
/// The pending slash amount of the member must be equal or more than `ExistentialDeposit`.
/// This call can be dispatched permissionlessly (i.e. by any account). If the execution
/// is successful, fee is refunded and caller may be rewarded with a part of the slash
/// based on the [`crate::pallet::Config::StakeAdapter`] configuration.
#[pallet::call_index(23)]
#[pallet::weight(T::WeightInfo::apply_slash())]
/// based on the [`crate::pezpallet::Config::StakeAdapter`] configuration.
#[pezpallet::call_index(23)]
#[pezpallet::weight(T::WeightInfo::apply_slash())]
pub fn apply_slash(
origin: OriginFor<T>,
member_account: AccountIdLookupOf<T>,
@@ -3161,15 +3161,15 @@ pub mod pallet {
/// Migrates delegated funds from the pool account to the `member_account`.
///
/// Fails unless [`crate::pallet::Config::StakeAdapter`] is of strategy type:
/// Fails unless [`crate::pezpallet::Config::StakeAdapter`] is of strategy type:
/// [`adapter::StakeStrategyType::Delegate`].
///
/// This is a permission-less call and refunds any fee if claim is successful.
///
/// If the pool has migrated to delegation based staking, the staked tokens of pool members
/// can be moved and held in their own account. See [`adapter::DelegateStake`]
#[pallet::call_index(24)]
#[pallet::weight(T::WeightInfo::migrate_delegation())]
#[pezpallet::call_index(24)]
#[pezpallet::weight(T::WeightInfo::migrate_delegation())]
pub fn migrate_delegation(
origin: OriginFor<T>,
member_account: AccountIdLookupOf<T>,
@@ -3211,7 +3211,7 @@ pub mod pallet {
ensure!(delegation.is_none(), Error::<T>::AlreadyMigrated);
T::StakeAdapter::migrate_delegation(
Pool::from(Pallet::<T>::generate_bonded_account(member.pool_id)),
Pool::from(Pezpallet::<T>::generate_bonded_account(member.pool_id)),
Member::from(member_account),
pool_contribution,
)?;
@@ -3223,14 +3223,14 @@ pub mod pallet {
/// Migrate pool from [`adapter::StakeStrategyType::Transfer`] to
/// [`adapter::StakeStrategyType::Delegate`].
///
/// Fails unless [`crate::pallet::Config::StakeAdapter`] is of strategy type:
/// Fails unless [`crate::pezpallet::Config::StakeAdapter`] is of strategy type:
/// [`adapter::StakeStrategyType::Delegate`].
///
/// This call can be dispatched permissionlessly, and refunds any fee if successful.
///
/// If the pool has already migrated to delegation based staking, this call will fail.
#[pallet::call_index(25)]
#[pallet::weight(T::WeightInfo::pool_migrate())]
#[pezpallet::call_index(25)]
#[pezpallet::weight(T::WeightInfo::pool_migrate())]
pub fn migrate_pool_to_delegate_stake(
origin: OriginFor<T>,
pool_id: PoolId,
@@ -3255,8 +3255,8 @@ pub mod pallet {
}
}
#[pallet::hooks]
impl<T: Config> Hooks<SystemBlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<SystemBlockNumberFor<T>> for Pezpallet<T> {
#[cfg(feature = "try-runtime")]
fn try_state(_n: SystemBlockNumberFor<T>) -> Result<(), TryRuntimeError> {
Self::do_try_state(u8::MAX)
@@ -3277,14 +3277,14 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// The amount of bond that MUST REMAIN IN BONDED in ALL POOLS.
///
/// It is the responsibility of the depositor to put these funds into the pool initially. Upon
/// unbond, they can never unbond to a value below this amount.
///
/// It is essentially `max { MinNominatorBond, MinCreateBond, MinJoinBond }`, where the former
/// is coming from the staking pallet and the latter two are configured in this pallet.
/// is coming from the staking pezpallet and the latter two are configured in this pezpallet.
pub fn depositor_min_bond() -> BalanceOf<T> {
T::StakeAdapter::minimum_nominator_bond()
.max(MinCreateBond::<T>::get())
@@ -3308,22 +3308,22 @@ impl<T: Config> Pallet<T> {
// Kill accounts from storage by making their balance go below ED. We assume that the
// accounts have no references that would prevent destruction once we get to this point. We
// don't work with the system pallet directly, but
// don't work with the system pezpallet directly, but
// 1. we drain the reward account and kill it. This account should never have any extra
// consumers anyway.
// 2. the bonded account should become a 'killed stash' in the staking system, and all of
// its consumers removed.
defensive_assert!(
pezframe_system::Pallet::<T>::consumers(&reward_account) == 0,
pezframe_system::Pezpallet::<T>::consumers(&reward_account) == 0,
"reward account of dissolving pool should have no consumers"
);
defensive_assert!(
pezframe_system::Pallet::<T>::consumers(&bonded_account) == 0,
pezframe_system::Pezpallet::<T>::consumers(&bonded_account) == 0,
"bonded account of dissolving pool should have no consumers"
);
defensive_assert!(
T::StakeAdapter::total_stake(Pool::from(bonded_pool.bonded_account())) == Zero::zero(),
"dissolving pool should not have any stake in the staking pallet"
"dissolving pool should not have any stake in the staking pezpallet"
);
// This shouldn't fail, but if it does we don't really care. Remaining balance can consist
@@ -3521,7 +3521,7 @@ impl<T: Config> Pallet<T> {
let nominator = T::Lookup::lookup(nominator)?;
let bouncer = T::Lookup::lookup(bouncer)?;
ensure!(amount >= Pallet::<T>::depositor_min_bond(), Error::<T>::MinimumBondNotMet);
ensure!(amount >= Pezpallet::<T>::depositor_min_bond(), Error::<T>::MinimumBondNotMet);
ensure!(
MaxPools::<T>::get().map_or(true, |max_pools| BondedPools::<T>::count() < max_pools),
Error::<T>::MaxPools
@@ -3760,7 +3760,7 @@ impl<T: Config> Pallet<T> {
T::StakeAdapter::member_slash(
Member::from(member_account.clone()),
Pool::from(Pallet::<T>::generate_bonded_account(member.pool_id)),
Pool::from(Pezpallet::<T>::generate_bonded_account(member.pool_id)),
pending_slash,
reporter,
)
@@ -3779,7 +3779,7 @@ impl<T: Config> Pallet<T> {
pool_member
);
let pool_account = Pallet::<T>::generate_bonded_account(pool_member.pool_id);
let pool_account = Pezpallet::<T>::generate_bonded_account(pool_member.pool_id);
// if the pool doesn't have any pending slash, it implies the member also does not have any
// pending slash.
if T::StakeAdapter::pending_slash(Pool::from(pool_account.clone())).is_zero() {
@@ -3812,9 +3812,9 @@ impl<T: Config> Pallet<T> {
T::Currency::thaw(&FreezeReason::PoolMinBalance.into(), reward_acc)
}
/// Ensure the correctness of the state of this pallet.
/// Ensure the correctness of the state of this pezpallet.
///
/// This should be valid before or after each state transition of this pallet.
/// This should be valid before or after each state transition of this pezpallet.
///
/// ## Invariants:
///
@@ -4000,7 +4000,7 @@ impl<T: Config> Pallet<T> {
}
for (pool_id, _pool) in BondedPools::<T>::iter() {
let pool_account = Pallet::<T>::generate_bonded_account(pool_id);
let pool_account = Pezpallet::<T>::generate_bonded_account(pool_id);
let subs = SubPoolsStorage::<T>::get(pool_id).unwrap_or_default();
let sum_unbonding_balance = subs.sum_unbonding_balance();
@@ -4078,7 +4078,7 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Returns the pending rewards for the specified `who` account.
///
/// In the case of error, `None` is returned. Used by runtime API.
@@ -4116,7 +4116,7 @@ impl<T: Config> Pallet<T> {
if let Some(pool) = BondedPool::<T>::get(pool_id) {
let bonded_balance =
T::StakeAdapter::active_stake(Pool::from(Self::generate_bonded_account(pool_id)));
Pallet::<T>::balance_to_point(bonded_balance, pool.points, new_funds)
Pezpallet::<T>::balance_to_point(bonded_balance, pool.points, new_funds)
} else {
Zero::zero()
}
@@ -4148,7 +4148,7 @@ impl<T: Config> Pallet<T> {
///
/// Useful to check this before calling [`Call::migrate_pool_to_delegate_stake`].
pub fn api_pool_needs_delegate_migration(pool_id: PoolId) -> bool {
// if the `Delegate` strategy is not used in the pallet, then no migration required.
// if the `Delegate` strategy is not used in the pezpallet, then no migration required.
if T::StakeAdapter::strategy_type() != adapter::StakeStrategyType::Delegate {
return false;
}
@@ -4171,7 +4171,7 @@ impl<T: Config> Pallet<T> {
///
/// Useful to check this before calling [`Call::migrate_delegation`].
pub fn api_member_needs_delegate_migration(who: T::AccountId) -> bool {
// if the `Delegate` strategy is not used in the pallet, then no migration required.
// if the `Delegate` strategy is not used in the pezpallet, then no migration required.
if T::StakeAdapter::strategy_type() != adapter::StakeStrategyType::Delegate {
return false;
}
@@ -4218,7 +4218,7 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> pezsp_staking::OnStakingUpdate<T::AccountId, BalanceOf<T>> for Pallet<T> {
impl<T: Config> pezsp_staking::OnStakingUpdate<T::AccountId, BalanceOf<T>> for Pezpallet<T> {
/// Reduces the balances of the [`SubPools`], that belong to the pool involved in the
/// slash, to the amount that is defined in the `slashed_unlocking` field of
/// [`pezsp_staking::OnStakingUpdate::on_slash`]
@@ -23,7 +23,7 @@ use pezframe_support::traits::{OnRuntimeUpgrade, UncheckedOnRuntimeUpgrade};
#[cfg(feature = "try-runtime")]
use pezsp_runtime::TryRuntimeError;
/// Exports for versioned migration `type`s for this pallet.
/// Exports for versioned migration `type`s for this pezpallet.
pub mod versioned {
use super::*;
@@ -32,7 +32,7 @@ pub mod versioned {
7,
8,
v8::VersionUncheckedMigrateV7ToV8<T>,
crate::pallet::Pallet<T>,
crate::pezpallet::Pezpallet<T>,
<T as pezframe_system::Config>::DbWeight,
>;
@@ -42,7 +42,7 @@ pub mod versioned {
6,
7,
v7::VersionUncheckedMigrateV6ToV7<T>,
crate::pallet::Pallet<T>,
crate::pezpallet::Pezpallet<T>,
<T as pezframe_system::Config>::DbWeight,
>;
@@ -51,7 +51,7 @@ pub mod versioned {
5,
6,
v6::MigrateToV6<T>,
crate::pallet::Pallet<T>,
crate::pezpallet::Pezpallet<T>,
<T as pezframe_system::Config>::DbWeight,
>;
}
@@ -112,7 +112,7 @@ pub mod unversioned {
/// [`adapter::StakeStrategyType::Delegate`].
///
/// Note: This only migrates the pools, the members are not migrated. They can use the
/// permission-less [`Pallet::migrate_delegation()`] to migrate their funds.
/// permission-less [`Pezpallet::migrate_delegation()`] to migrate their funds.
///
/// This migration does not break any existing pool storage item, does not need to happen in any
/// sequence and hence can be applied unversioned on a production runtime.
@@ -132,13 +132,13 @@ pub mod unversioned {
let mut count: u32 = 0;
BondedPools::<T>::iter_keys().take(MaxPools::get() as usize).for_each(|id| {
let pool_acc = Pallet::<T>::generate_bonded_account(id);
let pool_acc = Pezpallet::<T>::generate_bonded_account(id);
// only migrate if the pool is in Transfer Strategy.
if T::StakeAdapter::pool_strategy(Pool::from(pool_acc)) ==
adapter::StakeStrategyType::Transfer
{
let _ = Pallet::<T>::migrate_to_delegate_stake(id).map_err(|err| {
let _ = Pezpallet::<T>::migrate_to_delegate_stake(id).map_err(|err| {
log!(
warn,
"failed to migrate pool {:?} to delegate stake strategy with err: {:?}",
@@ -178,7 +178,7 @@ pub mod unversioned {
let mut pool_balances: Vec<BalanceOf<T>> = Vec::new();
BondedPools::<T>::iter_keys().take(MaxPools::get() as usize).for_each(|id| {
let pool_account = Pallet::<T>::generate_bonded_account(id);
let pool_account = Pezpallet::<T>::generate_bonded_account(id);
// we ensure migration is idempotent.
let pool_balance = T::StakeAdapter::total_balance(Pool::from(pool_account.clone()))
@@ -198,7 +198,7 @@ pub mod unversioned {
for (index, id) in
BondedPools::<T>::iter_keys().take(MaxPools::get() as usize).enumerate()
{
let pool_account = Pallet::<T>::generate_bonded_account(id);
let pool_account = Pezpallet::<T>::generate_bonded_account(id);
if T::StakeAdapter::pool_strategy(Pool::from(pool_account.clone())) ==
adapter::StakeStrategyType::Transfer
{
@@ -332,14 +332,14 @@ pub(crate) mod v7 {
impl<T: Config> V7BondedPool<T> {
#[allow(dead_code)]
fn bonded_account(&self) -> T::AccountId {
Pallet::<T>::generate_bonded_account(self.id)
Pezpallet::<T>::generate_bonded_account(self.id)
}
}
// NOTE: We cannot put a V7 prefix here since that would change the storage key.
#[pezframe_support::storage_alias]
pub type BondedPools<T: Config> =
CountedStorageMap<Pallet<T>, Twox64Concat, PoolId, V7BondedPoolInner<T>>;
CountedStorageMap<Pezpallet<T>, Twox64Concat, PoolId, V7BondedPoolInner<T>>;
pub struct VersionUncheckedMigrateV6ToV7<T>(core::marker::PhantomData<T>);
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV6ToV7<T> {
@@ -388,7 +388,7 @@ pub(crate) mod v7 {
);
ensure!(
Pallet::<T>::on_chain_storage_version() >= 7,
Pezpallet::<T>::on_chain_storage_version() >= 7,
"nomination-pools::migration::v7: wrong storage version"
);
@@ -406,8 +406,8 @@ mod v6 {
impl<T: Config> MigrateToV6<T> {
fn freeze_ed(pool_id: PoolId) -> Result<(), ()> {
let reward_acc = Pallet::<T>::generate_reward_account(pool_id);
Pallet::<T>::freeze_pool_deposit(&reward_acc).map_err(|e| {
let reward_acc = Pezpallet::<T>::generate_reward_account(pool_id);
Pezpallet::<T>::freeze_pool_deposit(&reward_acc).map_err(|e| {
log!(error, "Failed to freeze ED for pool {} with error: {:?}", pool_id, e);
()
})
@@ -442,7 +442,7 @@ mod v6 {
#[cfg(feature = "try-runtime")]
fn post_upgrade(_data: Vec<u8>) -> Result<(), TryRuntimeError> {
// there should be no ED imbalances anymore..
Pallet::<T>::check_ed_imbalance().map(|_| ())
Pezpallet::<T>::check_ed_imbalance().map(|_| ())
}
}
}
@@ -473,8 +473,8 @@ pub mod v5 {
pub struct MigrateToV5<T>(core::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV5<T> {
fn on_runtime_upgrade() -> Weight {
let in_code = Pallet::<T>::in_code_storage_version();
let onchain = Pallet::<T>::on_chain_storage_version();
let in_code = Pezpallet::<T>::in_code_storage_version();
let onchain = Pezpallet::<T>::on_chain_storage_version();
log!(
info,
@@ -490,7 +490,7 @@ pub mod v5 {
Some(old_value.migrate_to_v5())
});
in_code.put::<Pallet<T>>();
in_code.put::<Pezpallet<T>>();
log!(info, "Upgraded {} pools, storage to version {:?}", translated, in_code);
// reads: translated + onchain version.
@@ -560,7 +560,7 @@ pub mod v5 {
"a commission value has been incorrectly set"
);
ensure!(
Pallet::<T>::on_chain_storage_version() >= 5,
Pezpallet::<T>::on_chain_storage_version() >= 5,
"nomination-pools::migration::v5: wrong storage version"
);
@@ -628,8 +628,8 @@ pub mod v4 {
#[allow(deprecated)]
impl<T: Config, U: Get<Perbill>> OnRuntimeUpgrade for MigrateToV4<T, U> {
fn on_runtime_upgrade() -> Weight {
let current = Pallet::<T>::in_code_storage_version();
let onchain = Pallet::<T>::on_chain_storage_version();
let current = Pezpallet::<T>::in_code_storage_version();
let onchain = Pezpallet::<T>::on_chain_storage_version();
log!(
info,
@@ -654,7 +654,7 @@ pub mod v4 {
Some(old_value.migrate_to_v4())
});
StorageVersion::new(4).put::<Pallet<T>>();
StorageVersion::new(4).put::<Pezpallet<T>>();
log!(info, "Upgraded {} pools, storage to version {:?}", translated, current);
// reads: translated + onchain version.
@@ -694,7 +694,7 @@ pub mod v4 {
"global maximum commission error"
);
ensure!(
Pallet::<T>::on_chain_storage_version() >= 4,
Pezpallet::<T>::on_chain_storage_version() >= 4,
"nomination-pools::migration::v4: wrong storage version"
);
Ok(())
@@ -709,8 +709,8 @@ pub mod v3 {
pub struct MigrateToV3<T>(core::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV3<T> {
fn on_runtime_upgrade() -> Weight {
let current = Pallet::<T>::in_code_storage_version();
let onchain = Pallet::<T>::on_chain_storage_version();
let current = Pezpallet::<T>::in_code_storage_version();
let onchain = Pezpallet::<T>::on_chain_storage_version();
if onchain == 2 {
log!(
@@ -733,7 +733,7 @@ pub mod v3 {
metadata_removed += 1;
Metadata::<T>::remove(&id);
});
StorageVersion::new(3).put::<Pallet<T>>();
StorageVersion::new(3).put::<Pezpallet<T>>();
// metadata iterated + bonded pools read + a storage version read
let total_reads = metadata_iterated * 2 + 1;
// metadata removed + a storage version write
@@ -757,7 +757,7 @@ pub mod v3 {
"not all of the stale metadata has been removed"
);
ensure!(
Pallet::<T>::on_chain_storage_version() >= 3,
Pezpallet::<T>::on_chain_storage_version() >= 3,
"nomination-pools::migration::v3: wrong storage version"
);
Ok(())
@@ -890,7 +890,7 @@ pub mod v2 {
};
let accumulated_reward = RewardPool::<T>::current_balance(id);
let reward_account = Pallet::<T>::generate_reward_account(id);
let reward_account = Pezpallet::<T>::generate_reward_account(id);
let mut sum_paid_out = BalanceOf::<T>::zero();
members
@@ -938,7 +938,7 @@ pub mod v2 {
sum_paid_out = sum_paid_out.saturating_add(last_claim);
}
Pallet::<T>::deposit_event(Event::<T>::PaidOut {
Pezpallet::<T>::deposit_event(Event::<T>::PaidOut {
member: who.clone(),
pool_id: id,
payout: last_claim,
@@ -981,7 +981,7 @@ pub mod v2 {
total_points_locked,
current
);
current.put::<Pallet<T>>();
current.put::<Pezpallet<T>>();
T::DbWeight::get().reads_writes(members_translated + 1, reward_pools_translated + 1)
}
@@ -989,8 +989,8 @@ pub mod v2 {
impl<T: Config> OnRuntimeUpgrade for MigrateToV2<T> {
fn on_runtime_upgrade() -> Weight {
let current = Pallet::<T>::in_code_storage_version();
let onchain = Pallet::<T>::on_chain_storage_version();
let current = Pezpallet::<T>::in_code_storage_version();
let onchain = Pezpallet::<T>::on_chain_storage_version();
log!(
info,
@@ -1013,7 +1013,7 @@ pub mod v2 {
RewardPools::<T>::iter().try_for_each(|(id, _)| -> Result<(), TryRuntimeError> {
ensure!(
<T::Currency as pezframe_support::traits::fungible::Inspect<T::AccountId>>::balance(
&Pallet::<T>::generate_reward_account(id)
&Pezpallet::<T>::generate_reward_account(id)
) >= T::Currency::minimum_balance(),
"Reward accounts must have greater balance than ED."
);
@@ -1027,7 +1027,7 @@ pub mod v2 {
fn post_upgrade(_: Vec<u8>) -> Result<(), TryRuntimeError> {
// new version must be set.
ensure!(
Pallet::<T>::on_chain_storage_version() == 2,
Pezpallet::<T>::on_chain_storage_version() == 2,
"The onchain version must be updated after the migration."
);
@@ -1107,8 +1107,8 @@ pub mod v1 {
pub struct MigrateToV1<T>(core::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
fn on_runtime_upgrade() -> Weight {
let current = Pallet::<T>::in_code_storage_version();
let onchain = Pallet::<T>::on_chain_storage_version();
let current = Pezpallet::<T>::in_code_storage_version();
let onchain = Pezpallet::<T>::on_chain_storage_version();
log!(
info,
@@ -1125,7 +1125,7 @@ pub mod v1 {
Some(old_value.migrate_to_v1())
});
current.put::<Pallet<T>>();
current.put::<Pezpallet<T>>();
log!(info, "Upgraded {} pools, storage to version {:?}", translated, current);
@@ -1140,10 +1140,10 @@ pub mod v1 {
fn post_upgrade(_: Vec<u8>) -> Result<(), TryRuntimeError> {
// new version must be set.
ensure!(
Pallet::<T>::on_chain_storage_version() == 1,
Pezpallet::<T>::on_chain_storage_version() == 1,
"The onchain version must be updated after the migration."
);
Pallet::<T>::try_state(pezframe_system::Pallet::<T>::block_number())?;
Pezpallet::<T>::try_state(pezframe_system::Pezpallet::<T>::block_number())?;
Ok(())
}
}
@@ -1155,7 +1155,7 @@ mod helpers {
pub(crate) fn calculate_tvl_by_total_stake<T: Config>() -> BalanceOf<T> {
BondedPools::<T>::iter_keys()
.map(|id| {
T::StakeAdapter::total_stake(Pool::from(Pallet::<T>::generate_bonded_account(id)))
T::StakeAdapter::total_stake(Pool::from(Pezpallet::<T>::generate_bonded_account(id)))
})
.reduce(|acc, total_balance| acc + total_balance)
.unwrap_or_default()
@@ -32,7 +32,7 @@ pub type BlockNumber = u64;
pub type AccountId = u128;
pub type Balance = u128;
pub type RewardCounter = FixedU128;
// This sneaky little hack allows us to write code exactly as we would do in the pallet in the tests
// This sneaky little hack allows us to write code exactly as we would do in the pezpallet in the tests
// as well, e.g. `StorageItem::<T>::get()`.
pub type T = Runtime;
pub type Currency = <T as Config>::Currency;
@@ -70,7 +70,7 @@ impl StakingMock {
}
/// Mimics a slash towards a pool specified by `pool_id`.
/// This reduces the bonded balance of a pool by `amount` and calls [`Pools::on_slash`] to
/// enact changes in the nomination-pool pallet.
/// enact changes in the nomination-pool pezpallet.
///
/// Does not modify any [`SubPools`] of the pool as [`Default::default`] is passed for
/// `slashed_unlocking`.
@@ -165,7 +165,7 @@ impl pezsp_staking::StakingInterface for StakingMock {
staker_map.retain(|(unlocking_at, _amount)| *unlocking_at > current_era);
// if there was a withdrawal, notify the pallet.
// if there was a withdrawal, notify the pezpallet.
let withdraw_amount = unlocking_before.saturating_sub(unlocking(&staker_map));
Pools::on_withdraw(&who, withdraw_amount);
DelegateMock::on_withdraw(who, withdraw_amount);
@@ -578,7 +578,7 @@ impl ExtBuilder {
ext.execute_with(|| {
// for events to be deposited.
pezframe_system::Pallet::<Runtime>::set_block_number(1);
pezframe_system::Pezpallet::<Runtime>::set_block_number(1);
// make a pool
let amount_to_bond = Pools::depositor_min_bond();
@@ -623,7 +623,7 @@ pub fn run_blocks(n: u64) {
System::run_to_block::<AllPalletsWithSystem>(n + current_block);
}
/// All events of this pallet.
/// All events of this pezpallet.
pub fn pool_events_since_last_call() -> Vec<super::Event<Runtime>> {
let events = System::events()
.into_iter()
@@ -635,7 +635,7 @@ pub fn pool_events_since_last_call() -> Vec<super::Event<Runtime>> {
events.into_iter().skip(already_seen as usize).collect()
}
/// All events of the `Balances` pallet.
/// All events of the `Balances` pezpallet.
pub fn balances_events_since_last_call() -> Vec<pezpallet_balances::Event<Runtime>> {
let events = System::events()
.into_iter()
@@ -222,33 +222,33 @@ mod bonded_pool {
fn api_points_to_balance_works() {
ExtBuilder::default().build_and_execute(|| {
assert!(BondedPool::<Runtime>::get(1).is_some());
assert_eq!(Pallet::<Runtime>::api_points_to_balance(1, 10), 10);
assert_eq!(Pezpallet::<Runtime>::api_points_to_balance(1, 10), 10);
// slash half of the pool's balance. expected result of `fn api_points_to_balance`
// to be 1/2 of the pool's balance.
StakingMock::slash_by(1, Pools::depositor_min_bond() / 2);
assert_eq!(Pallet::<Runtime>::api_points_to_balance(1, 10), 5);
assert_eq!(Pezpallet::<Runtime>::api_points_to_balance(1, 10), 5);
// if pool does not exist, points to balance ratio is 0.
assert_eq!(BondedPool::<Runtime>::get(2), None);
assert_eq!(Pallet::<Runtime>::api_points_to_balance(2, 10), 0);
assert_eq!(Pezpallet::<Runtime>::api_points_to_balance(2, 10), 0);
})
}
#[test]
fn api_balance_to_points_works() {
ExtBuilder::default().build_and_execute(|| {
assert_eq!(Pallet::<Runtime>::api_balance_to_points(1, 0), 0);
assert_eq!(Pallet::<Runtime>::api_balance_to_points(1, 10), 10);
assert_eq!(Pezpallet::<Runtime>::api_balance_to_points(1, 0), 0);
assert_eq!(Pezpallet::<Runtime>::api_balance_to_points(1, 10), 10);
// slash half of the pool's balance. expect result of `fn api_balance_to_points`
// to be 2 * of the balance to add to the pool.
StakingMock::slash_by(1, Pools::depositor_min_bond() / 2);
assert_eq!(Pallet::<Runtime>::api_balance_to_points(1, 10), 20);
assert_eq!(Pezpallet::<Runtime>::api_balance_to_points(1, 10), 20);
// if pool does not exist, balance to points ratio is 0.
assert_eq!(BondedPool::<Runtime>::get(2), None);
assert_eq!(Pallet::<Runtime>::api_points_to_balance(2, 10), 0);
assert_eq!(Pezpallet::<Runtime>::api_points_to_balance(2, 10), 0);
})
}
@@ -26,14 +26,14 @@
// Executed Command:
// target/production/bizinikiwi-node
// benchmark
// pallet
// pezpallet
// --steps=50
// --repeat=20
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/pezkuwi-sdk/.git/.artifacts/bench.json
// --pallet=pezpallet_nomination_pools
// --pezpallet=pezpallet_nomination_pools
// --chain=dev
// --header=./bizinikiwi/HEADER-APACHE2
// --output=./bizinikiwi/pezframe/nomination-pools/src/weights.rs
@@ -6,7 +6,7 @@ edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME nomination pools pallet tests with the staking pallet"
description = "FRAME nomination pools pezpallet tests with the staking pezpallet"
publish = false
documentation = "https://docs.rs/pezpallet-nomination-pools-test-delegate-stake"
@@ -97,7 +97,7 @@ parameter_types! {
impl pezpallet_staking::Config for Runtime {
type OldCurrency = Balances;
type Currency = Balances;
type UnixTime = pezpallet_timestamp::Pallet<Self>;
type UnixTime = pezpallet_timestamp::Pezpallet<Self>;
type AdminOrigin = pezframe_system::EnsureRoot<Self::AccountId>;
type BondingDuration = BondingDuration;
type EraPayout = pezpallet_staking::ConvertCurve<RewardCurve>;
@@ -326,7 +326,7 @@ pub fn new_test_ext() -> pezsp_io::TestExternalities {
ext.execute_with(|| {
// for events to be deposited.
pezframe_system::Pallet::<Runtime>::set_block_number(1);
pezframe_system::Pezpallet::<Runtime>::set_block_number(1);
// set some limit for nominations.
assert_ok!(Staking::set_staking_configs(