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:
@@ -6,7 +6,7 @@ edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "FRAME Scheduler pallet"
|
||||
description = "FRAME Scheduler pezpallet"
|
||||
readme = "README.md"
|
||||
documentation = "https://docs.rs/pezpallet-scheduler"
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Scheduler pallet benchmarking.
|
||||
//! Scheduler pezpallet benchmarking.
|
||||
|
||||
use alloc::vec;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
@@ -35,7 +35,7 @@ const SEED: u32 = 0;
|
||||
const BLOCK_NUMBER: u32 = 2;
|
||||
|
||||
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 EventRecord { event, .. } = &events[events.len() - 1];
|
||||
@@ -56,7 +56,7 @@ fn fill_schedule<T: Config>(when: BlockNumberFor<T>, n: u32) -> Result<(), &'sta
|
||||
let call = make_call::<T>(None);
|
||||
let period = Some(((i + 100).into(), 100));
|
||||
let name = u32_to_name(i);
|
||||
Pallet::<T>::do_schedule_named(name, t, period, 0, origin.clone(), call)?;
|
||||
Pezpallet::<T>::do_schedule_named(name, t, period, 0, origin.clone(), call)?;
|
||||
}
|
||||
ensure!(Agenda::<T>::get(when).len() == n as usize, "didn't fill schedule");
|
||||
Ok(())
|
||||
@@ -141,7 +141,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
Pallet::<T>::service_agendas(&mut WeightMeter::new(), now, 0);
|
||||
Pezpallet::<T>::service_agendas(&mut WeightMeter::new(), now, 0);
|
||||
}
|
||||
|
||||
assert_eq!(IncompleteSince::<T>::get(), Some(now - One::one()));
|
||||
@@ -158,7 +158,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
Pallet::<T>::service_agenda(&mut WeightMeter::new(), true, now, now, 0);
|
||||
Pezpallet::<T>::service_agenda(&mut WeightMeter::new(), true, now, now, 0);
|
||||
}
|
||||
|
||||
assert_eq!(Agenda::<T>::get(now).len() as u32, s);
|
||||
@@ -178,7 +178,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
_result = Pallet::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
_result = Pezpallet::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
}
|
||||
|
||||
// assert!(_result.is_ok());
|
||||
@@ -201,7 +201,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
_result = Pallet::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
_result = Pezpallet::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
}
|
||||
|
||||
// assert!(result.is_ok());
|
||||
@@ -219,7 +219,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
_result = Pallet::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
_result = Pezpallet::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
}
|
||||
|
||||
// assert!(result.is_ok());
|
||||
@@ -237,7 +237,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
_result = Pallet::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
_result = Pezpallet::<T>::service_task(&mut counter, now, now, 0, true, task);
|
||||
}
|
||||
|
||||
// assert!(result.is_ok());
|
||||
@@ -253,7 +253,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
result = Pallet::<T>::execute_dispatch(&mut counter, origin, call);
|
||||
result = Pezpallet::<T>::execute_dispatch(&mut counter, origin, call);
|
||||
}
|
||||
|
||||
assert!(result.is_ok());
|
||||
@@ -271,7 +271,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
result = Pallet::<T>::execute_dispatch(&mut counter, origin, call);
|
||||
result = Pezpallet::<T>::execute_dispatch(&mut counter, origin, call);
|
||||
}
|
||||
|
||||
assert!(result.is_ok());
|
||||
@@ -395,7 +395,7 @@ mod benchmarks {
|
||||
|
||||
#[block]
|
||||
{
|
||||
Pallet::<T>::schedule_retry(
|
||||
Pezpallet::<T>::schedule_retry(
|
||||
&mut weight_counter,
|
||||
when,
|
||||
when,
|
||||
@@ -474,7 +474,7 @@ mod benchmarks {
|
||||
let address = Lookup::<T>::get(name).unwrap();
|
||||
let (when, index) = address;
|
||||
let period = BlockNumberFor::<T>::one();
|
||||
assert!(Pallet::<T>::set_retry(RawOrigin::Root.into(), (when, index), 10, period).is_ok());
|
||||
assert!(Pezpallet::<T>::set_retry(RawOrigin::Root.into(), (when, index), 10, period).is_ok());
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, (when, index));
|
||||
@@ -495,7 +495,7 @@ mod benchmarks {
|
||||
let address = Lookup::<T>::get(name).unwrap();
|
||||
let (when, index) = address;
|
||||
let period = BlockNumberFor::<T>::one();
|
||||
assert!(Pallet::<T>::set_retry_named(RawOrigin::Root.into(), name, 10, period).is_ok());
|
||||
assert!(Pezpallet::<T>::set_retry_named(RawOrigin::Root.into(), name, 10, period).is_ok());
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Root, name);
|
||||
@@ -507,7 +507,7 @@ mod benchmarks {
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite! {
|
||||
Pallet,
|
||||
Pezpallet,
|
||||
mock::new_test_ext(),
|
||||
mock::Test
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
//! [pezkuwi]: https://img.shields.io/badge/polkadot-E6007A?style=for-the-badge&logo=polkadot&logoColor=white
|
||||
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
|
||||
//!
|
||||
//! # Scheduler Pallet
|
||||
//! # Scheduler Pezpallet
|
||||
//!
|
||||
//! A Pallet for scheduling runtime calls.
|
||||
//! A Pezpallet for scheduling runtime calls.
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! This Pallet exposes capabilities for scheduling runtime calls to occur at a specified block
|
||||
//! This Pezpallet exposes capabilities for scheduling runtime calls to occur at a specified block
|
||||
//! number or at a specified period. These scheduled runtime calls may be named or anonymous and may
|
||||
//! be canceled.
|
||||
//!
|
||||
@@ -50,14 +50,14 @@
|
||||
#![doc = docify::embed!("src/tests.rs", scheduling_with_preimages_works)]
|
||||
|
||||
//!
|
||||
//! ## Pallet API
|
||||
//! ## Pezpallet API
|
||||
//!
|
||||
//! See the [`pallet`] module for more information about the interfaces this pallet exposes,
|
||||
//! See the [`pezpallet`] module for more information about the interfaces this pezpallet exposes,
|
||||
//! including its configuration trait, dispatchables, storage items, events and errors.
|
||||
//!
|
||||
//! ## Warning
|
||||
//!
|
||||
//! This Pallet executes all scheduled runtime calls in the [`on_initialize`] hook. Do not execute
|
||||
//! This Pezpallet executes all scheduled runtime calls in the [`on_initialize`] hook. Do not execute
|
||||
//! any runtime calls which should not be considered mandatory.
|
||||
//!
|
||||
//! Please be aware that any scheduled runtime calls executed in a future block may __fail__ or may
|
||||
@@ -108,7 +108,7 @@ use pezsp_runtime::{
|
||||
BoundedVec, DispatchError, RuntimeDebug,
|
||||
};
|
||||
|
||||
pub use pallet::*;
|
||||
pub use pezpallet::*;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
/// Just a simple index for naming period tasks.
|
||||
@@ -247,8 +247,8 @@ pub(crate) trait MarginalWeightInfo: WeightInfo {
|
||||
}
|
||||
impl<T: WeightInfo> MarginalWeightInfo for T {}
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod pezpallet {
|
||||
use super::*;
|
||||
use pezframe_support::{dispatch::PostDispatchInfo, pezpallet_prelude::*};
|
||||
use pezframe_system::pezpallet_prelude::{BlockNumberFor as SystemBlockNumberFor, OriginFor};
|
||||
@@ -256,12 +256,12 @@ pub mod pallet {
|
||||
/// The in-code storage version.
|
||||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(4);
|
||||
|
||||
#[pallet::pallet]
|
||||
#[pallet::storage_version(STORAGE_VERSION)]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
#[pezpallet::storage_version(STORAGE_VERSION)]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
/// `system::Config` should always be included in our implied traits.
|
||||
#[pallet::config]
|
||||
#[pezpallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
@@ -286,7 +286,7 @@ pub mod pallet {
|
||||
+ From<system::Call<Self>>;
|
||||
|
||||
/// The maximum weight that may be scheduled per block for any dispatchables.
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaximumWeight: Get<Weight>;
|
||||
|
||||
/// Required origin to schedule or cancel calls.
|
||||
@@ -306,10 +306,10 @@ pub mod pallet {
|
||||
/// NOTE:
|
||||
/// + Dependent pallets' benchmarks might require a higher limit for the setting. Set a
|
||||
/// higher limit under `runtime-benchmarks` feature.
|
||||
#[pallet::constant]
|
||||
#[pezpallet::constant]
|
||||
type MaxScheduledPerBlock: Get<u32>;
|
||||
|
||||
/// Weight information for extrinsics in this pallet.
|
||||
/// Weight information for extrinsics in this pezpallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
/// The preimage provider with which we look up call hashes to get the call.
|
||||
@@ -319,21 +319,21 @@ pub mod pallet {
|
||||
///
|
||||
/// Must return monotonically increasing values when called from consecutive blocks. It is
|
||||
/// generally expected that the values also do not differ "too much" between consecutive
|
||||
/// blocks. A future addition to this pallet will allow bigger difference between
|
||||
/// blocks. A future addition to this pezpallet will allow bigger difference between
|
||||
/// consecutive blocks to make it possible to be utilized by teyrchains with *Agile
|
||||
/// Coretime*. *Agile Coretime* teyrchains are currently not supported and must continue to
|
||||
/// use their local block number provider.
|
||||
///
|
||||
/// Can be configured to return either:
|
||||
/// - the local block number of the runtime via `pezframe_system::Pallet`
|
||||
/// - the local block number of the runtime via `pezframe_system::Pezpallet`
|
||||
/// - a remote block number, eg from the relay chain through `RelaychainDataProvider`
|
||||
/// - an arbitrary value through a custom implementation of the trait
|
||||
///
|
||||
/// Suggested values:
|
||||
/// - Solo- and Relay-chains should use `pezframe_system::Pallet`. There are no concerns with
|
||||
/// - Solo- and Relay-chains should use `pezframe_system::Pezpallet`. There are no concerns with
|
||||
/// this configuration.
|
||||
/// - Teyrchains should also use `pezframe_system::Pallet` for the time being. The scheduler
|
||||
/// pallet is not yet ready for the case that big numbers of blocks are skipped. In an
|
||||
/// - Teyrchains should also use `pezframe_system::Pezpallet` for the time being. The scheduler
|
||||
/// pezpallet is not yet ready for the case that big numbers of blocks are skipped. In an
|
||||
/// *Agile Coretime* chain with relay chain number provider configured, it could otherwise
|
||||
/// happen that the scheduler will not be able to catch up to its agendas, since too many
|
||||
/// relay blocks are missing if the teyrchain only produces blocks rarely.
|
||||
@@ -341,16 +341,16 @@ pub mod pallet {
|
||||
/// There is currently no migration provided to "hot-swap" block number providers and it is
|
||||
/// therefore highly advised to stay with the default (local) values. If you still want to
|
||||
/// swap block number providers on the fly, then please at least ensure that you do not run
|
||||
/// any pallet migration in the same runtime upgrade.
|
||||
/// any pezpallet migration in the same runtime upgrade.
|
||||
type BlockNumberProvider: BlockNumberProvider;
|
||||
}
|
||||
|
||||
/// Block number at which the agenda began incomplete execution.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type IncompleteSince<T: Config> = StorageValue<_, BlockNumberFor<T>>;
|
||||
|
||||
/// Items to be executed, indexed by the block number that they should be executed on.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Agenda<T: Config> = StorageMap<
|
||||
_,
|
||||
Twox64Concat,
|
||||
@@ -360,7 +360,7 @@ pub mod pallet {
|
||||
>;
|
||||
|
||||
/// Retry configurations for items to be executed, indexed by task address.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Retries<T: Config> = StorageMap<
|
||||
_,
|
||||
Blake2_128Concat,
|
||||
@@ -373,13 +373,13 @@ pub mod pallet {
|
||||
///
|
||||
/// For v3 -> v4 the previously unbounded identities are Blake2-256 hashed to form the v4
|
||||
/// identities.
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Lookup<T: Config> =
|
||||
StorageMap<_, Twox64Concat, TaskName, TaskAddress<BlockNumberFor<T>>>;
|
||||
|
||||
/// Events type.
|
||||
#[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> {
|
||||
/// Scheduled some task.
|
||||
Scheduled { when: BlockNumberFor<T>, index: u32 },
|
||||
@@ -413,7 +413,7 @@ pub mod pallet {
|
||||
AgendaIncomplete { when: BlockNumberFor<T> },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Failed to schedule a call
|
||||
FailedToSchedule,
|
||||
@@ -427,12 +427,12 @@ pub mod pallet {
|
||||
Named,
|
||||
}
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<SystemBlockNumberFor<T>> for Pallet<T> {
|
||||
#[pezpallet::hooks]
|
||||
impl<T: Config> Hooks<SystemBlockNumberFor<T>> for Pezpallet<T> {
|
||||
/// Execute the scheduled calls
|
||||
fn on_initialize(_now: SystemBlockNumberFor<T>) -> Weight {
|
||||
let now = T::BlockNumberProvider::current_block_number();
|
||||
let mut weight_counter = pezframe_system::Pallet::<T>::remaining_block_weight()
|
||||
let mut weight_counter = pezframe_system::Pezpallet::<T>::remaining_block_weight()
|
||||
.limit_to(T::MaximumWeight::get());
|
||||
Self::service_agendas(&mut weight_counter, now, u32::MAX);
|
||||
weight_counter.consumed()
|
||||
@@ -460,11 +460,11 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Anonymously schedule a task.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))]
|
||||
pub fn schedule(
|
||||
origin: OriginFor<T>,
|
||||
when: BlockNumberFor<T>,
|
||||
@@ -485,8 +485,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Cancel an anonymously scheduled task.
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))]
|
||||
pub fn cancel(origin: OriginFor<T>, when: BlockNumberFor<T>, index: u32) -> DispatchResult {
|
||||
T::ScheduleOrigin::ensure_origin(origin.clone())?;
|
||||
let origin = <T as Config>::RuntimeOrigin::from(origin);
|
||||
@@ -495,8 +495,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Schedule a named task.
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::schedule_named(T::MaxScheduledPerBlock::get()))]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::schedule_named(T::MaxScheduledPerBlock::get()))]
|
||||
pub fn schedule_named(
|
||||
origin: OriginFor<T>,
|
||||
id: TaskName,
|
||||
@@ -519,8 +519,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Cancel a named scheduled task.
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::cancel_named(T::MaxScheduledPerBlock::get()))]
|
||||
#[pezpallet::call_index(3)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::cancel_named(T::MaxScheduledPerBlock::get()))]
|
||||
pub fn cancel_named(origin: OriginFor<T>, id: TaskName) -> DispatchResult {
|
||||
T::ScheduleOrigin::ensure_origin(origin.clone())?;
|
||||
let origin = <T as Config>::RuntimeOrigin::from(origin);
|
||||
@@ -529,8 +529,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Anonymously schedule a task after a delay.
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))]
|
||||
#[pezpallet::call_index(4)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))]
|
||||
pub fn schedule_after(
|
||||
origin: OriginFor<T>,
|
||||
after: BlockNumberFor<T>,
|
||||
@@ -551,8 +551,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Schedule a named task after a delay.
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::schedule_named(T::MaxScheduledPerBlock::get()))]
|
||||
#[pezpallet::call_index(5)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::schedule_named(T::MaxScheduledPerBlock::get()))]
|
||||
pub fn schedule_named_after(
|
||||
origin: OriginFor<T>,
|
||||
id: TaskName,
|
||||
@@ -586,8 +586,8 @@ pub mod pallet {
|
||||
/// clones of the original task. Their retry configuration will be derived from the
|
||||
/// original task's configuration, but will have a lower value for `remaining` than the
|
||||
/// original `total_retries`.
|
||||
#[pallet::call_index(6)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::set_retry())]
|
||||
#[pezpallet::call_index(6)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::set_retry())]
|
||||
pub fn set_retry(
|
||||
origin: OriginFor<T>,
|
||||
task: TaskAddress<BlockNumberFor<T>>,
|
||||
@@ -623,8 +623,8 @@ pub mod pallet {
|
||||
/// clones of the original task. Their retry configuration will be derived from the
|
||||
/// original task's configuration, but will have a lower value for `remaining` than the
|
||||
/// original `total_retries`.
|
||||
#[pallet::call_index(7)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::set_retry_named())]
|
||||
#[pezpallet::call_index(7)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::set_retry_named())]
|
||||
pub fn set_retry_named(
|
||||
origin: OriginFor<T>,
|
||||
id: TaskName,
|
||||
@@ -654,8 +654,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Removes the retry configuration of a task.
|
||||
#[pallet::call_index(8)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::cancel_retry())]
|
||||
#[pezpallet::call_index(8)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::cancel_retry())]
|
||||
pub fn cancel_retry(
|
||||
origin: OriginFor<T>,
|
||||
task: TaskAddress<BlockNumberFor<T>>,
|
||||
@@ -668,8 +668,8 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Cancel the retry configuration of a named task.
|
||||
#[pallet::call_index(9)]
|
||||
#[pallet::weight(<T as Config>::WeightInfo::cancel_retry_named())]
|
||||
#[pezpallet::call_index(9)]
|
||||
#[pezpallet::weight(<T as Config>::WeightInfo::cancel_retry_named())]
|
||||
pub fn cancel_retry_named(origin: OriginFor<T>, id: TaskName) -> DispatchResult {
|
||||
T::ScheduleOrigin::ensure_origin(origin.clone())?;
|
||||
let origin = <T as Config>::RuntimeOrigin::from(origin);
|
||||
@@ -681,7 +681,7 @@ pub mod pallet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Migrate storage format from V1 to V4.
|
||||
///
|
||||
/// Returns the weight consumed by this migration.
|
||||
@@ -928,8 +928,8 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
/// Helper to migrate scheduler when the pallet origin type has changed.
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Helper to migrate scheduler when the pezpallet origin type has changed.
|
||||
pub fn migrate_origin<OldOrigin: Into<T::PalletsOrigin> + codec::Decode>() {
|
||||
Agenda::<T>::translate::<
|
||||
Vec<
|
||||
@@ -1226,7 +1226,7 @@ enum ServiceTaskError {
|
||||
}
|
||||
use ServiceTaskError::*;
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
impl<T: Config> Pezpallet<T> {
|
||||
/// Service up to `max` agendas queue starting from earliest incompletely executed agenda.
|
||||
fn service_agendas(weight: &mut WeightMeter, now: BlockNumberFor<T>, max: u32) {
|
||||
if weight.try_consume(T::WeightInfo::service_agendas_base()).is_err() {
|
||||
@@ -1533,7 +1533,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl<T: Config> schedule::v2::Anon<BlockNumberFor<T>, <T as Config>::RuntimeCall, T::PalletsOrigin>
|
||||
for Pallet<T>
|
||||
for Pezpallet<T>
|
||||
{
|
||||
type Address = TaskAddress<BlockNumberFor<T>>;
|
||||
type Hash = T::Hash;
|
||||
@@ -1569,7 +1569,7 @@ impl<T: Config> schedule::v2::Anon<BlockNumberFor<T>, <T as Config>::RuntimeCall
|
||||
// TODO: migrate `schedule::v2::Anon` to `v3`
|
||||
#[allow(deprecated)]
|
||||
impl<T: Config> schedule::v2::Named<BlockNumberFor<T>, <T as Config>::RuntimeCall, T::PalletsOrigin>
|
||||
for Pallet<T>
|
||||
for Pezpallet<T>
|
||||
{
|
||||
type Address = TaskAddress<BlockNumberFor<T>>;
|
||||
type Hash = T::Hash;
|
||||
@@ -1610,7 +1610,7 @@ impl<T: Config> schedule::v2::Named<BlockNumberFor<T>, <T as Config>::RuntimeCal
|
||||
}
|
||||
|
||||
impl<T: Config> schedule::v3::Anon<BlockNumberFor<T>, <T as Config>::RuntimeCall, T::PalletsOrigin>
|
||||
for Pallet<T>
|
||||
for Pezpallet<T>
|
||||
{
|
||||
type Address = TaskAddress<BlockNumberFor<T>>;
|
||||
type Hasher = T::Hashing;
|
||||
@@ -1649,7 +1649,7 @@ impl<T: Config> schedule::v3::Anon<BlockNumberFor<T>, <T as Config>::RuntimeCall
|
||||
use schedule::v3::TaskName;
|
||||
|
||||
impl<T: Config> schedule::v3::Named<BlockNumberFor<T>, <T as Config>::RuntimeCall, T::PalletsOrigin>
|
||||
for Pallet<T>
|
||||
for Pezpallet<T>
|
||||
{
|
||||
type Address = TaskAddress<BlockNumberFor<T>>;
|
||||
type Hasher = T::Hashing;
|
||||
@@ -1683,7 +1683,7 @@ impl<T: Config> schedule::v3::Named<BlockNumberFor<T>, <T as Config>::RuntimeCal
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps a pallet error to an `schedule::v3` error.
|
||||
/// Maps a pezpallet error to an `schedule::v3` error.
|
||||
fn map_err_to_v3_err<T: Config>(err: DispatchError) -> DispatchError {
|
||||
if err == DispatchError::from(Error::<T>::NotFound) {
|
||||
DispatchError::Unavailable
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Migrations for the scheduler pallet.
|
||||
//! Migrations for the scheduler pezpallet.
|
||||
|
||||
use super::*;
|
||||
use pezframe_support::traits::OnRuntimeUpgrade;
|
||||
@@ -32,7 +32,7 @@ pub mod v1 {
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
pub(crate) type Agenda<T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Pezpallet<T>,
|
||||
Twox64Concat,
|
||||
BlockNumberFor<T>,
|
||||
Vec<Option<ScheduledV1<<T as Config>::RuntimeCall, BlockNumberFor<T>>>>,
|
||||
@@ -41,7 +41,7 @@ pub mod v1 {
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
pub(crate) type Lookup<T: Config> =
|
||||
StorageMap<Pallet<T>, Twox64Concat, Vec<u8>, TaskAddress<BlockNumberFor<T>>>;
|
||||
StorageMap<Pezpallet<T>, Twox64Concat, Vec<u8>, TaskAddress<BlockNumberFor<T>>>;
|
||||
}
|
||||
|
||||
pub mod v2 {
|
||||
@@ -50,7 +50,7 @@ pub mod v2 {
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
pub(crate) type Agenda<T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Pezpallet<T>,
|
||||
Twox64Concat,
|
||||
BlockNumberFor<T>,
|
||||
Vec<Option<ScheduledV2Of<T>>>,
|
||||
@@ -59,7 +59,7 @@ pub mod v2 {
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
pub(crate) type Lookup<T: Config> =
|
||||
StorageMap<Pallet<T>, Twox64Concat, Vec<u8>, TaskAddress<BlockNumberFor<T>>>;
|
||||
StorageMap<Pezpallet<T>, Twox64Concat, Vec<u8>, TaskAddress<BlockNumberFor<T>>>;
|
||||
}
|
||||
|
||||
pub mod v3 {
|
||||
@@ -68,7 +68,7 @@ pub mod v3 {
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
pub(crate) type Agenda<T: Config> = StorageMap<
|
||||
Pallet<T>,
|
||||
Pezpallet<T>,
|
||||
Twox64Concat,
|
||||
BlockNumberFor<T>,
|
||||
Vec<Option<ScheduledV3Of<T>>>,
|
||||
@@ -77,15 +77,15 @@ pub mod v3 {
|
||||
|
||||
#[pezframe_support::storage_alias]
|
||||
pub(crate) type Lookup<T: Config> =
|
||||
StorageMap<Pallet<T>, Twox64Concat, Vec<u8>, TaskAddress<BlockNumberFor<T>>>;
|
||||
StorageMap<Pezpallet<T>, Twox64Concat, Vec<u8>, TaskAddress<BlockNumberFor<T>>>;
|
||||
|
||||
/// Migrate the scheduler pallet from V3 to V4.
|
||||
/// Migrate the scheduler pezpallet from V3 to V4.
|
||||
pub struct MigrateToV4<T>(core::marker::PhantomData<T>);
|
||||
|
||||
impl<T: Config> OnRuntimeUpgrade for MigrateToV4<T> {
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
|
||||
ensure!(StorageVersion::get::<Pallet<T>>() == 3, "Can only upgrade from version 3");
|
||||
ensure!(StorageVersion::get::<Pezpallet<T>>() == 3, "Can only upgrade from version 3");
|
||||
|
||||
let agendas = Agenda::<T>::iter_keys().count() as u32;
|
||||
let decodable_agendas = Agenda::<T>::iter_values().count() as u32;
|
||||
@@ -141,7 +141,7 @@ pub mod v3 {
|
||||
}
|
||||
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
let version = StorageVersion::get::<Pallet<T>>();
|
||||
let version = StorageVersion::get::<Pezpallet<T>>();
|
||||
if version != 3 {
|
||||
log::warn!(
|
||||
target: TARGET,
|
||||
@@ -152,12 +152,12 @@ pub mod v3 {
|
||||
return T::DbWeight::get().reads(1);
|
||||
}
|
||||
|
||||
crate::Pallet::<T>::migrate_v3_to_v4()
|
||||
crate::Pezpallet::<T>::migrate_v3_to_v4()
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(state: Vec<u8>) -> Result<(), TryRuntimeError> {
|
||||
ensure!(StorageVersion::get::<Pallet<T>>() == 4, "Must upgrade");
|
||||
ensure!(StorageVersion::get::<Pezpallet<T>>() == 4, "Must upgrade");
|
||||
|
||||
// Check that everything decoded fine.
|
||||
for k in crate::Agenda::<T>::iter_keys() {
|
||||
@@ -192,14 +192,14 @@ pub mod v4 {
|
||||
/// This migration cleans up empty agendas of the V4 scheduler.
|
||||
///
|
||||
/// This should be run on a scheduler that does not have
|
||||
/// <https://github.com/pezkuwichain/kurdistan-sdk/issues/41> since it piles up `None`-only agendas. This does not modify the pallet version.
|
||||
/// <https://github.com/pezkuwichain/kurdistan-sdk/issues/41> since it piles up `None`-only agendas. This does not modify the pezpallet version.
|
||||
pub struct CleanupAgendas<T>(core::marker::PhantomData<T>);
|
||||
|
||||
impl<T: Config> OnRuntimeUpgrade for CleanupAgendas<T> {
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, TryRuntimeError> {
|
||||
assert_eq!(
|
||||
StorageVersion::get::<Pallet<T>>(),
|
||||
StorageVersion::get::<Pezpallet<T>>(),
|
||||
4,
|
||||
"Can only cleanup agendas of the V4 scheduler"
|
||||
);
|
||||
@@ -218,7 +218,7 @@ pub mod v4 {
|
||||
}
|
||||
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
let version = StorageVersion::get::<Pallet<T>>();
|
||||
let version = StorageVersion::get::<Pezpallet<T>>();
|
||||
if version != 4 {
|
||||
log::warn!(target: TARGET, "Skipping CleanupAgendas migration since it was run on the wrong version: {:?} != 4", version);
|
||||
return T::DbWeight::get().reads(1);
|
||||
@@ -266,14 +266,14 @@ pub mod v4 {
|
||||
}
|
||||
}
|
||||
|
||||
// We don't modify the pallet version.
|
||||
// We don't modify the pezpallet version.
|
||||
|
||||
T::DbWeight::get().reads_writes(1 + keys.len().saturating_mul(2) as u64, writes)
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(state: Vec<u8>) -> Result<(), TryRuntimeError> {
|
||||
ensure!(StorageVersion::get::<Pallet<T>>() == 4, "Version must not change");
|
||||
ensure!(StorageVersion::get::<Pezpallet<T>>() == 4, "Version must not change");
|
||||
|
||||
let (old_agendas, non_empty_agendas): (u32, u32) =
|
||||
Decode::decode(&mut state.as_ref()).expect("Must decode pre_upgrade state");
|
||||
|
||||
@@ -29,7 +29,7 @@ use pezsp_runtime::{BuildStorage, Perbill};
|
||||
use pezsp_weights::constants::WEIGHT_REF_TIME_PER_SECOND;
|
||||
|
||||
// Logger module to track execution.
|
||||
#[pezframe_support::pallet]
|
||||
#[pezframe_support::pezpallet]
|
||||
pub mod logger {
|
||||
use super::{OriginCaller, OriginTrait};
|
||||
use pezframe_support::{pezpallet_prelude::*, parameter_types};
|
||||
@@ -42,13 +42,13 @@ pub mod logger {
|
||||
Log::get().clone()
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
#[pezpallet::pezpallet]
|
||||
pub struct Pezpallet<T>(_);
|
||||
|
||||
#[pallet::storage]
|
||||
#[pezpallet::storage]
|
||||
pub type Threshold<T: Config> = StorageValue<_, (BlockNumberFor<T>, BlockNumberFor<T>)>;
|
||||
|
||||
#[pallet::error]
|
||||
#[pezpallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Under the threshold.
|
||||
TooEarly,
|
||||
@@ -56,28 +56,28 @@ pub mod logger {
|
||||
TooLate,
|
||||
}
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
|
||||
#[pezpallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for 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>;
|
||||
}
|
||||
|
||||
#[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> {
|
||||
Logged(u32, Weight),
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T>
|
||||
#[pezpallet::call]
|
||||
impl<T: Config> Pezpallet<T>
|
||||
where
|
||||
<T as pezframe_system::Config>::RuntimeOrigin: OriginTrait<PalletsOrigin = OriginCaller>,
|
||||
{
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(*weight)]
|
||||
#[pezpallet::call_index(0)]
|
||||
#[pezpallet::weight(*weight)]
|
||||
pub fn log(origin: OriginFor<T>, i: u32, weight: Weight) -> DispatchResult {
|
||||
Self::deposit_event(Event::Logged(i, weight));
|
||||
Log::mutate(|log| {
|
||||
@@ -86,8 +86,8 @@ pub mod logger {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(*weight)]
|
||||
#[pezpallet::call_index(1)]
|
||||
#[pezpallet::weight(*weight)]
|
||||
pub fn log_without_filter(origin: OriginFor<T>, i: u32, weight: Weight) -> DispatchResult {
|
||||
Self::deposit_event(Event::Logged(i, weight));
|
||||
Log::mutate(|log| {
|
||||
@@ -96,10 +96,10 @@ pub mod logger {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(*weight)]
|
||||
#[pezpallet::call_index(2)]
|
||||
#[pezpallet::weight(*weight)]
|
||||
pub fn timed_log(origin: OriginFor<T>, i: u32, weight: Weight) -> DispatchResult {
|
||||
let now = pezframe_system::Pallet::<T>::block_number();
|
||||
let now = pezframe_system::Pezpallet::<T>::block_number();
|
||||
let (start, end) = Threshold::<T>::get().unwrap_or((0u32.into(), u32::MAX.into()));
|
||||
ensure!(now >= start, Error::<T>::TooEarly);
|
||||
ensure!(now <= end, Error::<T>::TooLate);
|
||||
@@ -230,7 +230,7 @@ impl Config for Test {
|
||||
type MaxScheduledPerBlock = ConstU32<10>;
|
||||
type WeightInfo = TestWeightInfo;
|
||||
type Preimages = Preimage;
|
||||
type BlockNumberProvider = pezframe_system::Pallet<Self>;
|
||||
type BlockNumberProvider = pezframe_system::Pezpallet<Self>;
|
||||
}
|
||||
|
||||
pub type LoggerCall = logger::Call<Test>;
|
||||
|
||||
@@ -1392,7 +1392,7 @@ fn try_schedule_retry_respects_weight_limits() {
|
||||
assert_eq!(Retries::<Test>::iter().count(), 0);
|
||||
assert_eq!(logger::log(), vec![]);
|
||||
// check the `RetryFailed` event happened
|
||||
let events = pezframe_system::Pallet::<Test>::events();
|
||||
let events = pezframe_system::Pezpallet::<Test>::events();
|
||||
let system_event: <Test as pezframe_system::Config>::RuntimeEvent =
|
||||
Event::RetryFailed { task: (4, 0), id: None }.into();
|
||||
// compare to the last event record
|
||||
@@ -1693,7 +1693,7 @@ fn on_initialize_weight_is_correct() {
|
||||
);
|
||||
assert_eq!(IncompleteSince::<Test>::get(), Some(now + 1));
|
||||
|
||||
pezframe_system::Pallet::<Test>::register_extra_weight_unchecked(
|
||||
pezframe_system::Pezpallet::<Test>::register_extra_weight_unchecked(
|
||||
BlockWeights::get().max_block,
|
||||
pezframe_support::dispatch::DispatchClass::Mandatory,
|
||||
);
|
||||
|
||||
@@ -44,10 +44,10 @@
|
||||
// frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// pezpallet
|
||||
// --extrinsic=*
|
||||
// --runtime=target/production/wbuild/pez-kitchensink-runtime/pez_kitchensink_runtime.wasm
|
||||
// --pallet=pezpallet_scheduler
|
||||
// --pezpallet=pezpallet_scheduler
|
||||
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
|
||||
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/scheduler/src/weights.rs
|
||||
// --wasm-execution=compiled
|
||||
|
||||
Reference in New Issue
Block a user