--- a/pallets/scheduler-v2/Cargo.toml +++ b/pallets/scheduler-v2/Cargo.toml @@ -13,18 +13,18 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } -sp-io = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } -sp-runtime = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } -sp-std = { version = "4.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } -sp-core = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } +frame-benchmarking = { default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } +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" } +sp-io = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } +sp-runtime = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } +sp-std = { version = "4.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } +sp-core = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } [dev-dependencies] -pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } -sp-core = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.29" } +pallet-preimage = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } +sp-core = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.30" } [features] default = ["std"] --- a/pallets/scheduler-v2/src/lib.rs +++ b/pallets/scheduler-v2/src/lib.rs @@ -113,7 +113,7 @@ } impl ScheduledCall { - pub fn new(call: ::Call) -> Result { + pub fn new(call: ::RuntimeCall) -> Result { let encoded = call.encode(); let len = encoded.len(); @@ -151,8 +151,8 @@ } } - fn decode(mut data: &[u8]) -> Result<::Call, DispatchError> { - ::Call::decode(&mut data) + fn decode(mut data: &[u8]) -> Result<::RuntimeCall, DispatchError> { + ::RuntimeCall::decode(&mut data) .map_err(|_| >::ScheduledCallCorrupted.into()) } } @@ -162,14 +162,14 @@ fn peek( call: &ScheduledCall, - ) -> Result<(::Call, Option), DispatchError>; + ) -> Result<(::RuntimeCall, 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>; + ) -> Result<(::RuntimeCall, Option), DispatchError>; } impl> SchedulerPreimages for PP { @@ -182,7 +182,7 @@ fn peek( call: &ScheduledCall, - ) -> Result<(::Call, Option), DispatchError> { + ) -> Result<(::RuntimeCall, Option), DispatchError> { match call { ScheduledCall::Inline(data) => Ok((ScheduledCall::::decode(data)?, None)), ScheduledCall::PreimageLookup { @@ -200,7 +200,7 @@ fn realize( call: &ScheduledCall, - ) -> Result<(::Call, Option), DispatchError> { + ) -> Result<(::RuntimeCall, Option), DispatchError> { let r = Self::peek(call)?; Self::drop(call); Ok(r) @@ -252,7 +252,7 @@ impl WeightCounter { fn check_accrue(&mut self, w: Weight) -> bool { let test = self.used.saturating_add(w); - if test > self.limit { + if test.any_gt(self.limit) { false } else { self.used = test; @@ -261,7 +261,7 @@ } fn can_accrue(&mut self, w: Weight) -> bool { - self.used.saturating_add(w) <= self.limit + self.used.saturating_add(w).all_lte(self.limit) } } @@ -300,12 +300,12 @@ #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The aggregated origin which the dispatch will take. - type Origin: OriginTrait + type RuntimeOrigin: OriginTrait + From - + IsType<::Origin> + + IsType<::RuntimeOrigin> + Clone; /// The caller origin, overarching type of all pallets origins. @@ -317,9 +317,9 @@ + MaxEncodedLen; /// The aggregated call type. - type Call: Parameter - + Dispatchable::Origin, PostInfo = PostDispatchInfo> - + UnfilteredDispatchable::Origin> + type RuntimeCall: Parameter + + Dispatchable::RuntimeOrigin, PostInfo = PostDispatchInfo> + + UnfilteredDispatchable::RuntimeOrigin> + GetDispatchInfo + From>; @@ -329,7 +329,7 @@ /// Required origin to schedule or cancel calls. type ScheduleOrigin: EnsureOrigin< - ::Origin, + ::RuntimeOrigin, Success = ScheduledEnsureOriginSuccess, >; @@ -356,7 +356,7 @@ type CallExecutor: DispatchCall; /// Required origin to set/change calls' priority. - type PrioritySetOrigin: EnsureOrigin<::Origin>; + type PrioritySetOrigin: EnsureOrigin<::RuntimeOrigin>; } #[pallet::storage] @@ -458,7 +458,7 @@ when: T::BlockNumber, maybe_periodic: Option>, priority: Option, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; @@ -466,7 +466,7 @@ T::PrioritySetOrigin::ensure_origin(origin.clone())?; } - let origin = ::Origin::from(origin); + let origin = ::RuntimeOrigin::from(origin); Self::do_schedule( DispatchTime::At(when), maybe_periodic, @@ -481,7 +481,7 @@ #[pallet::weight(::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))] pub fn cancel(origin: OriginFor, when: T::BlockNumber, index: u32) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; - let origin = ::Origin::from(origin); + let origin = ::RuntimeOrigin::from(origin); Self::do_cancel(Some(origin.caller().clone()), (when, index))?; Ok(()) } @@ -494,7 +494,7 @@ when: T::BlockNumber, maybe_periodic: Option>, priority: Option, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; @@ -502,7 +502,7 @@ T::PrioritySetOrigin::ensure_origin(origin.clone())?; } - let origin = ::Origin::from(origin); + let origin = ::RuntimeOrigin::from(origin); Self::do_schedule_named( id, DispatchTime::At(when), @@ -518,7 +518,7 @@ #[pallet::weight(::WeightInfo::cancel_named(T::MaxScheduledPerBlock::get()))] pub fn cancel_named(origin: OriginFor, id: TaskName) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; - let origin = ::Origin::from(origin); + let origin = ::RuntimeOrigin::from(origin); Self::do_cancel_named(Some(origin.caller().clone()), id)?; Ok(()) } @@ -534,7 +534,7 @@ after: T::BlockNumber, maybe_periodic: Option>, priority: Option, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; @@ -542,7 +542,7 @@ T::PrioritySetOrigin::ensure_origin(origin.clone())?; } - let origin = ::Origin::from(origin); + let origin = ::RuntimeOrigin::from(origin); Self::do_schedule( DispatchTime::After(after), maybe_periodic, @@ -565,7 +565,7 @@ after: T::BlockNumber, maybe_periodic: Option>, priority: Option, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResult { T::ScheduleOrigin::ensure_origin(origin.clone())?; @@ -573,7 +573,7 @@ T::PrioritySetOrigin::ensure_origin(origin.clone())?; } - let origin = ::Origin::from(origin); + let origin = ::RuntimeOrigin::from(origin); Self::do_schedule_named( id, DispatchTime::After(after), @@ -592,7 +592,7 @@ priority: schedule::Priority, ) -> DispatchResult { T::PrioritySetOrigin::ensure_origin(origin.clone())?; - let origin = ::Origin::from(origin); + let origin = ::RuntimeOrigin::from(origin); Self::do_change_named_priority(origin.caller().clone(), id, priority) } } @@ -816,7 +816,7 @@ /// Resolve the call dispatch, including any post-dispatch operations. fn dispatch_call( signer: Option, - function: ::Call, + function: ::RuntimeCall, ) -> Result< Result>, TransactionValidityError, @@ -1036,9 +1036,9 @@ fn execute_dispatch( weight: &mut WeightCounter, origin: T::PalletsOrigin, - call: ::Call, + call: ::RuntimeCall, ) -> Result { - let dispatch_origin: ::Origin = origin.into(); + let dispatch_origin: ::RuntimeOrigin = origin.into(); let base_weight = match dispatch_origin.clone().as_signed() { Some(_) => T::WeightInfo::execute_dispatch_signed(), _ => T::WeightInfo::execute_dispatch_unsigned(), --- a/runtime/common/config/pallets/scheduler.rs +++ b/runtime/common/config/pallets/scheduler.rs @@ -88,10 +88,10 @@ // } impl pallet_unique_scheduler_v2::Config for Runtime { - type Event = Event; - type Origin = Origin; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type PalletsOrigin = OriginCaller; - type Call = Call; + type RuntimeCall = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureSignedOrRoot; type OriginPrivilegeCmp = EqualOrRootOnly; --- a/test-pallets/utils/src/lib.rs +++ b/test-pallets/utils/src/lib.rs @@ -27,7 +27,7 @@ use pallet_unique_scheduler_v2::{TaskName, Pallet as SchedulerPallet}; #[pallet::config] - pub trait Config: frame_system::Config + pallet_unique_scheduler::Config { + pub trait Config: frame_system::Config + pallet_unique_scheduler_v2::Config { type RuntimeEvent: From> + IsType<::RuntimeEvent>; }