12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#![cfg_attr(not(feature = "std"), no_std)]53#![allow(clippy::type_complexity, clippy::boxed_local, clippy::unused_unit)]5455mod benchmarking;56pub mod weights;5758use sp_std::{prelude::*, marker::PhantomData, borrow::Borrow, cmp};59use codec::{Encode, Decode, Codec};60use sp_runtime::{61 RuntimeDebug,62 traits::{Zero, One, BadOrigin, Saturating},63};64use frame_support::{65 decl_module, decl_storage, decl_event, decl_error,66 dispatch::{Dispatchable, DispatchError, DispatchResult, Parameter},67 traits::{68 Get,69 schedule::{self, DispatchTime},70 OriginTrait, EnsureOrigin, IsType,71 },72 weights::{GetDispatchInfo, Weight},73};74use frame_system::{self as system, ensure_signed};75pub use weights::WeightInfo;76use scale_info::TypeInfo;77use sp_runtime::ApplyExtrinsicResult;78use sp_runtime::traits::{IdentifyAccount, Verify};79use sp_runtime::{MultiSignature};8081pub trait ApplyExtrinsic<C: Dispatchable> {82 fn apply_extrinsic(signer: Address, function: C) -> ApplyExtrinsicResult;83}848586pub type Signature = MultiSignature;87pub type Address = sp_runtime::MultiAddress<AccountId, ()>;88pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;8990919293949596pub trait Config: system::Config {97 98 type Event: From<Event<Self>> + Into<<Self as system::Config>::Event>;99100 101 type Origin: OriginTrait<PalletsOrigin = Self::PalletsOrigin>102 + From<Self::PalletsOrigin>103 + IsType<<Self as system::Config>::Origin>;104105 106 type PalletsOrigin: From<system::RawOrigin<Self::AccountId>> + Codec + TypeInfo + Clone + Eq;107108 109 type Call: Parameter110 + Dispatchable<Origin = <Self as Config>::Origin>111 + GetDispatchInfo112 + From<system::Call<Self>>;113114 115 116 type MaximumWeight: Get<Weight>;117118 119 type ScheduleOrigin: EnsureOrigin<<Self as system::Config>::Origin>;120121 122 123 type MaxScheduledPerBlock: Get<u32>;124125 126 type WeightInfo: WeightInfo;127128 type Executor: ApplyExtrinsic<<Self as Config>::Call>;129}130131pub const MAX_TASK_ID_LENGTH_IN_BYTES: u8 = 16;132133pub const PERIODIC_CALLS_LIMIT: u32 = 100;134135136137138pub type PeriodicIndex = u32;139140pub type TaskAddress<BlockNumber> = (BlockNumber, u32);141142#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))]143#[derive(Clone, RuntimeDebug, Encode, Decode)]144struct ScheduledV1<Call, BlockNumber> {145 maybe_id: Option<Vec<u8>>,146 priority: schedule::Priority,147 call: Call,148 maybe_periodic: Option<schedule::Period<BlockNumber>>,149}150151152#[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))]153#[derive(Clone, RuntimeDebug, Encode, Decode, TypeInfo)]154pub struct ScheduledV2<Call, BlockNumber, PalletsOrigin, AccountId> {155 156 maybe_id: Option<Vec<u8>>,157 158 priority: schedule::Priority,159 160 call: Call,161 162 maybe_periodic: Option<schedule::Period<BlockNumber>>,163 164 origin: PalletsOrigin,165 _phantom: PhantomData<AccountId>,166}167168169pub type Scheduled<Call, BlockNumber, PalletsOrigin, AccountId> =170 ScheduledV2<Call, BlockNumber, PalletsOrigin, AccountId>;171172173174175#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)]176enum Releases {177 V1,178 V2,179}180181impl Default for Releases {182 fn default() -> Self {183 Releases::V1184 }185}186187#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]188pub struct CallSpec {189 module: u32,190 method: u32,191}192193decl_storage! {194 trait Store for Module<T: Config> as Scheduler {195 196 pub Agenda: map hasher(twox_64_concat) T::BlockNumber197 => Vec<Option<Scheduled<<T as Config>::Call, T::BlockNumber, T::PalletsOrigin, T::AccountId>>>;198199 pub SpecAgenda: map hasher(twox_64_concat) T::BlockNumber200 => Vec<Option<CallSpec>>;201202 203 Lookup: map hasher(twox_64_concat) Vec<u8> => Option<TaskAddress<T::BlockNumber>>;204205 206 207 208 StorageVersion build(|_| Releases::V2): Releases;209 }210}211212decl_event!(213 pub enum Event<T> where <T as system::Config>::BlockNumber {214 215 Scheduled(BlockNumber, u32),216 217 Canceled(BlockNumber, u32),218 219 Dispatched(TaskAddress<BlockNumber>, Option<Vec<u8>>, DispatchResult),220 }221);222223decl_error! {224 pub enum Error for Module<T: Config> {225 226 FailedToSchedule,227 228 NotFound,229 230 TargetBlockNumberInPast,231 232 RescheduleNoChange,233 }234}235236decl_module! {237 238 pub struct Module<T: Config> for enum Call239 where240 origin: <T as system::Config>::Origin241 {242 type Error = Error<T>;243 fn deposit_event() = default;244245 246 247 248 249 250 251 252 253 254 255 #[weight = <T as Config>::WeightInfo::schedule(T::MaxScheduledPerBlock::get())]256 fn schedule(origin,257 when: T::BlockNumber,258 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,259 priority: schedule::Priority,260 call: Box<<T as Config>::Call>,261 )262 {263 let origin = <T as Config>::Origin::from(origin);264 Self::do_schedule_nameless(DispatchTime::At(when), maybe_periodic, priority, origin.caller().clone(), *call)?;265 }266267 268 269 270 271 272 273 274 275 276 277 #[weight = <T as Config>::WeightInfo::cancel(T::MaxScheduledPerBlock::get())]278 fn cancel(origin, when: T::BlockNumber, index: u32) {279 T::ScheduleOrigin::ensure_origin(origin.clone())?;280 let origin = <T as Config>::Origin::from(origin);281 Self::do_cancel(Some(origin.caller().clone()), (when, index))?;282 }283284 285 286 287 288 289 290 291 292 293 294 #[weight = <T as Config>::WeightInfo::schedule_named(T::MaxScheduledPerBlock::get())]295 fn schedule_named(origin,296 id: Vec<u8>,297 when: T::BlockNumber,298 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,299 priority: schedule::Priority,300 call: Box<<T as Config>::Call>,301 ) {302 T::ScheduleOrigin::ensure_origin(origin.clone())?;303 let origin = <T as Config>::Origin::from(origin);304 Self::do_schedule_named(305 id, DispatchTime::At(when), maybe_periodic, priority, origin.caller().clone(), *call306 )?;307 }308309 310 311 312 313 314 315 316 317 318 319 #[weight = <T as Config>::WeightInfo::cancel_named(T::MaxScheduledPerBlock::get())]320 fn cancel_named(origin, id: Vec<u8>) {321 T::ScheduleOrigin::ensure_origin(origin.clone())?;322 let origin = <T as Config>::Origin::from(origin);323 Self::do_cancel_named(Some(origin.caller().clone()), id)?;324 }325326 327 328 329 330 331 #[weight = <T as Config>::WeightInfo::schedule(T::MaxScheduledPerBlock::get())]332 fn schedule_after(origin,333 after: T::BlockNumber,334 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,335 priority: schedule::Priority,336 call: Box<<T as Config>::Call>,337 ) {338 T::ScheduleOrigin::ensure_origin(origin.clone())?;339 let origin = <T as Config>::Origin::from(origin);340 Self::do_schedule_nameless(341 DispatchTime::After(after), maybe_periodic, priority, origin.caller().clone(), *call342 )?;343 }344345 346 347 348 349 350 #[weight = <T as Config>::WeightInfo::schedule_named(T::MaxScheduledPerBlock::get())]351 fn schedule_named_after(origin,352 id: Vec<u8>,353 after: T::BlockNumber,354 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,355 priority: schedule::Priority,356 call: Box<<T as Config>::Call>,357 ) {358 T::ScheduleOrigin::ensure_origin(origin.clone())?;359 let origin = <T as Config>::Origin::from(origin);360 Self::do_schedule_named(361 id, DispatchTime::After(after), maybe_periodic, priority, origin.caller().clone(), *call362 )?;363 }364365 366 367 368 369 370 371 372 373 374 375 376 fn on_initialize(now: T::BlockNumber) -> Weight {377 let limit = T::MaximumWeight::get();378 let mut queued = Agenda::<T>::take(now)379 .into_iter()380 .enumerate()381 .filter_map(|(index, s)| s.map(|inner| (index as u32, inner)))382 .collect::<Vec<_>>();383 if queued.len() as u32 > T::MaxScheduledPerBlock::get() {384 log::warn!(385 target: "runtime::scheduler",386 "Warning: This block has more items queued in Scheduler than \387 expected from the runtime configuration. An update might be needed."388 );389 }390 queued.sort_by_key(|(_, s)| s.priority);391 let base_weight: Weight = T::DbWeight::get().reads_writes(1, 2); 392 let mut total_weight: Weight = 0; 393 queued.into_iter()394 .enumerate()395 .scan(base_weight, |cumulative_weight, (order, (index, s))| {396 *cumulative_weight = cumulative_weight397 .saturating_add(s.call.get_dispatch_info().weight);398399 let origin = <<T as Config>::Origin as From<T::PalletsOrigin>>::from(400 s.origin.clone()401 ).into();402403 if ensure_signed(origin).is_ok() {404 405 *cumulative_weight = cumulative_weight406 .saturating_add(T::DbWeight::get().reads_writes(1, 1));407 }408409 if s.maybe_id.is_some() {410 411 *cumulative_weight = cumulative_weight.saturating_add(T::DbWeight::get().writes(1));412 }413 if s.maybe_periodic.is_some() {414 415 *cumulative_weight = cumulative_weight.saturating_add(T::DbWeight::get().reads_writes(1, 1));416 }417418 Some((order, index, *cumulative_weight, s))419 })420 .filter_map(|(order, index, cumulative_weight, mut s)| {421 422 423 424 425 if s.priority <= schedule::HARD_DEADLINE || cumulative_weight <= limit || order == 0 {426427 428 429 430 431 432 433 434 let maybe_id = s.maybe_id.clone();435 if let Some((period, count)) = s.maybe_periodic {436 if count > 1 {437 s.maybe_periodic = Some((period, count - 1));438 } else {439 s.maybe_periodic = None;440 }441 let next = now + period;442 443 if let Some(ref id) = s.maybe_id {444 let next_index = Agenda::<T>::decode_len(now + period).unwrap_or(0);445 Lookup::<T>::insert(id, (next, next_index as u32));446 }447 Agenda::<T>::append(next, Some(s));448 } else if let Some(ref id) = s.maybe_id {449 Lookup::<T>::remove(id);450 }451 Self::deposit_event(RawEvent::Dispatched(452 (now, index),453 maybe_id,454 Ok(())455 ));456 total_weight = cumulative_weight;457 None458 } else {459 Some(Some(s))460 }461 })462 .for_each(|unused| {463 let next = now + One::one();464 Agenda::<T>::append(next, unused);465 });466467 total_weight468 }469 }470}471472impl<T: Config> Module<T> {473 fn resolve_time(when: DispatchTime<T::BlockNumber>) -> Result<T::BlockNumber, DispatchError> {474 let now = frame_system::Pallet::<T>::block_number();475476 let when = match when {477 DispatchTime::At(x) => x,478 479 480 DispatchTime::After(x) => now.saturating_add(x).saturating_add(One::one()),481 };482483 if when <= now {484 return Err(Error::<T>::TargetBlockNumberInPast.into());485 }486487 Ok(when)488 }489490 fn do_schedule(491 maybe_id: Option<Vec<u8>>,492 when: DispatchTime<T::BlockNumber>,493 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,494 priority: schedule::Priority,495 origin: T::PalletsOrigin,496 call: <T as Config>::Call,497 ) -> Result<(T::BlockNumber, u32), DispatchError> {498 let when = Self::resolve_time(when)?;499500 let sender = ensure_signed(501 <<T as Config>::Origin as From<T::PalletsOrigin>>::from(origin.clone()).into(),502 )503 .unwrap_or_default();504 let who_will_pay = sender; 505 let sponsor = T::PalletsOrigin::from(system::RawOrigin::Signed(who_will_pay));506 let r = call.clone().dispatch(sponsor.into());507508 509 510511 512 let maybe_periodic = maybe_periodic513 .filter(|p| p.1 > 1 && !p.0.is_zero())514 515 .map(|(p, c)| (p, cmp::min(c, PERIODIC_CALLS_LIMIT) - 1));516517 let s = Some(Scheduled {518 maybe_id,519 priority,520 call,521 maybe_periodic,522 origin,523 _phantom: PhantomData::<T::AccountId>::default(),524 });525 Agenda::<T>::append(when, s);526 let index = Agenda::<T>::decode_len(when).unwrap_or(1) as u32 - 1;527 if index > T::MaxScheduledPerBlock::get() {528 log::warn!(529 target: "runtime::scheduler",530 "Warning: There are more items queued in the Scheduler than \531 expected from the runtime configuration. An update might be needed.",532 );533 }534535 Ok((when, index))536 }537538 fn do_schedule_nameless(539 when: DispatchTime<T::BlockNumber>,540 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,541 priority: schedule::Priority,542 origin: T::PalletsOrigin,543 call: <T as Config>::Call,544 ) -> Result<TaskAddress<T::BlockNumber>, DispatchError> {545 let address = Self::do_schedule(None, when, maybe_periodic, priority, origin, call)?;546 let (when, index) = address;547548 Self::deposit_event(RawEvent::Scheduled(when, index));549550 Ok(address)551 }552553 fn do_cancel(554 origin: Option<T::PalletsOrigin>,555 (when, index): TaskAddress<T::BlockNumber>,556 ) -> Result<(), DispatchError> {557 let scheduled = Agenda::<T>::try_mutate(when, |agenda| {558 agenda.get_mut(index as usize).map_or(559 Ok(None),560 |s| -> Result<Option<Scheduled<_, _, _, _>>, DispatchError> {561 if let (Some(ref o), Some(ref s)) = (origin, s.borrow()) {562 if *o != s.origin {563 return Err(BadOrigin.into());564 }565 };566 Ok(s.take())567 },568 )569 })?;570 if let Some(s) = scheduled {571 if let Some(id) = s.maybe_id {572 Lookup::<T>::remove(id);573 574 }575 Self::deposit_event(RawEvent::Canceled(when, index));576 Ok(())577 } else {578 Err(Error::<T>::NotFound.into())579 }580 }581582 fn do_reschedule(583 (when, index): TaskAddress<T::BlockNumber>,584 new_time: DispatchTime<T::BlockNumber>,585 ) -> Result<TaskAddress<T::BlockNumber>, DispatchError> {586 let new_time = Self::resolve_time(new_time)?;587588 if new_time == when {589 return Err(Error::<T>::RescheduleNoChange.into());590 }591592 Agenda::<T>::try_mutate(when, |agenda| -> DispatchResult {593 let task = agenda.get_mut(index as usize).ok_or(Error::<T>::NotFound)?;594 let task = task.take().ok_or(Error::<T>::NotFound)?;595 Agenda::<T>::append(new_time, Some(task));596 Ok(())597 })?;598599 let new_index = Agenda::<T>::decode_len(new_time).unwrap_or(1) as u32 - 1;600 Self::deposit_event(RawEvent::Canceled(when, index));601 Self::deposit_event(RawEvent::Scheduled(new_time, new_index));602603 Ok((new_time, new_index))604 }605606 fn do_schedule_named(607 id: Vec<u8>,608 when: DispatchTime<T::BlockNumber>,609 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,610 priority: schedule::Priority,611 origin: T::PalletsOrigin,612 call: <T as Config>::Call,613 ) -> Result<TaskAddress<T::BlockNumber>, DispatchError> {614 615 if id.len() > MAX_TASK_ID_LENGTH_IN_BYTES.try_into().unwrap()616 || Lookup::<T>::contains_key(&id)617 {618 return Err(Error::<T>::FailedToSchedule.into());619 }620621 let address = Self::do_schedule(622 Some(id.clone()),623 when,624 maybe_periodic,625 priority,626 origin,627 call,628 )?;629 let (when, index) = address;630631 Lookup::<T>::insert(&id, &address);632 Self::deposit_event(RawEvent::Scheduled(when, index));633 Ok(address)634 }635636 fn do_cancel_named(origin: Option<T::PalletsOrigin>, id: Vec<u8>) -> DispatchResult {637 Lookup::<T>::try_mutate_exists(id, |lookup| -> DispatchResult {638 if let Some((when, index)) = lookup.take() {639 let i = index as usize;640 Agenda::<T>::try_mutate(when, |agenda| -> DispatchResult {641 if let Some(s) = agenda.get_mut(i) {642 if let (Some(ref o), Some(ref s)) = (origin, s.borrow()) {643 if *o != s.origin {644 return Err(BadOrigin.into());645 }646 }647 *s = None;648 }649 Ok(())650 })?;651 652 Self::deposit_event(RawEvent::Canceled(when, index));653 Ok(())654 } else {655 Err(Error::<T>::NotFound.into())656 }657 })658 }659660 fn do_reschedule_named(661 id: Vec<u8>,662 new_time: DispatchTime<T::BlockNumber>,663 ) -> Result<TaskAddress<T::BlockNumber>, DispatchError> {664 let new_time = Self::resolve_time(new_time)?;665666 Lookup::<T>::try_mutate_exists(667 id,668 |lookup| -> Result<TaskAddress<T::BlockNumber>, DispatchError> {669 let (when, index) = lookup.ok_or(Error::<T>::NotFound)?;670671 if new_time == when {672 return Err(Error::<T>::RescheduleNoChange.into());673 }674675 Agenda::<T>::try_mutate(when, |agenda| -> DispatchResult {676 let task = agenda.get_mut(index as usize).ok_or(Error::<T>::NotFound)?;677 let task = task.take().ok_or(Error::<T>::NotFound)?;678 Agenda::<T>::append(new_time, Some(task));679680 Ok(())681 })?;682683 let new_index = Agenda::<T>::decode_len(new_time).unwrap_or(1) as u32 - 1;684 Self::deposit_event(RawEvent::Canceled(when, index));685 Self::deposit_event(RawEvent::Scheduled(new_time, new_index));686687 *lookup = Some((new_time, new_index));688689 Ok((new_time, new_index))690 },691 )692 }693}694695impl<T: Config> schedule::Anon<T::BlockNumber, <T as Config>::Call, T::PalletsOrigin>696 for Module<T>697{698 type Address = TaskAddress<T::BlockNumber>;699700 fn schedule(701 when: DispatchTime<T::BlockNumber>,702 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,703 priority: schedule::Priority,704 origin: T::PalletsOrigin,705 call: <T as Config>::Call,706 ) -> Result<Self::Address, DispatchError> {707 Self::do_schedule_nameless(when, maybe_periodic, priority, origin, call)708 }709710 fn cancel((when, index): Self::Address) -> Result<(), ()> {711 Self::do_cancel(None, (when, index)).map_err(|_| ())712 }713714 fn reschedule(715 address: Self::Address,716 when: DispatchTime<T::BlockNumber>,717 ) -> Result<Self::Address, DispatchError> {718 Self::do_reschedule(address, when)719 }720721 fn next_dispatch_time((when, index): Self::Address) -> Result<T::BlockNumber, ()> {722 Agenda::<T>::get(when)723 .get(index as usize)724 .ok_or(())725 .map(|_| when)726 }727}728729impl<T: Config> schedule::Named<T::BlockNumber, <T as Config>::Call, T::PalletsOrigin>730 for Module<T>731{732 type Address = TaskAddress<T::BlockNumber>;733734 fn schedule_named(735 id: Vec<u8>,736 when: DispatchTime<T::BlockNumber>,737 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,738 priority: schedule::Priority,739 origin: T::PalletsOrigin,740 call: <T as Config>::Call,741 ) -> Result<Self::Address, ()> {742 Self::do_schedule_named(id, when, maybe_periodic, priority, origin, call).map_err(|_| ())743 }744745 fn cancel_named(id: Vec<u8>) -> Result<(), ()> {746 Self::do_cancel_named(None, id).map_err(|_| ())747 }748749 fn reschedule_named(750 id: Vec<u8>,751 when: DispatchTime<T::BlockNumber>,752 ) -> Result<Self::Address, DispatchError> {753 Self::do_reschedule_named(id, when)754 }755756 fn next_dispatch_time(id: Vec<u8>) -> Result<T::BlockNumber, ()> {757 Lookup::<T>::get(id)758 .and_then(|(when, index)| Agenda::<T>::get(when).get(index as usize).map(|_| when))759 .ok_or(())760 }761}762763#[cfg(test)]764#[allow(clippy::from_over_into)]765mod tests {766 use super::*;767768 use frame_support::{769 ord_parameter_types, parameter_types, traits::Contains, weights::constants::RocksDbWeight,770 };771 use sp_core::H256;772 use sp_runtime::{773 Perbill,774 testing::Header,775 traits::{BlakeTwo256, IdentityLookup},776 };777 use frame_system::{EnsureOneOf, EnsureRoot, EnsureSignedBy};778 use crate as scheduler;779780 mod logger {781 use super::*;782 use std::cell::RefCell;783784 thread_local! {785 static LOG: RefCell<Vec<(OriginCaller, u32)>> = RefCell::new(Vec::new());786 }787 pub trait Config: system::Config {788 type Event: From<Event> + Into<<Self as system::Config>::Event>;789 }790 decl_event! {791 pub enum Event {792 Logged(u32, Weight),793 }794 }795 decl_module! {796 pub struct Module<T: Config> for enum Call797 where798 origin: <T as system::Config>::Origin,799 <T as system::Config>::Origin: OriginTrait<PalletsOrigin = OriginCaller>800 {801 fn deposit_event() = default;802803 #[weight = *weight]804 fn log(origin, i: u32, weight: Weight) {805 Self::deposit_event(Event::Logged(i, weight));806 LOG.with(|log| {807 log.borrow_mut().push((origin.caller().clone(), i));808 })809 }810811 #[weight = *weight]812 fn log_without_filter(origin, i: u32, weight: Weight) {813 Self::deposit_event(Event::Logged(i, weight));814 LOG.with(|log| {815 log.borrow_mut().push((origin.caller().clone(), i));816 })817 }818 }819 }820 }821822 type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;823 type Block = frame_system::mocking::MockBlock<Test>;824825 frame_support::construct_runtime!(826 pub enum Test where827 Block = Block,828 NodeBlock = Block,829 UncheckedExtrinsic = UncheckedExtrinsic,830 {831 System: frame_system::{Pallet, Call, Config, Storage, Event<T>},832 Logger: logger::{Pallet, Call, Event},833 Scheduler: scheduler::{Pallet, Call, Storage, Event<T>},834 }835 );836837 838 pub struct BaseFilter;839 impl Contains<Call> for BaseFilter {840 fn contains(call: &Call) -> bool {841 !matches!(call, Call::Logger(logger::Call::log { .. }))842 }843 }844845 pub struct DummyExecutor; 846 impl<C: Dispatchable> ApplyExtrinsic<C> for DummyExecutor {847 fn apply_extrinsic(_signer: Address, _function: C) -> ApplyExtrinsicResult {848 todo!()849 }850 }851852 parameter_types! {853 pub const BlockHashCount: u64 = 250;854 pub BlockWeights: frame_system::limits::BlockWeights =855 frame_system::limits::BlockWeights::simple_max(2_000_000_000_000);856 }857 impl system::Config for Test {858 type BaseCallFilter = BaseFilter;859 type BlockWeights = ();860 type BlockLength = ();861 type DbWeight = RocksDbWeight;862 type Origin = Origin;863 type Call = Call;864 type Index = u64;865 type BlockNumber = u64;866 type Hash = H256;867 type Hashing = BlakeTwo256;868 type AccountId = u64;869 type Lookup = IdentityLookup<Self::AccountId>;870 type Header = Header;871 type Event = Event;872 type BlockHashCount = BlockHashCount;873 type Version = ();874 type PalletInfo = PalletInfo;875 type AccountData = ();876 type OnNewAccount = ();877 type OnKilledAccount = ();878 type SystemWeightInfo = ();879 type SS58Prefix = ();880 type OnSetCode = ();881 }882 impl logger::Config for Test {883 type Event = Event;884 }885 parameter_types! {886 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;887 pub const MaxScheduledPerBlock: u32 = 10;888 }889 ord_parameter_types! {890 pub const One: u64 = 1;891 }892893 impl Config for Test {894 type Event = Event;895 type Origin = Origin;896 type PalletsOrigin = OriginCaller;897 type Call = Call;898 type MaximumWeight = MaximumSchedulerWeight;899 type ScheduleOrigin = EnsureOneOf<u64, EnsureRoot<u64>, EnsureSignedBy<One, u64>>;900 type MaxScheduledPerBlock = MaxScheduledPerBlock;901 type WeightInfo = ();902 type Executor = DummyExecutor;903 }904}