git.delta.rocks / unique-network / refs/commits / be30378adea3

difftreelog

fix scheduler rebase

Daniel Shiposha2022-10-24parent: #c70bef7.patch.diff
in: master

7 files changed

modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -86,7 +86,7 @@
 use sp_std::{borrow::Borrow, cmp::Ordering, marker::PhantomData, prelude::*};
 
 use frame_support::{
-	dispatch::{DispatchError, DispatchResult, Dispatchable, UnfilteredDispatchable, Parameter},
+	dispatch::{DispatchError, DispatchResult, Dispatchable, UnfilteredDispatchable, Parameter, GetDispatchInfo},
 	traits::{
 		schedule::{self, DispatchTime, MaybeHashed},
 		NamedReservableCurrency, EnsureOrigin, Get, IsType, OriginTrait, PrivilegeCmp,
@@ -101,7 +101,7 @@
 pub type TaskAddress<BlockNumber> = (BlockNumber, u32);
 pub const MAX_TASK_ID_LENGTH_IN_BYTES: u8 = 16;
 
-type ScheduledId = [u8; MAX_TASK_ID_LENGTH_IN_BYTES as usize];
+pub type ScheduledId = [u8; MAX_TASK_ID_LENGTH_IN_BYTES as usize];
 pub type CallOrHashOf<T> =
 	MaybeHashed<<T as Config>::RuntimeCall, <T as frame_system::Config>::Hash>;
 
@@ -231,10 +231,10 @@
 
 		/// The aggregated call type.
 		type RuntimeCall: Parameter
-			+ Dispatchable<Origin = <Self as Config>::RuntimeOrigin, PostInfo = PostDispatchInfo>
-			+ UnfilteredDispatchable<Origin = <Self as system::Config>::RuntimeOrigin>
+			+ Dispatchable<RuntimeOrigin = <Self as Config>::RuntimeOrigin, PostInfo = PostDispatchInfo>
+			+ UnfilteredDispatchable<RuntimeOrigin = <Self as system::Config>::RuntimeOrigin>
 			+ GetDispatchInfo
-			+ From<system::RuntimeCall<Self>>;
+			+ From<system::Call<Self>>;
 
 		/// The maximum weight that may be scheduled per block for any dispatchables of less
 		/// priority than `schedule::HARD_DEADLINE`.
@@ -611,7 +611,7 @@
 			priority: schedule::Priority,
 		) -> DispatchResult {
 			T::PrioritySetOrigin::ensure_origin(origin.clone())?;
-			let origin = <T as Config>::Origin::from(origin);
+			let origin = <T as Config>::RuntimeOrigin::from(origin);
 			Self::do_change_named_priority(origin.caller().clone(), id, priority)
 		}
 	}
