feat: Rebrand Polkadot/Substrate references to PezkuwiChain

This commit systematically rebrands various references from Parity Technologies'
Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk.

Key changes include:
- Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks.
- Modified internal documentation and code comments to reflect PezkuwiChain naming and structure.
- Replaced direct references to  with  or specific paths within the  for XCM, Pezkuwi, and other modules.
- Cleaned up deprecated  issue and PR references in various  and  files, particularly in  and  modules.
- Adjusted image and logo URLs in documentation to point to PezkuwiChain assets.
- Removed or rephrased comments related to external Polkadot/Substrate PRs and issues.

This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
2025-12-14 00:04:10 +03:00
parent e4778b4576
commit 379cb741ed
9082 changed files with 997824 additions and 997542 deletions
@@ -19,15 +19,15 @@
#![cfg(feature = "runtime-benchmarks")]
use super::*;
use frame_benchmarking::v2::*;
use frame_support::assert_ok;
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
use pezframe_benchmarking::v2::*;
use pezframe_support::assert_ok;
use pezframe_system::{pezpallet_prelude::BlockNumberFor, RawOrigin};
use pezkuwi_primitives::Id as ParaId;
use sp_runtime::traits::Bounded;
use pezsp_runtime::traits::Bounded;
type CurrencyOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency;
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
<T as frame_system::Config>::AccountId,
<T as pezframe_system::Config>::AccountId,
>>::Balance;
#[benchmarks(where T: Config)]
mod benchmarks {
@@ -49,7 +49,7 @@ mod benchmarks {
worst_validation_code.clone()
));
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
worst_validation_code,
));
T::Registrar::execute_pending_transitions();
@@ -61,12 +61,12 @@ mod benchmarks {
let caller = RawOrigin::Root;
let _ =
AssignedSlots::<T>::set_max_permanent_slots(frame_system::Origin::<T>::Root.into(), 10);
AssignedSlots::<T>::set_max_permanent_slots(pezframe_system::Origin::<T>::Root.into(), 10);
register_teyrchain::<T>(para_id);
let counter = PermanentSlotCount::<T>::get();
let current_lease_period: BlockNumberFor<T> =
T::Leaser::lease_period_index(frame_system::Pallet::<T>::block_number())
T::Leaser::lease_period_index(pezframe_system::Pallet::<T>::block_number())
.and_then(|x| Some(x.0))
.unwrap();
#[extrinsic_call]
@@ -88,11 +88,11 @@ mod benchmarks {
let caller = RawOrigin::Root;
let _ =
AssignedSlots::<T>::set_max_temporary_slots(frame_system::Origin::<T>::Root.into(), 10);
AssignedSlots::<T>::set_max_temporary_slots(pezframe_system::Origin::<T>::Root.into(), 10);
register_teyrchain::<T>(para_id);
let current_lease_period: BlockNumberFor<T> =
T::Leaser::lease_period_index(frame_system::Pallet::<T>::block_number())
T::Leaser::lease_period_index(pezframe_system::Pallet::<T>::block_number())
.and_then(|x| Some(x.0))
.unwrap();
@@ -117,7 +117,7 @@ mod benchmarks {
let caller = RawOrigin::Root;
let _ =
AssignedSlots::<T>::set_max_temporary_slots(frame_system::Origin::<T>::Root.into(), 10);
AssignedSlots::<T>::set_max_temporary_slots(pezframe_system::Origin::<T>::Root.into(), 10);
register_teyrchain::<T>(para_id);
let _ = AssignedSlots::<T>::assign_temp_teyrchain_slot(
@@ -15,25 +15,25 @@
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
use super::{Config, MaxPermanentSlots, MaxTemporarySlots, Pallet, LOG_TARGET};
use frame_support::traits::{Get, GetStorageVersion, UncheckedOnRuntimeUpgrade};
use pezframe_support::traits::{Get, GetStorageVersion, UncheckedOnRuntimeUpgrade};
#[cfg(feature = "try-runtime")]
use alloc::vec::Vec;
#[cfg(feature = "try-runtime")]
use frame_support::ensure;
use pezframe_support::ensure;
pub mod v1 {
use super::*;
pub struct VersionUncheckedMigrateToV1<T>(core::marker::PhantomData<T>);
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateToV1<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
fn pre_upgrade() -> Result<Vec<u8>, pezsp_runtime::TryRuntimeError> {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
ensure!(on_chain_version < 1, "assigned_slots::MigrateToV1 migration can be deleted");
Ok(Default::default())
}
fn on_runtime_upgrade() -> frame_support::weights::Weight {
fn on_runtime_upgrade() -> pezframe_support::weights::Weight {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
if on_chain_version < 1 {
const MAX_PERMANENT_SLOTS: u32 = 100;
@@ -50,7 +50,7 @@ pub mod v1 {
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
fn post_upgrade(_state: Vec<u8>) -> Result<(), pezsp_runtime::TryRuntimeError> {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
ensure!(on_chain_version == 1, "assigned_slots::MigrateToV1 needs to be run");
assert_eq!(MaxPermanentSlots::<T>::get(), 100);
@@ -60,13 +60,13 @@ pub mod v1 {
}
/// [`VersionUncheckedMigrateToV1`] wrapped in a
/// [`VersionedMigration`](frame_support::migrations::VersionedMigration), ensuring the
/// [`VersionedMigration`](pezframe_support::migrations::VersionedMigration), ensuring the
/// migration is only performed when on-chain version is 0.
pub type MigrateToV1<T> = frame_support::migrations::VersionedMigration<
pub type MigrateToV1<T> = pezframe_support::migrations::VersionedMigration<
0,
1,
VersionUncheckedMigrateToV1<T>,
Pallet<T>,
<T as frame_system::Config>::DbWeight,
<T as pezframe_system::Config>::DbWeight,
>;
}
@@ -32,8 +32,8 @@ use crate::{
};
use alloc::vec::Vec;
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use frame_support::{pallet_prelude::*, traits::Currency};
use frame_system::pallet_prelude::*;
use pezframe_support::{pezpallet_prelude::*, traits::Currency};
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
use pezkuwi_primitives::Id as ParaId;
use pezkuwi_runtime_teyrchains::{
@@ -41,7 +41,7 @@ use pezkuwi_runtime_teyrchains::{
paras::{self},
};
use scale_info::TypeInfo;
use sp_runtime::traits::{One, Saturating, Zero};
use pezsp_runtime::traits::{One, Saturating, Zero};
const LOG_TARGET: &str = "runtime::assigned_slots";
@@ -101,11 +101,11 @@ impl WeightInfo for TestWeightInfo {
}
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
<T as frame_system::Config>::AccountId,
<T as pezframe_system::Config>::AccountId,
>>::Balance;
type LeasePeriodOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::LeasePeriod;
#[frame_support::pallet]
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
@@ -117,14 +117,14 @@ pub mod pallet {
pub struct Pallet<T>(_);
#[pallet::config]
#[pallet::disable_frame_system_supertrait_check]
#[pallet::disable_pezframe_system_supertrait_check]
pub trait Config: configuration::Config + paras::Config + slots::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// Origin for assigning slots.
type AssignSlotOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
type AssignSlotOrigin: EnsureOrigin<<Self as pezframe_system::Config>::RuntimeOrigin>;
/// The type representing the leasing system.
type Leaser: Leaser<
@@ -185,7 +185,7 @@ pub mod pallet {
pub type MaxPermanentSlots<T: Config> = StorageValue<_, u32, ValueQuery>;
#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
#[derive(pezframe_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub max_temporary_slots: u32,
pub max_permanent_slots: u32,
@@ -602,7 +602,7 @@ impl<T: Config> Pallet<T> {
/// Returns current lease period index.
fn current_lease_period_index() -> LeasePeriodOf<T> {
T::Leaser::lease_period_index(frame_system::Pallet::<T>::block_number())
T::Leaser::lease_period_index(pezframe_system::Pallet::<T>::block_number())
.and_then(|x| Some(x.0))
.unwrap()
}
@@ -635,31 +635,31 @@ mod tests {
use super::*;
use crate::{assigned_slots, mock::TestRegistrar, slots};
use frame_support::{assert_noop, assert_ok, derive_impl, parameter_types};
use frame_system::EnsureRoot;
use pallet_balances;
use pezframe_support::{assert_noop, assert_ok, derive_impl, parameter_types};
use pezframe_system::EnsureRoot;
use pezpallet_balances;
use pezkuwi_primitives::BlockNumber;
use pezkuwi_primitives_test_helpers::{dummy_head_data, dummy_validation_code};
use pezkuwi_runtime_teyrchains::{
configuration as teyrchains_configuration, paras as teyrchains_paras,
shared as teyrchains_shared,
};
use sp_core::H256;
use sp_runtime::{
use pezsp_core::H256;
use pezsp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
transaction_validity::TransactionPriority,
BuildStorage,
DispatchError::BadOrigin,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlockU32<Test>;
type UncheckedExtrinsic = pezframe_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = pezframe_system::mocking::MockBlockU32<Test>;
frame_support::construct_runtime!(
pezframe_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
System: pezframe_system,
Balances: pezpallet_balances,
Configuration: teyrchains_configuration,
ParasShared: teyrchains_shared,
Teyrchains: teyrchains_paras,
@@ -668,7 +668,7 @@ mod tests {
}
);
impl<C> frame_system::offchain::CreateTransactionBase<C> for Test
impl<C> pezframe_system::offchain::CreateTransactionBase<C> for Test
where
RuntimeCall: From<C>,
{
@@ -676,7 +676,7 @@ mod tests {
type RuntimeCall = RuntimeCall;
}
impl<C> frame_system::offchain::CreateBare<C> for Test
impl<C> pezframe_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
@@ -685,9 +685,9 @@ mod tests {
}
}
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type BaseCallFilter = pezframe_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
@@ -702,17 +702,17 @@ mod tests {
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type AccountData = pezpallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type AccountStore = System;
}
@@ -775,9 +775,9 @@ mod tests {
// This function basically just builds a genesis storage key/value store according to
// our desired mock up.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pezpallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
..Default::default()
}
@@ -18,21 +18,21 @@
#![cfg(feature = "runtime-benchmarks")]
use super::{Pallet as Auctions, *};
use frame_support::{
use pezframe_support::{
assert_ok,
traits::{EnsureOrigin, OnInitialize},
};
use frame_system::RawOrigin;
use pezframe_system::RawOrigin;
use pezkuwi_runtime_teyrchains::paras;
use sp_runtime::{traits::Bounded, SaturatedConversion};
use pezsp_runtime::{traits::Bounded, SaturatedConversion};
use frame_benchmarking::v2::*;
use pezframe_benchmarking::v2::*;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
let events = pezframe_system::Pallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
}
@@ -55,7 +55,7 @@ fn fill_winners<T: Config + paras::Config>(lease_period_index: LeasePeriodOf<T>)
.is_ok());
}
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
T::Registrar::worst_validation_code(),
));
@@ -81,7 +81,7 @@ fn fill_winners<T: Config + paras::Config>(lease_period_index: LeasePeriodOf<T>)
}
#[benchmarks(
where T: pallet_babe::Config + paras::Config,
where T: pezpallet_babe::Config + paras::Config,
)]
mod benchmarks {
use super::*;
@@ -113,7 +113,7 @@ mod benchmarks {
fn bid() -> Result<(), BenchmarkError> {
// If there is an offset, we need to be on that block to be able to do lease things.
let (_, offset) = T::Leaser::lease_period_length();
frame_system::Pallet::<T>::set_block_number(offset + One::one());
pezframe_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration = BlockNumberFor::<T>::max_value();
@@ -138,7 +138,7 @@ mod benchmarks {
)?;
T::Registrar::register(owner, new_para, worst_head_data, worst_validation_code.clone())?;
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
worst_validation_code,
));
@@ -188,12 +188,12 @@ mod benchmarks {
fn on_initialize() -> Result<(), BenchmarkError> {
// If there is an offset, we need to be on that block to be able to do lease things.
let (lease_length, offset) = T::Leaser::lease_period_length();
frame_system::Pallet::<T>::set_block_number(offset + One::one());
pezframe_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration: BlockNumberFor<T> = lease_length / 2u32.into();
let lease_period_index = LeasePeriodOf::<T>::zero();
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
let origin = T::InitiateOrigin::try_successful_origin()
.expect("InitiateOrigin has no successful origin required for the benchmark");
Auctions::<T>::new_auction(origin, duration, lease_period_index)?;
@@ -211,16 +211,16 @@ mod benchmarks {
}
// Move ahead to the block we want to initialize
frame_system::Pallet::<T>::set_block_number(duration + now + T::EndingPeriod::get());
pezframe_system::Pallet::<T>::set_block_number(duration + now + T::EndingPeriod::get());
// Trigger epoch change for new random number value:
{
pallet_babe::EpochStart::<T>::set((Zero::zero(), u32::MAX.into()));
pallet_babe::Pallet::<T>::on_initialize(duration + now + T::EndingPeriod::get());
let authorities = pallet_babe::Pallet::<T>::authorities();
pezpallet_babe::EpochStart::<T>::set((Zero::zero(), u32::MAX.into()));
pezpallet_babe::Pallet::<T>::on_initialize(duration + now + T::EndingPeriod::get());
let authorities = pezpallet_babe::Pallet::<T>::authorities();
// Check for non empty authority set since it otherwise emits a No-OP warning.
if !authorities.is_empty() {
pallet_babe::Pallet::<T>::enact_epoch_change(
pezpallet_babe::Pallet::<T>::enact_epoch_change(
authorities.clone(),
authorities,
None,
@@ -245,7 +245,7 @@ mod benchmarks {
fn cancel_auction() -> Result<(), BenchmarkError> {
// If there is an offset, we need to be on that block to be able to do lease things.
let (lease_length, offset) = T::Leaser::lease_period_length();
frame_system::Pallet::<T>::set_block_number(offset + One::one());
pezframe_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration: BlockNumberFor<T> = lease_length / 2u32.into();
+21 -21
View File
@@ -19,34 +19,34 @@
#[cfg(test)]
use super::*;
use crate::{auctions, mock::TestRegistrar};
use frame_support::{
use pezframe_support::{
assert_ok, derive_impl, ord_parameter_types, parameter_types, traits::EitherOfDiverse,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
use pallet_balances;
use pezframe_system::{EnsureRoot, EnsureSignedBy};
use pezpallet_balances;
use pezkuwi_primitives::{BlockNumber, Id as ParaId};
use pezkuwi_primitives_test_helpers::{dummy_head_data, dummy_validation_code};
use sp_core::H256;
use sp_runtime::{
use pezsp_core::H256;
use pezsp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
use std::{cell::RefCell, collections::BTreeMap};
type Block = frame_system::mocking::MockBlockU32<Test>;
type Block = pezframe_system::mocking::MockBlockU32<Test>;
frame_support::construct_runtime!(
pezframe_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
System: pezframe_system,
Balances: pezpallet_balances,
Auctions: auctions,
}
);
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type BaseCallFilter = pezframe_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
@@ -61,17 +61,17 @@ impl frame_system::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type AccountData = pezpallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type AccountStore = System;
}
@@ -182,7 +182,7 @@ impl Randomness<H256, BlockNumber> for TestPastRandomness {
if let Some((output, known_since)) = &*p.borrow() {
(*output, *known_since)
} else {
(H256::zero(), frame_system::Pallet::<Test>::block_number())
(H256::zero(), pezframe_system::Pallet::<Test>::block_number())
}
})
}
@@ -206,15 +206,15 @@ impl Config for Test {
// This function basically just builds a genesis storage key/value store according to
// our desired mock up.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pezpallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
..Default::default()
}
.assimilate_storage(&mut t)
.unwrap();
let mut ext: sp_io::TestExternalities = t.into();
let mut ext: pezsp_io::TestExternalities = t.into();
ext.execute_with(|| {
// Register para 0, 1, 2, and 3 for tests
assert_ok!(TestRegistrar::<Test>::register(
+15 -15
View File
@@ -25,20 +25,20 @@ use crate::{
use alloc::{vec, vec::Vec};
use codec::Decode;
use core::mem::swap;
use frame_support::{
use pezframe_support::{
dispatch::DispatchResult,
ensure,
traits::{Currency, Get, Randomness, ReservableCurrency},
weights::Weight,
};
use frame_system::pallet_prelude::BlockNumberFor;
use pezframe_system::pezpallet_prelude::BlockNumberFor;
pub use pallet::*;
use pezkuwi_primitives::Id as ParaId;
use sp_runtime::traits::{CheckedSub, One, Saturating, Zero};
use pezsp_runtime::traits::{CheckedSub, One, Saturating, Zero};
type CurrencyOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency;
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
<T as frame_system::Config>::AccountId,
<T as pezframe_system::Config>::AccountId,
>>::Balance;
pub trait WeightInfo {
@@ -70,28 +70,28 @@ pub type AuctionIndex = u32;
type LeasePeriodOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::LeasePeriod;
// Winning data type. This encodes the top bidders of each range together with their bid.
type WinningData<T> = [Option<(<T as frame_system::Config>::AccountId, ParaId, BalanceOf<T>)>;
type WinningData<T> = [Option<(<T as pezframe_system::Config>::AccountId, ParaId, BalanceOf<T>)>;
SlotRange::SLOT_RANGE_COUNT];
// Winners data type. This encodes each of the final winners of a teyrchain auction, the teyrchain
// index assigned to them, their winning bid and the range that they won.
type WinnersData<T> =
Vec<(<T as frame_system::Config>::AccountId, ParaId, BalanceOf<T>, SlotRange)>;
Vec<(<T as pezframe_system::Config>::AccountId, ParaId, BalanceOf<T>, SlotRange)>;
#[frame_support::pallet]
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
use frame_support::{dispatch::DispatchClass, pallet_prelude::*, traits::EnsureOrigin};
use frame_system::{ensure_root, ensure_signed, pallet_prelude::*};
use pezframe_support::{dispatch::DispatchClass, pezpallet_prelude::*, traits::EnsureOrigin};
use pezframe_system::{ensure_root, ensure_signed, pezpallet_prelude::*};
#[pallet::pallet]
pub struct Pallet<T>(_);
/// The module's configuration trait.
#[pallet::config]
pub trait Config: frame_system::Config {
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// The type representing the leasing system.
type Leaser: Leaser<
@@ -373,7 +373,7 @@ impl<T: Config> Auctioneer<BlockNumberFor<T>> for Pallet<T> {
impl<T: Config> Pallet<T> {
// A trick to allow me to initialize large arrays with nothing in them.
const EMPTY: Option<(<T as frame_system::Config>::AccountId, ParaId, BalanceOf<T>)> = None;
const EMPTY: Option<(<T as pezframe_system::Config>::AccountId, ParaId, BalanceOf<T>)> = None;
/// Create a new auction.
///
@@ -386,7 +386,7 @@ impl<T: Config> Pallet<T> {
) -> DispatchResult {
let maybe_auction = AuctionInfo::<T>::get();
ensure!(maybe_auction.is_none(), Error::<T>::AuctionInProgress);
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
if let Some((current_lease_period, _)) = T::Leaser::lease_period_index(now) {
// If there is no active lease period, then we don't need to make this check.
ensure!(lease_period_index >= current_lease_period, Error::<T>::LeasePeriodInPast);
@@ -399,7 +399,7 @@ impl<T: Config> Pallet<T> {
});
// Set the information.
let ending = frame_system::Pallet::<T>::block_number().saturating_add(duration);
let ending = pezframe_system::Pallet::<T>::block_number().saturating_add(duration);
AuctionInfo::<T>::put((lease_period_index, ending));
Self::deposit_event(Event::<T>::AuctionStarted {
@@ -435,7 +435,7 @@ impl<T: Config> Pallet<T> {
// Get the auction status and the current sample block. For the starting period, the sample
// block is zero.
let auction_status = Self::auction_status(frame_system::Pallet::<T>::block_number());
let auction_status = Self::auction_status(pezframe_system::Pallet::<T>::block_number());
// The offset into the ending samples of the auction.
let offset = match auction_status {
AuctionStatus::NotStarted => return Err(Error::<T>::AuctionEnded.into()),
+6 -6
View File
@@ -19,12 +19,12 @@
#[cfg(test)]
use super::*;
use crate::{auctions::mock::*, mock::TestRegistrar};
use frame_support::{assert_noop, assert_ok, assert_storage_noop};
use pallet_balances;
use pezframe_support::{assert_noop, assert_ok, assert_storage_noop};
use pezpallet_balances;
use pezkuwi_primitives::Id as ParaId;
use pezkuwi_primitives_test_helpers::{dummy_hash, dummy_head_data, dummy_validation_code};
use sp_core::H256;
use sp_runtime::DispatchError::BadOrigin;
use pezsp_core::H256;
use pezsp_runtime::DispatchError::BadOrigin;
#[test]
fn basic_setup_works() {
@@ -525,7 +525,7 @@ fn lower_bids_are_correctly_refunded() {
#[test]
fn initialize_winners_in_ending_period_works() {
new_test_ext().execute_with(|| {
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
let ed: u64 = <Test as pezpallet_balances::Config>::ExistentialDeposit::get();
assert_eq!(ed, 1);
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 1));
@@ -639,7 +639,7 @@ fn handle_bid_checks_existing_lease_periods() {
#[test]
fn less_winning_samples_work() {
new_test_ext().execute_with(|| {
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
let ed: u64 = <Test as pezpallet_balances::Config>::ExistentialDeposit::get();
assert_eq!(ed, 1);
EndingPeriod::set(30);
SampleLength::set(10);
@@ -19,14 +19,14 @@
#[cfg(feature = "runtime-benchmarks")]
use super::*;
use crate::claims::Call;
use frame_benchmarking::v2::*;
use frame_support::{
use pezframe_benchmarking::v2::*;
use pezframe_support::{
dispatch::{DispatchInfo, GetDispatchInfo},
traits::UnfilteredDispatchable,
};
use frame_system::RawOrigin;
use pezframe_system::RawOrigin;
use secp_utils::*;
use sp_runtime::{
use pezsp_runtime::{
traits::{DispatchTransaction, ValidateUnsigned},
DispatchResult,
};
@@ -66,10 +66,10 @@ fn create_claim_attest<T: Config>(input: u32) -> DispatchResult {
#[benchmarks(
where
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>> + From<Call<T>>,
<T as frame_system::Config>::RuntimeCall: Dispatchable<Info = DispatchInfo> + GetDispatchInfo,
<<T as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: AsSystemOriginSigner<T::AccountId> + AsTransactionAuthorizedOrigin + Clone,
<<T as frame_system::Config>::RuntimeCall as Dispatchable>::PostInfo: Default,
<T as pezframe_system::Config>::RuntimeCall: IsSubType<Call<T>> + From<Call<T>>,
<T as pezframe_system::Config>::RuntimeCall: Dispatchable<Info = DispatchInfo> + GetDispatchInfo,
<<T as pezframe_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: AsSystemOriginSigner<T::AccountId> + AsTransactionAuthorizedOrigin + Clone,
<<T as pezframe_system::Config>::RuntimeCall as Dispatchable>::PostInfo: Default,
)]
mod benchmarks {
use super::*;
@@ -95,7 +95,7 @@ mod benchmarks {
None,
)?;
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let source = sp_runtime::transaction_validity::TransactionSource::External;
let source = pezsp_runtime::transaction_validity::TransactionSource::External;
let call_enc =
Call::<T>::claim { dest: account.clone(), ethereum_signature: signature.clone() }
.encode();
@@ -162,7 +162,7 @@ mod benchmarks {
statement: StatementKind::Regular.to_text().to_vec(),
}
.encode();
let source = sp_runtime::transaction_validity::TransactionSource::External;
let source = pezsp_runtime::transaction_validity::TransactionSource::External;
#[block]
{
@@ -279,7 +279,7 @@ mod benchmarks {
}
let ext = PrevalidateAttests::<T>::new();
let call = super::Call::attest { statement: StatementKind::Regular.to_text().to_vec() };
let call: <T as frame_system::Config>::RuntimeCall = call.into();
let call: <T as pezframe_system::Config>::RuntimeCall = call.into();
let info = call.get_dispatch_info();
let attest_c = u32::MAX - c;
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&attest_c.encode())).unwrap();
+19 -19
View File
@@ -23,34 +23,34 @@ use secp_utils::*;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use crate::claims;
use frame_support::{derive_impl, ord_parameter_types, parameter_types, traits::WithdrawReasons};
use pallet_balances;
use sp_runtime::{traits::Identity, BuildStorage};
use pezframe_support::{derive_impl, ord_parameter_types, parameter_types, traits::WithdrawReasons};
use pezpallet_balances;
use pezsp_runtime::{traits::Identity, BuildStorage};
type Block = frame_system::mocking::MockBlock<Test>;
type Block = pezframe_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pezframe_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
Vesting: pallet_vesting,
System: pezframe_system,
Balances: pezpallet_balances,
Vesting: pezpallet_vesting,
Claims: claims,
}
);
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type AccountData = pallet_balances::AccountData<u64>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
type AccountData = pezpallet_balances::AccountData<u64>;
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type AccountStore = System;
}
@@ -60,7 +60,7 @@ parameter_types! {
WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
}
impl pallet_vesting::Config for Test {
impl pezpallet_vesting::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BlockNumberToBalance = Identity;
@@ -82,7 +82,7 @@ impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type VestingSchedule = Vesting;
type Prefix = Prefix;
type MoveClaimOrigin = frame_system::EnsureSignedBy<Six, u64>;
type MoveClaimOrigin = pezframe_system::EnsureSignedBy<Six, u64>;
type WeightInfo = TestWeightInfo;
}
@@ -104,10 +104,10 @@ pub fn frank() -> libsecp256k1::SecretKey {
// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
// We use default for brevity, but you can configure as desired if needed.
pallet_balances::GenesisConfig::<Test>::default()
pezpallet_balances::GenesisConfig::<Test>::default()
.assimilate_storage(&mut t)
.unwrap();
claims::GenesisConfig::<Test> {
+15 -15
View File
@@ -21,7 +21,7 @@ use alloc::{format, string::String};
use alloc::{vec, vec::Vec};
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use core::fmt::Debug;
use frame_support::{
use pezframe_support::{
ensure,
traits::{Currency, Get, IsSubType, VestingSchedule},
weights::Weight,
@@ -31,8 +31,8 @@ pub use pallet::*;
use pezkuwi_primitives::ValidityError;
use scale_info::TypeInfo;
use serde::{self, Deserialize, Deserializer, Serialize, Serializer};
use sp_io::{crypto::secp256k1_ecdsa_recover, hashing::keccak_256};
use sp_runtime::{
use pezsp_io::{crypto::secp256k1_ecdsa_recover, hashing::keccak_256};
use pezsp_runtime::{
impl_tx_ext_default,
traits::{
AsSystemOriginSigner, AsTransactionAuthorizedOrigin, CheckedSub, DispatchInfoOf,
@@ -46,9 +46,9 @@ use sp_runtime::{
};
type CurrencyOf<T> = <<T as Config>::VestingSchedule as VestingSchedule<
<T as frame_system::Config>::AccountId,
<T as pezframe_system::Config>::AccountId,
>>::Currency;
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
pub trait WeightInfo {
fn claim() -> Weight;
@@ -195,21 +195,21 @@ impl core::fmt::Debug for EcdsaSignature {
}
}
#[frame_support::pallet]
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
/// Configuration trait.
#[pallet::config]
pub trait Config: frame_system::Config {
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = BlockNumberFor<Self>>;
#[pallet::constant]
type Prefix: Get<&'static [u8]>;
@@ -586,7 +586,7 @@ impl<T: Config> Pallet<T> {
Some(res)
}
fn process_claim(signer: EthereumAddress, dest: T::AccountId) -> sp_runtime::DispatchResult {
fn process_claim(signer: EthereumAddress, dest: T::AccountId) -> pezsp_runtime::DispatchResult {
let balance_due = Claims::<T>::get(&signer).ok_or(Error::<T>::SignerHasNoClaim)?;
let new_total =
@@ -632,7 +632,7 @@ pub struct PrevalidateAttests<T>(core::marker::PhantomData<fn(T)>);
impl<T: Config> Debug for PrevalidateAttests<T>
where
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>,
<T as pezframe_system::Config>::RuntimeCall: IsSubType<Call<T>>,
{
#[cfg(feature = "std")]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
@@ -647,7 +647,7 @@ where
impl<T: Config> PrevalidateAttests<T>
where
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>,
<T as pezframe_system::Config>::RuntimeCall: IsSubType<Call<T>>,
{
/// Create new `TransactionExtension` to check runtime version.
pub fn new() -> Self {
@@ -657,8 +657,8 @@ where
impl<T: Config> TransactionExtension<T::RuntimeCall> for PrevalidateAttests<T>
where
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>,
<<T as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin:
<T as pezframe_system::Config>::RuntimeCall: IsSubType<Call<T>>,
<<T as pezframe_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin:
AsSystemOriginSigner<T::AccountId> + AsTransactionAuthorizedOrigin + Clone,
{
const IDENTIFIER: &'static str = "PrevalidateAttests";
+9 -9
View File
@@ -22,17 +22,17 @@ use crate::{claims, claims::mock::*};
use claims::Call as ClaimsCall;
use hex_literal::hex;
use secp_utils::*;
use sp_runtime::transaction_validity::TransactionSource::External;
use pezsp_runtime::transaction_validity::TransactionSource::External;
use codec::Encode;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use frame_support::{
use pezframe_support::{
assert_err, assert_noop, assert_ok,
dispatch::{GetDispatchInfo, Pays},
traits::ExistenceRequirement,
};
use sp_runtime::{
use pezsp_runtime::{
traits::DispatchTransaction, transaction_validity::TransactionLongevity,
DispatchError::BadOrigin, TokenError,
};
@@ -327,7 +327,7 @@ fn add_claim_works() {
None,
None
),
sp_runtime::traits::BadOrigin,
pezsp_runtime::traits::BadOrigin,
);
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
@@ -368,7 +368,7 @@ fn add_claim_with_vesting_works() {
Some((50, 10, 1)),
None
),
sp_runtime::traits::BadOrigin,
pezsp_runtime::traits::BadOrigin,
);
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
@@ -413,7 +413,7 @@ fn add_claim_with_statement_works() {
None,
Some(StatementKind::Regular)
),
sp_runtime::traits::BadOrigin,
pezsp_runtime::traits::BadOrigin,
);
assert_eq!(Balances::free_balance(42), 0);
let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Regular.to_text());
@@ -462,7 +462,7 @@ fn origin_signed_claiming_fail() {
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
),
sp_runtime::traits::BadOrigin,
pezsp_runtime::traits::BadOrigin,
);
});
}
@@ -565,8 +565,8 @@ fn real_eth_sig_works() {
#[test]
fn validate_unsigned_works() {
use sp_runtime::traits::ValidateUnsigned;
let source = sp_runtime::transaction_validity::TransactionSource::External;
use pezsp_runtime::traits::ValidateUnsigned;
let source = pezsp_runtime::transaction_validity::TransactionSource::External;
new_test_ext().execute_with(|| {
assert_eq!(
@@ -15,7 +15,7 @@
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
use super::*;
use frame_support::{
use pezframe_support::{
storage_alias,
traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion},
Twox64Concat,
@@ -45,7 +45,7 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactiveV2<T> {
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
fn pre_upgrade() -> Result<Vec<u8>, pezsp_runtime::TryRuntimeError> {
let total = Funds::<T>::iter_values()
.map(|item| {
CurrencyOf::<T>::total_balance(&Pallet::<T>::fund_account_id(item.fund_index))
@@ -55,7 +55,7 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactiveV2<T> {
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(total: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
fn post_upgrade(total: Vec<u8>) -> Result<(), pezsp_runtime::TryRuntimeError> {
if let Ok((total, active)) = <(BalanceOf<T>, BalanceOf<T>)>::decode(&mut total.as_slice()) {
ensure!(active - total == CurrencyOf::<T>::active_issuance(), "the total be correct");
Ok(())
@@ -77,7 +77,7 @@ pub mod crowdloan_index_migration {
Slots,
Twox64Concat,
ParaId,
Vec<Option<(<T as frame_system::Config>::AccountId, BalanceOf<T>)>>,
Vec<Option<(<T as pezframe_system::Config>::AccountId, BalanceOf<T>)>>,
>;
// The old way we generated fund accounts.
@@ -135,7 +135,7 @@ pub mod crowdloan_index_migration {
/// This migration converts crowdloans to use a crowdloan index rather than the teyrchain id as
/// a unique identifier. This makes it easier to swap two crowdloans between teyrchains.
pub fn migrate<T: Config>() -> frame_support::weights::Weight {
pub fn migrate<T: Config>() -> pezframe_support::weights::Weight {
let mut weight = Weight::zero();
// First migrate `NextTrieIndex` counter to `NextFundIndex`.
@@ -152,8 +152,8 @@ pub mod crowdloan_index_migration {
// Funds should only have a free balance and a reserve balance. Both of these are in the
// `Account` storage item, so we just swap them.
let account_info = frame_system::Account::<T>::take(&old_fund_account);
frame_system::Account::<T>::insert(&new_fund_account, account_info);
let account_info = pezframe_system::Account::<T>::take(&old_fund_account);
pezframe_system::Account::<T>::insert(&new_fund_account, account_info);
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 2));
@@ -191,7 +191,7 @@ pub mod crowdloan_index_migration {
// Old fund account is deleted.
let old_fund_account = old_fund_account_id::<T>(para_id);
ensure!(
frame_system::Account::<T>::get(&old_fund_account) == Default::default(),
pezframe_system::Account::<T>::get(&old_fund_account) == Default::default(),
"Old account wasn't reset to default value."
);
+63 -63
View File
@@ -57,9 +57,9 @@ use crate::{
};
use alloc::{vec, vec::Vec};
use codec::{Decode, Encode};
use frame_support::{
use pezframe_support::{
ensure,
pallet_prelude::{DispatchResult, Weight},
pezpallet_prelude::{DispatchResult, Weight},
storage::{child, ChildTriePrefixIterator},
traits::{
Currency, Defensive,
@@ -68,11 +68,11 @@ use frame_support::{
},
Identity, PalletId,
};
use frame_system::pallet_prelude::BlockNumberFor;
use pezframe_system::pezpallet_prelude::BlockNumberFor;
pub use pallet::*;
use pezkuwi_primitives::Id as ParaId;
use scale_info::TypeInfo;
use sp_runtime::{
use pezsp_runtime::{
traits::{
AccountIdConversion, CheckedAdd, Hash, IdentifyAccount, One, Saturating, Verify, Zero,
},
@@ -81,7 +81,7 @@ use sp_runtime::{
type CurrencyOf<T> = <<T as Config>::Auctioneer as Auctioneer<BlockNumberFor<T>>>::Currency;
type LeasePeriodOf<T> = <<T as Config>::Auctioneer as Auctioneer<BlockNumberFor<T>>>::LeasePeriod;
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
type FundIndex = u32;
@@ -170,11 +170,11 @@ pub struct FundInfo<AccountId, Balance, BlockNumber, LeasePeriod> {
pub fund_index: FundIndex,
}
#[frame_support::pallet]
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::{ensure_root, ensure_signed, pallet_prelude::*};
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::{ensure_root, ensure_signed, pezpallet_prelude::*};
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
@@ -185,9 +185,9 @@ pub mod pallet {
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config {
pub trait Config: pezframe_system::Config {
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// `PalletId` for the crowdloan pallet. An appropriate value could be
/// `PalletId(*b"py/cfund")`
@@ -325,7 +325,7 @@ pub mod pallet {
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(num: BlockNumberFor<T>) -> frame_support::weights::Weight {
fn on_initialize(num: BlockNumberFor<T>) -> pezframe_support::weights::Weight {
if let Some((sample, sub_sample)) = T::Auctioneer::auction_status(num).is_ending() {
// This is the very first block in the ending period
if sample.is_zero() && sub_sample.is_zero() {
@@ -376,7 +376,7 @@ pub mod pallet {
verifier: Option<MultiSigner>,
) -> DispatchResult {
let depositor = ensure_signed(origin)?;
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
ensure!(first_period <= last_period, Error::<T>::LastPeriodBeforeFirstPeriod);
let last_period_limit = first_period
@@ -414,7 +414,7 @@ pub mod pallet {
let deposit = T::SubmissionDeposit::get();
frame_system::Pallet::<T>::inc_providers(&Self::fund_account_id(fund_index));
pezframe_system::Pallet::<T>::inc_providers(&Self::fund_account_id(fund_index));
CurrencyOf::<T>::reserve(&depositor, deposit)?;
Funds::<T>::insert(
@@ -480,7 +480,7 @@ pub mod pallet {
ensure_signed(origin)?;
let mut fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
let fund_account = Self::fund_account_id(fund.fund_index);
Self::ensure_crowdloan_ended(now, &fund_account, &fund)?;
@@ -513,7 +513,7 @@ pub mod pallet {
ensure_signed(origin)?;
let mut fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
let fund_account = Self::fund_account_id(fund.fund_index);
Self::ensure_crowdloan_ended(now, &fund_account, &fund)?;
@@ -557,7 +557,7 @@ pub mod pallet {
let fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
let pot = Self::fund_account_id(fund.fund_index);
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
// Only allow dissolution when the raised funds goes to zero,
// and the caller is the fund creator or we are past the end date.
@@ -572,7 +572,7 @@ pub mod pallet {
// Crowdloan over, burn all funds.
let _imba = CurrencyOf::<T>::make_free_balance_be(&pot, Zero::zero());
let _ = frame_system::Pallet::<T>::dec_providers(&pot).defensive();
let _ = pezframe_system::Pallet::<T>::dec_providers(&pot).defensive();
CurrencyOf::<T>::unreserve(&fund.depositor, fund.deposit);
Funds::<T>::remove(index);
@@ -726,7 +726,7 @@ impl<T: Config> Pallet<T> {
now: BlockNumberFor<T>,
fund_account: &T::AccountId,
fund: &FundInfo<T::AccountId, BalanceOf<T>, BlockNumberFor<T>, LeasePeriodOf<T>>,
) -> sp_runtime::DispatchResult {
) -> pezsp_runtime::DispatchResult {
// `fund.end` can represent the end of a failed crowdloan or the beginning of retirement
// If the current lease period is past the first period they are trying to bid for, then
// it is already too late to win the bid.
@@ -759,11 +759,11 @@ impl<T: Config> Pallet<T> {
ensure!(fund.raised <= fund.cap, Error::<T>::CapExceeded);
// Make sure crowdloan has not ended
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
ensure!(now < fund.end, Error::<T>::ContributionPeriodOver);
// Make sure crowdloan is in a valid lease period
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
let (current_lease_period, _) =
T::Auctioneer::lease_period_index(now).ok_or(Error::<T>::NoLeasePeriod)?;
ensure!(current_lease_period <= fund.first_period, Error::<T>::ContributionPeriodOver);
@@ -840,9 +840,9 @@ impl<T: Config> crate::traits::OnSwap for Pallet<T> {
#[cfg(any(feature = "runtime-benchmarks", test))]
mod crypto {
use alloc::vec::Vec;
use sp_core::ed25519;
use sp_io::crypto::{ed25519_generate, ed25519_sign};
use sp_runtime::{MultiSignature, MultiSigner};
use pezsp_core::ed25519;
use pezsp_io::crypto::{ed25519_generate, ed25519_sign};
use pezsp_runtime::{MultiSignature, MultiSigner};
pub fn create_ed25519_pubkey(seed: Vec<u8>) -> MultiSigner {
ed25519_generate(0.into(), Some(seed)).into()
@@ -859,9 +859,9 @@ mod crypto {
mod tests {
use super::*;
use frame_support::{assert_noop, assert_ok, derive_impl, parameter_types};
use pezframe_support::{assert_noop, assert_ok, derive_impl, parameter_types};
use pezkuwi_primitives::Id as ParaId;
use sp_core::H256;
use pezsp_core::H256;
use std::{cell::RefCell, collections::BTreeMap, sync::Arc};
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
@@ -871,28 +871,28 @@ mod tests {
traits::{AuctionStatus, OnSwap},
};
use pezkuwi_primitives_test_helpers::{dummy_head_data, dummy_validation_code};
use sp_keystore::{testing::MemoryKeystore, KeystoreExt};
use sp_runtime::{
use pezsp_keystore::{testing::MemoryKeystore, KeystoreExt};
use pezsp_runtime::{
traits::{BlakeTwo256, IdentityLookup, TrailingZeroInput},
BuildStorage, DispatchResult,
};
type Block = frame_system::mocking::MockBlock<Test>;
type Block = pezframe_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pezframe_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
System: pezframe_system,
Balances: pezpallet_balances,
Crowdloan: crowdloan,
}
);
type BlockNumber = u64;
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type BaseCallFilter = pezframe_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
@@ -907,17 +907,17 @@ mod tests {
type RuntimeEvent = RuntimeEvent;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type AccountData = pezpallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type AccountStore = System;
}
@@ -963,7 +963,7 @@ mod tests {
let fund = Funds::<Test>::get(para).unwrap();
let account_id = Crowdloan::fund_account_id(fund.fund_index);
if winner {
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
let ed: u64 = <Test as pezpallet_balances::Config>::ExistentialDeposit::get();
let free_balance = Balances::free_balance(&account_id);
Balances::reserve(&account_id, free_balance - ed)
.expect("should be able to reserve free balance minus ED");
@@ -1075,20 +1075,20 @@ mod tests {
type WeightInfo = crate::crowdloan::TestWeightInfo;
}
use pallet_balances::Error as BalancesError;
use pezpallet_balances::Error as BalancesError;
// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pezpallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 1000), (2, 2000), (3, 3000), (4, 4000)],
..Default::default()
}
.assimilate_storage(&mut t)
.unwrap();
let keystore = MemoryKeystore::new();
let mut t: sp_io::TestExternalities = t.into();
let mut t: pezsp_io::TestExternalities = t.into();
t.register_extension(KeystoreExt(Arc::new(keystore)));
t
}
@@ -1787,7 +1787,7 @@ mod tests {
#[test]
fn withdraw_from_finished_works() {
new_test_ext().execute_with(|| {
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
let ed: u64 = <Test as pezpallet_balances::Config>::ExistentialDeposit::get();
assert_eq!(ed, 1);
let para = new_para();
let index = NextFundIndex::<Test>::get();
@@ -1950,19 +1950,19 @@ mod tests {
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking {
use super::{Pallet as Crowdloan, *};
use frame_support::{assert_ok, traits::OnInitialize};
use frame_system::RawOrigin;
use pezframe_support::{assert_ok, traits::OnInitialize};
use pezframe_system::RawOrigin;
use pezkuwi_runtime_teyrchains::paras;
use sp_core::crypto::UncheckedFrom;
use sp_runtime::traits::{Bounded, CheckedSub};
use pezsp_core::crypto::UncheckedFrom;
use pezsp_runtime::traits::{Bounded, CheckedSub};
use frame_benchmarking::v2::*;
use pezframe_benchmarking::v2::*;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
let events = pezframe_system::Pallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
}
@@ -1970,8 +1970,8 @@ mod benchmarking {
let cap = BalanceOf::<T>::max_value();
let (_, offset) = T::Auctioneer::lease_period_length();
// Set to the very beginning of lease period index 0.
frame_system::Pallet::<T>::set_block_number(offset);
let now = frame_system::Pallet::<T>::block_number();
pezframe_system::Pallet::<T>::set_block_number(offset);
let now = pezframe_system::Pallet::<T>::block_number();
let (lease_period_index, _) = T::Auctioneer::lease_period_index(now).unwrap_or_default();
let first_period = lease_period_index;
let last_period =
@@ -1993,7 +1993,7 @@ mod benchmarking {
validation_code.clone()
));
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
T::Registrar::execute_pending_transitions();
@@ -2051,7 +2051,7 @@ mod benchmarking {
CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
T::Registrar::register(caller.clone(), para_id, head_data, validation_code.clone())?;
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
@@ -2107,7 +2107,7 @@ mod benchmarking {
let caller: T::AccountId = whitelisted_caller();
let contributor = account("contributor", 0, 0);
contribute_fund::<T>(&contributor, fund_index);
frame_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
pezframe_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
#[extrinsic_call]
_(RawOrigin::Signed(caller), contributor.clone(), fund_index);
@@ -2136,7 +2136,7 @@ mod benchmarking {
}
let caller: T::AccountId = whitelisted_caller();
frame_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
pezframe_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
#[extrinsic_call]
_(RawOrigin::Signed(caller), fund_index);
@@ -2150,7 +2150,7 @@ mod benchmarking {
let end = lpl + offset;
let fund_index = create_fund::<T>(1337, end);
let caller: T::AccountId = whitelisted_caller();
frame_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
pezframe_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), fund_index);
@@ -2176,7 +2176,7 @@ mod benchmarking {
CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
T::Registrar::register(caller.clone(), para_id, head_data, validation_code.clone())?;
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
@@ -2262,11 +2262,11 @@ mod benchmarking {
)?;
}
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
let (lease_period_index, _) =
T::Auctioneer::lease_period_index(now).unwrap_or_default();
let duration = end_block
.checked_sub(&frame_system::Pallet::<T>::block_number())
.checked_sub(&pezframe_system::Pallet::<T>::block_number())
.ok_or("duration of auction less than zero")?;
T::Auctioneer::new_auction(duration, lease_period_index)?;
+2 -2
View File
@@ -49,7 +49,7 @@ macro_rules! impl_elections_weights {
/// to ensure election snapshot will not run out of memory. For now, we set them to smaller values
/// since the staking is bounded and the weight pipeline takes hours for this single pallet.
pub struct BenchmarkConfig;
impl pallet_election_provider_multi_phase::BenchmarkingConfig for BenchmarkConfig {
impl pezpallet_election_provider_multi_phase::BenchmarkingConfig for BenchmarkConfig {
const VOTERS: [u32; 2] = [1000, 2000];
const TARGETS: [u32; 2] = [500, 1000];
const ACTIVE_VOTERS: [u32; 2] = [500, 800];
@@ -60,4 +60,4 @@ impl pallet_election_provider_multi_phase::BenchmarkingConfig for BenchmarkConfi
}
/// The accuracy type used for genesis election provider;
pub type OnChainAccuracy = sp_runtime::Perbill;
pub type OnChainAccuracy = pezsp_runtime::Perbill;
+32 -32
View File
@@ -25,13 +25,13 @@
//! After the migration is complete, the pallet may be removed from both chains' runtimes as well as
//! the `pezkuwi-runtime-common` crate.
use frame_support::{dispatch::DispatchResult, traits::Currency, weights::Weight};
use pezframe_support::{dispatch::DispatchResult, traits::Currency, weights::Weight};
pub use pallet::*;
use pallet_identity;
use sp_core::Get;
use pezpallet_identity;
use pezsp_core::Get;
#[cfg(feature = "runtime-benchmarks")]
use frame_benchmarking::{account, v2::*, BenchmarkError};
use pezframe_benchmarking::{account, v2::*, BenchmarkError};
pub trait WeightInfo {
fn reap_identity(r: u32, s: u32) -> Weight;
@@ -58,28 +58,28 @@ impl WeightInfo for TestWeightInfo {
}
// Must use the same `Balance` as `T`'s Identity pallet to handle deposits.
type BalanceOf<T> = <<T as pallet_identity::Config>::Currency as Currency<
<T as frame_system::Config>::AccountId,
type BalanceOf<T> = <<T as pezpallet_identity::Config>::Currency as Currency<
<T as pezframe_system::Config>::AccountId,
>>::Balance;
#[frame_support::pallet]
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
use frame_support::{
use pezframe_support::{
dispatch::{DispatchResultWithPostInfo, PostDispatchInfo},
pallet_prelude::*,
pezpallet_prelude::*,
traits::EnsureOrigin,
};
use frame_system::pallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config + pallet_identity::Config {
pub trait Config: pezframe_system::Config + pezpallet_identity::Config {
/// Overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// The origin that can reap identities. Expected to be `EnsureSigned<AccountId>` on the
/// source chain such that anyone can all this function.
@@ -119,7 +119,7 @@ pub mod pallet {
// - number of registrars (required to calculate weight)
// - byte size of `IdentityInfo` (required to calculate remote deposit)
// - number of sub accounts (required to calculate both weight and remote deposit)
let (registrars, bytes, subs) = pallet_identity::Pallet::<T>::reap_identity(&who)?;
let (registrars, bytes, subs) = pezpallet_identity::Pallet::<T>::reap_identity(&who)?;
T::ReapIdentityHandler::on_reap_identity(&who, bytes, subs)?;
Self::deposit_event(Event::IdentityReaped { who });
let post = PostDispatchInfo {
@@ -137,7 +137,7 @@ pub mod pallet {
#[pallet::weight(<T as pallet::Config>::WeightInfo::poke_deposit())]
pub fn poke_deposit(origin: OriginFor<T>, who: T::AccountId) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
let (id_deposit, subs_deposit) = pallet_identity::Pallet::<T>::poke_deposit(&who)?;
let (id_deposit, subs_deposit) = pezpallet_identity::Pallet::<T>::poke_deposit(&who)?;
Self::deposit_event(Event::DepositUpdated {
who,
identity: id_deposit,
@@ -185,10 +185,10 @@ mod benchmarks {
use super::*;
use alloc::{boxed::Box, vec, vec::Vec};
use codec::Encode;
use frame_support::traits::EnsureOrigin;
use frame_system::RawOrigin;
use pallet_identity::{Data, IdentityInformationProvider, Judgement, Pallet as Identity};
use sp_runtime::{
use pezframe_support::traits::EnsureOrigin;
use pezframe_system::RawOrigin;
use pezpallet_identity::{Data, IdentityInformationProvider, Judgement, Pallet as Identity};
use pezsp_runtime::{
traits::{Bounded, Hash, StaticLookup},
Saturating,
};
@@ -196,9 +196,9 @@ mod benchmarks {
const SEED: u32 = 0;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
let events = pezframe_system::Pallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
}
@@ -210,12 +210,12 @@ mod benchmarks {
// set up target
let target: T::AccountId = account("target", 0, SEED);
let target_origin =
<T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(target.clone()));
<T as pezframe_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(target.clone()));
let target_lookup = T::Lookup::unlookup(target.clone());
let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());
// set identity
let info = <T as pallet_identity::Config>::IdentityInformation::create_identity_info();
let info = <T as pezpallet_identity::Config>::IdentityInformation::create_identity_info();
Identity::<T>::set_identity(
RawOrigin::Signed(target.clone()).into(),
Box::new(info.clone()),
@@ -243,15 +243,15 @@ mod benchmarks {
// registrar account
let registrar: T::AccountId = account("registrar", ii, SEED);
let registrar_lookup = T::Lookup::unlookup(registrar.clone());
let _ = <T as pallet_identity::Config>::Currency::make_free_balance_be(
let _ = <T as pezpallet_identity::Config>::Currency::make_free_balance_be(
&registrar,
<T as pallet_identity::Config>::Currency::minimum_balance(),
<T as pezpallet_identity::Config>::Currency::minimum_balance(),
);
// add registrar
Identity::<T>::add_registrar(registrar_origin.clone(), registrar_lookup)?;
Identity::<T>::set_fee(RawOrigin::Signed(registrar.clone()).into(), ii, 10u32.into())?;
let fields = <T as pallet_identity::Config>::IdentityInformation::all_fields();
let fields = <T as pezpallet_identity::Config>::IdentityInformation::all_fields();
Identity::<T>::set_fields(RawOrigin::Signed(registrar.clone()).into(), ii, fields)?;
// request and provide judgement
@@ -261,7 +261,7 @@ mod benchmarks {
ii,
target_lookup.clone(),
Judgement::Reasonable,
<T as frame_system::Config>::Hashing::hash_of(&info),
<T as pezframe_system::Config>::Hashing::hash_of(&info),
)?;
}
@@ -272,7 +272,7 @@ mod benchmarks {
assert_last_event::<T>(Event::<T>::IdentityReaped { who: target.clone() }.into());
let fields = <T as pallet_identity::Config>::IdentityInformation::all_fields();
let fields = <T as pezpallet_identity::Config>::IdentityInformation::all_fields();
assert!(!Identity::<T>::has_identity(&target, fields));
assert_eq!(Identity::<T>::subs(&target).len(), 0);
@@ -283,7 +283,7 @@ mod benchmarks {
fn poke_deposit() -> Result<(), BenchmarkError> {
let target: T::AccountId = account("target", 0, SEED);
let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());
let info = <T as pallet_identity::Config>::IdentityInformation::create_identity_info();
let info = <T as pezpallet_identity::Config>::IdentityInformation::create_identity_info();
let _ = Identity::<T>::set_identity_no_deposit(&target, info.clone());
@@ -292,13 +292,13 @@ mod benchmarks {
let _ = Identity::<T>::set_subs_no_deposit(&target, vec![(sub_account.clone(), name)]);
// expected deposits
let expected_id_deposit = <T as pallet_identity::Config>::BasicDeposit::get()
let expected_id_deposit = <T as pezpallet_identity::Config>::BasicDeposit::get()
.saturating_add(
<T as pallet_identity::Config>::ByteDeposit::get()
<T as pezpallet_identity::Config>::ByteDeposit::get()
.saturating_mul(<BalanceOf<T>>::from(info.encoded_size() as u32)),
);
// only 1 sub
let expected_sub_deposit = <T as pallet_identity::Config>::SubAccountDeposit::get();
let expected_sub_deposit = <T as pezpallet_identity::Config>::SubAccountDeposit::get();
#[extrinsic_call]
_(RawOrigin::Root, target.clone());
+54 -54
View File
@@ -17,42 +17,42 @@
//! Auxiliary `struct`/`enum`s for pezkuwi runtime.
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use frame_support::traits::{
use pezframe_support::traits::{
fungible::{Balanced, Credit},
tokens::imbalance::ResolveTo,
Contains, ContainsPair, Imbalance, OnUnbalanced,
};
use pallet_treasury::TreasuryAccountId;
use pezpallet_treasury::TreasuryAccountId;
use pezkuwi_primitives::Balance;
use sp_runtime::{traits::TryConvert, Perquintill, RuntimeDebug};
use pezsp_runtime::{traits::TryConvert, Perquintill, RuntimeDebug};
use xcm::VersionedLocation;
/// Logic for the author to get a portion of fees.
pub struct ToAuthor<R>(core::marker::PhantomData<R>);
impl<R> OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>> for ToAuthor<R>
impl<R> OnUnbalanced<Credit<R::AccountId, pezpallet_balances::Pallet<R>>> for ToAuthor<R>
where
R: pallet_balances::Config + pallet_authorship::Config,
<R as frame_system::Config>::AccountId: From<pezkuwi_primitives::AccountId>,
<R as frame_system::Config>::AccountId: Into<pezkuwi_primitives::AccountId>,
R: pezpallet_balances::Config + pezpallet_authorship::Config,
<R as pezframe_system::Config>::AccountId: From<pezkuwi_primitives::AccountId>,
<R as pezframe_system::Config>::AccountId: Into<pezkuwi_primitives::AccountId>,
{
fn on_nonzero_unbalanced(
amount: Credit<<R as frame_system::Config>::AccountId, pallet_balances::Pallet<R>>,
amount: Credit<<R as pezframe_system::Config>::AccountId, pezpallet_balances::Pallet<R>>,
) {
if let Some(author) = <pallet_authorship::Pallet<R>>::author() {
let _ = <pallet_balances::Pallet<R>>::resolve(&author, amount);
if let Some(author) = <pezpallet_authorship::Pallet<R>>::author() {
let _ = <pezpallet_balances::Pallet<R>>::resolve(&author, amount);
}
}
}
pub struct DealWithFees<R>(core::marker::PhantomData<R>);
impl<R> OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>> for DealWithFees<R>
impl<R> OnUnbalanced<Credit<R::AccountId, pezpallet_balances::Pallet<R>>> for DealWithFees<R>
where
R: pallet_balances::Config + pallet_authorship::Config + pallet_treasury::Config,
<R as frame_system::Config>::AccountId: From<pezkuwi_primitives::AccountId>,
<R as frame_system::Config>::AccountId: Into<pezkuwi_primitives::AccountId>,
R: pezpallet_balances::Config + pezpallet_authorship::Config + pezpallet_treasury::Config,
<R as pezframe_system::Config>::AccountId: From<pezkuwi_primitives::AccountId>,
<R as pezframe_system::Config>::AccountId: Into<pezkuwi_primitives::AccountId>,
{
fn on_unbalanceds(
mut fees_then_tips: impl Iterator<Item = Credit<R::AccountId, pallet_balances::Pallet<R>>>,
mut fees_then_tips: impl Iterator<Item = Credit<R::AccountId, pezpallet_balances::Pallet<R>>>,
) {
if let Some(fees) = fees_then_tips.next() {
// for fees, 80% to treasury, 20% to author
@@ -61,7 +61,7 @@ where
// for tips, if any, 100% to author
tips.merge_into(&mut split.1);
}
ResolveTo::<TreasuryAccountId<R>, pallet_balances::Pallet<R>>::on_unbalanced(split.0);
ResolveTo::<TreasuryAccountId<R>, pezpallet_balances::Pallet<R>>::on_unbalanced(split.0);
<ToAuthor<R> as OnUnbalanced<_>>::on_unbalanced(split.1);
}
}
@@ -93,7 +93,7 @@ pub struct EraPayoutParams {
/// A specialized function to compute the inflation of the staking system, tailored for pezkuwi
/// relay chains, such as Pezkuwi, Kusama and Zagros.
pub fn relay_era_payout(params: EraPayoutParams) -> (Balance, Balance) {
use sp_runtime::traits::Saturating;
use pezsp_runtime::traits::Saturating;
let EraPayoutParams {
total_staked,
@@ -111,7 +111,7 @@ pub fn relay_era_payout(params: EraPayoutParams) -> (Balance, Balance) {
let ideal_stake = ideal_stake.saturating_sub(legacy_auction_proportion.unwrap_or_default());
let stake = Perquintill::from_rational(total_staked, total_stakable);
let adjustment = pallet_staking_reward_fn::compute_inflation(stake, ideal_stake, falloff);
let adjustment = pezpallet_staking_reward_fn::compute_inflation(stake, ideal_stake, falloff);
let staking_inflation =
min_annual_inflation.saturating_add(delta_annual_inflation * adjustment);
@@ -243,10 +243,10 @@ where
pub mod benchmarks {
use super::VersionedLocatableAsset;
use core::marker::PhantomData;
use frame_support::traits::Get;
use pallet_asset_rate::AssetKindFactory;
use pallet_treasury::ArgumentsFactory as TreasuryArgumentsFactory;
use sp_core::{ConstU32, ConstU8};
use pezframe_support::traits::Get;
use pezpallet_asset_rate::AssetKindFactory;
use pezpallet_treasury::ArgumentsFactory as TreasuryArgumentsFactory;
use pezsp_core::{ConstU32, ConstU8};
use xcm::prelude::*;
/// Provides a factory method for the [`VersionedLocatableAsset`].
@@ -294,7 +294,7 @@ pub mod benchmarks {
#[cfg(test)]
mod tests {
use super::*;
use frame_support::{
use pezframe_support::{
derive_impl,
dispatch::DispatchClass,
parameter_types,
@@ -305,24 +305,24 @@ mod tests {
weights::Weight,
PalletId,
};
use frame_system::limits;
use pezframe_system::limits;
use pezkuwi_primitives::AccountId;
use sp_core::{ConstU64, H256};
use sp_runtime::{
use pezsp_core::{ConstU64, H256};
use pezsp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage, Perbill,
};
type Block = frame_system::mocking::MockBlock<Test>;
type Block = pezframe_system::mocking::MockBlock<Test>;
const TEST_ACCOUNT: AccountId = AccountId::new([1; 32]);
frame_support::construct_runtime!(
pezframe_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Authorship: pallet_authorship,
Balances: pallet_balances,
Treasury: pallet_treasury,
System: pezframe_system,
Authorship: pezpallet_authorship,
Balances: pezpallet_balances,
Treasury: pezpallet_treasury,
}
);
@@ -340,9 +340,9 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type BaseCallFilter = pezframe_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
@@ -357,17 +357,17 @@ mod tests {
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type AccountData = pezpallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type AccountStore = System;
}
@@ -377,9 +377,9 @@ mod tests {
pub TreasuryAccount: AccountId = Treasury::account_id();
}
impl pallet_treasury::Config for Test {
type Currency = pallet_balances::Pallet<Test>;
type RejectOrigin = frame_system::EnsureRoot<AccountId>;
impl pezpallet_treasury::Config for Test {
type Currency = pezpallet_balances::Pallet<Test>;
type RejectOrigin = pezframe_system::EnsureRoot<AccountId>;
type RuntimeEvent = RuntimeEvent;
type SpendPeriod = ();
type Burn = ();
@@ -388,7 +388,7 @@ mod tests {
type SpendFunds = ();
type MaxApprovals = MaxApprovals;
type WeightInfo = ();
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<u64>;
type SpendOrigin = pezframe_support::traits::NeverEnsureOrigin<u64>;
type AssetKind = ();
type Beneficiary = Self::AccountId;
type BeneficiaryLookup = IdentityLookup<Self::AccountId>;
@@ -409,15 +409,15 @@ mod tests {
Some(TEST_ACCOUNT)
}
}
impl pallet_authorship::Config for Test {
impl pezpallet_authorship::Config for Test {
type FindAuthor = OneAuthor;
type EventHandler = ();
}
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
// We use default for brevity, but you can configure as desired if needed.
pallet_balances::GenesisConfig::<Test>::default()
pezpallet_balances::GenesisConfig::<Test>::default()
.assimilate_storage(&mut t)
.unwrap();
t.into()
@@ -430,8 +430,8 @@ mod tests {
period_fraction: Perquintill,
auctioned_slots: u64,
) -> (Balance, Balance) {
use pallet_staking_reward_fn::compute_inflation;
use sp_runtime::traits::Saturating;
use pezpallet_staking_reward_fn::compute_inflation;
use pezsp_runtime::traits::Saturating;
let min_annual_inflation = Perquintill::from_rational(25u64, 1000u64);
let delta_annual_inflation = max_annual_inflation.saturating_sub(min_annual_inflation);
@@ -467,11 +467,11 @@ mod tests {
fn test_fees_and_tip_split() {
new_test_ext().execute_with(|| {
let fee =
<pallet_balances::Pallet<Test> as frame_support::traits::fungible::Balanced<
<pezpallet_balances::Pallet<Test> as pezframe_support::traits::fungible::Balanced<
AccountId,
>>::issue(10);
let tip =
<pallet_balances::Pallet<Test> as frame_support::traits::fungible::Balanced<
<pezpallet_balances::Pallet<Test> as pezframe_support::traits::fungible::Balanced<
AccountId,
>>::issue(20);
@@ -490,7 +490,7 @@ mod tests {
#[test]
fn compute_inflation_should_give_sensible_results() {
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
pezpallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(75),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
@@ -498,7 +498,7 @@ mod tests {
Perquintill::one()
);
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
pezpallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(50),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
@@ -506,7 +506,7 @@ mod tests {
Perquintill::from_rational(2u64, 3u64)
);
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
pezpallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(80),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
+35 -35
View File
@@ -26,15 +26,15 @@ use crate::{
};
use alloc::sync::Arc;
use codec::Encode;
use frame_support::{
use pezframe_support::{
assert_noop, assert_ok, derive_impl, parameter_types,
traits::{ConstU32, Currency},
weights::Weight,
PalletId,
};
use frame_support_test::TestRandomness;
use frame_system::EnsureRoot;
use pallet_identity::{self, legacy::IdentityInfo};
use pezframe_support_test::TestRandomness;
use pezframe_system::EnsureRoot;
use pezpallet_identity::{self, legacy::IdentityInfo};
use pezkuwi_primitives::{
BlockNumber, HeadData, Id as ParaId, SessionIndex, ValidationCode, LOWEST_PUBLIC_ID,
MAX_CODE_SIZE,
@@ -42,18 +42,18 @@ use pezkuwi_primitives::{
use pezkuwi_runtime_teyrchains::{
configuration, dmp, origin, paras, shared, Origin as ParaOrigin, ParaLifecycle,
};
use sp_core::{ConstUint, H256};
use sp_io::TestExternalities;
use sp_keyring::Sr25519Keyring;
use sp_keystore::{testing::MemoryKeystore, KeystoreExt};
use sp_runtime::{
use pezsp_core::{ConstUint, H256};
use pezsp_io::TestExternalities;
use pezsp_keyring::Sr25519Keyring;
use pezsp_keystore::{testing::MemoryKeystore, KeystoreExt};
use pezsp_runtime::{
traits::{BlakeTwo256, IdentityLookup, One, Verify},
transaction_validity::TransactionPriority,
AccountId32, BuildStorage, MultiSignature,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlockU32<Test>;
type UncheckedExtrinsic = pezframe_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = pezframe_system::mocking::MockBlockU32<Test>;
type AccountId = AccountId32;
type Balance = u32;
@@ -71,13 +71,13 @@ fn signed(i: u32) -> RuntimeOrigin {
RuntimeOrigin::signed(account_id)
}
frame_support::construct_runtime!(
pezframe_support::construct_runtime!(
pub enum Test
{
// System Stuff
System: frame_system,
Balances: pallet_balances,
Babe: pallet_babe,
System: pezframe_system,
Balances: pezpallet_balances,
Babe: pezpallet_babe,
// Teyrchains Runtime
Configuration: configuration,
@@ -93,12 +93,12 @@ frame_support::construct_runtime!(
Slots: slots,
// Migrators
Identity: pallet_identity,
Identity: pezpallet_identity,
IdentityMigrator: identity_migrator,
}
);
impl<C> frame_system::offchain::CreateTransactionBase<C> for Test
impl<C> pezframe_system::offchain::CreateTransactionBase<C> for Test
where
RuntimeCall: From<C>,
{
@@ -106,7 +106,7 @@ where
type RuntimeCall = RuntimeCall;
}
impl<C> frame_system::offchain::CreateBare<C> for Test
impl<C> pezframe_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
@@ -118,15 +118,15 @@ where
use crate::{auctions::Error as AuctionsError, crowdloan::Error as CrowdloanError};
parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(
pub BlockWeights: pezframe_system::limits::BlockWeights =
pezframe_system::limits::BlockWeights::simple_max(
Weight::from_parts(4 * 1024 * 1024, u64::MAX),
);
}
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type BaseCallFilter = pezframe_support::traits::Everything;
type BlockWeights = BlockWeights;
type BlockLength = ();
type DbWeight = ();
@@ -141,13 +141,13 @@ impl frame_system::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type AccountData = pezpallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
parameter_types! {
@@ -157,15 +157,15 @@ parameter_types! {
pub const MaxAuthorities: u32 = 100_000;
}
impl pallet_babe::Config for Test {
impl pezpallet_babe::Config for Test {
type EpochDuration = EpochDuration;
type ExpectedBlockTime = ExpectedBlockTime;
type EpochChangeTrigger = pallet_babe::ExternalTrigger;
type EpochChangeTrigger = pezpallet_babe::ExternalTrigger;
type DisabledValidators = ();
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxNominators = ConstU32<0>;
type KeyOwnerProof = sp_core::Void;
type KeyOwnerProof = pezsp_core::Void;
type EquivocationReportSystem = ();
}
@@ -173,7 +173,7 @@ parameter_types! {
pub const MinimumPeriod: Moment = 6_000 / 2;
}
impl pallet_timestamp::Config for Test {
impl pezpallet_timestamp::Config for Test {
type Moment = Moment;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
@@ -183,8 +183,8 @@ impl pallet_timestamp::Config for Test {
parameter_types! {
pub static ExistentialDeposit: Balance = 1;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type Balance = Balance;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -285,7 +285,7 @@ impl crowdloan::Config for Test {
type WeightInfo = crate::crowdloan::TestWeightInfo;
}
impl pallet_identity::Config for Test {
impl pezpallet_identity::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type Slashed = ();
@@ -319,7 +319,7 @@ impl identity_migrator::Config for Test {
/// Create a new set of test externalities.
pub fn new_test_ext() -> TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
configuration::GenesisConfig::<Test> {
config: configuration::HostConfiguration {
max_code_size: MAX_CODE_SIZE,
@@ -330,7 +330,7 @@ pub fn new_test_ext() -> TestExternalities {
.assimilate_storage(&mut t)
.unwrap();
let keystore = MemoryKeystore::new();
let mut ext: sp_io::TestExternalities = t.into();
let mut ext: pezsp_io::TestExternalities = t.into();
ext.register_extension(KeystoreExt(Arc::new(keystore)));
ext.execute_with(|| System::set_block_number(1));
ext
@@ -384,7 +384,7 @@ fn add_blocks(n: u32) {
fn run_to_block(n: u32) {
System::run_to_block_with::<AllPalletsWithSystem>(
n,
frame_system::RunToBlockHooks::default().before_initialize(|bn| {
pezframe_system::RunToBlockHooks::default().before_initialize(|bn| {
maybe_new_session(bn);
}),
);
+26 -26
View File
@@ -43,24 +43,24 @@ mod mock;
extern crate alloc;
use frame_support::{
use pezframe_support::{
parameter_types,
traits::{ConstU32, Currency, OneSessionHandler},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
};
use frame_system::limits;
use pezframe_system::limits;
use pezkuwi_primitives::{AssignmentId, Balance, BlockNumber, ValidatorId};
use sp_runtime::{FixedPointNumber, Perbill, Perquintill};
use pezsp_runtime::{FixedPointNumber, Perbill, Perquintill};
use static_assertions::const_assert;
pub use pallet_balances::Call as BalancesCall;
pub use pezpallet_balances::Call as BalancesCall;
#[cfg(feature = "std")]
pub use pallet_staking::StakerStatus;
pub use pallet_timestamp::Call as TimestampCall;
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
pub use sp_runtime::traits::Bounded;
pub use pezpallet_staking::StakerStatus;
pub use pezpallet_timestamp::Call as TimestampCall;
use pezpallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
pub use pezsp_runtime::traits::Bounded;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
pub use pezsp_runtime::BuildStorage;
/// Implementations of some helper traits passed into runtime modules as associated types.
pub use impls::ToAuthor;
@@ -68,8 +68,8 @@ pub use impls::ToAuthor;
#[deprecated(
note = "Please use fungible::Credit instead. This type will be removed some time after March 2024."
)]
pub type NegativeImbalance<T> = <pallet_balances::Pallet<T> as Currency<
<T as frame_system::Config>::AccountId,
pub type NegativeImbalance<T> = <pezpallet_balances::Pallet<T> as Currency<
<T as pezframe_system::Config>::AccountId,
>>::NegativeImbalance;
/// We assume that an on-initialize consumes 1% of the weight on average, hence a single extrinsic
@@ -122,14 +122,14 @@ pub type SlowAdjustingFeeUpdate<R> = TargetedFeeAdjustment<
#[macro_export]
macro_rules! impl_runtime_weights {
($runtime:ident) => {
use frame_support::{dispatch::DispatchClass, weights::Weight};
use frame_system::limits;
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
use pezframe_support::{dispatch::DispatchClass, weights::Weight};
use pezframe_system::limits;
use pezpallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
pub use pezkuwi_runtime_common::{
impl_elections_weights, AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT,
NORMAL_DISPATCH_RATIO,
};
use sp_runtime::{FixedPointNumber, Perquintill};
use pezsp_runtime::{FixedPointNumber, Perquintill};
// Implement the weight types of the elections module.
impl_elections_weights!($runtime);
@@ -166,17 +166,17 @@ macro_rules! impl_runtime_weights {
/// The type used for currency conversion.
///
/// This must only be used as long as the balance type is `u128`.
pub type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;
pub type CurrencyToVote = pezsp_staking::currency_to_vote::U128CurrencyToVote;
static_assertions::assert_eq_size!(pezkuwi_primitives::Balance, u128);
/// A placeholder since there is currently no provided session key handler for teyrchain validator
/// keys.
pub struct TeyrchainSessionKeyPlaceholder<T>(core::marker::PhantomData<T>);
impl<T> sp_runtime::BoundToRuntimeAppPublic for TeyrchainSessionKeyPlaceholder<T> {
impl<T> pezsp_runtime::BoundToRuntimeAppPublic for TeyrchainSessionKeyPlaceholder<T> {
type Public = ValidatorId;
}
impl<T: pallet_session::Config> OneSessionHandler<T::AccountId>
impl<T: pezpallet_session::Config> OneSessionHandler<T::AccountId>
for TeyrchainSessionKeyPlaceholder<T>
{
type Key = ValidatorId;
@@ -201,11 +201,11 @@ impl<T: pallet_session::Config> OneSessionHandler<T::AccountId>
/// A placeholder since there is currently no provided session key handler for teyrchain validator
/// keys.
pub struct AssignmentSessionKeyPlaceholder<T>(core::marker::PhantomData<T>);
impl<T> sp_runtime::BoundToRuntimeAppPublic for AssignmentSessionKeyPlaceholder<T> {
impl<T> pezsp_runtime::BoundToRuntimeAppPublic for AssignmentSessionKeyPlaceholder<T> {
type Public = AssignmentId;
}
impl<T: pallet_session::Config> OneSessionHandler<T::AccountId>
impl<T: pezpallet_session::Config> OneSessionHandler<T::AccountId>
for AssignmentSessionKeyPlaceholder<T>
{
type Key = AssignmentId;
@@ -229,24 +229,24 @@ impl<T: pallet_session::Config> OneSessionHandler<T::AccountId>
/// A reasonable benchmarking config for staking pallet.
pub struct StakingBenchmarkingConfig;
impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
impl pezpallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
type MaxValidators = ConstU32<1000>;
type MaxNominators = ConstU32<1000>;
}
/// Convert a balance to an unsigned 256-bit number, use in nomination pools.
pub struct BalanceToU256;
impl sp_runtime::traits::Convert<Balance, sp_core::U256> for BalanceToU256 {
fn convert(n: Balance) -> sp_core::U256 {
impl pezsp_runtime::traits::Convert<Balance, pezsp_core::U256> for BalanceToU256 {
fn convert(n: Balance) -> pezsp_core::U256 {
n.into()
}
}
/// Convert an unsigned 256-bit number to balance, use in nomination pools.
pub struct U256ToBalance;
impl sp_runtime::traits::Convert<sp_core::U256, Balance> for U256ToBalance {
fn convert(n: sp_core::U256) -> Balance {
use frame_support::traits::Defensive;
impl pezsp_runtime::traits::Convert<pezsp_core::U256, Balance> for U256ToBalance {
fn convert(n: pezsp_core::U256) -> Balance {
use pezframe_support::traits::Defensive;
n.try_into().defensive_unwrap_or(Balance::MAX)
}
}
+10 -10
View File
@@ -18,12 +18,12 @@
use crate::traits::Registrar;
use codec::{Decode, Encode};
use frame_support::{dispatch::DispatchResult, weights::Weight};
use frame_system::pallet_prelude::BlockNumberFor;
use pezframe_support::{dispatch::DispatchResult, weights::Weight};
use pezframe_system::pezpallet_prelude::BlockNumberFor;
use pezkuwi_primitives::{HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, ValidationCode};
use pezkuwi_runtime_teyrchains::paras;
use sp_keyring::Sr25519Keyring;
use sp_runtime::{traits::SaturatedConversion, DispatchError, Permill};
use pezsp_keyring::Sr25519Keyring;
use pezsp_runtime::{traits::SaturatedConversion, DispatchError, Permill};
use std::{cell::RefCell, collections::HashMap};
thread_local! {
@@ -37,7 +37,7 @@ thread_local! {
pub struct TestRegistrar<T>(core::marker::PhantomData<T>);
impl<T: frame_system::Config> Registrar for TestRegistrar<T> {
impl<T: pezframe_system::Config> Registrar for TestRegistrar<T> {
type AccountId = T::AccountId;
fn manager_of(id: ParaId) -> Option<Self::AccountId> {
@@ -140,7 +140,7 @@ impl<T: frame_system::Config> Registrar for TestRegistrar<T> {
OPERATIONS.with(|x| {
x.borrow_mut().push((
id,
frame_system::Pallet::<T>::block_number().saturated_into(),
pezframe_system::Pallet::<T>::block_number().saturated_into(),
true,
))
});
@@ -174,7 +174,7 @@ impl<T: frame_system::Config> Registrar for TestRegistrar<T> {
OPERATIONS.with(|x| {
x.borrow_mut().push((
id,
frame_system::Pallet::<T>::block_number().saturated_into(),
pezframe_system::Pallet::<T>::block_number().saturated_into(),
false,
))
});
@@ -196,7 +196,7 @@ impl<T: frame_system::Config> Registrar for TestRegistrar<T> {
fn execute_pending_transitions() {}
}
impl<T: frame_system::Config> TestRegistrar<T> {
impl<T: pezframe_system::Config> TestRegistrar<T> {
pub fn operations() -> Vec<(ParaId, BlockNumberFor<T>, bool)> {
OPERATIONS
.with(|x| x.borrow().iter().map(|(p, b, c)| (*p, (*b).into(), *c)).collect::<Vec<_>>())
@@ -225,7 +225,7 @@ impl<T: frame_system::Config> TestRegistrar<T> {
/// is more to satisfy type requirements rather than to test anything.
pub struct TestNextSessionRotation;
impl frame_support::traits::EstimateNextSessionRotation<u32> for TestNextSessionRotation {
impl pezframe_support::traits::EstimateNextSessionRotation<u32> for TestNextSessionRotation {
fn average_session_length() -> u32 {
10
}
@@ -261,7 +261,7 @@ pub fn conclude_pvf_checking<T: paras::Config>(
};
let signature = key.sign(&statement.signing_payload());
let _ = paras::Pallet::<T>::include_pvf_check_statement(
frame_system::Origin::<T>::None.into(),
pezframe_system::Origin::<T>::None.into(),
statement,
signature.into(),
);
@@ -19,19 +19,19 @@
#[cfg(feature = "runtime-benchmarks")]
use super::{Pallet as Registrar, *};
use crate::traits::Registrar as RegistrarT;
use frame_support::assert_ok;
use frame_system::RawOrigin;
use pezframe_support::assert_ok;
use pezframe_system::RawOrigin;
use pezkuwi_primitives::{MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MIN_CODE_SIZE};
use pezkuwi_runtime_teyrchains::{paras, shared, Origin as ParaOrigin};
use sp_runtime::traits::Bounded;
use pezsp_runtime::traits::Bounded;
use frame_benchmarking::v2::*;
use pezframe_benchmarking::v2::*;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
let events = pezframe_system::Pallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
}
@@ -49,7 +49,7 @@ fn register_para<T: Config>(id: u32) -> ParaId {
validation_code.clone()
));
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
return para;
@@ -66,7 +66,7 @@ fn next_scheduled_session<T: Config>() {
}
#[benchmarks(
where ParaOrigin: Into<<T as frame_system::Config>::RuntimeOrigin>,
where ParaOrigin: Into<<T as pezframe_system::Config>::RuntimeOrigin>,
)]
mod benchmarks {
use super::*;
@@ -103,7 +103,7 @@ mod benchmarks {
assert_last_event::<T>(Event::<T>::Registered { para_id: para, manager: caller }.into());
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
next_scheduled_session::<T>();
@@ -126,7 +126,7 @@ mod benchmarks {
assert_last_event::<T>(Event::<T>::Registered { para_id: para, manager }.into());
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
next_scheduled_session::<T>();
@@ -15,7 +15,7 @@
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
use super::*;
use frame_support::traits::{Contains, UncheckedOnRuntimeUpgrade};
use pezframe_support::traits::{Contains, UncheckedOnRuntimeUpgrade};
#[derive(Encode, Decode)]
pub struct ParaInfoV1<Account, Balance> {
@@ -46,12 +46,12 @@ impl<T: Config, UnlockParaIds: Contains<ParaId>> UncheckedOnRuntimeUpgrade
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
fn pre_upgrade() -> Result<Vec<u8>, pezsp_runtime::TryRuntimeError> {
Ok((Paras::<T>::iter_keys().count() as u32).encode())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
fn post_upgrade(state: Vec<u8>) -> Result<(), pezsp_runtime::TryRuntimeError> {
let old_count = u32::decode(&mut &state[..]).expect("Known good");
let new_count = Paras::<T>::iter_values().count() as u32;
@@ -60,10 +60,10 @@ impl<T: Config, UnlockParaIds: Contains<ParaId>> UncheckedOnRuntimeUpgrade
}
}
pub type MigrateToV1<T, UnlockParaIds> = frame_support::migrations::VersionedMigration<
pub type MigrateToV1<T, UnlockParaIds> = pezframe_support::migrations::VersionedMigration<
0,
1,
VersionUncheckedMigrateToV1<T, UnlockParaIds>,
super::Pallet<T>,
<T as frame_system::Config>::DbWeight,
<T as pezframe_system::Config>::DbWeight,
>;
@@ -20,27 +20,27 @@
use super::*;
use crate::paras_registrar;
use alloc::collections::btree_map::BTreeMap;
use frame_support::{derive_impl, parameter_types};
use frame_system::limits;
use pezframe_support::{derive_impl, parameter_types};
use pezframe_system::limits;
use pezkuwi_primitives::{Balance, BlockNumber, MAX_CODE_SIZE};
use pezkuwi_runtime_teyrchains::{configuration, origin, shared};
use sp_core::{ConstUint, H256};
use sp_io::TestExternalities;
use sp_keyring::Sr25519Keyring;
use sp_runtime::{
use pezsp_core::{ConstUint, H256};
use pezsp_io::TestExternalities;
use pezsp_keyring::Sr25519Keyring;
use pezsp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
transaction_validity::TransactionPriority,
BuildStorage, Perbill,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlockU32<Test>;
type UncheckedExtrinsic = pezframe_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = pezframe_system::mocking::MockBlockU32<Test>;
frame_support::construct_runtime!(
pezframe_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
System: pezframe_system,
Balances: pezpallet_balances,
Configuration: configuration,
Teyrchains: paras,
ParasShared: shared,
@@ -49,7 +49,7 @@ frame_support::construct_runtime!(
}
);
impl<C> frame_system::offchain::CreateTransactionBase<C> for Test
impl<C> pezframe_system::offchain::CreateTransactionBase<C> for Test
where
RuntimeCall: From<C>,
{
@@ -57,7 +57,7 @@ where
type RuntimeCall = RuntimeCall;
}
impl<C> frame_system::offchain::CreateBare<C> for Test
impl<C> pezframe_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
@@ -69,14 +69,14 @@ where
const NORMAL_RATIO: Perbill = Perbill::from_percent(75);
parameter_types! {
pub BlockWeights: limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX));
pezframe_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX));
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(4 * 1024 * 1024, NORMAL_RATIO);
}
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type BaseCallFilter = pezframe_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
@@ -91,21 +91,21 @@ impl frame_system::Config for Test {
type BlockLength = BlockLength;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u128>;
type AccountData = pezpallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: Balance = 1;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type Balance = Balance;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -131,7 +131,7 @@ impl paras::Config for Test {
type AssignCoretime = ();
type Fungible = Balances;
type CooldownRemovalMultiplier = ConstUint<1>;
type AuthorizeCurrentCodeOrigin = frame_system::EnsureRoot<u64>;
type AuthorizeCurrentCodeOrigin = pezframe_system::EnsureRoot<u64>;
}
impl configuration::Config for Test {
@@ -155,7 +155,7 @@ impl Config for Test {
}
pub fn new_test_ext() -> TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
configuration::GenesisConfig::<Test> {
config: configuration::HostConfiguration {
@@ -167,7 +167,7 @@ pub fn new_test_ext() -> TestExternalities {
.assimilate_storage(&mut t)
.unwrap();
pallet_balances::GenesisConfig::<Test> {
pezpallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10_000_000), (2, 10_000_000), (3, 10_000_000)],
..Default::default()
}
@@ -208,7 +208,7 @@ pub fn run_to_block(n: BlockNumber) {
// require adding it here.
System::run_to_block_with::<AllPalletsWithSystem>(
n,
frame_system::RunToBlockHooks::default().before_finalize(|bn| {
pezframe_system::RunToBlockHooks::default().before_finalize(|bn| {
// Session change every 3 blocks.
if (bn + 1) % BLOCKS_PER_SESSION == 0 {
let session_index = shared::CurrentSessionIndex::<Test>::get() + 1;
@@ -21,13 +21,13 @@ pub mod migration;
use alloc::{vec, vec::Vec};
use core::result;
use frame_support::{
use pezframe_support::{
dispatch::DispatchResult,
ensure,
pallet_prelude::Weight,
pezpallet_prelude::Weight,
traits::{Currency, Get, ReservableCurrency},
};
use frame_system::{self, ensure_root, ensure_signed};
use pezframe_system::{self, ensure_root, ensure_signed};
use pezkuwi_primitives::{HeadData, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID, MIN_CODE_SIZE};
use pezkuwi_runtime_teyrchains::{
configuration, ensure_teyrchain,
@@ -40,7 +40,7 @@ use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
pub use pallet::*;
use pezkuwi_runtime_teyrchains::paras::{OnNewHead, ParaKind};
use scale_info::TypeInfo;
use sp_runtime::{
use pezsp_runtime::{
traits::{CheckedSub, Saturating},
RuntimeDebug,
};
@@ -75,7 +75,7 @@ impl<Account, Balance> ParaInfo<Account, Balance> {
}
type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
<<T as Config>::Currency as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
pub trait WeightInfo {
fn reserve() -> Weight;
@@ -112,11 +112,11 @@ impl WeightInfo for TestWeightInfo {
}
}
#[frame_support::pallet]
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
@@ -127,17 +127,17 @@ pub mod pallet {
pub struct Pallet<T>(_);
#[pallet::config]
#[pallet::disable_frame_system_supertrait_check]
#[pallet::disable_pezframe_system_supertrait_check]
pub trait Config: configuration::Config + paras::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// The aggregated origin type must support the `teyrchains` origin. We require that we can
/// infallibly convert between this origin and the system origin, but in reality, they're
/// the same type, we just can't express that to the Rust type system without writing a
/// `where` clause everywhere.
type RuntimeOrigin: From<<Self as frame_system::Config>::RuntimeOrigin>
type RuntimeOrigin: From<<Self as pezframe_system::Config>::RuntimeOrigin>
+ Into<result::Result<Origin, <Self as Config>::RuntimeOrigin>>;
/// The system's currency for on-demand teyrchain payment.
@@ -568,7 +568,7 @@ impl<T: Config> Pallet<T> {
/// Ensure the origin is one of Root, the `para` owner, or the `para` itself.
/// If the origin is the `para` owner, the `para` must be unlocked.
fn ensure_root_para_or_owner(
origin: <T as frame_system::Config>::RuntimeOrigin,
origin: <T as pezframe_system::Config>::RuntimeOrigin,
id: ParaId,
) -> DispatchResult {
if let Ok(who) = ensure_signed(origin.clone()) {
@@ -585,7 +585,7 @@ impl<T: Config> Pallet<T> {
/// Ensure the origin is one of Root or the `para` itself.
fn ensure_root_or_para(
origin: <T as frame_system::Config>::RuntimeOrigin,
origin: <T as pezframe_system::Config>::RuntimeOrigin,
id: ParaId,
) -> DispatchResult {
if ensure_root(origin.clone()).is_ok() {
@@ -680,7 +680,7 @@ impl<T: Config> Pallet<T> {
genesis_head: HeadData,
validation_code: ValidationCode,
para_kind: ParaKind,
) -> Result<(ParaGenesisArgs, BalanceOf<T>), sp_runtime::DispatchError> {
) -> Result<(ParaGenesisArgs, BalanceOf<T>), pezsp_runtime::DispatchError> {
let config = configuration::ActiveConfig::<T>::get();
ensure!(validation_code.0.len() >= MIN_CODE_SIZE as usize, Error::<T>::InvalidCode);
ensure!(validation_code.0.len() <= config.max_code_size as usize, Error::<T>::CodeTooLarge);
@@ -22,10 +22,10 @@ use crate::{
mock::conclude_pvf_checking, paras_registrar, paras_registrar::mock::*,
traits::Registrar as RegistrarTrait,
};
use frame_support::{assert_noop, assert_ok};
use pallet_balances::Error as BalancesError;
use pezframe_support::{assert_noop, assert_ok};
use pezpallet_balances::Error as BalancesError;
use pezkuwi_primitives::SessionIndex;
use sp_runtime::traits::BadOrigin;
use pezsp_runtime::traits::BadOrigin;
#[test]
fn end_to_end_scenario_works() {
@@ -18,8 +18,8 @@
use alloc::boxed::Box;
use codec::Encode;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
use pezkuwi_primitives::Id as ParaId;
use pezkuwi_runtime_teyrchains::{
@@ -28,7 +28,7 @@ use pezkuwi_runtime_teyrchains::{
ParaLifecycle,
};
#[frame_support::pallet]
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
@@ -36,7 +36,7 @@ pub mod pallet {
pub struct Pallet<T>(_);
#[pallet::config]
#[pallet::disable_frame_system_supertrait_check]
#[pallet::disable_pezframe_system_supertrait_check]
pub trait Config: configuration::Config + paras::Config + dmp::Config + hrmp::Config {}
#[pallet::error]
+22 -22
View File
@@ -19,37 +19,37 @@
#[cfg(test)]
use super::*;
use sp_core::{crypto::AccountId32, H256};
use sp_keyring::{Ed25519Keyring, Sr25519Keyring};
use pezsp_core::{crypto::AccountId32, H256};
use pezsp_keyring::{Ed25519Keyring, Sr25519Keyring};
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use crate::purchase;
use frame_support::{
use pezframe_support::{
derive_impl, ord_parameter_types, parameter_types,
traits::{Currency, WithdrawReasons},
};
use sp_runtime::{
use pezsp_runtime::{
traits::{BlakeTwo256, Identity, IdentityLookup},
BuildStorage,
};
type Block = frame_system::mocking::MockBlock<Test>;
type Block = pezframe_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pezframe_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
Vesting: pallet_vesting,
System: pezframe_system,
Balances: pezpallet_balances,
Vesting: pezpallet_vesting,
Purchase: purchase,
}
);
type AccountId = AccountId32;
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type BaseCallFilter = pezframe_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
@@ -64,17 +64,17 @@ impl frame_system::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type AccountData = pezpallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type AccountStore = System;
}
@@ -84,7 +84,7 @@ parameter_types! {
WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
}
impl pallet_vesting::Config for Test {
impl pezpallet_vesting::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BlockNumberToBalance = Identity;
@@ -111,8 +111,8 @@ impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type VestingSchedule = Vesting;
type ValidityOrigin = frame_system::EnsureSignedBy<ValidityOrigin, AccountId>;
type ConfigurationOrigin = frame_system::EnsureSignedBy<ConfigurationOrigin, AccountId>;
type ValidityOrigin = pezframe_system::EnsureSignedBy<ValidityOrigin, AccountId>;
type ConfigurationOrigin = pezframe_system::EnsureSignedBy<ConfigurationOrigin, AccountId>;
type MaxStatementLength = MaxStatementLength;
type UnlockedProportion = UnlockedProportion;
type MaxUnlocked = MaxUnlocked;
@@ -120,9 +120,9 @@ impl Config for Test {
// This function basically just builds a genesis storage key/value store according to
// our desired mockup. It also executes our `setup` function which sets up this pallet for use.
pub fn new_test_ext() -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let mut ext = sp_io::TestExternalities::new(t);
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let mut ext = pezsp_io::TestExternalities::new(t);
ext.execute_with(|| setup());
ext
}
+14 -14
View File
@@ -18,21 +18,21 @@
use alloc::vec::Vec;
use codec::{Decode, Encode};
use frame_support::{
pallet_prelude::*,
use pezframe_support::{
pezpallet_prelude::*,
traits::{Currency, EnsureOrigin, ExistenceRequirement, Get, VestingSchedule},
};
use frame_system::pallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
use scale_info::TypeInfo;
use sp_core::sr25519;
use sp_runtime::{
use pezsp_core::sr25519;
use pezsp_runtime::{
traits::{CheckedAdd, Saturating, Verify, Zero},
AnySignature, DispatchError, DispatchResult, Permill, RuntimeDebug,
};
type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
<<T as Config>::Currency as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
/// The kind of statement an account needs to make for a claim to be valid.
#[derive(
@@ -89,7 +89,7 @@ pub struct AccountStatus<Balance> {
vat: Permill,
}
#[frame_support::pallet]
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
@@ -98,10 +98,10 @@ pub mod pallet {
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config {
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// Balances Pallet
type Currency: Currency<Self::AccountId>;
@@ -414,7 +414,7 @@ pub mod pallet {
) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?;
ensure!(
unlock_block > frame_system::Pallet::<T>::block_number(),
unlock_block > pezframe_system::Pallet::<T>::block_number(),
Error::<T>::InvalidUnlockBlock
);
// Possibly this is worse than having the caller account be the payment account?
@@ -460,12 +460,12 @@ where
/// WARNING: Executing this function will clear all storage used by this pallet.
/// Be sure this is what you want...
pub fn remove_pallet<T>() -> frame_support::weights::Weight
pub fn remove_pallet<T>() -> pezframe_support::weights::Weight
where
T: frame_system::Config,
T: pezframe_system::Config,
{
#[allow(deprecated)]
use frame_support::migration::remove_storage_prefix;
use pezframe_support::migration::remove_storage_prefix;
#[allow(deprecated)]
remove_storage_prefix(b"Purchase", b"Accounts", b"");
#[allow(deprecated)]
@@ -475,7 +475,7 @@ where
#[allow(deprecated)]
remove_storage_prefix(b"Purchase", b"UnlockBlock", b"");
<T as frame_system::Config>::BlockWeights::get().max_block
<T as pezframe_system::Config>::BlockWeights::get().max_block
}
#[cfg(test)]
+4 -4
View File
@@ -19,11 +19,11 @@
#[cfg(test)]
use super::*;
use sp_core::crypto::AccountId32;
use pezsp_core::crypto::AccountId32;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use frame_support::{assert_noop, assert_ok, traits::Currency};
use sp_runtime::{traits::Dispatchable, ArithmeticError, DispatchError::BadOrigin};
use pezframe_support::{assert_noop, assert_ok, traits::Currency};
use pezsp_runtime::{traits::Dispatchable, ArithmeticError, DispatchError::BadOrigin};
use crate::purchase::mock::*;
@@ -451,7 +451,7 @@ fn payout_works() {
);
// Vesting lock is removed in whole on block 101 (100 blocks after block 1)
System::set_block_number(100);
let vest_call = RuntimeCall::Vesting(pallet_vesting::Call::<Test>::vest {});
let vest_call = RuntimeCall::Vesting(pezpallet_vesting::Call::<Test>::vest {});
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(alice())));
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(bob())));
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), Some(45));
@@ -16,7 +16,7 @@
use super::*;
use crate::crowdloan;
use sp_runtime::traits::AccountIdConversion;
use pezsp_runtime::traits::AccountIdConversion;
/// Migrations for using fund index to create fund accounts instead of para ID.
pub mod slots_crowdloan_index_migration {
@@ -48,7 +48,7 @@ pub mod slots_crowdloan_index_migration {
Ok(())
}
pub fn migrate<T: Config + crowdloan::Config>() -> frame_support::weights::Weight {
pub fn migrate<T: Config + crowdloan::Config>() -> pezframe_support::weights::Weight {
let mut weight = Weight::zero();
for (para_id, mut leases) in Leases::<T>::iter() {
+41 -41
View File
@@ -26,18 +26,18 @@ pub mod migration;
use crate::traits::{LeaseError, Leaser, Registrar};
use alloc::{vec, vec::Vec};
use frame_support::{
pallet_prelude::*,
use pezframe_support::{
pezpallet_prelude::*,
traits::{Currency, ReservableCurrency},
weights::Weight,
};
use frame_system::pallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
use pezkuwi_primitives::Id as ParaId;
use sp_runtime::traits::{CheckedConversion, CheckedSub, Saturating, Zero};
use pezsp_runtime::traits::{CheckedConversion, CheckedSub, Saturating, Zero};
type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
<<T as Config>::Currency as Currency<<T as pezframe_system::Config>::AccountId>>::Balance;
type LeasePeriodOf<T> = BlockNumberFor<T>;
pub trait WeightInfo {
@@ -63,7 +63,7 @@ impl WeightInfo for TestWeightInfo {
}
}
#[frame_support::pallet]
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
@@ -72,10 +72,10 @@ pub mod pallet {
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config {
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// The currency type used for bidding.
type Currency: ReservableCurrency<Self::AccountId>;
@@ -92,7 +92,7 @@ pub mod pallet {
type LeaseOffset: Get<BlockNumberFor<Self>>;
/// The origin which may forcibly create or clear leases. Root can always do this.
type ForceOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
type ForceOrigin: EnsureOrigin<<Self as pezframe_system::Config>::RuntimeOrigin>;
/// Weight Information for the Extrinsics in the Pallet
type WeightInfo: WeightInfo;
@@ -346,7 +346,7 @@ impl<T: Config> Leaser<BlockNumberFor<T>> for Pallet<T> {
period_begin: Self::LeasePeriod,
period_count: Self::LeasePeriod,
) -> Result<(), LeaseError> {
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
let (current_lease_period, _) =
Self::lease_period_index(now).ok_or(LeaseError::NoLeasePeriod)?;
// Finally, we update the deposit held so it is `amount` for the new lease period
@@ -462,7 +462,7 @@ impl<T: Config> Leaser<BlockNumberFor<T>> for Pallet<T> {
first_period: Self::LeasePeriod,
last_period: Self::LeasePeriod,
) -> bool {
let now = frame_system::Pallet::<T>::block_number();
let now = pezframe_system::Pallet::<T>::block_number();
let (current_lease_period, _) = match Self::lease_period_index(now) {
Some(clp) => clp,
None => return true,
@@ -504,31 +504,31 @@ mod tests {
use super::*;
use crate::{mock::TestRegistrar, slots};
use frame_support::{assert_noop, assert_ok, derive_impl, parameter_types};
use frame_system::EnsureRoot;
use pallet_balances;
use pezframe_support::{assert_noop, assert_ok, derive_impl, parameter_types};
use pezframe_system::EnsureRoot;
use pezpallet_balances;
use pezkuwi_primitives::BlockNumber;
use pezkuwi_primitives_test_helpers::{dummy_head_data, dummy_validation_code};
use sp_core::H256;
use sp_runtime::{
use pezsp_core::H256;
use pezsp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
type Block = frame_system::mocking::MockBlockU32<Test>;
type Block = pezframe_system::mocking::MockBlockU32<Test>;
frame_support::construct_runtime!(
pezframe_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
System: pezframe_system,
Balances: pezpallet_balances,
Slots: slots,
}
);
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type BaseCallFilter = pezframe_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type RuntimeOrigin = RuntimeOrigin;
@@ -543,17 +543,17 @@ mod tests {
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type AccountData = pezpallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = pezframe_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type AccountStore = System;
}
@@ -575,9 +575,9 @@ mod tests {
// This function basically just builds a genesis storage key/value store according to
// our desired mock up.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pezpallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
..Default::default()
}
@@ -958,20 +958,20 @@ mod tests {
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking {
use super::*;
use frame_support::assert_ok;
use frame_system::RawOrigin;
use pezframe_support::assert_ok;
use pezframe_system::RawOrigin;
use pezkuwi_runtime_teyrchains::paras;
use sp_runtime::traits::{Bounded, One};
use pezsp_runtime::traits::{Bounded, One};
use frame_benchmarking::v2::*;
use pezframe_benchmarking::v2::*;
use crate::slots::Pallet as Slots;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
let events = pezframe_system::Pallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
}
@@ -990,7 +990,7 @@ mod benchmarking {
worst_validation_code.clone(),
));
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
pezframe_system::Origin::<T>::Root.into(),
worst_validation_code,
));
@@ -1009,7 +1009,7 @@ mod benchmarking {
#[benchmark]
fn force_lease() -> Result<(), BenchmarkError> {
// If there is an offset, we need to be on that block to be able to do lease things.
frame_system::Pallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
pezframe_system::Pallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
let para = ParaId::from(1337);
let leaser: T::AccountId = account("leaser", 0, 0);
T::Currency::make_free_balance_be(&leaser, BalanceOf::<T>::max_value());
@@ -1048,7 +1048,7 @@ mod benchmarking {
let period_count = 4u32.into();
// If there is an offset, we need to be on that block to be able to do lease things.
frame_system::Pallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
pezframe_system::Pallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
// Make T parathreads (on-demand teyrchains)
let paras_info = (0..t).map(|i| register_a_parathread::<T>(i)).collect::<Vec<_>>();
@@ -1105,7 +1105,7 @@ mod benchmarking {
let (para, _) = register_a_parathread::<T>(1);
// If there is an offset, we need to be on that block to be able to do lease things.
frame_system::Pallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
pezframe_system::Pallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
for i in 0..max_people {
let leaser = account("lease_deposit", i, 0);
+1 -1
View File
@@ -17,7 +17,7 @@
//! Traits used across pallets for Pezkuwi.
use alloc::vec::*;
use frame_support::{
use pezframe_support::{
dispatch::DispatchResult,
traits::{Currency, ReservableCurrency},
};
+16 -16
View File
@@ -17,18 +17,18 @@
//! Common try-runtime only tests for runtimes.
use alloc::{collections::btree_set::BTreeSet, vec::Vec};
use frame_support::{
use pezframe_support::{
dispatch::RawOrigin,
traits::{Get, Hooks},
};
use pallet_fast_unstake::{Pallet as FastUnstake, *};
use pallet_staking::*;
use pezpallet_fast_unstake::{Pallet as FastUnstake, *};
use pezpallet_staking::*;
/// register all inactive nominators for fast-unstake, and progress until they have all been
/// processed.
pub fn migrate_all_inactive_nominators<T: pallet_fast_unstake::Config + pallet_staking::Config>()
pub fn migrate_all_inactive_nominators<T: pezpallet_fast_unstake::Config + pezpallet_staking::Config>()
where
<T as frame_system::Config>::RuntimeEvent: TryInto<pallet_fast_unstake::Event<T>>,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pezpallet_fast_unstake::Event<T>>,
{
let mut unstaked_ok = 0;
let mut unstaked_err = 0;
@@ -64,35 +64,35 @@ where
target: "runtime::test",
"registered {} successfully, starting at {:?}.",
Queue::<T>::count(),
frame_system::Pallet::<T>::block_number(),
pezframe_system::Pallet::<T>::block_number(),
);
while Queue::<T>::count() != 0 || Head::<T>::get().is_some() {
let now = frame_system::Pallet::<T>::block_number();
let weight = <T as frame_system::Config>::BlockWeights::get().max_block;
let now = pezframe_system::Pallet::<T>::block_number();
let weight = <T as pezframe_system::Config>::BlockWeights::get().max_block;
let consumed = FastUnstake::<T>::on_idle(now, weight);
log::debug!(target: "runtime::test", "consumed {:?} ({})", consumed, consumed.ref_time() as f32 / weight.ref_time() as f32);
frame_system::Pallet::<T>::read_events_no_consensus()
pezframe_system::Pallet::<T>::read_events_no_consensus()
.into_iter()
.map(|r| r.event)
.filter_map(|e| {
let maybe_fast_unstake_event: Option<pallet_fast_unstake::Event<T>> =
let maybe_fast_unstake_event: Option<pezpallet_fast_unstake::Event<T>> =
e.try_into().ok();
maybe_fast_unstake_event
})
.for_each(|e: pallet_fast_unstake::Event<T>| match e {
pallet_fast_unstake::Event::<T>::Unstaked { result, .. } =>
.for_each(|e: pezpallet_fast_unstake::Event<T>| match e {
pezpallet_fast_unstake::Event::<T>::Unstaked { result, .. } =>
if result.is_ok() {
unstaked_ok += 1;
} else {
unstaked_err += 1
},
pallet_fast_unstake::Event::<T>::Slashed { .. } => unstaked_slashed += 1,
pallet_fast_unstake::Event::<T>::InternalError => unreachable!(),
pezpallet_fast_unstake::Event::<T>::Slashed { .. } => unstaked_slashed += 1,
pezpallet_fast_unstake::Event::<T>::InternalError => unreachable!(),
_ => {},
});
if now % 100u32.into() == sp_runtime::traits::Zero::zero() {
if now % 100u32.into() == pezsp_runtime::traits::Zero::zero() {
log::info!(
target: "runtime::test",
"status: ok {}, err {}, slash {}",
@@ -102,6 +102,6 @@ where
);
}
frame_system::Pallet::<T>::reset_events();
pezframe_system::Pallet::<T>::reset_events();
}
}
+6 -6
View File
@@ -19,14 +19,14 @@
use alloc::vec::Vec;
use codec::{DecodeLimit, Encode};
use core::marker::PhantomData;
use frame_support::traits::Get;
use frame_system::pallet_prelude::BlockNumberFor;
use pezframe_support::traits::Get;
use pezframe_system::pezpallet_prelude::BlockNumberFor;
use pezkuwi_primitives::Id as ParaId;
use pezkuwi_runtime_teyrchains::{
configuration::{self, HostConfiguration},
dmp, FeeTracker,
};
use sp_runtime::FixedPointNumber;
use pezsp_runtime::FixedPointNumber;
use xcm::{prelude::*, MAX_XCM_DECODE_DEPTH};
use xcm_builder::InspectMessageQueues;
use SendError::*;
@@ -133,7 +133,7 @@ where
fn deliver(
(config, para, blob): (HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>),
) -> Result<XcmHash, SendError> {
let hash = sp_io::hashing::blake2_256(&blob[..]);
let hash = pezsp_io::hashing::blake2_256(&blob[..]);
dmp::Pallet::<T>::queue_downward_message(&config, para, blob)
.map(|()| hash)
.map_err(|error| {
@@ -283,9 +283,9 @@ mod tests {
use super::*;
use crate::integration_tests::new_test_ext;
use alloc::vec;
use frame_support::{assert_ok, parameter_types};
use pezframe_support::{assert_ok, parameter_types};
use pezkuwi_runtime_teyrchains::FeeTracker;
use sp_runtime::FixedU128;
use pezsp_runtime::FixedU128;
use xcm::MAX_XCM_DECODE_DEPTH;
parameter_types! {