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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user