Skip to content

Commit 3e98022

Browse files
xlcgavofyork
andauthored
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 <[email protected]> * expose migration method * add notes * bump version * remove on_runtime_upgrade * fix test Co-authored-by: Gavin Wood <[email protected]>
1 parent ea1ef79 commit 3e98022

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/benchmarking.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ fn add_referendum<T: Trait>(n: u32) -> Result<ReferendumIndex, &'static str> {
7979
1.into(),
8080
None,
8181
63,
82+
system::RawOrigin::Root.into(),
8283
Call::enact_proposal(proposal_hash, referendum_index).into(),
8384
).map_err(|_| "failed to schedule named")?;
8485
Ok(referendum_index)

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ pub trait Trait: frame_system::Trait + Sized {
279279
type Slash: OnUnbalanced<NegativeImbalanceOf<Self>>;
280280

281281
/// The Scheduler.
282-
type Scheduler: ScheduleNamed<Self::BlockNumber, Self::Proposal>;
282+
type Scheduler: ScheduleNamed<Self::BlockNumber, Self::Proposal, Self::PalletsOrigin>;
283+
284+
/// Overarching type of all pallets origins.
285+
type PalletsOrigin: From<system::RawOrigin<Self::AccountId>>;
283286

284287
/// The maximum number of votes for an account.
285288
///
@@ -1625,6 +1628,7 @@ impl<T: Trait> Module<T> {
16251628
when,
16261629
None,
16271630
63,
1631+
system::RawOrigin::Root.into(),
16281632
Call::enact_proposal(status.proposal_hash, index).into(),
16291633
).is_err() {
16301634
frame_support::print("LOGIC ERROR: bake_referendum/schedule_named failed");

src/tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use sp_runtime::{
3131
testing::Header, Perbill,
3232
};
3333
use pallet_balances::{BalanceLock, Error as BalancesError};
34-
use frame_system::EnsureSignedBy;
34+
use frame_system::{EnsureSignedBy, EnsureRoot};
3535

3636
mod cancellation;
3737
mod delegation;
@@ -123,8 +123,10 @@ parameter_types! {
123123
impl pallet_scheduler::Trait for Test {
124124
type Event = Event;
125125
type Origin = Origin;
126+
type PalletsOrigin = OriginCaller;
126127
type Call = Call;
127128
type MaximumWeight = MaximumSchedulerWeight;
129+
type ScheduleOrigin = EnsureRoot<u64>;
128130
}
129131
parameter_types! {
130132
pub const ExistentialDeposit: u64 = 1;
@@ -196,6 +198,7 @@ impl super::Trait for Test {
196198
type Scheduler = Scheduler;
197199
type MaxVotes = MaxVotes;
198200
type OperationalPreimageOrigin = EnsureSignedBy<Six, u64>;
201+
type PalletsOrigin = OriginCaller;
199202
}
200203

201204
pub fn new_test_ext() -> sp_io::TestExternalities {

0 commit comments

Comments
 (0)