Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Allow specify schedule dispatch origin #6387

Merged
merged 29 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6d11c9d
allow specify schedule dispatch origin
xlc Jun 18, 2020
8aa6ed9
fix tests
xlc Jun 19, 2020
a572232
use caller origin for scheduled
xlc Jun 19, 2020
8eba0a4
fix tests
xlc Jun 19, 2020
d51269a
line width
xlc Jun 19, 2020
5f1ee49
check origin for cancel
xlc Jun 19, 2020
fb5b48d
line width
xlc Jun 19, 2020
b7c9cba
fix some issues for benchmarking
xlc Jun 19, 2020
b2e1067
fix doc test
xlc Jun 19, 2020
f61230b
another way to constraint origin
xlc Jun 20, 2020
061d78f
Merge remote-tracking branch 'origin/master' into update-scheduler
xlc Jun 20, 2020
f43f468
fix build issues
xlc Jun 21, 2020
14b7522
fix cancel
xlc Jun 21, 2020
2c4a7d2
line width
xlc Jun 21, 2020
bc166a7
fix benchmarks
xlc Jun 21, 2020
9fc1fc0
bump version
xlc Jun 21, 2020
97cbaf3
enable runtime upgrade
xlc Jun 22, 2020
9dc582a
add migration code and test
xlc Jun 23, 2020
dd97a5a
Merge remote-tracking branch 'origin/master' into update-scheduler
xlc Jun 23, 2020
ae0231a
Update frame/scheduler/src/lib.rs
xlc Jun 23, 2020
c3f9e55
expose migration method
xlc Jun 23, 2020
5f00a81
Merge remote-tracking branch 'origin/master' into update-scheduler
xlc Jun 23, 2020
39040bc
add notes
xlc Jun 23, 2020
79cde79
Merge remote-tracking branch 'origin/master' into update-scheduler
xlc Jun 24, 2020
4099003
Merge remote-tracking branch 'origin/master' into update-scheduler
xlc Jun 25, 2020
b9000e8
Merge remote-tracking branch 'origin/master' into update-scheduler
xlc Jun 27, 2020
5b65287
bump version
xlc Jun 27, 2020
f19c49f
remove on_runtime_upgrade
xlc Jun 27, 2020
40e99bc
fix test
xlc Jun 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,10 @@ parameter_types! {
impl pallet_scheduler::Trait for Runtime {
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
}

parameter_types! {
Expand Down Expand Up @@ -455,6 +457,7 @@ impl pallet_democracy::Trait for Runtime {
type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
type Slash = Treasury;
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
}

Expand Down
2 changes: 1 addition & 1 deletion frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub trait Trait<I: Instance=DefaultInstance>: frame_system::Trait {
}

/// Origin for the collective module.
#[derive(PartialEq, Eq, Clone, RuntimeDebug)]
#[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode)]
pub enum RawOrigin<AccountId, I> {
/// It has been condoned by a given number of members of the collective from a given total.
Members(MemberCount, MemberCount),
Expand Down
1 change: 1 addition & 0 deletions frame/democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ fn add_referendum<T: Trait>(n: u32) -> Result<ReferendumIndex, &'static str> {
0.into(),
None,
63,
system::RawOrigin::Root.into(),
Call::enact_proposal(proposal_hash, referendum_index).into(),
);
Ok(referendum_index)
Expand Down
6 changes: 5 additions & 1 deletion frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ pub trait Trait: frame_system::Trait + Sized {
type Slash: OnUnbalanced<NegativeImbalanceOf<Self>>;

/// The Scheduler.
type Scheduler: ScheduleNamed<Self::BlockNumber, Self::Proposal>;
type Scheduler: ScheduleNamed<Self::BlockNumber, Self::Proposal, Self::PalletsOrigin>;

/// Overarching type of all pallets origins.
type PalletsOrigin: From<system::RawOrigin<Self::AccountId>>;

/// The maximum number of votes for an account.
///
Expand Down Expand Up @@ -1642,6 +1645,7 @@ impl<T: Trait> Module<T> {
when,
None,
63,
system::RawOrigin::Root.into(),
Call::enact_proposal(status.proposal_hash, index).into(),
).is_err() {
frame_support::print("LOGIC ERROR: bake_referendum/schedule_named failed");
Expand Down
5 changes: 4 additions & 1 deletion frame/democracy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use sp_runtime::{
testing::Header, Perbill,
};
use pallet_balances::{BalanceLock, Error as BalancesError};
use frame_system::EnsureSignedBy;
use frame_system::{EnsureSignedBy, EnsureRoot};

mod cancellation;
mod delegation;
Expand Down Expand Up @@ -124,8 +124,10 @@ parameter_types! {
impl pallet_scheduler::Trait for Test {
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<u64>;
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
Expand Down Expand Up @@ -197,6 +199,7 @@ impl super::Trait for Test {
type Scheduler = Scheduler;
type MaxVotes = MaxVotes;
type OperationalPreimageOrigin = EnsureSignedBy<Six, u64>;
type PalletsOrigin = OriginCaller;
}

pub fn new_test_ext() -> sp_io::TestExternalities {
Expand Down
7 changes: 6 additions & 1 deletion frame/scheduler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ frame-benchmarking = { version = "2.0.0-rc3", default-features = false, path = "

[dev-dependencies]
sp-core = { version = "2.0.0-rc3", path = "../../primitives/core", default-features = false }
substrate-test-utils = { version = "2.0.0-rc3", path = "../../test-utils" }

[features]
default = ["std"]
Expand All @@ -34,4 +35,8 @@ std = [
"sp-io/std",
"sp-std/std"
]
runtime-benchmarks = ["frame-benchmarking"]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
1 change: 1 addition & 0 deletions frame/scheduler/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fn fill_schedule<T: Trait> (when: T::BlockNumber, n: u32) -> Result<(), &'static
Some((T::BlockNumber::one(), 100)),
// HARD_DEADLINE priority means it gets executed no matter what
0,
frame_system::RawOrigin::Root.into(),
call.clone().into(),
)?;
}
Expand Down
Loading