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
+1 -1
View File
@@ -27,7 +27,7 @@ use pezframe_system::RawOrigin;
use pezsp_runtime::traits::Saturating;
use super::*;
use crate::Pallet as TipsMod;
use crate::Pezpallet as TipsMod;
const SEED: u32 = 0;
+46 -46
View File
@@ -15,9 +15,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! # Tipping Pallet ( pezpallet-tips )
//! # Tipping Pezpallet ( pezpallet-tips )
//!
//! > NOTE: This pallet is tightly coupled with pezpallet-treasury.
//! > NOTE: This pezpallet is tightly coupled with pezpallet-treasury.
//!
//! A subsystem to allow for an agile "tipping" process, whereby a reward may be given without first
//! having a pre-determined stakeholder group come to consensus on how much should be paid.
@@ -82,7 +82,7 @@ use pezframe_system::pezpallet_prelude::BlockNumberFor;
#[cfg(any(feature = "try-runtime", test))]
use pezsp_runtime::TryRuntimeError;
pub use pallet::*;
pub use pezpallet::*;
pub use weights::WeightInfo;
const LOG_TARGET: &str = "runtime::tips";
@@ -118,8 +118,8 @@ pub struct OpenTip<
finders_fee: bool,
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
@@ -127,12 +127,12 @@ pub mod pallet {
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(4);
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
#[pallet::without_storage_info]
pub struct Pallet<T, I = ()>(_);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(STORAGE_VERSION)]
#[pezpallet::without_storage_info]
pub struct Pezpallet<T, I = ()>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config<I: 'static = ()>: pezframe_system::Config + pezpallet_treasury::Config<I> {
/// The overarching event type.
#[allow(deprecated)]
@@ -142,27 +142,27 @@ pub mod pallet {
/// Maximum acceptable reason length.
///
/// Benchmarks depend on this value, be sure to update weights file when changing this value
#[pallet::constant]
#[pezpallet::constant]
type MaximumReasonLength: Get<u32>;
/// The amount held on deposit per byte within the tip report reason or bounty description.
#[pallet::constant]
#[pezpallet::constant]
type DataDepositPerByte: Get<BalanceOf<Self, I>>;
/// The period for which a tip remains open after is has achieved threshold tippers.
#[pallet::constant]
#[pezpallet::constant]
type TipCountdown: Get<BlockNumberFor<Self>>;
/// The percent of the final tip which goes to the original reporter of the tip.
#[pallet::constant]
#[pezpallet::constant]
type TipFindersFee: Get<Percent>;
/// The non-zero amount held on deposit for placing a tip report.
#[pallet::constant]
#[pezpallet::constant]
type TipReportDepositBase: Get<BalanceOf<Self, I>>;
/// The maximum amount for a single tip.
#[pallet::constant]
#[pezpallet::constant]
type MaxTipAmount: Get<BalanceOf<Self, I>>;
/// Origin from which tippers must come.
@@ -175,14 +175,14 @@ pub mod pallet {
/// Handler for the unbalanced decrease when slashing for a removed tip.
type OnSlash: OnUnbalanced<NegativeImbalanceOf<Self, I>>;
/// Weight information for extrinsics in this pallet.
/// Weight information for extrinsics in this pezpallet.
type WeightInfo: WeightInfo;
}
/// TipsMap that are not yet completed. Keyed by the hash of `(reason, who)` from the value.
/// This has the insecure enumerable hash function since the key itself is already
/// guaranteed to be a secure hash.
#[pallet::storage]
#[pezpallet::storage]
pub type Tips<T: Config<I>, I: 'static = ()> = StorageMap<
_,
Twox64Concat,
@@ -193,12 +193,12 @@ pub mod pallet {
/// Simple preimage lookup from the reason's hash to the original data. Again, has an
/// insecure enumerable hash since the key is guaranteed to be the result of a secure hash.
#[pallet::storage]
#[pezpallet::storage]
pub type Reasons<T: Config<I>, I: 'static = ()> =
StorageMap<_, Identity, T::Hash, Vec<u8>, OptionQuery>;
#[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<I>, I: 'static = ()> {
/// A new tip suggestion has been opened.
NewTip { tip_hash: T::Hash },
@@ -212,7 +212,7 @@ pub mod pallet {
TipSlashed { tip_hash: T::Hash, finder: T::AccountId, deposit: BalanceOf<T, I> },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T, I = ()> {
/// The reason given is just too big.
ReasonTooBig,
@@ -230,8 +230,8 @@ pub mod pallet {
Premature,
}
#[pallet::call]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
#[pezpallet::call]
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
/// Report something `reason` that deserves a tip and claim any eventual the finder's fee.
///
/// The dispatch origin for this call must be _Signed_.
@@ -248,8 +248,8 @@ pub mod pallet {
/// ## Complexity
/// - `O(R)` where `R` length of `reason`.
/// - encoding and hashing of 'reason'
#[pallet::call_index(0)]
#[pallet::weight(<T as Config<I>>::WeightInfo::report_awesome(reason.len() as u32))]
#[pezpallet::call_index(0)]
#[pezpallet::weight(<T as Config<I>>::WeightInfo::report_awesome(reason.len() as u32))]
pub fn report_awesome(
origin: OriginFor<T>,
reason: Vec<u8>,
@@ -303,8 +303,8 @@ pub mod pallet {
/// ## Complexity
/// - `O(1)`
/// - Depends on the length of `T::Hash` which is fixed.
#[pallet::call_index(1)]
#[pallet::weight(<T as Config<I>>::WeightInfo::retract_tip())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(<T as Config<I>>::WeightInfo::retract_tip())]
pub fn retract_tip(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
let who = ensure_signed(origin)?;
let tip = Tips::<T, I>::get(&hash).ok_or(Error::<T, I>::UnknownTip)?;
@@ -339,13 +339,13 @@ pub mod pallet {
/// `ContainsLengthBound`. The actual cost depends on the implementation of
/// `T::Tippers`.
/// - `O(R)`: hashing and encoding of reason of length `R`
#[pallet::call_index(2)]
#[pallet::weight(<T as Config<I>>::WeightInfo::tip_new(reason.len() as u32, T::Tippers::max_len() as u32))]
#[pezpallet::call_index(2)]
#[pezpallet::weight(<T as Config<I>>::WeightInfo::tip_new(reason.len() as u32, T::Tippers::max_len() as u32))]
pub fn tip_new(
origin: OriginFor<T>,
reason: Vec<u8>,
who: AccountIdLookupOf<T>,
#[pallet::compact] tip_value: BalanceOf<T, I>,
#[pezpallet::compact] tip_value: BalanceOf<T, I>,
) -> DispatchResult {
let tipper = ensure_signed(origin)?;
let who = T::Lookup::lookup(who)?;
@@ -394,12 +394,12 @@ pub mod pallet {
///
/// Actually weight could be lower as it depends on how many tips are in `OpenTip` but it
/// is weighted as if almost full i.e of length `T-1`.
#[pallet::call_index(3)]
#[pallet::weight(<T as Config<I>>::WeightInfo::tip(T::Tippers::max_len() as u32))]
#[pezpallet::call_index(3)]
#[pezpallet::weight(<T as Config<I>>::WeightInfo::tip(T::Tippers::max_len() as u32))]
pub fn tip(
origin: OriginFor<T>,
hash: T::Hash,
#[pallet::compact] tip_value: BalanceOf<T, I>,
#[pezpallet::compact] tip_value: BalanceOf<T, I>,
) -> DispatchResult {
let tipper = ensure_signed(origin)?;
ensure!(T::Tippers::contains(&tipper), BadOrigin);
@@ -428,14 +428,14 @@ pub mod pallet {
/// - : `O(T)` where `T` is the number of tippers. decoding `Tipper` vec of length `T`. `T`
/// is charged as upper bound given by `ContainsLengthBound`. The actual cost depends on
/// the implementation of `T::Tippers`.
#[pallet::call_index(4)]
#[pallet::weight(<T as Config<I>>::WeightInfo::close_tip(T::Tippers::max_len() as u32))]
#[pezpallet::call_index(4)]
#[pezpallet::weight(<T as Config<I>>::WeightInfo::close_tip(T::Tippers::max_len() as u32))]
pub fn close_tip(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
ensure_signed(origin)?;
let tip = Tips::<T, I>::get(hash).ok_or(Error::<T, I>::UnknownTip)?;
let n = tip.closes.as_ref().ok_or(Error::<T, I>::StillOpen)?;
ensure!(pezframe_system::Pallet::<T>::block_number() >= *n, Error::<T, I>::Premature);
ensure!(pezframe_system::Pezpallet::<T>::block_number() >= *n, Error::<T, I>::Premature);
// closed.
Reasons::<T, I>::remove(&tip.reason);
Tips::<T, I>::remove(hash);
@@ -453,8 +453,8 @@ pub mod pallet {
///
/// ## Complexity
/// - O(1).
#[pallet::call_index(5)]
#[pallet::weight(<T as Config<I>>::WeightInfo::slash_tip(T::Tippers::max_len() as u32))]
#[pezpallet::call_index(5)]
#[pezpallet::weight(<T as Config<I>>::WeightInfo::slash_tip(T::Tippers::max_len() as u32))]
pub fn slash_tip(origin: OriginFor<T>, hash: T::Hash) -> DispatchResult {
T::RejectOrigin::ensure_origin(origin)?;
@@ -474,8 +474,8 @@ pub mod pallet {
}
}
#[pallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pallet<T, I> {
#[pezpallet::hooks]
impl<T: Config<I>, I: 'static> Hooks<BlockNumberFor<T>> for Pezpallet<T, I> {
fn integrity_test() {
assert!(
!T::TipReportDepositBase::get().is_zero(),
@@ -490,7 +490,7 @@ pub mod pallet {
}
}
impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> Pezpallet<T, I> {
// Add public immutables and private mutables.
/// Access tips storage from outside
@@ -529,7 +529,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Self::retain_active_tips(&mut tip.tips);
let threshold = T::Tippers::count().div_ceil(2);
if tip.tips.len() >= threshold && tip.closes.is_none() {
tip.closes = Some(pezframe_system::Pallet::<T>::block_number() + T::TipCountdown::get());
tip.closes = Some(pezframe_system::Pezpallet::<T>::block_number() + T::TipCountdown::get());
true
} else {
false
@@ -570,7 +570,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
tips.sort_by_key(|i| i.1);
let treasury = Self::account_id();
let max_payout = pezpallet_treasury::Pallet::<T, I>::pot();
let max_payout = pezpallet_treasury::Pezpallet::<T, I>::pot();
let mut payout = tips[tips.len() / 2].1.min(max_payout);
if !tip.deposit.is_zero() {
@@ -647,9 +647,9 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
}
}
/// Ensure the correctness of the state of this pallet.
/// Ensure the correctness of the state of this pezpallet.
///
/// This should be valid before and after each state transition of this pallet.
/// This should be valid before and after each state transition of this pezpallet.
///
/// ## Invariants:
/// 1. The number of entries in `Tips` should be equal to `Reasons`.
@@ -22,5 +22,5 @@
/// own storage identifier.
pub mod v4;
/// A migration that unreserves all funds held in the context of this pallet.
/// A migration that unreserves all funds held in the context of this pezpallet.
pub mod unreserve_deposits;
@@ -16,7 +16,7 @@
// limitations under the License.
//! A migration that unreserves all deposit and unlocks all stake held in the context of this
//! pallet.
//! pezpallet.
use alloc::collections::btree_map::BTreeMap;
use core::iter::Sum;
@@ -43,17 +43,17 @@ pub trait UnlockConfig<I>: 'static {
type AccountId: Parameter + Ord;
/// The currency type used in the runtime.
///
/// Should match the currency type previously used for the pallet, if applicable.
/// Should match the currency type previously used for the pezpallet, if applicable.
type Currency: LockableCurrency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
/// Base deposit to report a tip.
///
/// Should match the currency type previously used for the pallet, if applicable.
/// Should match the currency type previously used for the pezpallet, if applicable.
type TipReportDepositBase: pezsp_core::Get<BalanceOf<Self, I>>;
/// Deposit per byte to report a tip.
///
/// Should match the currency type previously used for the pallet, if applicable.
/// Should match the currency type previously used for the pezpallet, if applicable.
type DataDepositPerByte: pezsp_core::Get<BalanceOf<Self, I>>;
/// The name of the pallet as previously configured in
/// The name of the pezpallet as previously configured in
/// [`construct_runtime!`](pezframe_support::construct_runtime).
type PalletName: pezsp_core::Get<&'static str>;
/// The DB weight as configured in the runtime to calculate the correct weight.
@@ -80,21 +80,21 @@ type Tips<T: UnlockConfig<I>, I: 'static> = StorageMap<
/// A migration that unreserves all tip deposits.
///
/// Useful to prevent funds from being locked up when the pallet is deprecated.
/// Useful to prevent funds from being locked up when the pezpallet is deprecated.
///
/// The pallet should be made inoperable before or immediately after this migration is run.
/// The pezpallet should be made inoperable before or immediately after this migration is run.
///
/// (See also the `RemovePallet` migration in `frame/support/src/migrations.rs`)
pub struct UnreserveDeposits<T: UnlockConfig<I>, I: 'static>(core::marker::PhantomData<(T, I)>);
impl<T: UnlockConfig<I>, I: 'static> UnreserveDeposits<T, I> {
/// Calculates and returns the total amount reserved by each account by this pallet from open
/// Calculates and returns the total amount reserved by each account by this pezpallet from open
/// tips.
///
/// # Returns
///
/// * `BTreeMap<T::AccountId, T::Balance>`: Map of account IDs to their respective total
/// reserved balance by this pallet
/// reserved balance by this pezpallet
/// * `pezframe_support::weights::Weight`: The weight of this operation.
fn get_deposits() -> (BTreeMap<T::AccountId, BalanceOf<T, I>>, pezframe_support::weights::Weight) {
use pezsp_core::Get;
@@ -123,21 +123,21 @@ where
/// checks and prints some summary information.
///
/// Steps:
/// 1. Gets the deposited balances for each account stored in this pallet.
/// 1. Gets the deposited balances for each account stored in this pezpallet.
/// 2. Collects actual pre-migration reserved balances for each account.
/// 3. Checks the integrity of the deposited balances.
/// 4. Prints summary statistics about the state to be migrated.
/// 5. Returns the pre-migration actual reserved balance for each account that will
/// be part of the migration.
///
/// Fails with a `TryRuntimeError` if somehow the amount reserved by this pallet is greater than
/// Fails with a `TryRuntimeError` if somehow the amount reserved by this pezpallet is greater than
/// the actual total reserved amount for any accounts.
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<alloc::vec::Vec<u8>, pezsp_runtime::TryRuntimeError> {
use codec::Encode;
use pezframe_support::ensure;
// Get the Tips pallet view of balances it has reserved
// Get the Tips pezpallet view of balances it has reserved
let (account_deposits, _) = Self::get_deposits();
// Get the actual amounts reserved for accounts with open tips
@@ -147,7 +147,7 @@ where
.collect();
// The deposit amount must be less than or equal to the reserved amount.
// If it is higher, there is either a bug with the pallet or a bug in the calculation of the
// If it is higher, there is either a bug with the pezpallet or a bug in the calculation of the
// deposit amount.
ensure!(
account_deposits.iter().all(|(account, deposit)| *deposit <=
@@ -170,7 +170,7 @@ where
fn on_runtime_upgrade() -> pezframe_support::weights::Weight {
use pezframe_support::traits::Get;
// Get staked and deposited balances as reported by this pallet.
// Get staked and deposited balances as reported by this pezpallet.
let (account_deposits, initial_reads) = Self::get_deposits();
// Deposited funds need to be unreserved.
@@ -198,7 +198,7 @@ where
)
.map_err(|_| "Failed to decode account_reserved_before_bytes")?;
// Get deposited balances as reported by this pallet.
// Get deposited balances as reported by this pezpallet.
let (account_deposits, _) = Self::get_deposits();
// Check that the reserved balance is reduced by the expected deposited amount.
@@ -30,7 +30,7 @@ use pezframe_support::{
use crate as pezpallet_tips;
/// Migrate the entire storage of this pallet to a new prefix.
/// Migrate the entire storage of this pezpallet to a new prefix.
///
/// This new prefix must be the same as the one set in construct_runtime.
/// For safety, use `PalletInfo` to get it, as:
@@ -48,7 +48,7 @@ pub fn migrate<T: pezpallet_tips::Config, P: GetStorageVersion + PalletInfoAcces
if new_pallet_name == old_pallet_name {
log::info!(
target: LOG_TARGET,
"New pallet name is equal to the old prefix. No migration needs to be done.",
"New pezpallet name is equal to the old prefix. No migration needs to be done.",
);
return Weight::zero();
}
+3 -3
View File
@@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Treasury pallet tests.
//! Treasury pezpallet tests.
#![cfg(test)]
@@ -103,7 +103,7 @@ parameter_types! {
impl pezpallet_treasury::Config for Test {
type PalletId = TreasuryPalletId;
type Currency = pezpallet_balances::Pallet<Test>;
type Currency = pezpallet_balances::Pezpallet<Test>;
type RejectOrigin = pezframe_system::EnsureRoot<u128>;
type RuntimeEvent = RuntimeEvent;
type SpendPeriod = ConstU64<2>;
@@ -126,7 +126,7 @@ impl pezpallet_treasury::Config for Test {
impl pezpallet_treasury::Config<Instance1> for Test {
type PalletId = TreasuryPalletId2;
type Currency = pezpallet_balances::Pallet<Test>;
type Currency = pezpallet_balances::Pezpallet<Test>;
type RejectOrigin = pezframe_system::EnsureRoot<u128>;
type RuntimeEvent = RuntimeEvent;
type SpendPeriod = ConstU64<2>;
+2 -2
View File
@@ -44,10 +44,10 @@
// frame-omni-bencher
// v1
// benchmark
// pallet
// pezpallet
// --extrinsic=*
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
// --pallet=pezpallet_tips
// --pezpallet=pezpallet_tips
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/tips/src/weights.rs
// --wasm-execution=compiled