Allow specify schedule dispatch origin (#6387)

* allow specify schedule dispatch origin

* fix tests

* use caller origin for scheduled

* fix tests

* line width

* check origin for cancel

* line width

* fix some issues for benchmarking

* fix doc test

* another way to constraint origin

* fix build issues

* fix cancel

* line width

* fix benchmarks

* bump version

* enable runtime upgrade

* add migration code and test

* Update frame/scheduler/src/lib.rs

Co-authored-by: Gavin Wood <github@gavwood.com>

* expose migration method

* add notes

* bump version

* remove on_runtime_upgrade

* fix test

Co-authored-by: Gavin Wood <github@gavwood.com>
This commit is contained in:
Xiliang Chen
2020-07-03 01:05:15 +12:00
committed by GitHub
parent 540ae1c161
commit e1d0f84c67
16 changed files with 510 additions and 139 deletions
@@ -17,6 +17,7 @@
#![recursion_limit="128"]
use codec::{Codec, EncodeLike, Encode, Decode};
use sp_runtime::{generic, BuildStorage, traits::{BlakeTwo256, Block as _, Verify}};
use frame_support::{
Parameter, traits::Get, parameter_types,
@@ -44,7 +45,7 @@ mod module1 {
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
type Origin: From<Origin<Self, I>>;
type SomeParameter: Get<u32>;
type GenericType: Default + Clone + codec::Codec + codec::EncodeLike;
type GenericType: Default + Clone + Codec + EncodeLike;
}
frame_support::decl_module! {
@@ -87,7 +88,7 @@ mod module1 {
}
}
#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug, Encode, Decode)]
pub enum Origin<T: Trait<I>, I> where T::BlockNumber: From<u32> {
Members(u32),
_Phantom(std::marker::PhantomData<(T, I)>),
@@ -148,7 +149,7 @@ mod module2 {
}
}
#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug, Encode, Decode)]
pub enum Origin<T: Trait<I>, I=DefaultInstance> {
Members(u32),
_Phantom(std::marker::PhantomData<(T, I)>),