difftreelog
fix scheduler v2 after rebase
in: master
4 files changed
pallets/scheduler-v2/Cargo.tomldiffbeforeafterboth--- 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"]
pallets/scheduler-v2/src/lib.rsdiffbeforeafterboth113}113}114114115impl<T: Config> ScheduledCall<T> {115impl<T: Config> ScheduledCall<T> {116 pub fn new(call: <T as Config>::Call) -> Result<Self, DispatchError> {116 pub fn new(call: <T as Config>::RuntimeCall) -> Result<Self, DispatchError> {117 let encoded = call.encode();117 let encoded = call.encode();118 let len = encoded.len();118 let len = encoded.len();119119151 }151 }152 }152 }153153154 fn decode(mut data: &[u8]) -> Result<<T as Config>::Call, DispatchError> {154 fn decode(mut data: &[u8]) -> Result<<T as Config>::RuntimeCall, DispatchError> {155 <T as Config>::Call::decode(&mut data)155 <T as Config>::RuntimeCall::decode(&mut data)156 .map_err(|_| <Error<T>>::ScheduledCallCorrupted.into())156 .map_err(|_| <Error<T>>::ScheduledCallCorrupted.into())157 }157 }158}158}162162163 fn peek(163 fn peek(164 call: &ScheduledCall<T>,164 call: &ScheduledCall<T>,165 ) -> Result<(<T as pallet::Config>::Call, Option<u32>), DispatchError>;165 ) -> Result<(<T as pallet::Config>::RuntimeCall, Option<u32>), DispatchError>;166166167 /// Convert the given scheduled `call` value back into its original instance. If successful,167 /// Convert the given scheduled `call` value back into its original instance. If successful,168 /// `drop` any data backing it. This will not break the realisability of independently168 /// `drop` any data backing it. This will not break the realisability of independently169 /// created instances of `ScheduledCall` which happen to have identical data.169 /// created instances of `ScheduledCall` which happen to have identical data.170 fn realize(170 fn realize(171 call: &ScheduledCall<T>,171 call: &ScheduledCall<T>,172 ) -> Result<(<T as pallet::Config>::Call, Option<u32>), DispatchError>;172 ) -> Result<(<T as pallet::Config>::RuntimeCall, Option<u32>), DispatchError>;173}173}174174175impl<T: Config, PP: PreimageRecipient<T::Hash>> SchedulerPreimages<T> for PP {175impl<T: Config, PP: PreimageRecipient<T::Hash>> SchedulerPreimages<T> for PP {182182183 fn peek(183 fn peek(184 call: &ScheduledCall<T>,184 call: &ScheduledCall<T>,185 ) -> Result<(<T as pallet::Config>::Call, Option<u32>), DispatchError> {185 ) -> Result<(<T as pallet::Config>::RuntimeCall, Option<u32>), DispatchError> {186 match call {186 match call {187 ScheduledCall::Inline(data) => Ok((ScheduledCall::<T>::decode(data)?, None)),187 ScheduledCall::Inline(data) => Ok((ScheduledCall::<T>::decode(data)?, None)),188 ScheduledCall::PreimageLookup {188 ScheduledCall::PreimageLookup {200200201 fn realize(201 fn realize(202 call: &ScheduledCall<T>,202 call: &ScheduledCall<T>,203 ) -> Result<(<T as pallet::Config>::Call, Option<u32>), DispatchError> {203 ) -> Result<(<T as pallet::Config>::RuntimeCall, Option<u32>), DispatchError> {204 let r = Self::peek(call)?;204 let r = Self::peek(call)?;205 Self::drop(call);205 Self::drop(call);206 Ok(r)206 Ok(r)252impl WeightCounter {252impl WeightCounter {253 fn check_accrue(&mut self, w: Weight) -> bool {253 fn check_accrue(&mut self, w: Weight) -> bool {254 let test = self.used.saturating_add(w);254 let test = self.used.saturating_add(w);255 if test > self.limit {255 if test.any_gt(self.limit) {256 false256 false257 } else {257 } else {258 self.used = test;258 self.used = test;261 }261 }262262263 fn can_accrue(&mut self, w: Weight) -> bool {263 fn can_accrue(&mut self, w: Weight) -> bool {264 self.used.saturating_add(w) <= self.limit264 self.used.saturating_add(w).all_lte(self.limit)265 }265 }266}266}267267300300301 #[pallet::config]301 #[pallet::config]302 pub trait Config: frame_system::Config {302 pub trait Config: frame_system::Config {303 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;303 type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;304304305 /// The aggregated origin which the dispatch will take.305 /// The aggregated origin which the dispatch will take.306 type Origin: OriginTrait<PalletsOrigin = Self::PalletsOrigin>306 type RuntimeOrigin: OriginTrait<PalletsOrigin = Self::PalletsOrigin>307 + From<Self::PalletsOrigin>307 + From<Self::PalletsOrigin>308 + IsType<<Self as system::Config>::Origin>308 + IsType<<Self as system::Config>::RuntimeOrigin>309 + Clone;309 + Clone;310310311 /// The caller origin, overarching type of all pallets origins.311 /// The caller origin, overarching type of all pallets origins.317 + MaxEncodedLen;317 + MaxEncodedLen;318318319 /// The aggregated call type.319 /// The aggregated call type.320 type Call: Parameter320 type RuntimeCall: Parameter321 + Dispatchable<Origin = <Self as Config>::Origin, PostInfo = PostDispatchInfo>321 + Dispatchable<RuntimeOrigin = <Self as Config>::RuntimeOrigin, PostInfo = PostDispatchInfo>322 + UnfilteredDispatchable<Origin = <Self as system::Config>::Origin>322 + UnfilteredDispatchable<RuntimeOrigin = <Self as system::Config>::RuntimeOrigin>323 + GetDispatchInfo323 + GetDispatchInfo324 + From<system::Call<Self>>;324 + From<system::Call<Self>>;325325329329330 /// Required origin to schedule or cancel calls.330 /// Required origin to schedule or cancel calls.331 type ScheduleOrigin: EnsureOrigin<331 type ScheduleOrigin: EnsureOrigin<332 <Self as system::Config>::Origin,332 <Self as system::Config>::RuntimeOrigin,333 Success = ScheduledEnsureOriginSuccess<Self::AccountId>,333 Success = ScheduledEnsureOriginSuccess<Self::AccountId>,334 >;334 >;335335356 type CallExecutor: DispatchCall<Self, H160>;356 type CallExecutor: DispatchCall<Self, H160>;357357358 /// Required origin to set/change calls' priority.358 /// Required origin to set/change calls' priority.359 type PrioritySetOrigin: EnsureOrigin<<Self as system::Config>::Origin>;359 type PrioritySetOrigin: EnsureOrigin<<Self as system::Config>::RuntimeOrigin>;360 }360 }361361362 #[pallet::storage]362 #[pallet::storage]458 when: T::BlockNumber,458 when: T::BlockNumber,459 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,459 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,460 priority: Option<schedule::Priority>,460 priority: Option<schedule::Priority>,461 call: Box<<T as Config>::Call>,461 call: Box<<T as Config>::RuntimeCall>,462 ) -> DispatchResult {462 ) -> DispatchResult {463 T::ScheduleOrigin::ensure_origin(origin.clone())?;463 T::ScheduleOrigin::ensure_origin(origin.clone())?;464464465 if priority.is_some() {465 if priority.is_some() {466 T::PrioritySetOrigin::ensure_origin(origin.clone())?;466 T::PrioritySetOrigin::ensure_origin(origin.clone())?;467 }467 }468468469 let origin = <T as Config>::Origin::from(origin);469 let origin = <T as Config>::RuntimeOrigin::from(origin);470 Self::do_schedule(470 Self::do_schedule(471 DispatchTime::At(when),471 DispatchTime::At(when),472 maybe_periodic,472 maybe_periodic,481 #[pallet::weight(<T as Config>::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))]481 #[pallet::weight(<T as Config>::WeightInfo::cancel(T::MaxScheduledPerBlock::get()))]482 pub fn cancel(origin: OriginFor<T>, when: T::BlockNumber, index: u32) -> DispatchResult {482 pub fn cancel(origin: OriginFor<T>, when: T::BlockNumber, index: u32) -> DispatchResult {483 T::ScheduleOrigin::ensure_origin(origin.clone())?;483 T::ScheduleOrigin::ensure_origin(origin.clone())?;484 let origin = <T as Config>::Origin::from(origin);484 let origin = <T as Config>::RuntimeOrigin::from(origin);485 Self::do_cancel(Some(origin.caller().clone()), (when, index))?;485 Self::do_cancel(Some(origin.caller().clone()), (when, index))?;486 Ok(())486 Ok(())487 }487 }494 when: T::BlockNumber,494 when: T::BlockNumber,495 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,495 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,496 priority: Option<schedule::Priority>,496 priority: Option<schedule::Priority>,497 call: Box<<T as Config>::Call>,497 call: Box<<T as Config>::RuntimeCall>,498 ) -> DispatchResult {498 ) -> DispatchResult {499 T::ScheduleOrigin::ensure_origin(origin.clone())?;499 T::ScheduleOrigin::ensure_origin(origin.clone())?;500500501 if priority.is_some() {501 if priority.is_some() {502 T::PrioritySetOrigin::ensure_origin(origin.clone())?;502 T::PrioritySetOrigin::ensure_origin(origin.clone())?;503 }503 }504504505 let origin = <T as Config>::Origin::from(origin);505 let origin = <T as Config>::RuntimeOrigin::from(origin);506 Self::do_schedule_named(506 Self::do_schedule_named(507 id,507 id,508 DispatchTime::At(when),508 DispatchTime::At(when),518 #[pallet::weight(<T as Config>::WeightInfo::cancel_named(T::MaxScheduledPerBlock::get()))]518 #[pallet::weight(<T as Config>::WeightInfo::cancel_named(T::MaxScheduledPerBlock::get()))]519 pub fn cancel_named(origin: OriginFor<T>, id: TaskName) -> DispatchResult {519 pub fn cancel_named(origin: OriginFor<T>, id: TaskName) -> DispatchResult {520 T::ScheduleOrigin::ensure_origin(origin.clone())?;520 T::ScheduleOrigin::ensure_origin(origin.clone())?;521 let origin = <T as Config>::Origin::from(origin);521 let origin = <T as Config>::RuntimeOrigin::from(origin);522 Self::do_cancel_named(Some(origin.caller().clone()), id)?;522 Self::do_cancel_named(Some(origin.caller().clone()), id)?;523 Ok(())523 Ok(())524 }524 }534 after: T::BlockNumber,534 after: T::BlockNumber,535 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,535 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,536 priority: Option<schedule::Priority>,536 priority: Option<schedule::Priority>,537 call: Box<<T as Config>::Call>,537 call: Box<<T as Config>::RuntimeCall>,538 ) -> DispatchResult {538 ) -> DispatchResult {539 T::ScheduleOrigin::ensure_origin(origin.clone())?;539 T::ScheduleOrigin::ensure_origin(origin.clone())?;540540541 if priority.is_some() {541 if priority.is_some() {542 T::PrioritySetOrigin::ensure_origin(origin.clone())?;542 T::PrioritySetOrigin::ensure_origin(origin.clone())?;543 }543 }544544545 let origin = <T as Config>::Origin::from(origin);545 let origin = <T as Config>::RuntimeOrigin::from(origin);546 Self::do_schedule(546 Self::do_schedule(547 DispatchTime::After(after),547 DispatchTime::After(after),548 maybe_periodic,548 maybe_periodic,565 after: T::BlockNumber,565 after: T::BlockNumber,566 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,566 maybe_periodic: Option<schedule::Period<T::BlockNumber>>,567 priority: Option<schedule::Priority>,567 priority: Option<schedule::Priority>,568 call: Box<<T as Config>::Call>,568 call: Box<<T as Config>::RuntimeCall>,569 ) -> DispatchResult {569 ) -> DispatchResult {570 T::ScheduleOrigin::ensure_origin(origin.clone())?;570 T::ScheduleOrigin::ensure_origin(origin.clone())?;571571572 if priority.is_some() {572 if priority.is_some() {573 T::PrioritySetOrigin::ensure_origin(origin.clone())?;573 T::PrioritySetOrigin::ensure_origin(origin.clone())?;574 }574 }575575576 let origin = <T as Config>::Origin::from(origin);576 let origin = <T as Config>::RuntimeOrigin::from(origin);577 Self::do_schedule_named(577 Self::do_schedule_named(578 id,578 id,579 DispatchTime::After(after),579 DispatchTime::After(after),592 priority: schedule::Priority,592 priority: schedule::Priority,593 ) -> DispatchResult {593 ) -> DispatchResult {594 T::PrioritySetOrigin::ensure_origin(origin.clone())?;594 T::PrioritySetOrigin::ensure_origin(origin.clone())?;595 let origin = <T as Config>::Origin::from(origin);595 let origin = <T as Config>::RuntimeOrigin::from(origin);596 Self::do_change_named_priority(origin.caller().clone(), id, priority)596 Self::do_change_named_priority(origin.caller().clone(), id, priority)597 }597 }598 }598 }816 /// Resolve the call dispatch, including any post-dispatch operations.816 /// Resolve the call dispatch, including any post-dispatch operations.817 fn dispatch_call(817 fn dispatch_call(818 signer: Option<T::AccountId>,818 signer: Option<T::AccountId>,819 function: <T as Config>::Call,819 function: <T as Config>::RuntimeCall,820 ) -> Result<820 ) -> Result<821 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,821 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,822 TransactionValidityError,822 TransactionValidityError,1036 fn execute_dispatch(1036 fn execute_dispatch(1037 weight: &mut WeightCounter,1037 weight: &mut WeightCounter,1038 origin: T::PalletsOrigin,1038 origin: T::PalletsOrigin,1039 call: <T as Config>::Call,1039 call: <T as Config>::RuntimeCall,1040 ) -> Result<DispatchResult, ServiceTaskError> {1040 ) -> Result<DispatchResult, ServiceTaskError> {1041 let dispatch_origin: <T as Config>::Origin = origin.into();1041 let dispatch_origin: <T as Config>::RuntimeOrigin = origin.into();1042 let base_weight = match dispatch_origin.clone().as_signed() {1042 let base_weight = match dispatch_origin.clone().as_signed() {1043 Some(_) => T::WeightInfo::execute_dispatch_signed(),1043 Some(_) => T::WeightInfo::execute_dispatch_signed(),1044 _ => T::WeightInfo::execute_dispatch_unsigned(),1044 _ => T::WeightInfo::execute_dispatch_unsigned(),runtime/common/config/pallets/scheduler.rsdiffbeforeafterboth--- 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<AccountId>;
type OriginPrivilegeCmp = EqualOrRootOnly;
test-pallets/utils/src/lib.rsdiffbeforeafterboth--- 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<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
}