fix: Complete snowbridge pezpallet rebrand and critical bug fixes
- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs) - pallet/ directories → pezpallet/ (4 locations) - Fixed pezpallet.rs self-include recursion bug - Fixed sc-chain-spec hardcoded crate name in derive macro - Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API) - Added BizinikiwiConfig type alias for zombienet tests - Deleted obsolete session state files Verified: pezsnowbridge-pezpallet-*, pezpallet-staking, pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
@@ -15,14 +15,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Benchmarks for pallet origin restriction.
|
||||
//! Benchmarks for pezpallet origin restriction.
|
||||
|
||||
use super::*;
|
||||
use pezframe_benchmarking::{v2::*, BenchmarkError};
|
||||
use pezsp_runtime::traits::DispatchTransaction;
|
||||
|
||||
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
|
||||
pezframe_system::Pallet::<T>::assert_last_event(generic_event.into());
|
||||
pezframe_system::Pezpallet::<T>::assert_last_event(generic_event.into());
|
||||
}
|
||||
|
||||
#[benchmarks]
|
||||
@@ -37,7 +37,7 @@ mod benches {
|
||||
|
||||
Usages::<T>::insert(&entity, Usage { used: 1u32.into(), at_block: 0u32.into() });
|
||||
|
||||
pezframe_system::Pallet::<T>::set_block_number(1_000u32.into());
|
||||
pezframe_system::Pezpallet::<T>::set_block_number(1_000u32.into());
|
||||
|
||||
#[extrinsic_call]
|
||||
_(pezframe_system::RawOrigin::Root, entity.clone());
|
||||
@@ -67,5 +67,5 @@ mod benches {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
impl_benchmark_test_suite!(Pezpallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! # Origin restriction pallet and transaction extension
|
||||
//! # Origin restriction pezpallet and transaction extension
|
||||
//!
|
||||
//! This pallet tracks certain origin and limits how much total "fee usage" they can accumulate.
|
||||
//! This pezpallet tracks certain origin and limits how much total "fee usage" they can accumulate.
|
||||
//! Usage gradually recovers as blocks pass.
|
||||
//!
|
||||
//! First the entity is extracted from the restricted origin, the entity represents the granularity
|
||||
@@ -95,9 +95,9 @@ pub trait RestrictedEntity<OriginCaller, Balance>: Sized {
|
||||
fn benchmarked_restricted_origin() -> OriginCaller;
|
||||
}
|
||||
|
||||
pub use pallet::*;
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
pub use pezpallet::*;
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::{pezpallet_prelude::*, traits::ContainsPair};
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
@@ -118,11 +118,11 @@ pub mod pallet {
|
||||
T,
|
||||
>>::Balance;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
/// The current usage for each entity.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Usages<T: Config> = StorageMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -130,7 +130,7 @@ pub mod pallet {
|
||||
Usage<BalanceOf<T>, BlockNumberFor<T>>,
|
||||
>;
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config:
|
||||
pezframe_system::Config<
|
||||
RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
|
||||
@@ -139,7 +139,7 @@ pub mod pallet {
|
||||
+ Send
|
||||
+ Sync
|
||||
{
|
||||
/// The weight information for this pallet.
|
||||
/// The weight information for this pezpallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
/// The type that represent the entities tracked, its allowance and the conversion from
|
||||
@@ -165,7 +165,7 @@ pub mod pallet {
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// The origin has no usage tracked.
|
||||
NoUsage,
|
||||
@@ -173,19 +173,19 @@ pub mod pallet {
|
||||
NotZero,
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(fn deposit_event)]
|
||||
#[pezpallet::event]
|
||||
#[pezpallet::generate_deposit(fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// Usage for an entity is cleaned.
|
||||
UsageCleaned { entity: T::RestrictedEntity },
|
||||
}
|
||||
|
||||
#[pallet::call(weight = <T as Config>::WeightInfo)]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call(weight = <T as Config>::WeightInfo)]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Allow to clean usage associated with an entity when it is zero or when there is no
|
||||
/// longer any allowance for the origin.
|
||||
// This could be an unsigned call
|
||||
#[pallet::call_index(1)]
|
||||
#[pezpallet::call_index(1)]
|
||||
pub fn clean_usage(
|
||||
origin: OriginFor<T>,
|
||||
entity: T::RestrictedEntity,
|
||||
@@ -200,7 +200,7 @@ pub mod pallet {
|
||||
return Err(Error::<T>::NoUsage.into());
|
||||
};
|
||||
|
||||
let now = pezframe_system::Pallet::<T>::block_number();
|
||||
let now = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let elapsed = now.saturating_sub(usage.at_block).saturated_into::<u32>();
|
||||
|
||||
let allowance = entity.allowance();
|
||||
@@ -297,7 +297,7 @@ impl<T: Config> TransactionExtension<T::RuntimeCall> for RestrictOrigin<T> {
|
||||
return Err(InvalidTransaction::Call.into());
|
||||
}
|
||||
|
||||
let now = pezframe_system::Pallet::<T>::block_number();
|
||||
let now = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let mut usage = match Usages::<T>::get(&entity) {
|
||||
Some(mut usage) => {
|
||||
let elapsed = now.saturating_sub(usage.at_block).saturated_into::<u32>();
|
||||
|
||||
@@ -51,35 +51,35 @@ pub type UncheckedExtrinsic = pezsp_runtime::generic::UncheckedExtrinsic<
|
||||
pub const CALL_WEIGHT: u64 = 15;
|
||||
pub const CALL_WEIGHT_EXCESS: u64 = 150;
|
||||
|
||||
/// A small mock pallet to test calls from within the runtime.
|
||||
#[pezframe_support::pallet(dev_mode)]
|
||||
/// A small mock pezpallet to test calls from within the runtime.
|
||||
#[pezframe_support::pezpallet(dev_mode)]
|
||||
pub mod mock_pallet {
|
||||
use super::{CALL_WEIGHT, CALL_WEIGHT_EXCESS};
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(Weight::from_parts(CALL_WEIGHT, 0))]
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(Weight::from_parts(CALL_WEIGHT, 0))]
|
||||
pub fn do_something(_origin: OriginFor<T>) -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(Weight::from_parts(CALL_WEIGHT, 0))]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(Weight::from_parts(CALL_WEIGHT, 0))]
|
||||
pub fn do_something_refunded(_origin: OriginFor<T>) -> DispatchResultWithPostInfo {
|
||||
Ok(Pays::No.into())
|
||||
}
|
||||
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(Weight::from_parts(CALL_WEIGHT_EXCESS, 0))]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(Weight::from_parts(CALL_WEIGHT_EXCESS, 0))]
|
||||
pub fn do_something_allowed_excess(_origin: OriginFor<T>) -> DispatchResult {
|
||||
Ok(())
|
||||
}
|
||||
@@ -95,7 +95,7 @@ pezframe_support::construct_runtime!(
|
||||
}
|
||||
);
|
||||
|
||||
/// Convenience aliases for the mock pallet calls.
|
||||
/// Convenience aliases for the mock pezpallet calls.
|
||||
pub type MockPalletCall = mock_pallet::Call<Test>;
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
|
||||
@@ -236,7 +236,7 @@ fn restrict_origin_extension_disabled_behavior() {
|
||||
advance_by(1);
|
||||
|
||||
// 1) Attempt from restricted origin => Expect InvalidTransaction::Call
|
||||
// because the pallet explicitly forbids restricted origins if the extension is off.
|
||||
// because the pezpallet explicitly forbids restricted origins if the extension is off.
|
||||
assert_noop!(
|
||||
exec_signed_tx_disabled(RESTRICTED_ORIGIN_1, MockPalletCall::do_something {}),
|
||||
pezsp_runtime::transaction_validity::InvalidTransaction::Call
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
use pezframe_support::weights::Weight;
|
||||
|
||||
/// Weight functions needed for pallet origins restriction.
|
||||
/// Weight functions needed for pezpallet origins restriction.
|
||||
pub trait WeightInfo {
|
||||
fn clean_usage() -> Weight;
|
||||
fn restrict_origin_tx_ext() -> Weight;
|
||||
|
||||
Reference in New Issue
Block a user