modifiedruntime/common/config/pallets/scheduler.rsdiffbeforeafterboth
before · runtime/common/config/pallets/scheduler.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	traits::{PrivilegeCmp, EnsureOrigin},19	weights::Weight,20	parameter_types,21};22use frame_system::{EnsureRoot, RawOrigin};23use sp_runtime::Perbill;24use core::cmp::Ordering;25use codec::Decode;26use crate::{27	runtime_common::{scheduler::SchedulerPaymentExecutor, config::substrate::RuntimeBlockWeights},28	Runtime, Call, Event, Origin, OriginCaller, Balances,29};30use pallet_unique_scheduler::ScheduledEnsureOriginSuccess;31use up_common::types::AccountId;3233parameter_types! {34	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *35		RuntimeBlockWeights::get().max_block;36	pub const MaxScheduledPerBlock: u32 = 50;3738	pub const NoPreimagePostponement: Option<u32> = Some(10);39	pub const Preimage: Option<u32> = Some(10);40}4142pub struct EnsureSignedOrRoot<AccountId>(sp_std::marker::PhantomData<AccountId>);43impl<O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>>, AccountId: Decode>44	EnsureOrigin<O> for EnsureSignedOrRoot<AccountId>45{46	type Success = ScheduledEnsureOriginSuccess<AccountId>;47	fn try_origin(o: O) -> Result<Self::Success, O> {48		o.into().and_then(|o| match o {49			RawOrigin::Root => Ok(ScheduledEnsureOriginSuccess::Root),50			RawOrigin::Signed(who) => Ok(ScheduledEnsureOriginSuccess::Signed(who)),51			r => Err(O::from(r)),52		})53	}54}5556pub struct EqualOrRootOnly;57impl PrivilegeCmp<OriginCaller> for EqualOrRootOnly {58	fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {59		use RawOrigin::*;6061		let left = left.clone().try_into().ok()?;62		let right = right.clone().try_into().ok()?;6364		match (left, right) {65			(Root, Root) => Some(Ordering::Equal),66			(Root, _) => Some(Ordering::Greater),67			(_, Root) => Some(Ordering::Less),68			lr @ _ => (lr.0 == lr.1).then(|| Ordering::Equal),69		}70	}71}7273impl pallet_unique_scheduler::Config for Runtime {74	type RuntimeEvent = RuntimeEvent;75	type RuntimeOrigin = RuntimeOrigin;76	type Currency = Balances;77	type PalletsOrigin = OriginCaller;78	type RuntimeCall = RuntimeCall;79	type MaximumWeight = MaximumSchedulerWeight;80	type ScheduleOrigin = EnsureSignedOrRoot<AccountId>;81	type PrioritySetOrigin = EnsureRoot<AccountId>;82	type MaxScheduledPerBlock = MaxScheduledPerBlock;83	type WeightInfo = ();84	type CallExecutor = SchedulerPaymentExecutor;85	type OriginPrivilegeCmp = EqualOrRootOnly;86	type PreimageProvider = ();87	type NoPreimagePostponement = NoPreimagePostponement;88}
after · runtime/common/config/pallets/scheduler.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{18	traits::{PrivilegeCmp, EnsureOrigin},19	weights::Weight,20	parameter_types,21};22use frame_system::{EnsureRoot, RawOrigin};23use sp_runtime::Perbill;24use core::cmp::Ordering;25use codec::Decode;26use crate::{27	runtime_common::{scheduler::SchedulerPaymentExecutor, config::substrate::RuntimeBlockWeights},28	Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, OriginCaller, Balances,29};30use pallet_unique_scheduler::ScheduledEnsureOriginSuccess;31use up_common::types::AccountId;3233parameter_types! {34	pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *35		RuntimeBlockWeights::get().max_block;36	pub const MaxScheduledPerBlock: u32 = 50;3738	pub const NoPreimagePostponement: Option<u32> = Some(10);39	pub const Preimage: Option<u32> = Some(10);40}4142pub struct EnsureSignedOrRoot<AccountId>(sp_std::marker::PhantomData<AccountId>);43impl<O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>>, AccountId: Decode>44	EnsureOrigin<O> for EnsureSignedOrRoot<AccountId>45{46	type Success = ScheduledEnsureOriginSuccess<AccountId>;47	fn try_origin(o: O) -> Result<Self::Success, O> {48		o.into().and_then(|o| match o {49			RawOrigin::Root => Ok(ScheduledEnsureOriginSuccess::Root),50			RawOrigin::Signed(who) => Ok(ScheduledEnsureOriginSuccess::Signed(who)),51			r => Err(O::from(r)),52		})53	}54}5556pub struct EqualOrRootOnly;57impl PrivilegeCmp<OriginCaller> for EqualOrRootOnly {58	fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {59		use RawOrigin::*;6061		let left = left.clone().try_into().ok()?;62		let right = right.clone().try_into().ok()?;6364		match (left, right) {65			(Root, Root) => Some(Ordering::Equal),66			(Root, _) => Some(Ordering::Greater),67			(_, Root) => Some(Ordering::Less),68			lr @ _ => (lr.0 == lr.1).then(|| Ordering::Equal),69		}70	}71}7273impl pallet_unique_scheduler::Config for Runtime {74	type RuntimeEvent = RuntimeEvent;75	type RuntimeOrigin = RuntimeOrigin;76	type Currency = Balances;77	type PalletsOrigin = OriginCaller;78	type RuntimeCall = RuntimeCall;79	type MaximumWeight = MaximumSchedulerWeight;80	type ScheduleOrigin = EnsureSignedOrRoot<AccountId>;81	type PrioritySetOrigin = EnsureRoot<AccountId>;82	type MaxScheduledPerBlock = MaxScheduledPerBlock;83	type WeightInfo = ();84	type CallExecutor = SchedulerPaymentExecutor;85	type OriginPrivilegeCmp = EqualOrRootOnly;86	type PreimageProvider = ();87	type NoPreimagePostponement = NoPreimagePostponement;88}
modifiedruntime/common/config/test_pallets.rsdiffbeforeafterboth
--- a/runtime/common/config/test_pallets.rs
+++ b/runtime/common/config/test_pallets.rs
@@ -14,8 +14,8 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-use crate::{Runtime, Event};
+use crate::{Runtime, RuntimeEvent};
 
 impl pallet_test_utils::Config for Runtime {
-	type Event = Event;
+	type RuntimeEvent = RuntimeEvent;
 }
