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