fix: Complete snowbridge pezpallet rebrand and critical bug fixes

- snowbridge-pezpallet-* → pezsnowbridge-pezpallet-* (201 refs)
- pallet/ directories → pezpallet/ (4 locations)
- Fixed pezpallet.rs self-include recursion bug
- Fixed sc-chain-spec hardcoded crate name in derive macro
- Reverted .pezpallet_by_name() to .pallet_by_name() (subxt API)
- Added BizinikiwiConfig type alias for zombienet tests
- Deleted obsolete session state files

Verified: pezsnowbridge-pezpallet-*, pezpallet-staking,
pezpallet-staking-async, pezframe-benchmarking-cli all pass cargo check
This commit is contained in:
2025-12-16 09:57:23 +03:00
parent eea003e14d
commit 3139ffa25e
3022 changed files with 42157 additions and 23579 deletions
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Benchmarking for assigned_slots pallet
//! Benchmarking for assigned_slots pezpallet
#![cfg(feature = "runtime-benchmarks")]
use super::*;
@@ -33,7 +33,7 @@ type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Curre
mod benchmarks {
use super::*;
use crate::assigned_slots::Pallet as AssignedSlots;
use crate::assigned_slots::Pezpallet as AssignedSlots;
fn register_teyrchain<T: Config>(para_id: ParaId) {
let who: T::AccountId = whitelisted_caller();
@@ -48,7 +48,7 @@ mod benchmarks {
worst_head_data,
worst_validation_code.clone()
));
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
assert_ok!(paras::Pezpallet::<T>::add_trusted_validation_code(
pezframe_system::Origin::<T>::Root.into(),
worst_validation_code,
));
@@ -66,7 +66,7 @@ mod benchmarks {
let counter = PermanentSlotCount::<T>::get();
let current_lease_period: BlockNumberFor<T> =
T::Leaser::lease_period_index(pezframe_system::Pallet::<T>::block_number())
T::Leaser::lease_period_index(pezframe_system::Pezpallet::<T>::block_number())
.and_then(|x| Some(x.0))
.unwrap();
#[extrinsic_call]
@@ -92,7 +92,7 @@ mod benchmarks {
register_teyrchain::<T>(para_id);
let current_lease_period: BlockNumberFor<T> =
T::Leaser::lease_period_index(pezframe_system::Pallet::<T>::block_number())
T::Leaser::lease_period_index(pezframe_system::Pezpallet::<T>::block_number())
.and_then(|x| Some(x.0))
.unwrap();
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
use super::{Config, MaxPermanentSlots, MaxTemporarySlots, Pallet, LOG_TARGET};
use super::{Config, MaxPermanentSlots, MaxTemporarySlots, Pezpallet, LOG_TARGET};
use pezframe_support::traits::{Get, GetStorageVersion, UncheckedOnRuntimeUpgrade};
#[cfg(feature = "try-runtime")]
@@ -28,13 +28,13 @@ pub mod v1 {
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateToV1<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, pezsp_runtime::TryRuntimeError> {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
ensure!(on_chain_version < 1, "assigned_slots::MigrateToV1 migration can be deleted");
Ok(Default::default())
}
fn on_runtime_upgrade() -> pezframe_support::weights::Weight {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
if on_chain_version < 1 {
const MAX_PERMANENT_SLOTS: u32 = 100;
const MAX_TEMPORARY_SLOTS: u32 = 100;
@@ -51,7 +51,7 @@ pub mod v1 {
#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), pezsp_runtime::TryRuntimeError> {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
ensure!(on_chain_version == 1, "assigned_slots::MigrateToV1 needs to be run");
assert_eq!(MaxPermanentSlots::<T>::get(), 100);
assert_eq!(MaxTemporarySlots::<T>::get(), 100);
@@ -66,7 +66,7 @@ pub mod v1 {
0,
1,
VersionUncheckedMigrateToV1<T>,
Pallet<T>,
Pezpallet<T>,
<T as pezframe_system::Config>::DbWeight,
>;
}
@@ -14,27 +14,27 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! This pallet allows to assign permanent (long-lived) or temporary
//! This pezpallet allows to assign permanent (long-lived) or temporary
//! (short-lived) teyrchain slots to paras, leveraging the existing
//! teyrchain slot lease mechanism. Temporary slots are given turns
//! in a fair (though best-effort) manner.
//! The dispatchables must be called from the configured origin
//! (typically `Sudo` or a governance origin).
//! This pallet should not be used on a production relay chain,
//! This pezpallet should not be used on a production relay chain,
//! only on a test relay chain (e.g. Pezkuwichain).
pub mod benchmarking;
pub mod migration;
use crate::{
slots::{self, Pallet as Slots, WeightInfo as SlotsWeightInfo},
slots::{self, Pezpallet as Slots, WeightInfo as SlotsWeightInfo},
traits::{LeaseError, Leaser, Registrar},
};
use alloc::vec::Vec;
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use pezframe_support::{pezpallet_prelude::*, traits::Currency};
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
pub use pezpallet::*;
use pezkuwi_primitives::Id as ParaId;
use pezkuwi_runtime_teyrchains::{
configuration,
@@ -105,19 +105,19 @@ type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Curre
>>::Balance;
type LeasePeriodOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::LeasePeriod;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pallet::disable_pezframe_system_supertrait_check]
#[pezpallet::config]
#[pezpallet::disable_pezframe_system_supertrait_check]
pub trait Config: configuration::Config + paras::Config + slots::Config {
/// The overarching event type.
#[allow(deprecated)]
@@ -134,32 +134,32 @@ pub mod pallet {
>;
/// The number of lease periods a permanent teyrchain slot lasts.
#[pallet::constant]
#[pezpallet::constant]
type PermanentSlotLeasePeriodLength: Get<u32>;
/// The number of lease periods a temporary teyrchain slot lasts.
#[pallet::constant]
#[pezpallet::constant]
type TemporarySlotLeasePeriodLength: Get<u32>;
/// The max number of temporary slots to be scheduled per lease periods.
#[pallet::constant]
#[pezpallet::constant]
type MaxTemporarySlotPerLeasePeriod: Get<u32>;
/// Weight Information for the Extrinsics in the Pallet
/// Weight Information for the Extrinsics in the Pezpallet
type WeightInfo: WeightInfo;
}
/// Assigned permanent slots, with their start lease period, and duration.
#[pallet::storage]
#[pezpallet::storage]
pub type PermanentSlots<T: Config> =
StorageMap<_, Twox64Concat, ParaId, (LeasePeriodOf<T>, LeasePeriodOf<T>), OptionQuery>;
/// Number of assigned (and active) permanent slots.
#[pallet::storage]
#[pezpallet::storage]
pub type PermanentSlotCount<T: Config> = StorageValue<_, u32, ValueQuery>;
/// Assigned temporary slots.
#[pallet::storage]
#[pezpallet::storage]
pub type TemporarySlots<T: Config> = StorageMap<
_,
Twox64Concat,
@@ -169,22 +169,22 @@ pub mod pallet {
>;
/// Number of assigned temporary slots.
#[pallet::storage]
#[pezpallet::storage]
pub type TemporarySlotCount<T: Config> = StorageValue<_, u32, ValueQuery>;
/// Number of active temporary slots in current slot lease period.
#[pallet::storage]
#[pezpallet::storage]
pub type ActiveTemporarySlotCount<T: Config> = StorageValue<_, u32, ValueQuery>;
/// The max number of temporary slots that can be assigned.
#[pallet::storage]
#[pezpallet::storage]
pub type MaxTemporarySlots<T: Config> = StorageValue<_, u32, ValueQuery>;
/// The max number of permanent slots that can be assigned.
#[pallet::storage]
#[pezpallet::storage]
pub type MaxPermanentSlots<T: Config> = StorageValue<_, u32, ValueQuery>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(pezframe_support::DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub max_temporary_slots: u32,
@@ -193,7 +193,7 @@ pub mod pallet {
pub _config: PhantomData<T>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
MaxPermanentSlots::<T>::put(&self.max_permanent_slots);
@@ -201,8 +201,8 @@ pub mod pallet {
}
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A teyrchain was assigned a permanent teyrchain slot
PermanentSlotAssigned(ParaId),
@@ -214,7 +214,7 @@ pub mod pallet {
MaxTemporarySlotsChanged { slots: u32 },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// The specified teyrchain is not registered.
ParaDoesntExist,
@@ -238,8 +238,8 @@ pub mod pallet {
MaxTemporarySlotsExceeded,
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
if let Some((lease_period, first_block)) = Self::lease_period_index(n) {
// If we're beginning a new lease period then handle that.
@@ -253,11 +253,11 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Assign a permanent teyrchain slot and immediately create a lease for it.
#[pallet::call_index(0)]
#[pallet::weight((<T as Config>::WeightInfo::assign_perm_teyrchain_slot(), DispatchClass::Operational))]
#[pezpallet::call_index(0)]
#[pezpallet::weight((<T as Config>::WeightInfo::assign_perm_teyrchain_slot(), DispatchClass::Operational))]
pub fn assign_perm_teyrchain_slot(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
T::AssignSlotOrigin::ensure_origin(origin)?;
@@ -314,8 +314,8 @@ pub mod pallet {
/// Assign a temporary teyrchain slot. The function tries to create a lease for it
/// immediately if `SlotLeasePeriodStart::Current` is specified, and if the number
/// of currently active temporary slots is below `MaxTemporarySlotPerLeasePeriod`.
#[pallet::call_index(1)]
#[pallet::weight((<T as Config>::WeightInfo::assign_temp_teyrchain_slot(), DispatchClass::Operational))]
#[pezpallet::call_index(1)]
#[pezpallet::weight((<T as Config>::WeightInfo::assign_temp_teyrchain_slot(), DispatchClass::Operational))]
pub fn assign_temp_teyrchain_slot(
origin: OriginFor<T>,
id: ParaId,
@@ -401,8 +401,8 @@ pub mod pallet {
}
/// Unassign a permanent or temporary teyrchain slot
#[pallet::call_index(2)]
#[pallet::weight((<T as Config>::WeightInfo::unassign_teyrchain_slot(), DispatchClass::Operational))]
#[pezpallet::call_index(2)]
#[pezpallet::weight((<T as Config>::WeightInfo::unassign_teyrchain_slot(), DispatchClass::Operational))]
pub fn unassign_teyrchain_slot(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
T::AssignSlotOrigin::ensure_origin(origin.clone())?;
@@ -435,7 +435,7 @@ pub mod pallet {
if let Err(err) = pezkuwi_runtime_teyrchains::schedule_teyrchain_downgrade::<T>(id)
{
// Treat failed downgrade as warning .. slot lease has been cleared,
// so the teyrchain will be downgraded anyway by the slots pallet
// so the teyrchain will be downgraded anyway by the slots pezpallet
// at the end of the lease period .
log::warn!(
target: LOG_TARGET,
@@ -451,8 +451,8 @@ pub mod pallet {
}
/// Sets the storage value [`MaxPermanentSlots`].
#[pallet::call_index(3)]
#[pallet::weight((<T as Config>::WeightInfo::set_max_permanent_slots(), DispatchClass::Operational))]
#[pezpallet::call_index(3)]
#[pezpallet::weight((<T as Config>::WeightInfo::set_max_permanent_slots(), DispatchClass::Operational))]
pub fn set_max_permanent_slots(origin: OriginFor<T>, slots: u32) -> DispatchResult {
ensure_root(origin)?;
@@ -463,8 +463,8 @@ pub mod pallet {
}
/// Sets the storage value [`MaxTemporarySlots`].
#[pallet::call_index(4)]
#[pallet::weight((<T as Config>::WeightInfo::set_max_temporary_slots(), DispatchClass::Operational))]
#[pezpallet::call_index(4)]
#[pezpallet::weight((<T as Config>::WeightInfo::set_max_temporary_slots(), DispatchClass::Operational))]
pub fn set_max_temporary_slots(origin: OriginFor<T>, slots: u32) -> DispatchResult {
ensure_root(origin)?;
@@ -476,7 +476,7 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// Allocate temporary slot leases up to `MaxTemporarySlotPerLeasePeriod` per lease period.
/// Beyond the already active temporary slot leases, this function will activate more leases
/// in the following order of preference:
@@ -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(pezframe_system::Pallet::<T>::block_number())
T::Leaser::lease_period_index(pezframe_system::Pezpallet::<T>::block_number())
.and_then(|x| Some(x.0))
.unwrap()
}
@@ -615,7 +615,7 @@ impl<T: Config> Pallet<T> {
/// Handles start of a lease period.
fn manage_lease_period_start(lease_period_index: LeasePeriodOf<T>) -> Weight {
// Note: leases that have ended in previous lease period, should have been cleaned in slots
// pallet.
// pezpallet.
if let Err(err) = Self::allocate_temporary_slot_leases(lease_period_index) {
log::error!(
target: LOG_TARGET,
@@ -629,7 +629,7 @@ impl<T: Config> Pallet<T> {
}
}
/// tests for this pallet
/// tests for this pezpallet
#[cfg(test)]
mod tests {
use super::*;
@@ -14,10 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Benchmarking for auctions pallet
//! Benchmarking for auctions pezpallet
#![cfg(feature = "runtime-benchmarks")]
use super::{Pallet as Auctions, *};
use super::{Pezpallet as Auctions, *};
use pezframe_support::{
assert_ok,
traits::{EnsureOrigin, OnInitialize},
@@ -29,7 +29,7 @@ use pezsp_runtime::{traits::Bounded, SaturatedConversion};
use pezframe_benchmarking::v2::*;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = pezframe_system::Pallet::<T>::events();
let events = pezframe_system::Pezpallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
@@ -54,7 +54,7 @@ fn fill_winners<T: Config + paras::Config>(lease_period_index: LeasePeriodOf<T>)
)
.is_ok());
}
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
assert_ok!(paras::Pezpallet::<T>::add_trusted_validation_code(
pezframe_system::Origin::<T>::Root.into(),
T::Registrar::worst_validation_code(),
));
@@ -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();
pezframe_system::Pallet::<T>::set_block_number(offset + One::one());
pezframe_system::Pezpallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration = BlockNumberFor::<T>::max_value();
@@ -137,7 +137,7 @@ mod benchmarks {
worst_validation_code.clone(),
)?;
T::Registrar::register(owner, new_para, worst_head_data, worst_validation_code.clone())?;
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
assert_ok!(paras::Pezpallet::<T>::add_trusted_validation_code(
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();
pezframe_system::Pallet::<T>::set_block_number(offset + One::one());
pezframe_system::Pezpallet::<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 = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<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
pezframe_system::Pallet::<T>::set_block_number(duration + now + T::EndingPeriod::get());
pezframe_system::Pezpallet::<T>::set_block_number(duration + now + T::EndingPeriod::get());
// Trigger epoch change for new random number value:
{
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();
pezpallet_babe::Pezpallet::<T>::on_initialize(duration + now + T::EndingPeriod::get());
let authorities = pezpallet_babe::Pezpallet::<T>::authorities();
// Check for non empty authority set since it otherwise emits a No-OP warning.
if !authorities.is_empty() {
pezpallet_babe::Pallet::<T>::enact_epoch_change(
pezpallet_babe::Pezpallet::<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();
pezframe_system::Pallet::<T>::set_block_number(offset + One::one());
pezframe_system::Pezpallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration: BlockNumberFor<T> = lease_length / 2u32.into();
+2 -2
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Mocking utilities for testing in auctions pallet.
//! Mocking utilities for testing in auctions pezpallet.
#[cfg(test)]
use super::*;
@@ -182,7 +182,7 @@ impl Randomness<H256, BlockNumber> for TestPastRandomness {
if let Some((output, known_since)) = &*p.borrow() {
(*output, *known_since)
} else {
(H256::zero(), pezframe_system::Pallet::<Test>::block_number())
(H256::zero(), pezframe_system::Pezpallet::<Test>::block_number())
}
})
}
+42 -42
View File
@@ -32,7 +32,7 @@ use pezframe_support::{
weights::Weight,
};
use pezframe_system::pezpallet_prelude::BlockNumberFor;
pub use pallet::*;
pub use pezpallet::*;
use pezkuwi_primitives::Id as ParaId;
use pezsp_runtime::traits::{CheckedSub, One, Saturating, Zero};
@@ -77,17 +77,17 @@ type WinningData<T> = [Option<(<T as pezframe_system::Config>::AccountId, ParaId
type WinnersData<T> =
Vec<(<T as pezframe_system::Config>::AccountId, ParaId, BalanceOf<T>, SlotRange)>;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::{dispatch::DispatchClass, pezpallet_prelude::*, traits::EnsureOrigin};
use pezframe_system::{ensure_root, ensure_signed, pezpallet_prelude::*};
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
/// The module's configuration trait.
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
@@ -104,13 +104,13 @@ pub mod pallet {
type Registrar: Registrar<AccountId = Self::AccountId>;
/// The number of blocks over which an auction may be retroactively ended.
#[pallet::constant]
#[pezpallet::constant]
type EndingPeriod: Get<BlockNumberFor<Self>>;
/// The length of each sample to take during the ending period.
///
/// `EndingPeriod` / `SampleLength` = Total # of Samples
#[pallet::constant]
#[pezpallet::constant]
type SampleLength: Get<BlockNumberFor<Self>>;
/// Something that provides randomness in the runtime.
@@ -119,12 +119,12 @@ pub mod pallet {
/// The origin which may initiate auctions.
type InitiateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// Weight Information for the Extrinsics in the Pallet
/// Weight Information for the Extrinsics in the Pezpallet
type WeightInfo: WeightInfo;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// An auction started. Provides its index and the block number where it will begin to
/// close and the first lease period of the quadruplet that is auctioned.
@@ -156,7 +156,7 @@ pub mod pallet {
WinningOffset { auction_index: AuctionIndex, block_number: BlockNumberFor<T> },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// This auction is already in progress.
AuctionInProgress,
@@ -175,7 +175,7 @@ pub mod pallet {
}
/// Number of auctions started so far.
#[pallet::storage]
#[pezpallet::storage]
pub type AuctionCounter<T> = StorageValue<_, AuctionIndex, ValueQuery>;
/// Information relating to the current auction, if there is one.
@@ -183,36 +183,36 @@ pub mod pallet {
/// The first item in the tuple is the lease period index that the first of the four
/// contiguous lease periods on auction is for. The second is the block number when the
/// auction will "begin to end", i.e. the first block of the Ending Period of the auction.
#[pallet::storage]
#[pezpallet::storage]
pub type AuctionInfo<T: Config> = StorageValue<_, (LeasePeriodOf<T>, BlockNumberFor<T>)>;
/// Amounts currently reserved in the accounts of the bidders currently winning
/// (sub-)ranges.
#[pallet::storage]
#[pezpallet::storage]
pub type ReservedAmounts<T: Config> =
StorageMap<_, Twox64Concat, (T::AccountId, ParaId), BalanceOf<T>>;
/// The winning bids for each of the 10 ranges at each sample in the final Ending Period of
/// the current auction. The map's key is the 0-based index into the Sample Size. The
/// first sample of the ending period is 0; the last is `Sample Size - 1`.
#[pallet::storage]
#[pezpallet::storage]
pub type Winning<T: Config> = StorageMap<_, Twox64Concat, BlockNumberFor<T>, WinningData<T>>;
#[pallet::extra_constants]
impl<T: Config> Pallet<T> {
#[pallet::constant_name(SlotRangeCount)]
#[pezpallet::extra_constants]
impl<T: Config> Pezpallet<T> {
#[pezpallet::constant_name(SlotRangeCount)]
fn slot_range_count() -> u32 {
SlotRange::SLOT_RANGE_COUNT as u32
}
#[pallet::constant_name(LeasePeriodsPerSlot)]
#[pezpallet::constant_name(LeasePeriodsPerSlot)]
fn lease_periods_per_slot() -> u32 {
SlotRange::LEASE_PERIODS_PER_SLOT as u32
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
let mut weight = T::DbWeight::get().reads(1);
@@ -243,19 +243,19 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Create a new auction.
///
/// This can only happen when there isn't already an auction in progress and may only be
/// called by the root origin. Accepts the `duration` of this auction and the
/// `lease_period_index` of the initial lease period of the four that are to be auctioned.
#[pallet::call_index(0)]
#[pallet::weight((T::WeightInfo::new_auction(), DispatchClass::Operational))]
#[pezpallet::call_index(0)]
#[pezpallet::weight((T::WeightInfo::new_auction(), DispatchClass::Operational))]
pub fn new_auction(
origin: OriginFor<T>,
#[pallet::compact] duration: BlockNumberFor<T>,
#[pallet::compact] lease_period_index: LeasePeriodOf<T>,
#[pezpallet::compact] duration: BlockNumberFor<T>,
#[pezpallet::compact] lease_period_index: LeasePeriodOf<T>,
) -> DispatchResult {
T::InitiateOrigin::ensure_origin(origin)?;
Self::do_new_auction(duration, lease_period_index)
@@ -277,15 +277,15 @@ pub mod pallet {
/// absolute lease period index value, not an auction-specific offset.
/// - `amount` is the amount to bid to be held as deposit for the teyrchain should the
/// bid win. This amount is held throughout the range.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::bid())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::bid())]
pub fn bid(
origin: OriginFor<T>,
#[pallet::compact] para: ParaId,
#[pallet::compact] auction_index: AuctionIndex,
#[pallet::compact] first_slot: LeasePeriodOf<T>,
#[pallet::compact] last_slot: LeasePeriodOf<T>,
#[pallet::compact] amount: BalanceOf<T>,
#[pezpallet::compact] para: ParaId,
#[pezpallet::compact] auction_index: AuctionIndex,
#[pezpallet::compact] first_slot: LeasePeriodOf<T>,
#[pezpallet::compact] last_slot: LeasePeriodOf<T>,
#[pezpallet::compact] amount: BalanceOf<T>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::handle_bid(who, para, auction_index, first_slot, last_slot, amount)?;
@@ -295,8 +295,8 @@ pub mod pallet {
/// Cancel an in-progress auction.
///
/// Can only be called by Root origin.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::cancel_auction())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::cancel_auction())]
pub fn cancel_auction(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
// Unreserve all bids.
@@ -311,7 +311,7 @@ pub mod pallet {
}
}
impl<T: Config> Auctioneer<BlockNumberFor<T>> for Pallet<T> {
impl<T: Config> Auctioneer<BlockNumberFor<T>> for Pezpallet<T> {
type AccountId = T::AccountId;
type LeasePeriod = BlockNumberFor<T>;
type Currency = CurrencyOf<T>;
@@ -371,7 +371,7 @@ impl<T: Config> Auctioneer<BlockNumberFor<T>> for Pallet<T> {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
// A trick to allow me to initialize large arrays with nothing in them.
const EMPTY: Option<(<T as pezframe_system::Config>::AccountId, ParaId, BalanceOf<T>)> = None;
@@ -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 = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<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 = pezframe_system::Pallet::<T>::block_number().saturating_add(duration);
let ending = pezframe_system::Pezpallet::<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(pezframe_system::Pallet::<T>::block_number());
let auction_status = Self::auction_status(pezframe_system::Pezpallet::<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()),
+1 -1
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Tests for the auctions pallet.
//! Tests for the auctions pezpallet.
#[cfg(test)]
use super::*;
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Benchmarking for claims pallet
//! Benchmarking for claims pezpallet
#[cfg(feature = "runtime-benchmarks")]
use super::*;
@@ -40,7 +40,7 @@ fn create_claim<T: Config>(input: u32) -> DispatchResult {
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&input.encode())).unwrap();
let eth_address = eth(&secret_key);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
super::Pallet::<T>::mint_claim(
super::Pezpallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
@@ -54,7 +54,7 @@ fn create_claim_attest<T: Config>(input: u32) -> DispatchResult {
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&input.encode())).unwrap();
let eth_address = eth(&secret_key);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
super::Pallet::<T>::mint_claim(
super::Pezpallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
@@ -87,7 +87,7 @@ mod benchmarks {
let account: T::AccountId = account("user", c, SEED);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
let signature = sig::<T>(&secret_key, &account.encode(), &[][..]);
super::Pallet::<T>::mint_claim(
super::Pezpallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
@@ -104,7 +104,7 @@ mod benchmarks {
{
let call = <Call<T> as Decode>::decode(&mut &*call_enc)
.expect("call is encoded above, encoding must be correct");
super::Pallet::<T>::validate_unsigned(source, &call)
super::Pezpallet::<T>::validate_unsigned(source, &call)
.map_err(|e| -> &'static str { e.into() })?;
call.dispatch_bypass_filter(RawOrigin::None.into())?;
}
@@ -148,7 +148,7 @@ mod benchmarks {
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
let statement = StatementKind::Regular;
let signature = sig::<T>(&secret_key, &account.encode(), statement.to_text());
super::Pallet::<T>::mint_claim(
super::Pezpallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
@@ -168,7 +168,7 @@ mod benchmarks {
{
let call = <Call<T> as Decode>::decode(&mut &*call_enc)
.expect("call is encoded above, encoding must be correct");
super::Pallet::<T>::validate_unsigned(source, &call)
super::Pezpallet::<T>::validate_unsigned(source, &call)
.map_err(|e| -> &'static str { e.into() })?;
call.dispatch_bypass_filter(RawOrigin::None.into())?;
}
@@ -191,7 +191,7 @@ mod benchmarks {
let account: T::AccountId = account("user", c, SEED);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
let statement = StatementKind::Regular;
super::Pallet::<T>::mint_claim(
super::Pezpallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
@@ -265,7 +265,7 @@ mod benchmarks {
#[block]
{
for _ in 0..i {
assert!(super::Pallet::<T>::eth_recover(&signature, &data, extra).is_some());
assert!(super::Pezpallet::<T>::eth_recover(&signature, &data, extra).is_some());
}
}
}
@@ -287,7 +287,7 @@ mod benchmarks {
let account: T::AccountId = account("user", c, SEED);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
let statement = StatementKind::Regular;
super::Pallet::<T>::mint_claim(
super::Pezpallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
@@ -311,7 +311,7 @@ mod benchmarks {
}
impl_benchmark_test_suite!(
Pallet,
Pezpallet,
crate::claims::mock::new_test_ext(),
crate::claims::mock::Test,
);
+1 -1
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Mocking utilities for testing in claims pallet.
//! Mocking utilities for testing in claims pezpallet.
#[cfg(test)]
use super::*;
+36 -36
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Pallet to process claims from Ethereum addresses.
//! Pezpallet to process claims from Ethereum addresses.
#[cfg(not(feature = "std"))]
use alloc::{format, string::String};
@@ -27,7 +27,7 @@ use pezframe_support::{
weights::Weight,
DefaultNoBound,
};
pub use pallet::*;
pub use pezpallet::*;
use pezkuwi_primitives::ValidityError;
use scale_info::TypeInfo;
use serde::{self, Deserialize, Deserializer, Serialize, Serializer};
@@ -195,36 +195,36 @@ impl core::fmt::Debug for EcdsaSignature {
}
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
/// Configuration trait.
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = BlockNumberFor<Self>>;
#[pallet::constant]
#[pezpallet::constant]
type Prefix: Get<&'static [u8]>;
type MoveClaimOrigin: EnsureOrigin<Self::RuntimeOrigin>;
type WeightInfo: WeightInfo;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Someone claimed some DOTs.
Claimed { who: T::AccountId, ethereum_address: EthereumAddress, amount: BalanceOf<T> },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Invalid Ethereum signature.
InvalidEthereumSignature,
@@ -241,29 +241,29 @@ pub mod pallet {
VestedBalanceExists,
}
#[pallet::storage]
#[pezpallet::storage]
pub type Claims<T: Config> = StorageMap<_, Identity, EthereumAddress, BalanceOf<T>>;
#[pallet::storage]
#[pezpallet::storage]
pub type Total<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
/// Vesting schedule for a claim.
/// First balance is the total amount that should be held for vesting.
/// Second balance is how much should be unlocked per block.
/// The block number is when the vesting should start.
#[pallet::storage]
#[pezpallet::storage]
pub type Vesting<T: Config> =
StorageMap<_, Identity, EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>;
/// The statement kind that must be signed, if any.
#[pallet::storage]
#[pezpallet::storage]
pub type Signing<T> = StorageMap<_, Identity, EthereumAddress, StatementKind>;
/// Pre-claimed Ethereum accounts, by the Account ID that they are claimed to.
#[pallet::storage]
#[pezpallet::storage]
pub type Preclaims<T: Config> = StorageMap<_, Identity, T::AccountId, EthereumAddress>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub claims:
@@ -271,7 +271,7 @@ pub mod pallet {
pub vesting: Vec<(EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>))>,
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
// build `Claims`
@@ -304,11 +304,11 @@ pub mod pallet {
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Make a claim to collect your DOTs.
///
/// The dispatch origin for this call must be _None_.
@@ -333,8 +333,8 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::claim())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::claim())]
pub fn claim(
origin: OriginFor<T>,
dest: T::AccountId,
@@ -366,8 +366,8 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::mint_claim())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::mint_claim())]
pub fn mint_claim(
origin: OriginFor<T>,
who: EthereumAddress,
@@ -415,8 +415,8 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::claim_attest())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::claim_attest())]
pub fn claim_attest(
origin: OriginFor<T>,
dest: T::AccountId,
@@ -454,8 +454,8 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(3)]
#[pallet::weight((
#[pezpallet::call_index(3)]
#[pezpallet::weight((
T::WeightInfo::attest(),
DispatchClass::Normal,
Pays::No
@@ -471,8 +471,8 @@ pub mod pallet {
Ok(())
}
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::move_claim())]
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::WeightInfo::move_claim())]
pub fn move_claim(
origin: OriginFor<T>,
old: EthereumAddress,
@@ -495,8 +495,8 @@ pub mod pallet {
}
}
#[pallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pallet<T> {
#[pezpallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pezpallet<T> {
type Call = Call<T>;
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
@@ -558,7 +558,7 @@ fn to_ascii_hex(data: &[u8]) -> Vec<u8> {
r
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
// Constructs the message that Ethereum RPC's `personal_sign` and `eth_sign` would sign.
fn ethereum_signable_message(what: &[u8], extra: &[u8]) -> Vec<u8> {
let prefix = T::Prefix::get();
@@ -719,7 +719,7 @@ mod secp_utils {
what: &[u8],
extra: &[u8],
) -> EcdsaSignature {
let msg = keccak_256(&super::Pallet::<T>::ethereum_signable_message(
let msg = keccak_256(&super::Pezpallet::<T>::ethereum_signable_message(
&to_ascii_hex(what)[..],
extra,
));
+9 -9
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Tests for the claims pallet.
//! Tests for the claims pezpallet.
#[cfg(test)]
use super::*;
@@ -570,7 +570,7 @@ fn validate_unsigned_works() {
new_test_ext().execute_with(|| {
assert_eq!(
Pallet::<Test>::validate_unsigned(
Pezpallet::<Test>::validate_unsigned(
source,
&ClaimsCall::claim {
dest: 1,
@@ -586,14 +586,14 @@ fn validate_unsigned_works() {
})
);
assert_eq!(
Pallet::<Test>::validate_unsigned(
Pezpallet::<Test>::validate_unsigned(
source,
&ClaimsCall::claim { dest: 0, ethereum_signature: EcdsaSignature([0; 65]) }
),
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
);
assert_eq!(
Pallet::<Test>::validate_unsigned(
Pezpallet::<Test>::validate_unsigned(
source,
&ClaimsCall::claim {
dest: 1,
@@ -609,7 +609,7 @@ fn validate_unsigned_works() {
statement: StatementKind::Regular.to_text().to_vec(),
};
assert_eq!(
Pallet::<Test>::validate_unsigned(source, &call),
Pezpallet::<Test>::validate_unsigned(source, &call),
Ok(ValidTransaction {
priority: 100,
requires: vec![],
@@ -619,7 +619,7 @@ fn validate_unsigned_works() {
})
);
assert_eq!(
Pallet::<Test>::validate_unsigned(
Pezpallet::<Test>::validate_unsigned(
source,
&ClaimsCall::claim_attest {
dest: 1,
@@ -637,7 +637,7 @@ fn validate_unsigned_works() {
statement: StatementKind::Regular.to_text().to_vec(),
};
assert_eq!(
Pallet::<Test>::validate_unsigned(source, &call),
Pezpallet::<Test>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
@@ -648,7 +648,7 @@ fn validate_unsigned_works() {
statement: StatementKind::Regular.to_text().to_vec(),
};
assert_eq!(
Pallet::<Test>::validate_unsigned(source, &call),
Pezpallet::<Test>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
@@ -659,7 +659,7 @@ fn validate_unsigned_works() {
statement: StatementKind::Saft.to_text().to_vec(),
};
assert_eq!(
Pallet::<Test>::validate_unsigned(source, &call),
Pezpallet::<Test>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::InvalidStatement.into()).into(),
);
});
@@ -24,18 +24,18 @@ use pezframe_support::{
pub struct MigrateToTrackInactiveV2<T>(core::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactiveV2<T> {
fn on_runtime_upgrade() -> Weight {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
let on_chain_version = Pezpallet::<T>::on_chain_storage_version();
if on_chain_version == 1 {
let mut translated = 0u64;
for item in Funds::<T>::iter_values() {
let b =
CurrencyOf::<T>::total_balance(&Pallet::<T>::fund_account_id(item.fund_index));
CurrencyOf::<T>::total_balance(&Pezpallet::<T>::fund_account_id(item.fund_index));
CurrencyOf::<T>::deactivate(b);
translated.saturating_inc();
}
StorageVersion::new(2).put::<Pallet<T>>();
StorageVersion::new(2).put::<Pezpallet<T>>();
log::info!(target: "runtime::crowdloan", "Summed {} funds, storage to version 1", translated);
T::DbWeight::get().reads_writes(translated * 2 + 1, translated * 2 + 1)
} else {
@@ -48,7 +48,7 @@ impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactiveV2<T> {
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))
CurrencyOf::<T>::total_balance(&Pezpallet::<T>::fund_account_id(item.fund_index))
})
.fold(BalanceOf::<T>::zero(), |a, i| a.saturating_add(i));
Ok((total, CurrencyOf::<T>::active_issuance()).encode())
@@ -70,7 +70,7 @@ pub mod crowdloan_index_migration {
use super::*;
#[storage_alias]
type NextTrieIndex<T: Config> = StorageValue<Pallet<T>, FundIndex>;
type NextTrieIndex<T: Config> = StorageValue<Pezpallet<T>, FundIndex>;
#[storage_alias]
type Leases<T: Config> = StorageMap<
@@ -148,7 +148,7 @@ pub mod crowdloan_index_migration {
// Migrate all accounts from `old_fund_account` to `fund_account` using `fund_index`.
for (para_id, fund) in Funds::<T>::iter() {
let old_fund_account = old_fund_account_id::<T>(para_id);
let new_fund_account = Pallet::<T>::fund_account_id(fund.fund_index);
let new_fund_account = Pezpallet::<T>::fund_account_id(fund.fund_index);
// 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.
@@ -196,7 +196,7 @@ pub mod crowdloan_index_migration {
);
// New fund account has the correct balance.
let new_fund_account = Pallet::<T>::fund_account_id(fund.fund_index);
let new_fund_account = Pezpallet::<T>::fund_account_id(fund.fund_index);
let total_balance = CurrencyOf::<T>::total_balance(&new_fund_account);
ensure!(
+86 -86
View File
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! # Teyrchain `Crowdloaning` pallet
//! # Teyrchain `Crowdloaning` pezpallet
//!
//! The point of this pallet is to allow teyrchain projects to offer the ability to help fund a
//! The point of this pezpallet is to allow teyrchain projects to offer the ability to help fund a
//! deposit for the teyrchain. When the crowdloan has ended, the funds are returned.
//!
//! Each fund has a child-trie which stores all contributors account IDs together with the amount
@@ -69,7 +69,7 @@ use pezframe_support::{
Identity, PalletId,
};
use pezframe_system::pezpallet_prelude::BlockNumberFor;
pub use pallet::*;
pub use pezpallet::*;
use pezkuwi_primitives::Id as ParaId;
use scale_info::TypeInfo;
use pezsp_runtime::{
@@ -170,8 +170,8 @@ pub struct FundInfo<AccountId, Balance, BlockNumber, LeasePeriod> {
pub fund_index: FundIndex,
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::{ensure_root, ensure_signed, pezpallet_prelude::*};
@@ -179,19 +179,19 @@ pub mod pallet {
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
#[pallet::pallet]
#[pallet::without_storage_info]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::without_storage_info]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// `PalletId` for the crowdloan pallet. An appropriate value could be
/// `PalletId` for the crowdloan pezpallet. An appropriate value could be
/// `PalletId(*b"py/cfund")`
#[pallet::constant]
#[pezpallet::constant]
type PalletId: Get<PalletId>;
/// The amount to be held on deposit by the depositor of a crowdloan.
@@ -199,11 +199,11 @@ pub mod pallet {
/// The minimum amount that may be contributed into a crowdloan. Should almost certainly be
/// at least `ExistentialDeposit`.
#[pallet::constant]
#[pezpallet::constant]
type MinContribution: Get<BalanceOf<Self>>;
/// Max number of storage keys to remove per extrinsic call.
#[pallet::constant]
#[pezpallet::constant]
type RemoveKeysLimit: Get<u32>;
/// The teyrchain registrar type. We just use this to ensure that only the manager of a para
@@ -220,12 +220,12 @@ pub mod pallet {
/// The maximum length for the memo attached to a crowdloan contribution.
type MaxMemoLength: Get<u8>;
/// Weight Information for the Extrinsics in the Pallet
/// Weight Information for the Extrinsics in the Pezpallet
type WeightInfo: WeightInfo;
}
/// Info on all of the funds.
#[pallet::storage]
#[pezpallet::storage]
pub type Funds<T: Config> = StorageMap<
_,
Twox64Concat,
@@ -235,19 +235,19 @@ pub mod pallet {
/// The funds that have had additional contributions during the last block. This is used
/// in order to determine which funds should submit new or updated bids.
#[pallet::storage]
#[pezpallet::storage]
pub type NewRaise<T> = StorageValue<_, Vec<ParaId>, ValueQuery>;
/// The number of auctions that have entered into their ending period so far.
#[pallet::storage]
#[pezpallet::storage]
pub type EndingsCount<T> = StorageValue<_, u32, ValueQuery>;
/// Tracker for the next available fund index
#[pallet::storage]
#[pezpallet::storage]
pub type NextFundIndex<T> = StorageValue<_, u32, ValueQuery>;
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Create a new crowdloaning campaign.
Created { para_id: ParaId },
@@ -262,7 +262,7 @@ pub mod pallet {
AllRefunded { para_id: ParaId },
/// Fund is dissolved.
Dissolved { para_id: ParaId },
/// The result of trying to submit a new bid to the Slots pallet.
/// The result of trying to submit a new bid to the Slots pezpallet.
HandleBidResult { para_id: ParaId, result: DispatchResult },
/// The configuration to a crowdloan has been edited.
Edited { para_id: ParaId },
@@ -272,7 +272,7 @@ pub mod pallet {
AddedToNewRaise { para_id: ParaId },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// The current lease period is more than the first lease period.
FirstPeriodInPast,
@@ -323,8 +323,8 @@ pub mod pallet {
NoLeasePeriod,
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
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
@@ -357,26 +357,26 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Create a new crowdloaning campaign for a teyrchain slot with the given lease period
/// range.
///
/// This applies a lock to your teyrchain configuration, ensuring that it cannot be changed
/// by the teyrchain manager.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::create())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::create())]
pub fn create(
origin: OriginFor<T>,
#[pallet::compact] index: ParaId,
#[pallet::compact] cap: BalanceOf<T>,
#[pallet::compact] first_period: LeasePeriodOf<T>,
#[pallet::compact] last_period: LeasePeriodOf<T>,
#[pallet::compact] end: BlockNumberFor<T>,
#[pezpallet::compact] index: ParaId,
#[pezpallet::compact] cap: BalanceOf<T>,
#[pezpallet::compact] first_period: LeasePeriodOf<T>,
#[pezpallet::compact] last_period: LeasePeriodOf<T>,
#[pezpallet::compact] end: BlockNumberFor<T>,
verifier: Option<MultiSigner>,
) -> DispatchResult {
let depositor = ensure_signed(origin)?;
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<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();
pezframe_system::Pallet::<T>::inc_providers(&Self::fund_account_id(fund_index));
pezframe_system::Pezpallet::<T>::inc_providers(&Self::fund_account_id(fund_index));
CurrencyOf::<T>::reserve(&depositor, deposit)?;
Funds::<T>::insert(
@@ -441,12 +441,12 @@ pub mod pallet {
/// Contribute to a crowd sale. This will transfer some balance over to fund a teyrchain
/// slot. It will be withdrawable when the crowdloan has ended and the funds are unused.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::contribute())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::contribute())]
pub fn contribute(
origin: OriginFor<T>,
#[pallet::compact] index: ParaId,
#[pallet::compact] value: BalanceOf<T>,
#[pezpallet::compact] index: ParaId,
#[pezpallet::compact] value: BalanceOf<T>,
signature: Option<MultiSignature>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -470,17 +470,17 @@ pub mod pallet {
///
/// - `who`: The account whose contribution should be withdrawn.
/// - `index`: The teyrchain to whose crowdloan the contribution was made.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::withdraw())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::withdraw())]
pub fn withdraw(
origin: OriginFor<T>,
who: T::AccountId,
#[pallet::compact] index: ParaId,
#[pezpallet::compact] index: ParaId,
) -> DispatchResult {
ensure_signed(origin)?;
let mut fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
let fund_account = Self::fund_account_id(fund.fund_index);
Self::ensure_crowdloan_ended(now, &fund_account, &fund)?;
@@ -504,16 +504,16 @@ pub mod pallet {
/// times to fully refund all users. We will refund `RemoveKeysLimit` users at a time.
///
/// Origin must be signed, but can come from anyone.
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::refund(T::RemoveKeysLimit::get()))]
#[pezpallet::call_index(3)]
#[pezpallet::weight(T::WeightInfo::refund(T::RemoveKeysLimit::get()))]
pub fn refund(
origin: OriginFor<T>,
#[pallet::compact] index: ParaId,
#[pezpallet::compact] index: ParaId,
) -> DispatchResultWithPostInfo {
ensure_signed(origin)?;
let mut fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
let fund_account = Self::fund_account_id(fund.fund_index);
Self::ensure_crowdloan_ended(now, &fund_account, &fund)?;
@@ -550,14 +550,14 @@ pub mod pallet {
}
/// Remove a fund after the retirement period has ended and all funds have been returned.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::dissolve())]
pub fn dissolve(origin: OriginFor<T>, #[pallet::compact] index: ParaId) -> DispatchResult {
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::WeightInfo::dissolve())]
pub fn dissolve(origin: OriginFor<T>, #[pezpallet::compact] index: ParaId) -> DispatchResult {
let who = ensure_signed(origin)?;
let fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
let pot = Self::fund_account_id(fund.fund_index);
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<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 _ = pezframe_system::Pallet::<T>::dec_providers(&pot).defensive();
let _ = pezframe_system::Pezpallet::<T>::dec_providers(&pot).defensive();
CurrencyOf::<T>::unreserve(&fund.depositor, fund.deposit);
Funds::<T>::remove(index);
@@ -583,15 +583,15 @@ pub mod pallet {
/// Edit the configuration for an in-progress crowdloan.
///
/// Can only be called by Root origin.
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::edit())]
#[pezpallet::call_index(5)]
#[pezpallet::weight(T::WeightInfo::edit())]
pub fn edit(
origin: OriginFor<T>,
#[pallet::compact] index: ParaId,
#[pallet::compact] cap: BalanceOf<T>,
#[pallet::compact] first_period: LeasePeriodOf<T>,
#[pallet::compact] last_period: LeasePeriodOf<T>,
#[pallet::compact] end: BlockNumberFor<T>,
#[pezpallet::compact] index: ParaId,
#[pezpallet::compact] cap: BalanceOf<T>,
#[pezpallet::compact] first_period: LeasePeriodOf<T>,
#[pezpallet::compact] last_period: LeasePeriodOf<T>,
#[pezpallet::compact] end: BlockNumberFor<T>,
verifier: Option<MultiSigner>,
) -> DispatchResult {
ensure_root(origin)?;
@@ -621,8 +621,8 @@ pub mod pallet {
/// Add an optional memo to an existing crowdloan contribution.
///
/// Origin must be Signed, and the user must have contributed to the crowdloan.
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::add_memo())]
#[pezpallet::call_index(6)]
#[pezpallet::weight(T::WeightInfo::add_memo())]
pub fn add_memo(origin: OriginFor<T>, index: ParaId, memo: Vec<u8>) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -640,8 +640,8 @@ pub mod pallet {
/// Poke the fund into `NewRaise`
///
/// Origin must be Signed, and the fund has non-zero raise.
#[pallet::call_index(7)]
#[pallet::weight(T::WeightInfo::poke())]
#[pezpallet::call_index(7)]
#[pezpallet::weight(T::WeightInfo::poke())]
pub fn poke(origin: OriginFor<T>, index: ParaId) -> DispatchResult {
ensure_signed(origin)?;
let fund = Funds::<T>::get(index).ok_or(Error::<T>::InvalidParaId)?;
@@ -655,11 +655,11 @@ pub mod pallet {
/// Contribute your entire balance to a crowd sale. This will transfer the entire balance of
/// a user over to fund a teyrchain slot. It will be withdrawable when the crowdloan has
/// ended and the funds are unused.
#[pallet::call_index(8)]
#[pallet::weight(T::WeightInfo::contribute())]
#[pezpallet::call_index(8)]
#[pezpallet::weight(T::WeightInfo::contribute())]
pub fn contribute_all(
origin: OriginFor<T>,
#[pallet::compact] index: ParaId,
#[pezpallet::compact] index: ParaId,
signature: Option<MultiSignature>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -669,7 +669,7 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// The account ID of the fund pot.
///
/// This actually does computation. If you need to keep using it, then make sure you cache the
@@ -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 = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
ensure!(now < fund.end, Error::<T>::ContributionPeriodOver);
// Make sure crowdloan is in a valid lease period
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<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);
@@ -831,7 +831,7 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> crate::traits::OnSwap for Pallet<T> {
impl<T: Config> crate::traits::OnSwap for Pezpallet<T> {
fn on_swap(one: ParaId, other: ParaId) {
Funds::<T>::mutate(one, |x| Funds::<T>::mutate(other, |y| core::mem::swap(x, y)))
}
@@ -1425,7 +1425,7 @@ mod tests {
let para_2 = new_para();
let index = NextFundIndex::<Test>::get();
assert_ok!(Crowdloan::create(RuntimeOrigin::signed(1), para_2, 1000, 1, 4, 40, None));
// Emulate a win by leasing out and putting a deposit. Slots pallet would normally do
// Emulate a win by leasing out and putting a deposit. Slots pezpallet would normally do
// this.
let crowdloan_account = Crowdloan::fund_account_id(index);
set_winner(para_2, crowdloan_account, true);
@@ -1799,7 +1799,7 @@ mod tests {
// Fund crowdloans.
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
// simulate the reserving of para's funds. this actually happens in the Slots pallet.
// simulate the reserving of para's funds. this actually happens in the Slots pezpallet.
assert_ok!(Balances::reserve(&account_id, 149));
System::run_to_block::<AllPalletsWithSystem>(19);
@@ -1810,7 +1810,7 @@ mod tests {
System::run_to_block::<AllPalletsWithSystem>(20);
// simulate the unreserving of para's funds, now that the lease expired. this actually
// happens in the Slots pallet.
// happens in the Slots pezpallet.
Balances::unreserve(&account_id, 150);
// para has no reserved funds, indicating it did ot win the auction.
@@ -1949,7 +1949,7 @@ mod tests {
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking {
use super::{Pallet as Crowdloan, *};
use super::{Pezpallet as Crowdloan, *};
use pezframe_support::{assert_ok, traits::OnInitialize};
use pezframe_system::RawOrigin;
use pezkuwi_runtime_teyrchains::paras;
@@ -1959,7 +1959,7 @@ mod benchmarking {
use pezframe_benchmarking::v2::*;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = pezframe_system::Pallet::<T>::events();
let events = pezframe_system::Pezpallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
@@ -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.
pezframe_system::Pallet::<T>::set_block_number(offset);
let now = pezframe_system::Pallet::<T>::block_number();
pezframe_system::Pezpallet::<T>::set_block_number(offset);
let now = pezframe_system::Pezpallet::<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 =
@@ -1992,7 +1992,7 @@ mod benchmarking {
head_data,
validation_code.clone()
));
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
assert_ok!(paras::Pezpallet::<T>::add_trusted_validation_code(
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
@@ -2050,7 +2050,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(
assert_ok!(paras::Pezpallet::<T>::add_trusted_validation_code(
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);
pezframe_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
pezframe_system::Pezpallet::<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();
pezframe_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
pezframe_system::Pezpallet::<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();
pezframe_system::Pallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
pezframe_system::Pezpallet::<T>::set_block_number(BlockNumberFor::<T>::max_value());
#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), fund_index);
@@ -2175,7 +2175,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(
assert_ok!(paras::Pezpallet::<T>::add_trusted_validation_code(
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
@@ -2262,11 +2262,11 @@ mod benchmarking {
)?;
}
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
let (lease_period_index, _) =
T::Auctioneer::lease_period_index(now).unwrap_or_default();
let duration = end_block
.checked_sub(&pezframe_system::Pallet::<T>::block_number())
.checked_sub(&pezframe_system::Pezpallet::<T>::block_number())
.ok_or("duration of auction less than zero")?;
T::Auctioneer::new_auction(duration, lease_period_index)?;
+2 -2
View File
@@ -45,9 +45,9 @@ macro_rules! impl_elections_weights {
};
}
/// The numbers configured here could always be more than the the maximum limits of staking pallet
/// The numbers configured here could always be more than the the maximum limits of staking pezpallet
/// 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.
/// since the staking is bounded and the weight pipeline takes hours for this single pezpallet.
pub struct BenchmarkConfig;
impl pezpallet_election_provider_multi_phase::BenchmarkingConfig for BenchmarkConfig {
const VOTERS: [u32; 2] = [1000, 2000];
+26 -26
View File
@@ -13,20 +13,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! This pallet is designed to go into a source chain and destination chain to migrate data. The
//! This pezpallet is designed to go into a source chain and destination chain to migrate data. The
//! design motivations are:
//!
//! - Call some function on the source chain that executes some migration (clearing state,
//! forwarding an XCM program).
//! - Call some function (probably from an XCM program) on the destination chain.
//! - Avoid cluttering the source pallet with new dispatchables that are unrelated to its
//! - Avoid cluttering the source pezpallet with new dispatchables that are unrelated to its
//! functionality and only used for migration.
//!
//! After the migration is complete, the pallet may be removed from both chains' runtimes as well as
//! After the migration is complete, the pezpallet may be removed from both chains' runtimes as well as
//! the `pezkuwi-runtime-common` crate.
use pezframe_support::{dispatch::DispatchResult, traits::Currency, weights::Weight};
pub use pallet::*;
pub use pezpallet::*;
use pezpallet_identity;
use pezsp_core::Get;
@@ -57,13 +57,13 @@ impl WeightInfo for TestWeightInfo {
}
}
// Must use the same `Balance` as `T`'s Identity pallet to handle deposits.
// Must use the same `Balance` as `T`'s Identity pezpallet to handle deposits.
type BalanceOf<T> = <<T as pezpallet_identity::Config>::Currency as Currency<
<T as pezframe_system::Config>::AccountId,
>>::Balance;
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::{
dispatch::{DispatchResultWithPostInfo, PostDispatchInfo},
@@ -72,10 +72,10 @@ pub mod pallet {
};
use pezframe_system::pezpallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config + pezpallet_identity::Config {
/// Overarching event type.
#[allow(deprecated)]
@@ -88,12 +88,12 @@ pub mod pallet {
/// A handler for what to do when an identity is reaped.
type ReapIdentityHandler: OnReapIdentity<Self::AccountId>;
/// Weight information for the extrinsics in the pallet.
/// Weight information for the extrinsics in the pezpallet.
type WeightInfo: WeightInfo;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// The identity and all sub accounts were reaped for `who`.
IdentityReaped { who: T::AccountId },
@@ -102,12 +102,12 @@ pub mod pallet {
DepositUpdated { who: T::AccountId, identity: BalanceOf<T>, subs: BalanceOf<T> },
}
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Reap the `IdentityInfo` of `who` from the Identity pallet of `T`, unreserving any
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Reap the `IdentityInfo` of `who` from the Identity pezpallet of `T`, unreserving any
/// deposits held and removing storage items associated with `who`.
#[pallet::call_index(0)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::reap_identity(
#[pezpallet::call_index(0)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::reap_identity(
T::MaxRegistrars::get(),
T::MaxSubAccounts::get()
))]
@@ -119,11 +119,11 @@ 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) = pezpallet_identity::Pallet::<T>::reap_identity(&who)?;
let (registrars, bytes, subs) = pezpallet_identity::Pezpallet::<T>::reap_identity(&who)?;
T::ReapIdentityHandler::on_reap_identity(&who, bytes, subs)?;
Self::deposit_event(Event::IdentityReaped { who });
let post = PostDispatchInfo {
actual_weight: Some(<T as pallet::Config>::WeightInfo::reap_identity(
actual_weight: Some(<T as pezpallet::Config>::WeightInfo::reap_identity(
registrars, subs,
)),
pays_fee: Pays::No,
@@ -133,11 +133,11 @@ pub mod pallet {
/// Update the deposit of `who`. Meant to be called by the system with an XCM `Transact`
/// Instruction.
#[pallet::call_index(1)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::poke_deposit())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(<T as pezpallet::Config>::WeightInfo::poke_deposit())]
pub fn poke_deposit(origin: OriginFor<T>, who: T::AccountId) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
let (id_deposit, subs_deposit) = pezpallet_identity::Pallet::<T>::poke_deposit(&who)?;
let (id_deposit, subs_deposit) = pezpallet_identity::Pezpallet::<T>::poke_deposit(&who)?;
Self::deposit_event(Event::DepositUpdated {
who,
identity: id_deposit,
@@ -187,7 +187,7 @@ mod benchmarks {
use codec::Encode;
use pezframe_support::traits::EnsureOrigin;
use pezframe_system::RawOrigin;
use pezpallet_identity::{Data, IdentityInformationProvider, Judgement, Pallet as Identity};
use pezpallet_identity::{Data, IdentityInformationProvider, Judgement, Pezpallet as Identity};
use pezsp_runtime::{
traits::{Bounded, Hash, StaticLookup},
Saturating,
@@ -196,7 +196,7 @@ mod benchmarks {
const SEED: u32 = 0;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = pezframe_system::Pallet::<T>::events();
let events = pezframe_system::Pezpallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
@@ -316,7 +316,7 @@ mod benchmarks {
}
impl_benchmark_test_suite!(
Pallet,
Pezpallet,
crate::integration_tests::new_test_ext(),
crate::integration_tests::Test,
);
+10 -10
View File
@@ -29,30 +29,30 @@ 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, pezpallet_balances::Pallet<R>>> for ToAuthor<R>
impl<R> OnUnbalanced<Credit<R::AccountId, pezpallet_balances::Pezpallet<R>>> for ToAuthor<R>
where
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 pezframe_system::Config>::AccountId, pezpallet_balances::Pallet<R>>,
amount: Credit<<R as pezframe_system::Config>::AccountId, pezpallet_balances::Pezpallet<R>>,
) {
if let Some(author) = <pezpallet_authorship::Pallet<R>>::author() {
let _ = <pezpallet_balances::Pallet<R>>::resolve(&author, amount);
if let Some(author) = <pezpallet_authorship::Pezpallet<R>>::author() {
let _ = <pezpallet_balances::Pezpallet<R>>::resolve(&author, amount);
}
}
}
pub struct DealWithFees<R>(core::marker::PhantomData<R>);
impl<R> OnUnbalanced<Credit<R::AccountId, pezpallet_balances::Pallet<R>>> for DealWithFees<R>
impl<R> OnUnbalanced<Credit<R::AccountId, pezpallet_balances::Pezpallet<R>>> for DealWithFees<R>
where
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, pezpallet_balances::Pallet<R>>>,
mut fees_then_tips: impl Iterator<Item = Credit<R::AccountId, pezpallet_balances::Pezpallet<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>, pezpallet_balances::Pallet<R>>::on_unbalanced(split.0);
ResolveTo::<TreasuryAccountId<R>, pezpallet_balances::Pezpallet<R>>::on_unbalanced(split.0);
<ToAuthor<R> as OnUnbalanced<_>>::on_unbalanced(split.1);
}
}
@@ -378,7 +378,7 @@ mod tests {
}
impl pezpallet_treasury::Config for Test {
type Currency = pezpallet_balances::Pallet<Test>;
type Currency = pezpallet_balances::Pezpallet<Test>;
type RejectOrigin = pezframe_system::EnsureRoot<AccountId>;
type RuntimeEvent = RuntimeEvent;
type SpendPeriod = ();
@@ -467,11 +467,11 @@ mod tests {
fn test_fees_and_tip_split() {
new_test_ext().execute_with(|| {
let fee =
<pezpallet_balances::Pallet<Test> as pezframe_support::traits::fungible::Balanced<
<pezpallet_balances::Pezpallet<Test> as pezframe_support::traits::fungible::Balanced<
AccountId,
>>::issue(10);
let tip =
<pezpallet_balances::Pallet<Test> as pezframe_support::traits::fungible::Balanced<
<pezpallet_balances::Pezpallet<Test> as pezframe_support::traits::fungible::Balanced<
AccountId,
>>::issue(20);
@@ -357,8 +357,8 @@ fn maybe_new_session(n: u32) {
let session_index = shared::CurrentSessionIndex::<Test>::get() + 1;
let validators_pub_keys = validators_public_keys(VALIDATORS);
shared::Pallet::<Test>::set_session_index(session_index);
shared::Pallet::<Test>::set_active_validators_ascending(validators_pub_keys);
shared::Pezpallet::<Test>::set_session_index(session_index);
shared::Pezpallet::<Test>::set_active_validators_ascending(validators_pub_keys);
Paras::test_on_new_session();
}
}
+2 -2
View File
@@ -68,7 +68,7 @@ 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> = <pezpallet_balances::Pallet<T> as Currency<
pub type NegativeImbalance<T> = <pezpallet_balances::Pezpallet<T> as Currency<
<T as pezframe_system::Config>::AccountId,
>>::NegativeImbalance;
@@ -227,7 +227,7 @@ impl<T: pezpallet_session::Config> OneSessionHandler<T::AccountId>
fn on_disabled(_: u32) {}
}
/// A reasonable benchmarking config for staking pallet.
/// A reasonable benchmarking config for staking pezpallet.
pub struct StakingBenchmarkingConfig;
impl pezpallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
type MaxValidators = ConstU32<1000>;
+3 -3
View File
@@ -140,7 +140,7 @@ impl<T: pezframe_system::Config> Registrar for TestRegistrar<T> {
OPERATIONS.with(|x| {
x.borrow_mut().push((
id,
pezframe_system::Pallet::<T>::block_number().saturated_into(),
pezframe_system::Pezpallet::<T>::block_number().saturated_into(),
true,
))
});
@@ -174,7 +174,7 @@ impl<T: pezframe_system::Config> Registrar for TestRegistrar<T> {
OPERATIONS.with(|x| {
x.borrow_mut().push((
id,
pezframe_system::Pallet::<T>::block_number().saturated_into(),
pezframe_system::Pezpallet::<T>::block_number().saturated_into(),
false,
))
});
@@ -260,7 +260,7 @@ pub fn conclude_pvf_checking<T: paras::Config>(
validator_index: validator_index.into(),
};
let signature = key.sign(&statement.signing_payload());
let _ = paras::Pallet::<T>::include_pvf_check_statement(
let _ = paras::Pezpallet::<T>::include_pvf_check_statement(
pezframe_system::Origin::<T>::None.into(),
statement,
signature.into(),
@@ -14,10 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Benchmarking for paras_registrar pallet
//! Benchmarking for paras_registrar pezpallet
#[cfg(feature = "runtime-benchmarks")]
use super::{Pallet as Registrar, *};
use super::{Pezpallet as Registrar, *};
use crate::traits::Registrar as RegistrarT;
use pezframe_support::assert_ok;
use pezframe_system::RawOrigin;
@@ -28,7 +28,7 @@ use pezsp_runtime::traits::Bounded;
use pezframe_benchmarking::v2::*;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = pezframe_system::Pallet::<T>::events();
let events = pezframe_system::Pezpallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
@@ -48,7 +48,7 @@ fn register_para<T: Config>(id: u32) -> ParaId {
genesis_head,
validation_code.clone()
));
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pallet::<T>::add_trusted_validation_code(
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pezpallet::<T>::add_trusted_validation_code(
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
@@ -61,8 +61,8 @@ fn para_origin(id: u32) -> ParaOrigin {
// This function moves forward to the next scheduled session for teyrchain lifecycle upgrades.
fn next_scheduled_session<T: Config>() {
shared::Pallet::<T>::set_session_index(shared::Pallet::<T>::scheduled_session());
paras::Pallet::<T>::test_on_new_session();
shared::Pezpallet::<T>::set_session_index(shared::Pezpallet::<T>::scheduled_session());
paras::Pezpallet::<T>::test_on_new_session();
}
#[benchmarks(
@@ -83,7 +83,7 @@ mod benchmarks {
Event::<T>::Reserved { para_id: LOWEST_PUBLIC_ID, who: caller }.into(),
);
assert!(Paras::<T>::get(LOWEST_PUBLIC_ID).is_some());
assert_eq!(paras::Pallet::<T>::lifecycle(LOWEST_PUBLIC_ID), None);
assert_eq!(paras::Pezpallet::<T>::lifecycle(LOWEST_PUBLIC_ID), None);
Ok(())
}
@@ -101,13 +101,13 @@ mod benchmarks {
_(RawOrigin::Signed(caller.clone()), para, genesis_head, validation_code.clone());
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(
assert_eq!(paras::Pezpallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pezpallet::<T>::add_trusted_validation_code(
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
next_scheduled_session::<T>();
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
assert_eq!(paras::Pezpallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
Ok(())
}
@@ -124,13 +124,13 @@ mod benchmarks {
_(RawOrigin::Root, manager.clone(), deposit, para, genesis_head, validation_code.clone());
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(
assert_eq!(paras::Pezpallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pezpallet::<T>::add_trusted_validation_code(
pezframe_system::Origin::<T>::Root.into(),
validation_code,
));
next_scheduled_session::<T>();
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
assert_eq!(paras::Pezpallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
Ok(())
}
@@ -164,8 +164,8 @@ mod benchmarks {
Registrar::<T>::make_teyrchain(teyrchain)?;
next_scheduled_session::<T>();
assert_eq!(paras::Pallet::<T>::lifecycle(teyrchain), Some(ParaLifecycle::Teyrchain));
assert_eq!(paras::Pallet::<T>::lifecycle(parathread), Some(ParaLifecycle::Parathread));
assert_eq!(paras::Pezpallet::<T>::lifecycle(teyrchain), Some(ParaLifecycle::Teyrchain));
assert_eq!(paras::Pezpallet::<T>::lifecycle(parathread), Some(ParaLifecycle::Parathread));
let caller: T::AccountId = whitelisted_caller();
Registrar::<T>::swap(teyrchain_origin.into(), teyrchain, parathread)?;
@@ -175,8 +175,8 @@ mod benchmarks {
next_scheduled_session::<T>();
// Swapped!
assert_eq!(paras::Pallet::<T>::lifecycle(teyrchain), Some(ParaLifecycle::Parathread));
assert_eq!(paras::Pallet::<T>::lifecycle(parathread), Some(ParaLifecycle::Teyrchain));
assert_eq!(paras::Pezpallet::<T>::lifecycle(teyrchain), Some(ParaLifecycle::Parathread));
assert_eq!(paras::Pezpallet::<T>::lifecycle(parathread), Some(ParaLifecycle::Teyrchain));
Ok(())
}
@@ -64,6 +64,6 @@ pub type MigrateToV1<T, UnlockParaIds> = pezframe_support::migrations::Versioned
0,
1,
VersionUncheckedMigrateToV1<T, UnlockParaIds>,
super::Pallet<T>,
super::Pezpallet<T>,
<T as pezframe_system::Config>::DbWeight,
>;
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Mocking utilities for testing in paras_registrar pallet.
//! Mocking utilities for testing in paras_registrar pezpallet.
#[cfg(test)]
use super::*;
@@ -204,7 +204,7 @@ pub const VALIDATORS: &[Sr25519Keyring] = &[
];
pub fn run_to_block(n: BlockNumber) {
// NOTE that this function only simulates modules of interest. Depending on new pallet may
// NOTE that this function only simulates modules of interest. Depending on new pezpallet may
// require adding it here.
System::run_to_block_with::<AllPalletsWithSystem>(
n,
@@ -214,8 +214,8 @@ pub fn run_to_block(n: BlockNumber) {
let session_index = shared::CurrentSessionIndex::<Test>::get() + 1;
let validators_pub_keys = VALIDATORS.iter().map(|v| v.public().into()).collect();
shared::Pallet::<Test>::set_session_index(session_index);
shared::Pallet::<Test>::set_active_validators_ascending(validators_pub_keys);
shared::Pezpallet::<Test>::set_session_index(session_index);
shared::Pezpallet::<Test>::set_active_validators_ascending(validators_pub_keys);
Teyrchains::test_on_new_session();
}
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Pallet to handle teyrchain registration and related fund management.
//! Pezpallet to handle teyrchain registration and related fund management.
//! In essence this is a simple wrapper around `paras`.
pub mod migration;
@@ -37,7 +37,7 @@ use pezkuwi_runtime_teyrchains::{
use crate::traits::{OnSwap, Registrar};
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
pub use pallet::*;
pub use pezpallet::*;
use pezkuwi_runtime_teyrchains::paras::{OnNewHead, ParaKind};
use scale_info::TypeInfo;
use pezsp_runtime::{
@@ -112,8 +112,8 @@ impl WeightInfo for TestWeightInfo {
}
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
@@ -121,13 +121,13 @@ pub mod pallet {
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::pallet]
#[pallet::without_storage_info]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::without_storage_info]
#[pezpallet::storage_version(STORAGE_VERSION)]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pallet::disable_pezframe_system_supertrait_check]
#[pezpallet::config]
#[pezpallet::disable_pezframe_system_supertrait_check]
pub trait Config: configuration::Config + paras::Config {
/// The overarching event type.
#[allow(deprecated)]
@@ -148,19 +148,19 @@ pub mod pallet {
/// The deposit to be paid to run a on-demand teyrchain.
/// This should include the cost for storing the genesis head and validation code.
#[pallet::constant]
#[pezpallet::constant]
type ParaDeposit: Get<BalanceOf<Self>>;
/// The deposit to be paid per byte stored on chain.
#[pallet::constant]
#[pezpallet::constant]
type DataDepositPerByte: Get<BalanceOf<Self>>;
/// Weight Information for the Extrinsics in the Pallet
/// Weight Information for the Extrinsics in the Pezpallet
type WeightInfo: WeightInfo;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
Registered { para_id: ParaId, manager: T::AccountId },
Deregistered { para_id: ParaId },
@@ -168,7 +168,7 @@ pub mod pallet {
Swapped { para_id: ParaId, other_id: ParaId },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// The ID is not registered.
NotRegistered,
@@ -203,22 +203,22 @@ pub mod pallet {
}
/// Pending swap operations.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type PendingSwap<T> = StorageMap<_, Twox64Concat, ParaId, ParaId>;
/// Amount held on deposit for each para and the original depositor.
///
/// The given account ID is responsible for registering the code and initial head data, but may
/// only do so if it isn't yet registered. (After that, it's up to governance to do so.)
#[pallet::storage]
#[pezpallet::storage]
pub type Paras<T: Config> =
StorageMap<_, Twox64Concat, ParaId, ParaInfo<T::AccountId, BalanceOf<T>>>;
/// The next free `ParaId`.
#[pallet::storage]
#[pezpallet::storage]
pub type NextFreeParaId<T> = StorageValue<_, ParaId, ValueQuery>;
#[pallet::genesis_config]
#[pezpallet::genesis_config]
pub struct GenesisConfig<T: Config> {
#[serde(skip)]
pub _config: core::marker::PhantomData<T>,
@@ -231,18 +231,18 @@ pub mod pallet {
}
}
#[pallet::genesis_build]
#[pezpallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
NextFreeParaId::<T>::put(self.next_free_para_id);
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Register head data and validation code for a reserved Para Id.
///
/// ## Arguments
@@ -257,14 +257,14 @@ pub mod pallet {
/// The deposit is required to cover the costs associated with storing the genesis head
/// data and the validation code.
/// This accounts for the potential to store validation code of a size up to the
/// `max_code_size`, as defined in the configuration pallet
/// `max_code_size`, as defined in the configuration pezpallet
///
/// Anything already reserved previously for this para ID is accounted for.
///
/// ## Events
/// The `Registered` event is emitted in case of success.
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::register())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(<T as Config>::WeightInfo::register())]
pub fn register(
origin: OriginFor<T>,
id: ParaId,
@@ -282,8 +282,8 @@ pub mod pallet {
///
/// The deposit taken can be specified for this registration. Any `ParaId`
/// can be registered, including sub-1000 IDs which are System Teyrchains.
#[pallet::call_index(1)]
#[pallet::weight(<T as Config>::WeightInfo::force_register())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(<T as Config>::WeightInfo::force_register())]
pub fn force_register(
origin: OriginFor<T>,
who: T::AccountId,
@@ -300,8 +300,8 @@ pub mod pallet {
///
/// The caller must be Root, the `para` owner, or the `para` itself. The para must be an
/// on-demand teyrchain.
#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::deregister())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(<T as Config>::WeightInfo::deregister())]
pub fn deregister(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, id)?;
Self::do_deregister(id)
@@ -319,8 +319,8 @@ pub mod pallet {
/// `ParaId` to be a long-term identifier of a notional "teyrchain". However, their
/// scheduling info (i.e. whether they're an on-demand teyrchain or lease holding
/// teyrchain), auction information and the auction deposit are switched.
#[pallet::call_index(3)]
#[pallet::weight(<T as Config>::WeightInfo::swap())]
#[pezpallet::call_index(3)]
#[pezpallet::weight(<T as Config>::WeightInfo::swap())]
pub fn swap(origin: OriginFor<T>, id: ParaId, other: ParaId) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, id)?;
@@ -333,11 +333,11 @@ pub mod pallet {
// Sanity check that `id` is even a para.
let id_lifecycle =
paras::Pallet::<T>::lifecycle(id).ok_or(Error::<T>::NotRegistered)?;
paras::Pezpallet::<T>::lifecycle(id).ok_or(Error::<T>::NotRegistered)?;
if PendingSwap::<T>::get(other) == Some(id) {
let other_lifecycle =
paras::Pallet::<T>::lifecycle(other).ok_or(Error::<T>::NotRegistered)?;
paras::Pezpallet::<T>::lifecycle(other).ok_or(Error::<T>::NotRegistered)?;
// identify which is a lease holding teyrchain and which is a parathread (on-demand
// teyrchain)
if id_lifecycle == ParaLifecycle::Teyrchain &&
@@ -371,8 +371,8 @@ pub mod pallet {
/// previously locked para to deregister or swap a para without using governance.
///
/// Can only be called by the Root origin or the teyrchain.
#[pallet::call_index(4)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn remove_lock(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
Self::ensure_root_or_para(origin, para)?;
<Self as Registrar>::remove_lock(para);
@@ -383,7 +383,7 @@ pub mod pallet {
///
/// This function will reserve a new Para Id to be owned/managed by the origin account.
/// The origin account is able to register head data and validation code using `register` to
/// create an on-demand teyrchain. Using the Slots pallet, an on-demand teyrchain can then
/// create an on-demand teyrchain. Using the Slots pezpallet, an on-demand teyrchain can then
/// be upgraded to a lease holding teyrchain.
///
/// ## Arguments
@@ -396,8 +396,8 @@ pub mod pallet {
/// ## Events
/// The `Reserved` event is emitted in case of success, which provides the ID reserved for
/// use.
#[pallet::call_index(5)]
#[pallet::weight(<T as Config>::WeightInfo::reserve())]
#[pezpallet::call_index(5)]
#[pezpallet::weight(<T as Config>::WeightInfo::reserve())]
pub fn reserve(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let id = NextFreeParaId::<T>::get().max(LOWEST_PUBLIC_ID);
@@ -411,8 +411,8 @@ pub mod pallet {
///
/// Can be called by Root, the teyrchain, or the teyrchain manager if the teyrchain is
/// unlocked.
#[pallet::call_index(6)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
#[pezpallet::call_index(6)]
#[pezpallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn add_lock(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, para)?;
<Self as Registrar>::apply_lock(para);
@@ -430,8 +430,8 @@ pub mod pallet {
///
/// Can be called by Root, the teyrchain, or the teyrchain manager if the teyrchain is
/// unlocked.
#[pallet::call_index(7)]
#[pallet::weight(<T as Config>::WeightInfo::schedule_code_upgrade(new_code.0.len() as u32))]
#[pezpallet::call_index(7)]
#[pezpallet::weight(<T as Config>::WeightInfo::schedule_code_upgrade(new_code.0.len() as u32))]
pub fn schedule_code_upgrade(
origin: OriginFor<T>,
para: ParaId,
@@ -450,8 +450,8 @@ pub mod pallet {
///
/// Can be called by Root, the teyrchain, or the teyrchain manager if the teyrchain is
/// unlocked.
#[pallet::call_index(8)]
#[pallet::weight(<T as Config>::WeightInfo::set_current_head(new_head.0.len() as u32))]
#[pezpallet::call_index(8)]
#[pezpallet::weight(<T as Config>::WeightInfo::set_current_head(new_head.0.len() as u32))]
pub fn set_current_head(
origin: OriginFor<T>,
para: ParaId,
@@ -464,7 +464,7 @@ pub mod pallet {
}
}
impl<T: Config> Registrar for Pallet<T> {
impl<T: Config> Registrar for Pezpallet<T> {
type AccountId = T::AccountId;
/// Return the manager `AccountId` of a para if one exists.
@@ -480,12 +480,12 @@ impl<T: Config> Registrar for Pallet<T> {
// Return if a para is a parathread (on-demand teyrchain)
fn is_parathread(id: ParaId) -> bool {
paras::Pallet::<T>::is_parathread(id)
paras::Pezpallet::<T>::is_parathread(id)
}
// Return if a para is a lease holding teyrchain
fn is_teyrchain(id: ParaId) -> bool {
paras::Pallet::<T>::is_teyrchain(id)
paras::Pezpallet::<T>::is_teyrchain(id)
}
// Apply a lock to the teyrchain.
@@ -520,7 +520,7 @@ impl<T: Config> Registrar for Pallet<T> {
fn make_teyrchain(id: ParaId) -> DispatchResult {
// Para backend should think this is an on-demand teyrchain...
ensure!(
paras::Pallet::<T>::lifecycle(id) == Some(ParaLifecycle::Parathread),
paras::Pezpallet::<T>::lifecycle(id) == Some(ParaLifecycle::Parathread),
Error::<T>::NotParathread
);
pezkuwi_runtime_teyrchains::schedule_parathread_upgrade::<T>(id)
@@ -533,7 +533,7 @@ impl<T: Config> Registrar for Pallet<T> {
fn make_parathread(id: ParaId) -> DispatchResult {
// Para backend should think this is a teyrchain...
ensure!(
paras::Pallet::<T>::lifecycle(id) == Some(ParaLifecycle::Teyrchain),
paras::Pezpallet::<T>::lifecycle(id) == Some(ParaLifecycle::Teyrchain),
Error::<T>::NotTeyrchain
);
pezkuwi_runtime_teyrchains::schedule_teyrchain_downgrade::<T>(id)
@@ -559,12 +559,12 @@ impl<T: Config> Registrar for Pallet<T> {
#[cfg(any(feature = "runtime-benchmarks", test))]
fn execute_pending_transitions() {
use pezkuwi_runtime_teyrchains::shared;
shared::Pallet::<T>::set_session_index(shared::Pallet::<T>::scheduled_session());
paras::Pallet::<T>::test_on_new_session();
shared::Pezpallet::<T>::set_session_index(shared::Pezpallet::<T>::scheduled_session());
paras::Pezpallet::<T>::test_on_new_session();
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<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(
@@ -605,7 +605,7 @@ impl<T: Config> Pallet<T> {
id: ParaId,
) -> DispatchResult {
ensure!(!Paras::<T>::contains_key(id), Error::<T>::AlreadyRegistered);
ensure!(paras::Pallet::<T>::lifecycle(id).is_none(), Error::<T>::AlreadyRegistered);
ensure!(paras::Pezpallet::<T>::lifecycle(id).is_none(), Error::<T>::AlreadyRegistered);
let deposit = deposit_override.unwrap_or_else(T::ParaDeposit::get);
<T as Config>::Currency::reserve(&who, deposit)?;
@@ -634,7 +634,7 @@ impl<T: Config> Pallet<T> {
ensure!(!ensure_reserved, Error::<T>::NotReserved);
Default::default()
};
ensure!(paras::Pallet::<T>::lifecycle(id).is_none(), Error::<T>::AlreadyRegistered);
ensure!(paras::Pezpallet::<T>::lifecycle(id).is_none(), Error::<T>::AlreadyRegistered);
let (genesis, deposit) =
Self::validate_onboarding_data(genesis_head, validation_code, ParaKind::Parathread)?;
let deposit = deposit_override.unwrap_or(deposit);
@@ -656,7 +656,7 @@ impl<T: Config> Pallet<T> {
/// Deregister a Para Id, freeing all data returning any deposit.
fn do_deregister(id: ParaId) -> DispatchResult {
match paras::Pallet::<T>::lifecycle(id) {
match paras::Pezpallet::<T>::lifecycle(id) {
// Para must be a parathread (on-demand teyrchain), or not exist at all.
Some(ParaLifecycle::Parathread) | None => {},
_ => return Err(Error::<T>::NotParathread.into()),
@@ -708,7 +708,7 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> OnNewHead for Pallet<T> {
impl<T: Config> OnNewHead for Pezpallet<T> {
fn on_new_head(id: ParaId, _head: &HeadData) -> Weight {
// mark the teyrchain locked if the locked value is not already set
let mut writes = 0;
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Tests for the paras_registrar pallet.
//! Tests for the paras_registrar pezpallet.
#[cfg(test)]
use super::*;
@@ -257,7 +257,7 @@ fn deregister_works() {
assert!(Teyrchains::is_parathread(para_id));
assert_ok!(mock::Registrar::deregister(RuntimeOrigin::root(), para_id,));
run_to_session(START_SESSION_INDEX + 4);
assert!(paras::Pallet::<Test>::lifecycle(para_id).is_none());
assert!(paras::Pezpallet::<Test>::lifecycle(para_id).is_none());
assert_eq!(Balances::reserved_balance(&1), 0);
});
}
@@ -20,7 +20,7 @@ use alloc::boxed::Box;
use codec::Encode;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
pub use pezpallet::*;
use pezkuwi_primitives::Id as ParaId;
use pezkuwi_runtime_teyrchains::{
configuration, dmp, hrmp,
@@ -28,18 +28,18 @@ use pezkuwi_runtime_teyrchains::{
ParaLifecycle,
};
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pallet::disable_pezframe_system_supertrait_check]
#[pezpallet::config]
#[pezpallet::disable_pezframe_system_supertrait_check]
pub trait Config: configuration::Config + paras::Config + dmp::Config + hrmp::Config {}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// The specified teyrchain is not registered.
ParaDoesntExist,
@@ -64,18 +64,18 @@ pub mod pallet {
TooManyCores,
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Schedule a para to be initialized at the start of the next session.
///
/// This should only be used for TESTING and not on PRODUCTION chains. It automatically
/// assigns Coretime to the chain and increases the number of cores. Thus, there is no
/// running coretime chain required.
#[pallet::call_index(0)]
#[pallet::weight((1_000, DispatchClass::Operational))]
#[pezpallet::call_index(0)]
#[pezpallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_para_initialize(
origin: OriginFor<T>,
id: ParaId,
@@ -96,8 +96,8 @@ pub mod pallet {
}
/// Schedule a para to be cleaned up at the start of the next session.
#[pallet::call_index(1)]
#[pallet::weight((1_000, DispatchClass::Operational))]
#[pezpallet::call_index(1)]
#[pezpallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_para_cleanup(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
ensure_root(origin)?;
pezkuwi_runtime_teyrchains::schedule_para_cleanup::<T>(id)
@@ -106,8 +106,8 @@ pub mod pallet {
}
/// Upgrade a parathread (on-demand teyrchain) to a lease holding teyrchain
#[pallet::call_index(2)]
#[pallet::weight((1_000, DispatchClass::Operational))]
#[pezpallet::call_index(2)]
#[pezpallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_parathread_upgrade(
origin: OriginFor<T>,
id: ParaId,
@@ -115,7 +115,7 @@ pub mod pallet {
ensure_root(origin)?;
// Para backend should think this is a parathread (on-demand teyrchain)...
ensure!(
paras::Pallet::<T>::lifecycle(id) == Some(ParaLifecycle::Parathread),
paras::Pezpallet::<T>::lifecycle(id) == Some(ParaLifecycle::Parathread),
Error::<T>::NotParathread,
);
pezkuwi_runtime_teyrchains::schedule_parathread_upgrade::<T>(id)
@@ -124,8 +124,8 @@ pub mod pallet {
}
/// Downgrade a lease holding teyrchain to an on-demand teyrchain
#[pallet::call_index(3)]
#[pallet::weight((1_000, DispatchClass::Operational))]
#[pezpallet::call_index(3)]
#[pezpallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_teyrchain_downgrade(
origin: OriginFor<T>,
id: ParaId,
@@ -133,7 +133,7 @@ pub mod pallet {
ensure_root(origin)?;
// Para backend should think this is a teyrchain...
ensure!(
paras::Pallet::<T>::lifecycle(id) == Some(ParaLifecycle::Teyrchain),
paras::Pezpallet::<T>::lifecycle(id) == Some(ParaLifecycle::Teyrchain),
Error::<T>::NotTeyrchain,
);
pezkuwi_runtime_teyrchains::schedule_teyrchain_downgrade::<T>(id)
@@ -145,17 +145,17 @@ pub mod pallet {
///
/// The given teyrchain should exist and the payload should not exceed the preconfigured
/// size `config.max_downward_message_size`.
#[pallet::call_index(4)]
#[pallet::weight((1_000, DispatchClass::Operational))]
#[pezpallet::call_index(4)]
#[pezpallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_queue_downward_xcm(
origin: OriginFor<T>,
id: ParaId,
xcm: Box<xcm::opaque::VersionedXcm>,
) -> DispatchResult {
ensure_root(origin)?;
ensure!(paras::Pallet::<T>::is_valid_para(id), Error::<T>::ParaDoesntExist);
ensure!(paras::Pezpallet::<T>::is_valid_para(id), Error::<T>::ParaDoesntExist);
let config = configuration::ActiveConfig::<T>::get();
dmp::Pallet::<T>::queue_downward_message(&config, id, xcm.encode()).map_err(|e| match e
dmp::Pezpallet::<T>::queue_downward_message(&config, id, xcm.encode()).map_err(|e| match e
{
dmp::QueueDownwardMessageError::ExceedsMaxMessageSize =>
Error::<T>::ExceedsMaxMessageSize.into(),
@@ -167,8 +167,8 @@ pub mod pallet {
///
/// This is equivalent to sending an `Hrmp::hrmp_init_open_channel` extrinsic followed by
/// `Hrmp::hrmp_accept_open_channel`.
#[pallet::call_index(5)]
#[pallet::weight((1_000, DispatchClass::Operational))]
#[pezpallet::call_index(5)]
#[pezpallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_establish_hrmp_channel(
origin: OriginFor<T>,
sender: ParaId,
@@ -178,13 +178,13 @@ pub mod pallet {
) -> DispatchResult {
ensure_root(origin)?;
hrmp::Pallet::<T>::init_open_channel(
hrmp::Pezpallet::<T>::init_open_channel(
sender,
recipient,
max_capacity,
max_message_size,
)?;
hrmp::Pallet::<T>::accept_open_channel(recipient, sender)?;
hrmp::Pezpallet::<T>::accept_open_channel(recipient, sender)?;
Ok(())
}
}
+2 -2
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Mocking utilities for testing in purchase pallet.
//! Mocking utilities for testing in purchase pezpallet.
#[cfg(test)]
use super::*;
@@ -119,7 +119,7 @@ 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.
// our desired mockup. It also executes our `setup` function which sets up this pezpallet for use.
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);
+43 -43
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Pallet to process purchase of DOTs.
//! Pezpallet to process purchase of DOTs.
use alloc::vec::Vec;
use codec::{Decode, Encode};
@@ -23,7 +23,7 @@ use pezframe_support::{
traits::{Currency, EnsureOrigin, ExistenceRequirement, Get, VestingSchedule},
};
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
pub use pezpallet::*;
use scale_info::TypeInfo;
use pezsp_core::sr25519;
use pezsp_runtime::{
@@ -89,24 +89,24 @@ pub struct AccountStatus<Balance> {
vat: Permill,
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
#[pallet::pallet]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::without_storage_info]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// Balances Pallet
/// Balances Pezpallet
type Currency: Currency<Self::AccountId>;
/// Vesting Pallet
/// Vesting Pezpallet
type VestingSchedule: VestingSchedule<
Self::AccountId,
Moment = BlockNumberFor<Self>,
@@ -116,24 +116,24 @@ pub mod pallet {
/// The origin allowed to set account status.
type ValidityOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The origin allowed to make configurations to the pallet.
/// The origin allowed to make configurations to the pezpallet.
type ConfigurationOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The maximum statement length for the statement users to sign when creating an account.
#[pallet::constant]
#[pezpallet::constant]
type MaxStatementLength: Get<u32>;
/// The amount of purchased locked DOTs that we will unlock for basic actions on the chain.
#[pallet::constant]
#[pezpallet::constant]
type UnlockedProportion: Get<Permill>;
/// The maximum amount of locked DOTs that we will unlock.
#[pallet::constant]
#[pezpallet::constant]
type MaxUnlocked: Get<BalanceOf<Self>>;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A new account was created.
AccountCreated { who: T::AccountId },
@@ -151,7 +151,7 @@ pub mod pallet {
UnlockBlockUpdated { block_number: BlockNumberFor<T> },
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// Account is not currently valid to use.
InvalidAccount,
@@ -172,41 +172,41 @@ pub mod pallet {
}
// A map of all participants in the HEZ purchase process.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type Accounts<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountId, AccountStatus<BalanceOf<T>>, ValueQuery>;
// The account that will be used to payout participants of the HEZ purchase process.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type PaymentAccount<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;
// The statement purchasers will need to sign to participate.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type Statement<T> = StorageValue<_, Vec<u8>, ValueQuery>;
// The block where all locked dots will unlock.
#[pallet::storage]
#[pezpallet::storage]
pub(super) type UnlockBlock<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Create a new account. Proof of existence through a valid signed message.
///
/// We check that the account does not exist at this stage.
///
/// Origin must match the `ValidityOrigin`.
#[pallet::call_index(0)]
#[pallet::weight(Weight::from_parts(200_000_000, 0) + T::DbWeight::get().reads_writes(4, 1))]
#[pezpallet::call_index(0)]
#[pezpallet::weight(Weight::from_parts(200_000_000, 0) + T::DbWeight::get().reads_writes(4, 1))]
pub fn create_account(
origin: OriginFor<T>,
who: T::AccountId,
signature: Vec<u8>,
) -> DispatchResult {
T::ValidityOrigin::ensure_origin(origin)?;
// Account is already being tracked by the pallet.
// Account is already being tracked by the pezpallet.
ensure!(!Accounts::<T>::contains_key(&who), Error::<T>::ExistingAccount);
// Account should not have a vesting schedule.
ensure!(
@@ -236,8 +236,8 @@ pub mod pallet {
/// We check that the account exists at this stage, but has not completed the process.
///
/// Origin must match the `ValidityOrigin`.
#[pallet::call_index(1)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn update_validity_status(
origin: OriginFor<T>,
who: T::AccountId,
@@ -265,8 +265,8 @@ pub mod pallet {
/// We check that the account is valid for a balance transfer at this point.
///
/// Origin must match the `ValidityOrigin`.
#[pallet::call_index(2)]
#[pallet::weight(T::DbWeight::get().reads_writes(2, 1))]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::DbWeight::get().reads_writes(2, 1))]
pub fn update_balance(
origin: OriginFor<T>,
who: T::AccountId,
@@ -303,8 +303,8 @@ pub mod pallet {
///
/// Origin must match the configured `PaymentAccount` (if it is not configured then this
/// will always fail with `BadOrigin`).
#[pallet::call_index(3)]
#[pallet::weight(T::DbWeight::get().reads_writes(4, 2))]
#[pezpallet::call_index(3)]
#[pezpallet::weight(T::DbWeight::get().reads_writes(4, 2))]
pub fn payout(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
// Payments must be made directly by the `PaymentAccount`.
let payment_account = ensure_signed(origin)?;
@@ -376,8 +376,8 @@ pub mod pallet {
/// Set the account that will be used to payout users in the HEZ purchase process.
///
/// Origin must match the `ConfigurationOrigin`
#[pallet::call_index(4)]
#[pallet::weight(T::DbWeight::get().writes(1))]
#[pezpallet::call_index(4)]
#[pezpallet::weight(T::DbWeight::get().writes(1))]
pub fn set_payment_account(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?;
// Possibly this is worse than having the caller account be the payment account?
@@ -389,8 +389,8 @@ pub mod pallet {
/// Set the statement that must be signed for a user to participate on the HEZ sale.
///
/// Origin must match the `ConfigurationOrigin`
#[pallet::call_index(5)]
#[pallet::weight(T::DbWeight::get().writes(1))]
#[pezpallet::call_index(5)]
#[pezpallet::weight(T::DbWeight::get().writes(1))]
pub fn set_statement(origin: OriginFor<T>, statement: Vec<u8>) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?;
ensure!(
@@ -406,15 +406,15 @@ pub mod pallet {
/// Set the block where locked DOTs will become unlocked.
///
/// Origin must match the `ConfigurationOrigin`
#[pallet::call_index(6)]
#[pallet::weight(T::DbWeight::get().writes(1))]
#[pezpallet::call_index(6)]
#[pezpallet::weight(T::DbWeight::get().writes(1))]
pub fn set_unlock_block(
origin: OriginFor<T>,
unlock_block: BlockNumberFor<T>,
) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?;
ensure!(
unlock_block > pezframe_system::Pallet::<T>::block_number(),
unlock_block > pezframe_system::Pezpallet::<T>::block_number(),
Error::<T>::InvalidUnlockBlock
);
// Possibly this is worse than having the caller account be the payment account?
@@ -425,7 +425,7 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
fn verify_signature(who: &T::AccountId, signature: &[u8]) -> Result<(), DispatchError> {
// sr25519 always expects a 64 byte signature.
let signature: AnySignature = sr25519::Signature::try_from(signature)
@@ -458,7 +458,7 @@ where
Ok(bytes)
}
/// WARNING: Executing this function will clear all storage used by this pallet.
/// WARNING: Executing this function will clear all storage used by this pezpallet.
/// Be sure this is what you want...
pub fn remove_pallet<T>() -> pezframe_support::weights::Weight
where
+1 -1
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Tests for the purchase pallet.
//! Tests for the purchase pezpallet.
#[cfg(test)]
use super::*;
@@ -56,7 +56,7 @@ pub mod slots_crowdloan_index_migration {
// the para id must have a crowdloan
if let Some(fund) = crowdloan::Funds::<T>::get(para_id) {
let old_fund_account = old_fund_account_id::<T>(para_id);
let new_fund_account = crowdloan::Pallet::<T>::fund_account_id(fund.fund_index);
let new_fund_account = crowdloan::Pezpallet::<T>::fund_account_id(fund.fund_index);
// look for places the old account is used, and replace with the new account.
for (who, _amount) in leases.iter_mut().flatten() {
+38 -38
View File
@@ -19,7 +19,7 @@
//! teyrchains and parathreads to be swapped.
//!
//! This doesn't handle the mechanics of determining which para ID actually ends up with a teyrchain
//! lease. This must handled by a separately, through the trait interface that this pallet provides
//! lease. This must handled by a separately, through the trait interface that this pezpallet provides
//! or the root dispatchables.
pub mod migration;
@@ -32,7 +32,7 @@ use pezframe_support::{
weights::Weight,
};
use pezframe_system::pezpallet_prelude::*;
pub use pallet::*;
pub use pezpallet::*;
use pezkuwi_primitives::Id as ParaId;
use pezsp_runtime::traits::{CheckedConversion, CheckedSub, Saturating, Zero};
@@ -63,15 +63,15 @@ impl WeightInfo for TestWeightInfo {
}
}
#[pezframe_support::pallet]
pub mod pallet {
#[pezframe_support::pezpallet]
pub mod pezpallet {
use super::*;
#[pallet::pallet]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);
#[pezpallet::pezpallet]
#[pezpallet::without_storage_info]
pub struct Pezpallet<T>(_);
#[pallet::config]
#[pezpallet::config]
pub trait Config: pezframe_system::Config {
/// The overarching event type.
#[allow(deprecated)]
@@ -84,17 +84,17 @@ pub mod pallet {
type Registrar: Registrar<AccountId = Self::AccountId>;
/// The number of blocks over which a single period lasts.
#[pallet::constant]
#[pezpallet::constant]
type LeasePeriod: Get<BlockNumberFor<Self>>;
/// The number of blocks to offset each lease period by.
#[pallet::constant]
#[pezpallet::constant]
type LeaseOffset: Get<BlockNumberFor<Self>>;
/// The origin which may forcibly create or clear leases. Root can always do this.
type ForceOrigin: EnsureOrigin<<Self as pezframe_system::Config>::RuntimeOrigin>;
/// Weight Information for the Extrinsics in the Pallet
/// Weight Information for the Extrinsics in the Pezpallet
type WeightInfo: WeightInfo;
}
@@ -107,19 +107,19 @@ pub mod pallet {
/// items are for the subsequent lease periods.
///
/// The default value (an empty list) implies that the teyrchain no longer exists (or never
/// existed) as far as this pallet is concerned.
/// existed) as far as this pezpallet is concerned.
///
/// If a teyrchain doesn't exist *yet* but is scheduled to exist in the future, then it
/// will be left-padded with one or more `None`s to denote the fact that nothing is held on
/// deposit for the non-existent chain currently, but is held at some point in the future.
///
/// It is illegal for a `None` value to trail in the list.
#[pallet::storage]
#[pezpallet::storage]
pub type Leases<T: Config> =
StorageMap<_, Twox64Concat, ParaId, Vec<Option<(T::AccountId, BalanceOf<T>)>>, ValueQuery>;
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
#[pezpallet::event]
#[pezpallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A new `[lease_period]` is beginning.
NewLeasePeriod { lease_period: LeasePeriodOf<T> },
@@ -136,7 +136,7 @@ pub mod pallet {
},
}
#[pallet::error]
#[pezpallet::error]
pub enum Error<T> {
/// The teyrchain ID is not onboarding.
ParaNotOnboarding,
@@ -144,8 +144,8 @@ pub mod pallet {
LeaseError,
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
#[pezpallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pezpallet<T> {
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
if let Some((lease_period, first_block)) = Self::lease_period_index(n) {
// If we're beginning a new lease period then handle that.
@@ -159,14 +159,14 @@ pub mod pallet {
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
#[pezpallet::call]
impl<T: Config> Pezpallet<T> {
/// Just a connect into the `lease_out` call, in case Root wants to force some lease to
/// happen independently of any other on-chain mechanism to use it.
///
/// The dispatch origin for this call must match `T::ForceOrigin`.
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::force_lease())]
#[pezpallet::call_index(0)]
#[pezpallet::weight(T::WeightInfo::force_lease())]
pub fn force_lease(
origin: OriginFor<T>,
para: ParaId,
@@ -184,8 +184,8 @@ pub mod pallet {
/// Clear all leases for a Para Id, refunding any deposits back to the original owners.
///
/// The dispatch origin for this call must match `T::ForceOrigin`.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::clear_all_leases())]
#[pezpallet::call_index(1)]
#[pezpallet::weight(T::WeightInfo::clear_all_leases())]
pub fn clear_all_leases(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
T::ForceOrigin::ensure_origin(origin)?;
let deposits = Self::all_deposits_held(para);
@@ -207,8 +207,8 @@ pub mod pallet {
/// let them onboard from here.
///
/// Origin must be signed, but can be called by anyone.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::trigger_onboard())]
#[pezpallet::call_index(2)]
#[pezpallet::weight(T::WeightInfo::trigger_onboard())]
pub fn trigger_onboard(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
ensure_signed(origin)?;
let leases = Leases::<T>::get(para);
@@ -224,7 +224,7 @@ pub mod pallet {
}
}
impl<T: Config> Pallet<T> {
impl<T: Config> Pezpallet<T> {
/// A new lease period is beginning. We're at the start of the first block of it.
///
/// We need to on-board and off-board teyrchains as needed. We should also handle reducing/
@@ -328,13 +328,13 @@ impl<T: Config> Pallet<T> {
}
}
impl<T: Config> crate::traits::OnSwap for Pallet<T> {
impl<T: Config> crate::traits::OnSwap for Pezpallet<T> {
fn on_swap(one: ParaId, other: ParaId) {
Leases::<T>::mutate(one, |x| Leases::<T>::mutate(other, |y| core::mem::swap(x, y)))
}
}
impl<T: Config> Leaser<BlockNumberFor<T>> for Pallet<T> {
impl<T: Config> Leaser<BlockNumberFor<T>> for Pezpallet<T> {
type AccountId = T::AccountId;
type LeasePeriod = BlockNumberFor<T>;
type Currency = T::Currency;
@@ -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 = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<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 = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<T>::block_number();
let (current_lease_period, _) = match Self::lease_period_index(now) {
Some(clp) => clp,
None => return true,
@@ -498,7 +498,7 @@ impl<T: Config> Leaser<BlockNumberFor<T>> for Pallet<T> {
}
}
/// tests for this pallet
/// tests for this pezpallet
#[cfg(test)]
mod tests {
use super::*;
@@ -965,10 +965,10 @@ mod benchmarking {
use pezframe_benchmarking::v2::*;
use crate::slots::Pallet as Slots;
use crate::slots::Pezpallet as Slots;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = pezframe_system::Pallet::<T>::events();
let events = pezframe_system::Pezpallet::<T>::events();
let system_event: <T as pezframe_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let pezframe_system::EventRecord { event, .. } = &events[events.len() - 1];
@@ -989,7 +989,7 @@ mod benchmarking {
worst_head_data,
worst_validation_code.clone(),
));
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
assert_ok!(paras::Pezpallet::<T>::add_trusted_validation_code(
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.
pezframe_system::Pallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
pezframe_system::Pezpallet::<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.
pezframe_system::Pallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
pezframe_system::Pezpallet::<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.
pezframe_system::Pallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
pezframe_system::Pezpallet::<T>::set_block_number(T::LeaseOffset::get() + One::one());
for i in 0..max_people {
let leaser = account("lease_deposit", i, 0);
+5 -5
View File
@@ -21,7 +21,7 @@ use pezframe_support::{
dispatch::RawOrigin,
traits::{Get, Hooks},
};
use pezpallet_fast_unstake::{Pallet as FastUnstake, *};
use pezpallet_fast_unstake::{Pezpallet as FastUnstake, *};
use pezpallet_staking::*;
/// register all inactive nominators for fast-unstake, and progress until they have all been
@@ -64,15 +64,15 @@ where
target: "runtime::test",
"registered {} successfully, starting at {:?}.",
Queue::<T>::count(),
pezframe_system::Pallet::<T>::block_number(),
pezframe_system::Pezpallet::<T>::block_number(),
);
while Queue::<T>::count() != 0 || Head::<T>::get().is_some() {
let now = pezframe_system::Pallet::<T>::block_number();
let now = pezframe_system::Pezpallet::<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);
pezframe_system::Pallet::<T>::read_events_no_consensus()
pezframe_system::Pezpallet::<T>::read_events_no_consensus()
.into_iter()
.map(|r| r.event)
.filter_map(|e| {
@@ -102,6 +102,6 @@ where
);
}
pezframe_system::Pallet::<T>::reset_events();
pezframe_system::Pezpallet::<T>::reset_events();
}
}
+4 -4
View File
@@ -124,7 +124,7 @@ where
let versioned_xcm = W::wrap_version(&d, xcm).map_err(|()| DestinationUnsupported)?;
versioned_xcm.check_is_decodable().map_err(|()| ExceedsMaxMessageSize)?;
let blob = versioned_xcm.encode();
dmp::Pallet::<T>::can_queue_downward_message(&config, &para, &blob)
dmp::Pezpallet::<T>::can_queue_downward_message(&config, &para, &blob)
.map_err(Into::<SendError>::into)?;
Ok(((config, para, blob), price))
@@ -134,7 +134,7 @@ where
(config, para, blob): (HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>),
) -> Result<XcmHash, SendError> {
let hash = pezsp_io::hashing::blake2_256(&blob[..]);
dmp::Pallet::<T>::queue_downward_message(&config, para, blob)
dmp::Pezpallet::<T>::queue_downward_message(&config, para, blob)
.map(|()| hash)
.map_err(|error| {
log::debug!(
@@ -148,7 +148,7 @@ where
#[cfg(feature = "runtime-benchmarks")]
fn ensure_successful_delivery(location: Option<Location>) {
if let Some((0, [Teyrchain(id)])) = location.as_ref().map(|l| l.unpack()) {
dmp::Pallet::<T>::make_teyrchain_reachable(*id);
dmp::Pezpallet::<T>::make_teyrchain_reachable(*id);
}
}
}
@@ -367,7 +367,7 @@ mod tests {
c.max_downward_message_size = u32::MAX;
});
dmp::Pallet::<crate::integration_tests::Test>::make_teyrchain_reachable(5555);
dmp::Pezpallet::<crate::integration_tests::Test>::make_teyrchain_reachable(5555);
// Check that the good message is validated:
assert_ok!(<Router as SendXcm>::validate(