modifiedruntime/common/construct_runtime/mod.rsdiffbeforeafterboth
--- 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<T>} = 61,
 
-                // #[runtimes(opal)]
-                // Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
+                #[runtimes(opal)]
+                Scheduler: pallet_unique_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
 
                 Configuration: pallet_configuration::{Pallet, Call, Storage} = 63,
 
modifiedruntime/common/scheduler.rsdiffbeforeafterboth
--- a/runtime/common/scheduler.rs
+++ b/runtime/common/scheduler.rs
@@ -16,7 +16,7 @@
 
 use frame_support::{
 	traits::NamedReservableCurrency,
-	weights::{GetDispatchInfo, PostDispatchInfo, DispatchInfo},
+	dispatch::{GetDispatchInfo, PostDispatchInfo, DispatchInfo},
 };
 use sp_runtime::{
 	traits::{Dispatchable, Applyable, Member},
@@ -25,7 +25,7 @@
 	DispatchErrorWithPostInfo, DispatchError,
 };
 use codec::Encode;
-use crate::{Runtime, Call, Origin, Balances};
+use crate::{Runtime, RuntimeCall, RuntimeOrigin, Balances};
 use up_common::types::{AccountId, Balance};
 use fp_self_contained::SelfContainedCall;
 use pallet_unique_scheduler::DispatchCall;
@@ -62,20 +62,20 @@
 impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>
 	DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor
 where
-	<T as frame_system::Config>::Call: Member
-		+ Dispatchable<Origin = Origin, Info = DispatchInfo>
+	<T as frame_system::Config>::RuntimeCall: Member
+		+ Dispatchable<RuntimeOrigin = RuntimeOrigin, Info = DispatchInfo>
 		+ SelfContainedCall<SignedInfo = SelfContainedSignedInfo>
 		+ GetDispatchInfo
 		+ From<frame_system::Call<Runtime>>,
 	SelfContainedSignedInfo: Send + Sync + 'static,
-	Call: From<<T as frame_system::Config>::Call>
-		+ From<<T as pallet_unique_scheduler::Config>::Call>
+	RuntimeCall: From<<T as frame_system::Config>::RuntimeCall>
+		+ From<<T as pallet_unique_scheduler::Config>::RuntimeCall>
 		+ SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,
 	sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,
 {
 	fn dispatch_call(
 		signer: Option<<T as frame_system::Config>::AccountId>,
-		call: <T as pallet_unique_scheduler::Config>::Call,
+		call: <T as pallet_unique_scheduler::Config>::RuntimeCall,
 	) -> Result<
 		Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,
 		TransactionValidityError,
@@ -93,7 +93,7 @@
 
 		let extrinsic = fp_self_contained::CheckedExtrinsic::<
 			AccountId,
-			Call,
+			RuntimeCall,
 			SignedExtraScheduler,
 			SelfContainedSignedInfo,
 		> {
@@ -107,7 +107,7 @@
 	fn reserve_balance(
 		id: [u8; 16],
 		sponsor: <T as frame_system::Config>::AccountId,
-		call: <T as pallet_unique_scheduler::Config>::Call,
+		call: <T as pallet_unique_scheduler::Config>::RuntimeCall,
 		count: u32,
 	) -> Result<(), DispatchError> {
 		let dispatch_info = call.get_dispatch_info();
@@ -125,7 +125,7 @@
 	fn pay_for_call(
 		id: [u8; 16],
 		sponsor: <T as frame_system::Config>::AccountId,
-		call: <T as pallet_unique_scheduler::Config>::Call,
+		call: <T as pallet_unique_scheduler::Config>::RuntimeCall,
 	) -> Result<u128, DispatchError> {
 		let dispatch_info = call.get_dispatch_info();
 		let weight: Balance =
modifiedtest-pallets/utils/Cargo.tomldiffbeforeafterboth
--- a/test-pallets/utils/Cargo.toml
+++ b/test-pallets/utils/Cargo.toml
@@ -8,8 +8,8 @@
 [dependencies]
 codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
 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.29" }
-frame-system = { default-features = false, 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.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 }
 
 [features]
modifiedtest-pallets/utils/src/lib.rsdiffbeforeafterboth
--- a/test-pallets/utils/src/lib.rs
+++ b/test-pallets/utils/src/lib.rs
@@ -28,7 +28,7 @@
 
 	#[pallet::config]
 	pub trait Config: frame_system::Config + pallet_unique_scheduler::Config {
-		type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
+		type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
 	}
 
 	#[pallet::event]