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
@@ -20,7 +20,7 @@
use super::*;
#[allow(unused)]
use crate::Pallet as CollatorSelection;
use crate::Pezpallet as CollatorSelection;
use alloc::vec::Vec;
use codec::Decode;
use core::cmp;
@@ -36,7 +36,7 @@ pub type BalanceOf<T> =
const SEED: u32 = 0;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = pezframe_system::Pallet::<T>::events();
let events = pezframe_system::Pezpallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let EventRecord { event, .. } = &events[events.len() - 1];
@@ -49,8 +49,8 @@ fn create_funded_user<T: Config>(
balance_factor: u32,
) -> T::AccountId {
let user = account(string, n, SEED);
let balance = <T as pallet::Config>::Currency::minimum_balance() * balance_factor.into();
let _ = <T as pallet::Config>::Currency::make_free_balance_be(&user, balance);
let balance = <T as pezpallet::Config>::Currency::minimum_balance() * balance_factor.into();
let _ = <T as pezpallet::Config>::Currency::make_free_balance_be(&user, balance);
user
}
@@ -79,8 +79,8 @@ fn register_validators<T: Config + session::Config>(count: u32) -> Vec<T::Accoun
let validators = (0..count).map(|c| validator::<T>(c)).collect::<Vec<_>>();
for (who, keys) in validators.clone() {
<session::Pallet<T>>::ensure_can_pay_key_deposit(&who).unwrap();
<session::Pallet<T>>::set_keys(RawOrigin::Signed(who).into(), keys, Vec::new()).unwrap();
<session::Pezpallet<T>>::ensure_can_pay_key_deposit(&who).unwrap();
<session::Pezpallet<T>>::set_keys(RawOrigin::Signed(who).into(), keys, Vec::new()).unwrap();
}
validators.into_iter().map(|(who, _)| who).collect()
@@ -91,7 +91,7 @@ fn register_candidates<T: Config>(count: u32) {
assert!(CandidacyBond::<T>::get() > 0u32.into(), "Bond cannot be zero!");
for who in candidates {
<T as pallet::Config>::Currency::make_free_balance_be(
<T as pezpallet::Config>::Currency::make_free_balance_be(
&who,
CandidacyBond::<T>::get() * 3u32.into(),
);
@@ -148,7 +148,7 @@ mod benchmarks {
T::UpdateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
// need to fill up candidates
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
CandidacyBond::<T>::put(<T as pezpallet::Config>::Currency::minimum_balance());
DesiredCandidates::<T>::put(c);
// get accounts and keys for the `c` candidates
let mut candidates = (0..c).map(|cc| validator::<T>(cc)).collect::<Vec<_>>();
@@ -159,23 +159,23 @@ mod benchmarks {
candidates.push((new_invulnerable.clone(), new_invulnerable_keys));
// set their keys ...
for (who, keys) in candidates.clone() {
<session::Pallet<T>>::ensure_can_pay_key_deposit(&who).unwrap();
<session::Pallet<T>>::set_keys(RawOrigin::Signed(who).into(), keys, Vec::new())
<session::Pezpallet<T>>::ensure_can_pay_key_deposit(&who).unwrap();
<session::Pezpallet<T>>::set_keys(RawOrigin::Signed(who).into(), keys, Vec::new())
.unwrap();
}
// ... and register them.
for (who, _) in candidates.iter() {
let deposit = CandidacyBond::<T>::get();
<T as pallet::Config>::Currency::make_free_balance_be(who, deposit * 1000_u32.into());
<T as pezpallet::Config>::Currency::make_free_balance_be(who, deposit * 1000_u32.into());
CandidateList::<T>::try_mutate(|list| {
list.try_push(CandidateInfo { who: who.clone(), deposit }).unwrap();
Ok::<(), BenchmarkError>(())
})
.unwrap();
<T as pallet::Config>::Currency::reserve(who, deposit)?;
<T as pezpallet::Config>::Currency::reserve(who, deposit)?;
LastAuthoredBlock::<T>::insert(
who.clone(),
pezframe_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
pezframe_system::Pezpallet::<T>::block_number() + T::KickThreshold::get(),
);
}
@@ -232,7 +232,7 @@ mod benchmarks {
k: Linear<0, { T::MaxCandidates::get() }>,
) -> Result<(), BenchmarkError> {
let initial_bond_amount: BalanceOf<T> =
<T as pallet::Config>::Currency::minimum_balance() * 2u32.into();
<T as pezpallet::Config>::Currency::minimum_balance() * 2u32.into();
CandidacyBond::<T>::put(initial_bond_amount);
register_validators::<T>(c);
register_candidates::<T>(c);
@@ -242,12 +242,12 @@ mod benchmarks {
let bond_amount = if k > 0 {
CandidateList::<T>::mutate(|candidates| {
for info in candidates.iter_mut().skip(kicked as usize) {
info.deposit = <T as pallet::Config>::Currency::minimum_balance() * 3u32.into();
info.deposit = <T as pezpallet::Config>::Currency::minimum_balance() * 3u32.into();
}
});
<T as pallet::Config>::Currency::minimum_balance() * 3u32.into()
<T as pezpallet::Config>::Currency::minimum_balance() * 3u32.into()
} else {
<T as pallet::Config>::Currency::minimum_balance()
<T as pezpallet::Config>::Currency::minimum_balance()
};
#[extrinsic_call]
@@ -261,7 +261,7 @@ mod benchmarks {
fn update_bond(
c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>,
) -> Result<(), BenchmarkError> {
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
CandidacyBond::<T>::put(<T as pezpallet::Config>::Currency::minimum_balance());
DesiredCandidates::<T>::put(c);
register_validators::<T>(c);
@@ -270,8 +270,8 @@ mod benchmarks {
let caller = CandidateList::<T>::get()[0].who.clone();
v2::whitelist!(caller);
let bond_amount: BalanceOf<T> = <T as pallet::Config>::Currency::minimum_balance() +
<T as pallet::Config>::Currency::minimum_balance();
let bond_amount: BalanceOf<T> = <T as pezpallet::Config>::Currency::minimum_balance() +
<T as pezpallet::Config>::Currency::minimum_balance();
#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), bond_amount);
@@ -281,7 +281,7 @@ mod benchmarks {
);
assert!(
CandidateList::<T>::get().iter().last().unwrap().deposit ==
<T as pallet::Config>::Currency::minimum_balance() * 2u32.into()
<T as pezpallet::Config>::Currency::minimum_balance() * 2u32.into()
);
Ok(())
}
@@ -290,18 +290,18 @@ mod benchmarks {
// one.
#[benchmark]
fn register_as_candidate(c: Linear<1, { T::MaxCandidates::get() - 1 }>) {
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
CandidacyBond::<T>::put(<T as pezpallet::Config>::Currency::minimum_balance());
DesiredCandidates::<T>::put(c + 1);
register_validators::<T>(c);
register_candidates::<T>(c);
let caller: T::AccountId = whitelisted_caller();
let bond: BalanceOf<T> = <T as pallet::Config>::Currency::minimum_balance() * 2u32.into();
<T as pallet::Config>::Currency::make_free_balance_be(&caller, bond);
let bond: BalanceOf<T> = <T as pezpallet::Config>::Currency::minimum_balance() * 2u32.into();
<T as pezpallet::Config>::Currency::make_free_balance_be(&caller, bond);
<session::Pallet<T>>::ensure_can_pay_key_deposit(&caller).unwrap();
<session::Pallet<T>>::set_keys(
<session::Pezpallet<T>>::ensure_can_pay_key_deposit(&caller).unwrap();
<session::Pezpallet<T>>::set_keys(
RawOrigin::Signed(caller.clone()).into(),
keys::<T>(c + 1),
Vec::new(),
@@ -318,18 +318,18 @@ mod benchmarks {
#[benchmark]
fn take_candidate_slot(c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>) {
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
CandidacyBond::<T>::put(<T as pezpallet::Config>::Currency::minimum_balance());
DesiredCandidates::<T>::put(1);
register_validators::<T>(c);
register_candidates::<T>(c);
let caller: T::AccountId = whitelisted_caller();
let bond: BalanceOf<T> = <T as pallet::Config>::Currency::minimum_balance() * 10u32.into();
<T as pallet::Config>::Currency::make_free_balance_be(&caller, bond);
let bond: BalanceOf<T> = <T as pezpallet::Config>::Currency::minimum_balance() * 10u32.into();
<T as pezpallet::Config>::Currency::make_free_balance_be(&caller, bond);
<session::Pallet<T>>::ensure_can_pay_key_deposit(&caller).unwrap();
<session::Pallet<T>>::set_keys(
<session::Pezpallet<T>>::ensure_can_pay_key_deposit(&caller).unwrap();
<session::Pezpallet<T>>::set_keys(
RawOrigin::Signed(caller.clone()).into(),
keys::<T>(c + 1),
Vec::new(),
@@ -350,7 +350,7 @@ mod benchmarks {
// worse case is the last candidate leaving.
#[benchmark]
fn leave_intent(c: Linear<{ min_candidates::<T>() + 1 }, { T::MaxCandidates::get() }>) {
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
CandidacyBond::<T>::put(<T as pezpallet::Config>::Currency::minimum_balance());
DesiredCandidates::<T>::put(c);
register_validators::<T>(c);
@@ -368,24 +368,24 @@ mod benchmarks {
// worse case is paying a non-existing candidate account.
#[benchmark]
fn note_author() {
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
<T as pallet::Config>::Currency::make_free_balance_be(
CandidacyBond::<T>::put(<T as pezpallet::Config>::Currency::minimum_balance());
<T as pezpallet::Config>::Currency::make_free_balance_be(
&<CollatorSelection<T>>::account_id(),
<T as pallet::Config>::Currency::minimum_balance() * 4u32.into(),
<T as pezpallet::Config>::Currency::minimum_balance() * 4u32.into(),
);
let author = account("author", 0, SEED);
let new_block: BlockNumberFor<T> = 10u32.into();
pezframe_system::Pallet::<T>::set_block_number(new_block);
assert!(<T as pallet::Config>::Currency::free_balance(&author) == 0u32.into());
pezframe_system::Pezpallet::<T>::set_block_number(new_block);
assert!(<T as pezpallet::Config>::Currency::free_balance(&author) == 0u32.into());
#[block]
{
<CollatorSelection<T> as EventHandler<_, _>>::note_author(author.clone())
}
assert!(<T as pallet::Config>::Currency::free_balance(&author) > 0u32.into());
assert_eq!(pezframe_system::Pallet::<T>::block_number(), new_block);
assert!(<T as pezpallet::Config>::Currency::free_balance(&author) > 0u32.into());
assert_eq!(pezframe_system::Pezpallet::<T>::block_number(), new_block);
}
// worst case for new session.
@@ -394,9 +394,9 @@ mod benchmarks {
r: Linear<1, { T::MaxCandidates::get() }>,
c: Linear<1, { T::MaxCandidates::get() }>,
) {
CandidacyBond::<T>::put(<T as pallet::Config>::Currency::minimum_balance());
CandidacyBond::<T>::put(<T as pezpallet::Config>::Currency::minimum_balance());
DesiredCandidates::<T>::put(c);
pezframe_system::Pallet::<T>::set_block_number(0u32.into());
pezframe_system::Pezpallet::<T>::set_block_number(0u32.into());
register_validators::<T>(c);
register_candidates::<T>(c);
@@ -427,7 +427,7 @@ mod benchmarks {
let min_candidates = min_candidates::<T>();
let pre_length = CandidateList::<T>::decode_len().unwrap_or_default();
pezframe_system::Pallet::<T>::set_block_number(new_block);
pezframe_system::Pezpallet::<T>::set_block_number(new_block);
let current_length: u32 = CandidateList::<T>::decode_len()
.unwrap_or_default()
@@ -13,14 +13,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Collator Selection pallet.
//! Collator Selection pezpallet.
//!
//! A pallet to manage collators in a teyrchain.
//! A pezpallet to manage collators in a teyrchain.
//!
//! ## Overview
//!
//! The Collator Selection pallet manages the collators of a teyrchain. **Collation is _not_ a
//! secure activity** and this pallet does not implement any game-theoretic mechanisms to meet BFT
//! The Collator Selection pezpallet manages the collators of a teyrchain. **Collation is _not_ a
//! secure activity** and this pezpallet does not implement any game-theoretic mechanisms to meet BFT
//! safety assumptions of the chosen set.
//!
//! ## Terminology
@@ -67,7 +67,7 @@
//!
//! ### Rewards
//!
//! The Collator Selection pallet maintains an on-chain account (the "Pot"). In each block, the
//! The Collator Selection pezpallet maintains an on-chain account (the "Pot"). In each block, the
//! collator who authored it receives:
//!
//! - Half the value of the Pot.
@@ -85,7 +85,7 @@ extern crate alloc;
use core::marker::PhantomData;
use pezframe_support::traits::TypedGet;
pub use pallet::*;
pub use pezpallet::*;
#[cfg(test)]
mod mock;
@@ -100,8 +100,8 @@ pub mod weights;
const LOG_TARGET: &str = "runtime::collator-selection";
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
pub use crate::weights::WeightInfo;
use alloc::vec::Vec;
use core::ops::Div;
@@ -128,7 +128,7 @@ pub mod pallet {
type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance;
/// A convertor from collators id. Since this pallet does not have stash/controller, this is
/// A convertor from collators id. Since this pezpallet does not have stash/controller, this is
/// just identity.
pub struct IdentityCollator;
impl<T> pezsp_runtime::traits::Convert<T, Option<T>> for IdentityCollator {
@@ -137,8 +137,8 @@ pub mod pallet {
}
}
/// Configure the pallet by specifying the parameters and types on which it depends.
#[pallet::config]
/// Configure the pezpallet by specifying the parameters and types on which it depends.
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// Overarching event type.
#[allow(deprecated)]
@@ -147,31 +147,31 @@ pub mod pallet {
/// The currency mechanism.
type Currency: ReservableCurrency<Self::AccountId>;
/// Origin that can dictate updating parameters of this pallet.
/// Origin that can dictate updating parameters of this pezpallet.
type UpdateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// Account Identifier from which the internal Pot is generated.
#[pallet::constant]
#[pezpallet::constant]
type PotId: Get<PalletId>;
/// Maximum number of candidates that we should have.
///
/// This does not take into account the invulnerables.
#[pallet::constant]
#[pezpallet::constant]
type MaxCandidates: Get<u32>;
/// Minimum number eligible collators. Should always be greater than zero. This includes
/// Invulnerable collators. This ensures that there will always be one collator who can
/// produce a block.
#[pallet::constant]
#[pezpallet::constant]
type MinEligibleCollators: Get<u32>;
/// Maximum number of invulnerables.
#[pallet::constant]
#[pezpallet::constant]
type MaxInvulnerables: Get<u32>;
// Will be kicked if block is not produced in threshold.
#[pallet::constant]
#[pezpallet::constant]
type KickThreshold: Get<BlockNumberFor<Self>>;
/// A stable ID for a validator.
@@ -185,13 +185,13 @@ pub mod pallet {
/// Validate a user is registered
type ValidatorRegistration: ValidatorRegistration<Self::ValidatorId>;
/// The weight information of this pallet.
/// The weight information of this pezpallet.
type WeightInfo: WeightInfo;
}
#[pallet::extra_constants]
impl<T: Config> Pallet<T> {
/// Gets this pallet's derived pot account.
#[pezpallet::extra_constants]
impl<T: Config> Pezpallet<T> {
/// Gets this pezpallet's derived pot account.
fn pot_account() -> T::AccountId {
Self::account_id()
}
@@ -208,12 +208,12 @@ pub mod pallet {
pub deposit: Balance,
}
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
/// The invulnerable, permissioned collators. This list must be sorted.
#[pallet::storage]
#[pezpallet::storage]
pub type Invulnerables<T: Config> =
StorageValue<_, BoundedVec<T::AccountId, T::MaxInvulnerables>, ValueQuery>;
@@ -222,7 +222,7 @@ pub mod pallet {
///
/// This list is sorted in ascending order by deposit and when the deposits are equal, the least
/// recently updated is considered greater.
#[pallet::storage]
#[pezpallet::storage]
pub type CandidateList<T: Config> = StorageValue<
_,
BoundedVec<CandidateInfo<T::AccountId, BalanceOf<T>>, T::MaxCandidates>,
@@ -230,23 +230,23 @@ pub mod pallet {
>;
/// Last block authored by collator.
#[pallet::storage]
#[pezpallet::storage]
pub type LastAuthoredBlock<T: Config> =
StorageMap<_, Twox64Concat, T::AccountId, BlockNumberFor<T>, ValueQuery>;
/// Desired number of candidates.
///
/// This should ideally always be less than [`Config::MaxCandidates`] for weights to be correct.
#[pallet::storage]
#[pezpallet::storage]
pub type DesiredCandidates<T> = StorageValue<_, u32, ValueQuery>;
/// Fixed amount to deposit to become a collator.
///
/// When a collator calls `leave_intent` they immediately receive the deposit back.
#[pallet::storage]
#[pezpallet::storage]
pub type CandidacyBond<T> = StorageValue<_, BalanceOf<T>, ValueQuery>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub invulnerables: Vec<T::AccountId>,
@@ -254,7 +254,7 @@ pub mod pallet {
pub desired_candidates: u32,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
let duplicate_invulnerables = self
@@ -282,8 +282,8 @@ pub mod pallet {
}
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// New Invulnerables were set.
NewInvulnerables { invulnerables: Vec<T::AccountId> },
@@ -308,9 +308,9 @@ pub mod pallet {
InvalidInvulnerableSkipped { account_id: T::AccountId },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// The pallet has too many candidates.
/// The pezpallet has too many candidates.
TooManyCandidates,
/// Leaving would result in too few candidates.
TooFewEligibleCollators,
@@ -346,8 +346,8 @@ pub mod pallet {
InvalidUnreserve,
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
fn integrity_test() {
assert!(T::MinEligibleCollators::get() > 0, "chain must require at least one collator");
assert!(
@@ -363,8 +363,8 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Set the list of invulnerable (fixed) collators. These collators must do some
/// preparation, namely to have registered session keys.
///
@@ -378,8 +378,8 @@ pub mod pallet {
/// `new`, they should be removed with `remove_invulnerable_candidate` after execution.
///
/// Must be called by the `UpdateOrigin`.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::set_invulnerables(new.len() as u32))]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::set_invulnerables(new.len() as u32))]
pub fn set_invulnerables(origin: OriginFor<T>, new: Vec<T::AccountId>) -> DispatchResult {
T::UpdateOrigin::ensure_origin(origin)?;
@@ -450,8 +450,8 @@ pub mod pallet {
/// there should be no other way to have more candidates than the desired number.
///
/// The origin for this call must be the `UpdateOrigin`.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::set_desired_candidates())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::set_desired_candidates())]
pub fn set_desired_candidates(
origin: OriginFor<T>,
max: u32,
@@ -473,8 +473,8 @@ pub mod pallet {
/// back.
///
/// The origin for this call must be the `UpdateOrigin`.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::set_candidacy_bond(
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::set_candidacy_bond(
T::MaxCandidates::get(),
T::MaxCandidates::get()
))]
@@ -519,8 +519,8 @@ pub mod pallet {
/// registered session keys and (b) be able to reserve the `CandidacyBond`.
///
/// This call is not available to `Invulnerable` collators.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::register_as_candidate(T::MaxCandidates::get()))]
#[pezpallet::call_index(3)]
#[pezpallet::weight(T::WeightInfo::register_as_candidate(T::MaxCandidates::get()))]
pub fn register_as_candidate(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
@@ -549,7 +549,7 @@ pub mod pallet {
T::Currency::reserve(&who, deposit)?;
LastAuthoredBlock::<T>::insert(
who.clone(),
pezframe_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
pezframe_system::Pezpallet::<T>::block_number() + T::KickThreshold::get(),
);
candidates
.try_insert(0, CandidateInfo { who: who.clone(), deposit })
@@ -569,8 +569,8 @@ pub mod pallet {
///
/// This call will fail if the total number of candidates would drop below
/// `MinEligibleCollators`.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCandidates::get()))]
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::WeightInfo::leave_intent(T::MaxCandidates::get()))]
pub fn leave_intent(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
ensure!(
@@ -588,8 +588,8 @@ pub mod pallet {
/// registered session keys. If `who` is a candidate, they will be removed.
///
/// The origin for this call must be the `UpdateOrigin`.
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::add_invulnerable(
#[pezpallet::call_index(5)]
#[pezpallet::weight(T::WeightInfo::add_invulnerable(
T::MaxInvulnerables::get().saturating_sub(1),
T::MaxCandidates::get()
))]
@@ -641,8 +641,8 @@ pub mod pallet {
/// be sorted.
///
/// The origin for this call must be the `UpdateOrigin`.
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::remove_invulnerable(T::MaxInvulnerables::get()))]
#[pezpallet::call_index(6)]
#[pezpallet::weight(T::WeightInfo::remove_invulnerable(T::MaxInvulnerables::get()))]
pub fn remove_invulnerable(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
T::UpdateOrigin::ensure_origin(origin)?;
@@ -669,8 +669,8 @@ pub mod pallet {
///
/// This call will fail if `origin` is not a collator candidate, the updated bond is lower
/// than the minimum candidacy bond, and/or the amount cannot be reserved.
#[pallet::call_index(7)]
#[pallet::weight(T::WeightInfo::update_bond(T::MaxCandidates::get()))]
#[pezpallet::call_index(7)]
#[pezpallet::weight(T::WeightInfo::update_bond(T::MaxCandidates::get()))]
pub fn update_bond(
origin: OriginFor<T>,
new_deposit: BalanceOf<T>,
@@ -731,8 +731,8 @@ pub mod pallet {
/// This call will fail if the caller is already a collator candidate or invulnerable, the
/// caller does not have registered session keys, the target is not a collator candidate,
/// and/or the `deposit` amount cannot be reserved.
#[pallet::call_index(8)]
#[pallet::weight(T::WeightInfo::take_candidate_slot(T::MaxCandidates::get()))]
#[pezpallet::call_index(8)]
#[pezpallet::weight(T::WeightInfo::take_candidate_slot(T::MaxCandidates::get()))]
pub fn take_candidate_slot(
origin: OriginFor<T>,
deposit: BalanceOf<T>,
@@ -803,7 +803,7 @@ pub mod pallet {
LastAuthoredBlock::<T>::remove(target_info.who.clone());
LastAuthoredBlock::<T>::insert(
who.clone(),
pezframe_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
pezframe_system::Pezpallet::<T>::block_number() + T::KickThreshold::get(),
);
Self::deposit_event(Event::CandidateReplaced { old: target, new: who, deposit });
@@ -811,7 +811,7 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Get a unique, inaccessible account ID from the `PotId`.
pub fn account_id() -> T::AccountId {
T::PotId::get().into_account_truncating()
@@ -872,7 +872,7 @@ pub mod pallet {
///
/// Return value is the number of candidates left in the list.
pub fn kick_stale_candidates(candidates: impl IntoIterator<Item = T::AccountId>) -> u32 {
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
let kick_threshold = T::KickThreshold::get();
let min_collators = T::MinEligibleCollators::get();
candidates
@@ -907,9 +907,9 @@ pub mod pallet {
.expect("filter_map operation can't result in a bounded vec larger than its original; qed")
}
/// 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
///
@@ -924,7 +924,7 @@ pub mod pallet {
pezframe_support::ensure!(
desired_candidates <= T::MaxCandidates::get(),
"Shouldn't demand more candidates than the pallet config allows."
"Shouldn't demand more candidates than the pezpallet config allows."
);
pezframe_support::ensure!(
@@ -940,7 +940,7 @@ pub mod pallet {
/// Keep track of number of authored blocks per authority, uncles are counted as well since
/// they're a valid proof of being online.
impl<T: Config + pezpallet_authorship::Config>
pezpallet_authorship::EventHandler<T::AccountId, BlockNumberFor<T>> for Pallet<T>
pezpallet_authorship::EventHandler<T::AccountId, BlockNumberFor<T>> for Pezpallet<T>
{
fn note_author(author: T::AccountId) {
let pot = Self::account_id();
@@ -952,9 +952,9 @@ pub mod pallet {
// `reward` is half of pot account minus ED, this should never fail.
let _success = T::Currency::transfer(&pot, &author, reward, KeepAlive);
debug_assert!(_success.is_ok());
LastAuthoredBlock::<T>::insert(author, pezframe_system::Pallet::<T>::block_number());
LastAuthoredBlock::<T>::insert(author, pezframe_system::Pezpallet::<T>::block_number());
pezframe_system::Pallet::<T>::register_extra_weight_unchecked(
pezframe_system::Pezpallet::<T>::register_extra_weight_unchecked(
T::WeightInfo::note_author(),
DispatchClass::Mandatory,
);
@@ -962,12 +962,12 @@ pub mod pallet {
}
/// Play the role of the session manager.
impl<T: Config> SessionManager<T::AccountId> for Pallet<T> {
impl<T: Config> SessionManager<T::AccountId> for Pezpallet<T> {
fn new_session(index: SessionIndex) -> Option<Vec<T::AccountId>> {
log::info!(
"assembling new collators for new session {} at #{:?}",
index,
<pezframe_system::Pallet<T>>::block_number(),
<pezframe_system::Pezpallet<T>>::block_number(),
);
// The `expect` below is safe because the list is a `BoundedVec` with a max size of
@@ -985,7 +985,7 @@ pub mod pallet {
let removed = candidates_len_before.saturating_sub(active_candidates_count);
let result = Self::assemble_collators();
pezframe_system::Pallet::<T>::register_extra_weight_unchecked(
pezframe_system::Pezpallet::<T>::register_extra_weight_unchecked(
T::WeightInfo::new_session(removed, candidates_len_before),
DispatchClass::Mandatory,
);
@@ -1008,6 +1008,6 @@ where
{
type Type = <R as pezframe_system::Config>::AccountId;
fn get() -> Self::Type {
<crate::Pallet<R>>::account_id()
<crate::Pezpallet<R>>::account_id()
}
}
@@ -39,13 +39,13 @@ pub mod v2 {
1,
2,
UncheckedMigrationToV2<T>,
Pallet<T>,
Pezpallet<T>,
<T as pezframe_system::Config>::DbWeight,
>;
#[storage_alias]
pub type Candidates<T: Config> = StorageValue<
Pallet<T>,
Pezpallet<T>,
BoundedVec<CandidateInfo<<T as pezframe_system::Config>::AccountId, <<T as Config>::Currency as Currency<<T as pezframe_system::Config>::AccountId>>::Balance>, <T as Config>::MaxCandidates>,
ValueQuery,
>;
@@ -127,14 +127,14 @@ pub mod v1 {
pub struct MigrateToV1<T>(PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
fn on_runtime_upgrade() -> Weight {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
if on_chain_version == 0 {
let invulnerables_len = Invulnerables::<T>::get().to_vec().len();
Invulnerables::<T>::mutate(|invulnerables| {
invulnerables.sort();
});
StorageVersion::new(1).put::<Pallet<T>>();
StorageVersion::new(1).put::<Pezpallet<T>>();
log::info!(
target: LOG_TARGET,
"Sorted {} Invulnerables, upgraded storage to version 1",
@@ -179,7 +179,7 @@ pub mod v1 {
"after migration, there should be the same number of invulnerables"
);
let on_chain_version = Pallet::<T>::on_chain_storage_version();
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
pezframe_support::ensure!(on_chain_version >= 1, "must_upgrade");
Ok(())
@@ -204,7 +204,7 @@ mod tests {
fn migrate_to_v2_with_new_candidates() {
new_test_ext().execute_with(|| {
let storage_version = StorageVersion::new(1);
storage_version.put::<Pallet<Test>>();
storage_version.put::<Pezpallet<Test>>();
let one = 1u64;
let two = 2u64;
@@ -252,7 +252,7 @@ mod tests {
// Run migration
v2::MigrationToV2::<Test>::on_runtime_upgrade();
let new_storage_version = StorageVersion::get::<Pallet<Test>>();
let new_storage_version = StorageVersion::get::<Pezpallet<Test>>();
assert_eq!(new_storage_version, 2);
// 10 should have been unreserved from the old candidacy
@@ -270,7 +270,7 @@ mod tests {
fn migrate_to_v2_without_new_candidates() {
new_test_ext().execute_with(|| {
let storage_version = StorageVersion::new(1);
storage_version.put::<Pallet<Test>>();
storage_version.put::<Pezpallet<Test>>();
let one = 1u64;
let two = 2u64;
@@ -306,7 +306,7 @@ mod tests {
// Run migration
v2::MigrationToV2::<Test>::on_runtime_upgrade();
let new_storage_version = StorageVersion::get::<Pallet<Test>>();
let new_storage_version = StorageVersion::get::<Pezpallet<Test>>();
assert_eq!(new_storage_version, 2);
// Nothing changes deposit-wise
@@ -26,7 +26,7 @@ use pezsp_runtime::{testing::UintAuthorityId, traits::OpaqueKeys, BuildStorage,
type Block = pezframe_system::mocking::MockBlock<Test>;
// Configure a mock runtime to test the pallet.
// Configure a mock runtime to test the pezpallet.
pezframe_support::construct_runtime!(
pub enum Test
{