difftreelog
fix scheduler rebase
in: master
7 files changed
pallets/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)
}
}
runtime/common/config/pallets/scheduler.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/scheduler.rs
+++ b/runtime/common/config/pallets/scheduler.rs
@@ -25,7 +25,7 @@
use codec::Decode;
use crate::{
runtime_common::{scheduler::SchedulerPaymentExecutor, config::substrate::RuntimeBlockWeights},
- Runtime, Call, Event, Origin, OriginCaller, Balances,
+ Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, OriginCaller, Balances,
};
use pallet_unique_scheduler::ScheduledEnsureOriginSuccess;
use up_common::types::AccountId;
runtime/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;
}
runtime/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,
runtime/common/scheduler.rsdiffbeforeafterboth1// 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::NamedReservableCurrency,19 weights::{GetDispatchInfo, PostDispatchInfo, DispatchInfo},20};21use sp_runtime::{22 traits::{Dispatchable, Applyable, Member},23 generic::Era,24 transaction_validity::TransactionValidityError,25 DispatchErrorWithPostInfo, DispatchError,26};27use codec::Encode;28use crate::{Runtime, Call, Origin, Balances};29use up_common::types::{AccountId, Balance};30use fp_self_contained::SelfContainedCall;31use pallet_unique_scheduler::DispatchCall;32use pallet_transaction_payment::ChargeTransactionPayment;3334type SponsorshipChargeTransactionPayment =35 pallet_charge_transaction::ChargeTransactionPayment<Runtime>;3637/// The SignedExtension to the basic transaction logic.38pub type SignedExtraScheduler = (39 frame_system::CheckSpecVersion<Runtime>,40 frame_system::CheckGenesis<Runtime>,41 frame_system::CheckEra<Runtime>,42 frame_system::CheckNonce<Runtime>,43 frame_system::CheckWeight<Runtime>,44 ChargeTransactionPayment<Runtime>,45);4647fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {48 (49 frame_system::CheckSpecVersion::<Runtime>::new(),50 frame_system::CheckGenesis::<Runtime>::new(),51 frame_system::CheckEra::<Runtime>::from(Era::Immortal),52 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(53 from,54 )),55 frame_system::CheckWeight::<Runtime>::new(),56 ChargeTransactionPayment::<Runtime>::from(0),57 )58}5960pub struct SchedulerPaymentExecutor;6162impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>63 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor64where65 <T as frame_system::Config>::Call: Member66 + Dispatchable<Origin = Origin, Info = DispatchInfo>67 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>68 + GetDispatchInfo69 + From<frame_system::Call<Runtime>>,70 SelfContainedSignedInfo: Send + Sync + 'static,71 Call: From<<T as frame_system::Config>::Call>72 + From<<T as pallet_unique_scheduler::Config>::Call>73 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,74 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,75{76 fn dispatch_call(77 signer: Option<<T as frame_system::Config>::AccountId>,78 call: <T as pallet_unique_scheduler::Config>::Call,79 ) -> Result<80 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,81 TransactionValidityError,82 > {83 let dispatch_info = call.get_dispatch_info();84 let len = call.encoded_size();8586 let signed = match signer {87 Some(signer) => fp_self_contained::CheckedSignature::Signed(88 signer.clone().into(),89 get_signed_extras(signer.into()),90 ),91 None => fp_self_contained::CheckedSignature::Unsigned,92 };9394 let extrinsic = fp_self_contained::CheckedExtrinsic::<95 AccountId,96 Call,97 SignedExtraScheduler,98 SelfContainedSignedInfo,99 > {100 signed,101 function: call.into(),102 };103104 extrinsic.apply::<Runtime>(&dispatch_info, len)105 }106107 fn reserve_balance(108 id: [u8; 16],109 sponsor: <T as frame_system::Config>::AccountId,110 call: <T as pallet_unique_scheduler::Config>::Call,111 count: u32,112 ) -> Result<(), DispatchError> {113 let dispatch_info = call.get_dispatch_info();114 let weight: Balance =115 SponsorshipChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)116 .saturating_mul(count.into());117118 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(119 &id,120 &(sponsor.into()),121 weight,122 )123 }124125 fn pay_for_call(126 id: [u8; 16],127 sponsor: <T as frame_system::Config>::AccountId,128 call: <T as pallet_unique_scheduler::Config>::Call,129 ) -> Result<u128, DispatchError> {130 let dispatch_info = call.get_dispatch_info();131 let weight: Balance =132 SponsorshipChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);133 Ok(134 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(135 &id,136 &(sponsor.into()),137 weight,138 ),139 )140 }141142 fn cancel_reserve(143 id: [u8; 16],144 sponsor: <T as frame_system::Config>::AccountId,145 ) -> Result<u128, DispatchError> {146 Ok(147 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(148 &id,149 &(sponsor.into()),150 u128::MAX,151 ),152 )153 }154}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::NamedReservableCurrency,19 dispatch::{GetDispatchInfo, PostDispatchInfo, DispatchInfo},20};21use sp_runtime::{22 traits::{Dispatchable, Applyable, Member},23 generic::Era,24 transaction_validity::TransactionValidityError,25 DispatchErrorWithPostInfo, DispatchError,26};27use codec::Encode;28use crate::{Runtime, RuntimeCall, RuntimeOrigin, Balances};29use up_common::types::{AccountId, Balance};30use fp_self_contained::SelfContainedCall;31use pallet_unique_scheduler::DispatchCall;32use pallet_transaction_payment::ChargeTransactionPayment;3334type SponsorshipChargeTransactionPayment =35 pallet_charge_transaction::ChargeTransactionPayment<Runtime>;3637/// The SignedExtension to the basic transaction logic.38pub type SignedExtraScheduler = (39 frame_system::CheckSpecVersion<Runtime>,40 frame_system::CheckGenesis<Runtime>,41 frame_system::CheckEra<Runtime>,42 frame_system::CheckNonce<Runtime>,43 frame_system::CheckWeight<Runtime>,44 ChargeTransactionPayment<Runtime>,45);4647fn get_signed_extras(from: <Runtime as frame_system::Config>::AccountId) -> SignedExtraScheduler {48 (49 frame_system::CheckSpecVersion::<Runtime>::new(),50 frame_system::CheckGenesis::<Runtime>::new(),51 frame_system::CheckEra::<Runtime>::from(Era::Immortal),52 frame_system::CheckNonce::<Runtime>::from(frame_system::Pallet::<Runtime>::account_nonce(53 from,54 )),55 frame_system::CheckWeight::<Runtime>::new(),56 ChargeTransactionPayment::<Runtime>::from(0),57 )58}5960pub struct SchedulerPaymentExecutor;6162impl<T: frame_system::Config + pallet_unique_scheduler::Config, SelfContainedSignedInfo>63 DispatchCall<T, SelfContainedSignedInfo> for SchedulerPaymentExecutor64where65 <T as frame_system::Config>::RuntimeCall: Member66 + Dispatchable<RuntimeOrigin = RuntimeOrigin, Info = DispatchInfo>67 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>68 + GetDispatchInfo69 + From<frame_system::Call<Runtime>>,70 SelfContainedSignedInfo: Send + Sync + 'static,71 RuntimeCall: From<<T as frame_system::Config>::RuntimeCall>72 + From<<T as pallet_unique_scheduler::Config>::RuntimeCall>73 + SelfContainedCall<SignedInfo = SelfContainedSignedInfo>,74 sp_runtime::AccountId32: From<<T as frame_system::Config>::AccountId>,75{76 fn dispatch_call(77 signer: Option<<T as frame_system::Config>::AccountId>,78 call: <T as pallet_unique_scheduler::Config>::RuntimeCall,79 ) -> Result<80 Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>,81 TransactionValidityError,82 > {83 let dispatch_info = call.get_dispatch_info();84 let len = call.encoded_size();8586 let signed = match signer {87 Some(signer) => fp_self_contained::CheckedSignature::Signed(88 signer.clone().into(),89 get_signed_extras(signer.into()),90 ),91 None => fp_self_contained::CheckedSignature::Unsigned,92 };9394 let extrinsic = fp_self_contained::CheckedExtrinsic::<95 AccountId,96 RuntimeCall,97 SignedExtraScheduler,98 SelfContainedSignedInfo,99 > {100 signed,101 function: call.into(),102 };103104 extrinsic.apply::<Runtime>(&dispatch_info, len)105 }106107 fn reserve_balance(108 id: [u8; 16],109 sponsor: <T as frame_system::Config>::AccountId,110 call: <T as pallet_unique_scheduler::Config>::RuntimeCall,111 count: u32,112 ) -> Result<(), DispatchError> {113 let dispatch_info = call.get_dispatch_info();114 let weight: Balance =115 SponsorshipChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0)116 .saturating_mul(count.into());117118 <Balances as NamedReservableCurrency<AccountId>>::reserve_named(119 &id,120 &(sponsor.into()),121 weight,122 )123 }124125 fn pay_for_call(126 id: [u8; 16],127 sponsor: <T as frame_system::Config>::AccountId,128 call: <T as pallet_unique_scheduler::Config>::RuntimeCall,129 ) -> Result<u128, DispatchError> {130 let dispatch_info = call.get_dispatch_info();131 let weight: Balance =132 SponsorshipChargeTransactionPayment::traditional_fee(0, &dispatch_info, 0);133 Ok(134 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(135 &id,136 &(sponsor.into()),137 weight,138 ),139 )140 }141142 fn cancel_reserve(143 id: [u8; 16],144 sponsor: <T as frame_system::Config>::AccountId,145 ) -> Result<u128, DispatchError> {146 Ok(147 <Balances as NamedReservableCurrency<AccountId>>::unreserve_named(148 &id,149 &(sponsor.into()),150 u128::MAX,151 ),152 )153 }154}test-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]
test-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]