From d1cb9dcf372b74d51cbe482f1faeeeaafbeda993 Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Thu, 20 Oct 2022 10:27:37 +0000 Subject: [PATCH] fix: enable scheduler v2 --- --- a/pallets/scheduler-v2/src/benchmarking.rs +++ b/pallets/scheduler-v2/src/benchmarking.rs @@ -68,7 +68,10 @@ let name = u32_to_name(i); Scheduler::::do_schedule_named(name, t, period, 0, origin.clone(), call)?; } - ensure!(Agenda::::get(when).len() == n as usize, "didn't fill schedule"); + ensure!( + Agenda::::get(when).len() == n as usize, + "didn't fill schedule" + ); Ok(()) } @@ -93,19 +96,30 @@ false => None, }; let origin = make_origin::(signed); - Scheduled { maybe_id, priority, call, maybe_periodic, origin, _phantom: PhantomData } + Scheduled { + maybe_id, + priority, + call, + maybe_periodic, + origin, + _phantom: PhantomData, + } } fn bounded(len: u32) -> Option> { - let call = - <::Call>::from(SystemCall::remark { remark: vec![0; len as usize] }); - ScheduledCall::new(call).ok() + let call = <::Call>::from(SystemCall::remark { + remark: vec![0; len as usize], + }); + ScheduledCall::new(call).ok() } fn make_call(maybe_lookup_len: Option) -> ScheduledCall { let bound = EncodedCall::bound() as u32; let mut len = match maybe_lookup_len { - Some(len) => len.min(>::MaxSize::get() - 2).max(bound) - 3, + Some(len) => { + len.min(>::MaxSize::get() - 2) + .max(bound) - 3 + } None => bound.saturating_sub(4), }; @@ -114,11 +128,11 @@ Some(x) => x, None => { len -= 1; - continue - }, + continue; + } }; if c.lookup_needed() == maybe_lookup_len.is_some() { - break c + break c; } if maybe_lookup_len.is_some() { len += 1; @@ -126,7 +140,7 @@ if len > 0 { len -= 1; } else { - break c + break c; } } } @@ -140,11 +154,14 @@ } fn dummy_counter() -> WeightCounter { - WeightCounter { used: Weight::zero(), limit: Weight::MAX } + WeightCounter { + used: Weight::zero(), + limit: Weight::MAX, + } } benchmarks! { - // `service_agendas` when no work is done. + // `service_agendas` when no work is done. service_agendas_base { let now = T::BlockNumber::from(BLOCK_NUMBER); IncompleteSince::::put(now - One::one()); @@ -154,7 +171,7 @@ assert_eq!(IncompleteSince::::get(), Some(now - One::one())); } - // `service_agenda` when no work is done. + // `service_agenda` when no work is done. service_agenda_base { let now = BLOCK_NUMBER.into(); let s in 0 .. T::MaxScheduledPerBlock::get(); @@ -166,7 +183,7 @@ assert_eq!(executed, 0); } - // `service_task` when the task is a non-periodic, non-named, non-fetched call which is not + // `service_task` when the task is a non-periodic, non-named, non-fetched call which is not // dispatched (e.g. due to being overweight). service_task_base { let now = BLOCK_NUMBER.into(); @@ -179,7 +196,7 @@ //assert_eq!(result, Ok(())); } - // `service_task` when the task is a non-periodic, non-named, fetched call (with a known + // `service_task` when the task is a non-periodic, non-named, fetched call (with a known // preimage length) and which is not dispatched (e.g. due to being overweight). service_task_fetched { let s in (EncodedCall::bound() as u32) .. (>::MaxSize::get()); @@ -192,7 +209,7 @@ } verify { } - // `service_task` when the task is a non-periodic, named, non-fetched call which is not + // `service_task` when the task is a non-periodic, named, non-fetched call which is not // dispatched (e.g. due to being overweight). service_task_named { let now = BLOCK_NUMBER.into(); @@ -204,7 +221,7 @@ } verify { } - // `service_task` when the task is a periodic, non-named, non-fetched call which is not + // `service_task` when the task is a periodic, non-named, non-fetched call which is not // dispatched (e.g. due to being overweight). service_task_periodic { let now = BLOCK_NUMBER.into(); @@ -216,7 +233,7 @@ } verify { } - // `execute_dispatch` when the origin is `Signed`, not counting the dispatable's weight. + // `execute_dispatch` when the origin is `Signed`, not counting the dispatable's weight. execute_dispatch_signed { let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::MAX }; let origin = make_origin::(true); @@ -227,7 +244,7 @@ verify { } - // `execute_dispatch` when the origin is not `Signed`, not counting the dispatable's weight. + // `execute_dispatch` when the origin is not `Signed`, not counting the dispatable's weight. execute_dispatch_unsigned { let mut counter = WeightCounter { used: Weight::zero(), limit: Weight::MAX }; let origin = make_origin::(false); @@ -238,7 +255,7 @@ verify { } - schedule { + schedule { let s in 0 .. (T::MaxScheduledPerBlock::get() - 1); let when = BLOCK_NUMBER.into(); let periodic = Some((T::BlockNumber::one(), 100)); @@ -255,7 +272,7 @@ ); } - cancel { + cancel { let s in 1 .. T::MaxScheduledPerBlock::get(); let when = BLOCK_NUMBER.into(); @@ -275,7 +292,7 @@ ); } - schedule_named { + schedule_named { let s in 0 .. (T::MaxScheduledPerBlock::get() - 1); let id = u32_to_name(s); let when = BLOCK_NUMBER.into(); @@ -293,7 +310,7 @@ ); } - cancel_named { + cancel_named { let s in 1 .. T::MaxScheduledPerBlock::get(); let when = BLOCK_NUMBER.into(); @@ -311,5 +328,5 @@ ); } - // impl_benchmark_test_suite!(Scheduler, crate::mock::new_test_ext(), crate::mock::Test); + // impl_benchmark_test_suite!(Scheduler, crate::mock::new_test_ext(), crate::mock::Test); } --- a/pallets/scheduler-v2/src/lib.rs +++ b/pallets/scheduler-v2/src/lib.rs @@ -77,22 +77,17 @@ use codec::{Codec, Decode, Encode, MaxEncodedLen}; use frame_support::{ - dispatch::{ - DispatchError, DispatchResult, Dispatchable, GetDispatchInfo, Parameter, RawOrigin, - }, - ensure, + dispatch::{DispatchError, DispatchResult, Dispatchable, GetDispatchInfo, Parameter}, traits::{ schedule::{self, DispatchTime}, - EnsureOrigin, Get, IsType, OriginTrait, - PalletInfoAccess, PrivilegeCmp, StorageVersion, - PreimageProvider, PreimageRecipient, ConstU32, + EnsureOrigin, Get, IsType, OriginTrait, PrivilegeCmp, StorageVersion, PreimageRecipient, + ConstU32, }, weights::Weight, }; use frame_system::{self as system}; use scale_info::TypeInfo; -use sp_io::hashing::blake2_256; use sp_runtime::{ traits::{BadOrigin, One, Saturating, Zero, Hash}, BoundedVec, RuntimeDebug, @@ -112,11 +107,8 @@ #[derive(Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(T))] pub enum ScheduledCall { - Inline(EncodedCall), - PreimageLookup { - hash: T::Hash, - unbounded_len: u32, - }, + Inline(EncodedCall), + PreimageLookup { hash: T::Hash, unbounded_len: u32 }, } impl ScheduledCall { @@ -128,9 +120,16 @@ Ok(bounded) => Ok(Self::Inline(bounded)), Err(_) => { let hash = ::Hashing::hash_of(&encoded); - ::Preimages::note_preimage(encoded.try_into().map_err(|_| >::TooBigScheduledCall)?); + ::Preimages::note_preimage( + encoded + .try_into() + .map_err(|_| >::TooBigScheduledCall)?, + ); - Ok(Self::PreimageLookup { hash, unbounded_len: len as u32 }) + Ok(Self::PreimageLookup { + hash, + unbounded_len: len as u32, + }) } } } @@ -153,43 +152,54 @@ fn decode(mut data: &[u8]) -> Result<::Call, DispatchError> { ::Call::decode(&mut data) - .map_err(|_| >::ScheduledCallCorrupted.into()) + .map_err(|_| >::ScheduledCallCorrupted.into()) } } pub trait SchedulerPreimages: PreimageRecipient { - fn drop(call: &ScheduledCall); + fn drop(call: &ScheduledCall); - fn peek(call: &ScheduledCall) -> Result<(::Call, Option), DispatchError>; + fn peek( + call: &ScheduledCall, + ) -> Result<(::Call, Option), DispatchError>; /// Convert the given scheduled `call` value back into its original instance. If successful, /// `drop` any data backing it. This will not break the realisability of independently /// created instances of `ScheduledCall` which happen to have identical data. - fn realize(call: &ScheduledCall) -> Result<(::Call, Option), DispatchError>; + fn realize( + call: &ScheduledCall, + ) -> Result<(::Call, Option), DispatchError>; } impl> SchedulerPreimages for PP { - fn drop(call: &ScheduledCall) { - match call { - ScheduledCall::Inline(_) => {}, - ScheduledCall::PreimageLookup { hash, .. } => Self::unrequest_preimage(hash), - } - } + fn drop(call: &ScheduledCall) { + match call { + ScheduledCall::Inline(_) => {} + ScheduledCall::PreimageLookup { hash, .. } => Self::unrequest_preimage(hash), + } + } - fn peek(call: &ScheduledCall) -> Result<(::Call, Option), DispatchError> { + fn peek( + call: &ScheduledCall, + ) -> Result<(::Call, Option), DispatchError> { match call { ScheduledCall::Inline(data) => Ok((ScheduledCall::::decode(data)?, None)), - ScheduledCall::PreimageLookup { hash, unbounded_len } => { + ScheduledCall::PreimageLookup { + hash, + unbounded_len, + } => { let (preimage, len) = Self::get_preimage(hash) .ok_or(>::PreimageNotFound) .map(|preimage| (preimage, *unbounded_len))?; Ok((ScheduledCall::::decode(preimage.as_slice())?, Some(len))) - }, + } } } - fn realize(call: &ScheduledCall) -> Result<(::Call, Option), DispatchError> { + fn realize( + call: &ScheduledCall, + ) -> Result<(::Call, Option), DispatchError> { let r = Self::peek(call)?; Self::drop(call); Ok(r) @@ -205,16 +215,16 @@ /// The unique identity for this task, if there is one. maybe_id: Option, - /// This task's priority. + /// This task's priority. priority: schedule::Priority, - /// The call to be dispatched. + /// The call to be dispatched. call: Call, - /// If the call is periodic, then this points to the information concerning that. + /// If the call is periodic, then this points to the information concerning that. maybe_periodic: Option>, - /// The origin with which to dispatch the call. + /// The origin with which to dispatch the call. origin: PalletsOrigin, _phantom: PhantomData, } @@ -276,68 +286,66 @@ /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); - #[pallet::pallet] + #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; + type Event: From> + IsType<::Event>; - /// The aggregated origin which the dispatch will take. + /// The aggregated origin which the dispatch will take. type Origin: OriginTrait - + From - + IsType<::Origin> + + From + + IsType<::Origin> + Clone; - /// The caller origin, overarching type of all pallets origins. - type PalletsOrigin: From> - + Codec - + Clone - + Eq - + TypeInfo - + MaxEncodedLen; + /// The caller origin, overarching type of all pallets origins. + type PalletsOrigin: From> + + Codec + + Clone + + Eq + + TypeInfo + + MaxEncodedLen; - /// The aggregated call type. - type Call: Parameter - + Dispatchable< - Origin = ::Origin, - PostInfo = PostDispatchInfo, - > + GetDispatchInfo - + From>; + /// The aggregated call type. + type Call: Parameter + + Dispatchable::Origin, PostInfo = PostDispatchInfo> + + GetDispatchInfo + + From>; - /// The maximum weight that may be scheduled per block for any dispatchables. - #[pallet::constant] - type MaximumWeight: Get; + /// The maximum weight that may be scheduled per block for any dispatchables. + #[pallet::constant] + type MaximumWeight: Get; - /// Required origin to schedule or cancel calls. - type ScheduleOrigin: EnsureOrigin<::Origin>; + /// Required origin to schedule or cancel calls. + type ScheduleOrigin: EnsureOrigin<::Origin>; - /// Compare the privileges of origins. - /// - /// This will be used when canceling a task, to ensure that the origin that tries - /// to cancel has greater or equal privileges as the origin that created the scheduled task. - /// - /// For simplicity the [`EqualPrivilegeOnly`](frame_support::traits::EqualPrivilegeOnly) can - /// be used. This will only check if two given origins are equal. - type OriginPrivilegeCmp: PrivilegeCmp; + /// Compare the privileges of origins. + /// + /// This will be used when canceling a task, to ensure that the origin that tries + /// to cancel has greater or equal privileges as the origin that created the scheduled task. + /// + /// For simplicity the [`EqualPrivilegeOnly`](frame_support::traits::EqualPrivilegeOnly) can + /// be used. This will only check if two given origins are equal. + type OriginPrivilegeCmp: PrivilegeCmp; - /// The maximum number of scheduled calls in the queue for a single block. - #[pallet::constant] - type MaxScheduledPerBlock: Get; + /// The maximum number of scheduled calls in the queue for a single block. + #[pallet::constant] + type MaxScheduledPerBlock: Get; - /// Weight information for extrinsics in this pallet. - type WeightInfo: WeightInfo; + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; - /// The preimage provider with which we look up call hashes to get the call. + /// The preimage provider with which we look up call hashes to get the call. type Preimages: SchedulerPreimages; - } + } - #[pallet::storage] + #[pallet::storage] pub type IncompleteSince = StorageValue<_, T::BlockNumber>; - /// Items to be executed, indexed by the block number that they should be executed on. + /// Items to be executed, indexed by the block number that they should be executed on. #[pallet::storage] pub type Agenda = StorageMap< _, @@ -347,12 +355,12 @@ ValueQuery, >; - /// Lookup from a name to the block number and index of the task. + /// Lookup from a name to the block number and index of the task. #[pallet::storage] pub(crate) type Lookup = StorageMap<_, Twox64Concat, TaskName, TaskAddress>; - /// Events type. + /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { @@ -367,19 +375,28 @@ result: DispatchResult, }, /// The call for the provided hash was not found so the task has been aborted. - CallUnavailable { task: TaskAddress, id: Option<[u8; 32]> }, + CallUnavailable { + task: TaskAddress, + id: Option<[u8; 32]>, + }, /// The given task was unable to be renewed since the agenda is full at that block. - PeriodicFailed { task: TaskAddress, id: Option<[u8; 32]> }, + PeriodicFailed { + task: TaskAddress, + id: Option<[u8; 32]>, + }, /// The given task can never be executed since it is overweight. - PermanentlyOverweight { task: TaskAddress, id: Option<[u8; 32]> }, + PermanentlyOverweight { + task: TaskAddress, + id: Option<[u8; 32]>, + }, } - #[pallet::error] + #[pallet::error] pub enum Error { /// Failed to schedule a call FailedToSchedule, - /// There is no place for a new task in the agenda - AgendaIsExhausted, + /// There is no place for a new task in the agenda + AgendaIsExhausted, /// Scheduled call is corrupted ScheduledCallCorrupted, /// Scheduled call preimage is not found @@ -396,20 +413,22 @@ Named, } - #[pallet::hooks] + #[pallet::hooks] impl Hooks> for Pallet { /// Execute the scheduled calls fn on_initialize(now: T::BlockNumber) -> Weight { - let mut weight_counter = - WeightCounter { used: Weight::zero(), limit: T::MaximumWeight::get() }; + let mut weight_counter = WeightCounter { + used: Weight::zero(), + limit: T::MaximumWeight::get(), + }; Self::service_agendas(&mut weight_counter, now, u32::max_value()); weight_counter.used } } - #[pallet::call] + #[pallet::call] impl Pallet { - /// Anonymously schedule a task. + /// Anonymously schedule a task. #[pallet::weight(::WeightInfo::schedule(T::MaxScheduledPerBlock::get()))] pub fn schedule( origin: OriginFor, @@ -522,11 +541,11 @@ )?; Ok(()) } - } + } } impl Pallet { - fn resolve_time(when: DispatchTime) -> Result { + fn resolve_time(when: DispatchTime) -> Result { let now = frame_system::Pallet::::block_number(); let when = match when { @@ -537,13 +556,13 @@ }; if when <= now { - return Err(Error::::TargetBlockNumberInPast.into()) + return Err(Error::::TargetBlockNumberInPast.into()); } Ok(when) } - fn place_task( + fn place_task( when: T::BlockNumber, what: ScheduledOf, ) -> Result, (DispatchError, ScheduledOf)> { @@ -553,11 +572,14 @@ if let Some(name) = maybe_name { Lookup::::insert(name, address) } - Self::deposit_event(Event::Scheduled { when: address.0, index: address.1 }); + Self::deposit_event(Event::Scheduled { + when: address.0, + index: address.1, + }); Ok(address) } - fn push_to_agenda( + fn push_to_agenda( when: T::BlockNumber, what: ScheduledOf, ) -> Result)> { @@ -571,14 +593,14 @@ agenda[hole_index] = Some(what); hole_index as u32 } else { - return Err((>::AgendaIsExhausted.into(), what)) + return Err((>::AgendaIsExhausted.into(), what)); } }; Agenda::::insert(when, agenda); Ok(index) } - fn do_schedule( + fn do_schedule( when: DispatchTime, maybe_periodic: Option>, priority: schedule::Priority, @@ -603,7 +625,7 @@ Self::place_task(when, task).map_err(|x| x.0) } - fn do_cancel( + fn do_cancel( origin: Option, (when, index): TaskAddress, ) -> Result<(), DispatchError> { @@ -616,7 +638,7 @@ T::OriginPrivilegeCmp::cmp_privilege(o, &s.origin), Some(Ordering::Less) | None ) { - return Err(BadOrigin.into()) + return Err(BadOrigin.into()); } }; Ok(s.take()) @@ -624,7 +646,7 @@ ) })?; if let Some(s) = scheduled { - T::Preimages::drop(&s.call); + T::Preimages::drop(&s.call); if let Some(id) = s.maybe_id { Lookup::::remove(id); @@ -632,11 +654,11 @@ Self::deposit_event(Event::Canceled { when, index }); Ok(()) } else { - return Err(Error::::NotFound.into()) + return Err(Error::::NotFound.into()); } } - fn do_schedule_named( + fn do_schedule_named( id: TaskName, when: DispatchTime, maybe_periodic: Option>, @@ -646,7 +668,7 @@ ) -> Result, DispatchError> { // ensure id it is unique if Lookup::::contains_key(&id) { - return Err(Error::::FailedToSchedule.into()) + return Err(Error::::FailedToSchedule.into()); } let when = Self::resolve_time(when)?; @@ -668,7 +690,7 @@ Self::place_task(when, task).map_err(|x| x.0) } - fn do_cancel_named(origin: Option, id: TaskName) -> DispatchResult { + fn do_cancel_named(origin: Option, id: TaskName) -> DispatchResult { Lookup::::try_mutate_exists(id, |lookup| -> DispatchResult { if let Some((when, index)) = lookup.take() { let i = index as usize; @@ -679,7 +701,7 @@ T::OriginPrivilegeCmp::cmp_privilege(o, &s.origin), Some(Ordering::Less) | None ) { - return Err(BadOrigin.into()) + return Err(BadOrigin.into()); } T::Preimages::drop(&s.call); } @@ -690,7 +712,7 @@ Self::deposit_event(Event::Canceled { when, index }); Ok(()) } else { - return Err(Error::::NotFound.into()) + return Err(Error::::NotFound.into()); } }) } @@ -708,7 +730,7 @@ /// Service up to `max` agendas queue starting from earliest incompletely executed agenda. fn service_agendas(weight: &mut WeightCounter, now: T::BlockNumber, max: u32) { if !weight.check_accrue(T::WeightInfo::service_agendas_base()) { - return + return; } let mut incomplete_since = now + One::one(); @@ -745,13 +767,18 @@ .iter() .enumerate() .filter_map(|(index, maybe_item)| { - maybe_item.as_ref().map(|item| (index as u32, item.priority)) + maybe_item + .as_ref() + .map(|item| (index as u32, item.priority)) }) .collect::>(); ordered.sort_by_key(|k| k.1); let within_limit = weight.check_accrue(T::WeightInfo::service_agenda_base(ordered.len() as u32)); - debug_assert!(within_limit, "weight limit should have been checked in advance"); + debug_assert!( + within_limit, + "weight limit should have been checked in advance" + ); // Items which we know can be executed and have postponed for execution in a later block. let mut postponed = (ordered.len() as u32).saturating_sub(max); @@ -770,22 +797,22 @@ ); if !weight.can_accrue(base_weight) { postponed += 1; - break + break; } let result = Self::service_task(weight, now, when, agenda_index, *executed == 0, task); agenda[agenda_index as usize] = match result { Err((Unavailable, slot)) => { dropped += 1; slot - }, + } Err((Overweight, slot)) => { postponed += 1; slot - }, + } Ok(()) => { *executed += 1; None - }, + } }; } if postponed > 0 || dropped > 0 { @@ -833,7 +860,7 @@ id: task.maybe_id, }); Err((Unavailable, Some(task))) - }, + } Err(Overweight) if is_first => { T::Preimages::drop(&task.call); Self::deposit_event(Event::PermanentlyOverweight { @@ -841,7 +868,7 @@ id: task.maybe_id, }); Err((Unavailable, Some(task))) - }, + } Err(Overweight) => Err((Overweight, Some(task))), Ok(result) => { Self::deposit_event(Event::Dispatched { @@ -857,7 +884,7 @@ } let wake = now.saturating_add(period); match Self::place_task(wake, task) { - Ok(_) => {}, + Ok(_) => {} Err((_, task)) => { // TODO: Leave task in storage somewhere for it to be rescheduled // manually. @@ -866,13 +893,13 @@ task: (when, agenda_index), id: task.maybe_id, }); - }, + } } } else { T::Preimages::drop(&task.call); } Ok(()) - }, + } } } @@ -897,13 +924,15 @@ let max_weight = base_weight.saturating_add(call_weight); if !weight.can_accrue(max_weight) { - return Err(Overweight) + return Err(Overweight); } let (maybe_actual_call_weight, result) = match call.dispatch(dispatch_origin) { Ok(post_info) => (post_info.actual_weight, Ok(())), - Err(error_and_info) => - (error_and_info.post_info.actual_weight, Err(error_and_info.error)), + Err(error_and_info) => ( + error_and_info.post_info.actual_weight, + Err(error_and_info.error), + ), }; let call_weight = maybe_actual_call_weight.unwrap_or(call_weight); weight.check_accrue(base_weight); --- a/runtime/common/config/pallets/scheduler.rs +++ b/runtime/common/config/pallets/scheduler.rs @@ -70,22 +70,22 @@ } } -impl pallet_unique_scheduler::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type Currency = Balances; - type PalletsOrigin = OriginCaller; - type RuntimeCall = RuntimeCall; - type MaximumWeight = MaximumSchedulerWeight; - type ScheduleOrigin = EnsureSignedOrRoot; - type PrioritySetOrigin = EnsureRoot; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type WeightInfo = (); - type CallExecutor = SchedulerPaymentExecutor; - type OriginPrivilegeCmp = EqualOrRootOnly; - type PreimageProvider = (); - type NoPreimagePostponement = NoPreimagePostponement; -} +// impl pallet_unique_scheduler::Config for Runtime { +// type RuntimeEvent = RuntimeEvent; +// type RuntimeOrigin = RuntimeOrigin; +// type Currency = Balances; +// type PalletsOrigin = OriginCaller; +// type RuntimeCall = RuntimeCall; +// type MaximumWeight = MaximumSchedulerWeight; +// type ScheduleOrigin = EnsureSignedOrRoot; +// type PrioritySetOrigin = EnsureRoot; +// type MaxScheduledPerBlock = MaxScheduledPerBlock; +// type WeightInfo = (); +// type CallExecutor = SchedulerPaymentExecutor; +// type OriginPrivilegeCmp = EqualOrRootOnly; +// type PreimageProvider = (); +// type NoPreimagePostponement = NoPreimagePostponement; +// } impl pallet_unique_scheduler_v2::Config for Runtime { type Event = Event; --- a/runtime/common/construct_runtime/mod.rs +++ b/runtime/common/construct_runtime/mod.rs @@ -57,8 +57,8 @@ Inflation: pallet_inflation::{Pallet, Call, Storage} = 60, Unique: pallet_unique::{Pallet, Call, Storage, Event} = 61, - #[runtimes(opal)] - Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event} = 62, + // #[runtimes(opal)] + // Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event} = 62, Configuration: pallet_configuration::{Pallet, Call, Storage} = 63, @@ -97,7 +97,7 @@ Maintenance: pallet_maintenance::{Pallet, Call, Storage, Event} = 154, #[runtimes(opal)] - SchedulerV2: pallet_unique_scheduler_v2::{Pallet, Call, Storage, Event} = 154, + Scheduler: pallet_unique_scheduler_v2::{Pallet, Call, Storage, Event} = 154, #[runtimes(opal)] TestUtils: pallet_test_utils = 255, --- a/test-pallets/utils/Cargo.toml +++ b/test-pallets/utils/Cargo.toml @@ -10,7 +10,8 @@ scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } -pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false } +# pallet-unique-scheduler = { path = '../../pallets/scheduler', default-features = false } +pallet-unique-scheduler-v2 = { path = '../../pallets/scheduler-v2', default-features = false } [features] default = ["std"] @@ -19,6 +20,6 @@ "scale-info/std", "frame-support/std", "frame-system/std", - "pallet-unique-scheduler/std", + "pallet-unique-scheduler-v2/std", ] try-runtime = ["frame-support/try-runtime", "pallet-unique-scheduler/try-runtime"] --- a/test-pallets/utils/src/lib.rs +++ b/test-pallets/utils/src/lib.rs @@ -24,7 +24,7 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; - use pallet_unique_scheduler::{ScheduledId, Pallet as SchedulerPallet}; + use pallet_unique_scheduler_v2::{TaskName, Pallet as SchedulerPallet}; #[pallet::config] pub trait Config: frame_system::Config + pallet_unique_scheduler::Config { @@ -94,7 +94,7 @@ #[pallet::weight(10_000)] pub fn self_canceling_inc( origin: OriginFor, - id: ScheduledId, + id: TaskName, max_test_value: u32, ) -> DispatchResult { Self::ensure_origin_and_enabled(origin.clone())?; -- gitstuff