difftreelog
feat(Scheduler) scheduler-runtime interface [WIP]
in: master
3 files changed
Cargo.lockdiffbeforeafterboth6272 "parity-scale-codec",6272 "parity-scale-codec",6273 "scale-info",6273 "scale-info",6274 "serde",6274 "serde",6275 "sp-api",6275 "sp-core",6276 "sp-core",6276 "sp-io",6277 "sp-io",6277 "sp-runtime",6278 "sp-runtime",pallets/scheduler/src/lib.rsdiffbeforeafterboth--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -55,11 +55,11 @@
mod benchmarking;
pub mod weights;
-use sp_std::{prelude::*, marker::PhantomData, borrow::Borrow};
+use sp_std::{prelude::*, marker::PhantomData, borrow::Borrow, cmp};
use codec::{Encode, Decode, Codec};
use sp_runtime::{
RuntimeDebug,
- traits::{One, BadOrigin, Saturating},
+ traits::{Zero, One, BadOrigin, Saturating},
};
use frame_support::{
decl_module, decl_storage, decl_event, decl_error,
@@ -242,7 +242,6 @@
type Error = Error<T>;
fn deposit_event() = default;
-
/// Anonymously schedule a task.
///
/// # <weight>
@@ -506,14 +505,14 @@
let sponsor = T::PalletsOrigin::from(system::RawOrigin::Signed(who_will_pay));
let r = call.clone().dispatch(sponsor.into());
- //T::PaymentHandler::validate(sponsor.into(), call.clone(), ); todo dispatch call
+ //T::PaymentHandler::apply();
+ //T::PaymentHandler::validate(sponsor.into(), call.clone(), ); todo dispatch extrinsic here
// sanitize maybe_periodic
- let maybe_periodic = None;
- // let maybe_periodic = maybe_periodic
- // .filter(|p| p.1 > 1 && !p.0.is_zero())
- // // Limit the repetitions to 100 calls and remove one from the number of repetitions since we will schedule one now.
- // .map(|(p, c)| (p, std::cmp::min(c, PERIODIC_CALLS_LIMIT) - 1));
+ let maybe_periodic = maybe_periodic
+ .filter(|p| p.1 > 1 && !p.0.is_zero())
+ // Limit the repetitions to 100 calls and remove one from the number of repetitions since we will schedule one now.
+ .map(|(p, c)| (p, cmp::min(c, PERIODIC_CALLS_LIMIT) - 1));
let s = Some(Scheduled {
maybe_id,
@@ -571,6 +570,7 @@
if let Some(s) = scheduled {
if let Some(id) = s.maybe_id {
Lookup::<T>::remove(id);
+ // todo add back money / displace to another function for consistency
}
Self::deposit_event(RawEvent::Canceled(when, index));
Ok(())
@@ -648,6 +648,7 @@
}
Ok(())
})?;
+ // todo add money back / displace to another function
Self::deposit_event(RawEvent::Canceled(when, index));
Ok(())
} else {
@@ -795,7 +796,7 @@
pub struct Module<T: Config> for enum Call
where
origin: <T as system::Config>::Origin,
- <T as system::Config>::Origin: OriginTrait<PalletsOrigin = OriginCaller>
+ <T as system::Config>::Origin: OriginTrait<PalletsOrigin = OriginCaller>
{
fn deposit_event() = default;
@@ -841,6 +842,13 @@
}
}
+ pub struct DummyExecutor; // todo do something with naming and function body
+ impl<C: Dispatchable> ApplyExtrinsic<C> for DummyExecutor {
+ fn apply_extrinsic(_signer: Address, _function: C) -> ApplyExtrinsicResult {
+ todo!()
+ }
+ }
+
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
@@ -891,7 +899,6 @@
type ScheduleOrigin = EnsureOneOf<u64, EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = ();
- type SponsorshipHandler = ();
- type PaymentHandler = ();
+ type Executor = DummyExecutor;
}
}
runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -815,34 +815,35 @@
pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,
);
-impl pallet_unq_scheduler::Config for Runtime {
- type Event = Event;
- type Origin = Origin;
- type PalletsOrigin = OriginCaller;
- type Call = Call;
- type MaximumWeight = MaximumSchedulerWeight;
- type ScheduleOrigin = EnsureSigned<AccountId>;
- type MaxScheduledPerBlock = MaxScheduledPerBlock;
- type WeightInfo = ();
- type Executor = Ex;
-}
-
// pub fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic {
// node_testing::keyring::sign(xt, SPEC_VERSION, TRANSACTION_VERSION, GENESIS_HASH)
// }
-struct Ex;
-impl<C: Dispatchable> ApplyExtrinsic<C> for Ex {
+pub struct SchedulerPaymentExecutor;
+impl<C: Dispatchable> ApplyExtrinsic<C> for SchedulerPaymentExecutor {
fn apply_extrinsic(signer: Address, function: C) -> ApplyExtrinsicResult {
- let extrinsic = sign(fp_self_contained::CheckedExtrinsic {
+ /*let extrinsic = sign(fp_self_contained::CheckedExtrinsic {
signed: fp_self_contained::CheckedSignature::SelfContained(None),
- function: function,
+ function,
});
- Executive::apply_extrinsic(extrinsic)
+ Executive::apply_extrinsic(extrinsic)*/
+ todo!()
}
}
+impl pallet_unq_scheduler::Config for Runtime {
+ type Event = Event;
+ type Origin = Origin;
+ type PalletsOrigin = OriginCaller;
+ type Call = Call;
+ type MaximumWeight = MaximumSchedulerWeight;
+ type ScheduleOrigin = EnsureSigned<AccountId>;
+ type MaxScheduledPerBlock = MaxScheduledPerBlock;
+ type WeightInfo = ();
+ type Executor = SchedulerPaymentExecutor;
+}
+
impl pallet_evm_transaction_payment::Config for Runtime {
type EvmSponsorshipHandler = EvmSponsorshipHandler;
type Currency = Balances;