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

SetMembers configurable origin #13159

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
3 changes: 3 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type MaxMembers = CouncilMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
}

parameter_types! {
Expand Down Expand Up @@ -1052,6 +1053,7 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {
type MaxMembers = TechnicalMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
}

type EnsureRootOrHalfCouncil = EitherOfDiverse<
Expand Down Expand Up @@ -1646,6 +1648,7 @@ impl pallet_collective::Config<AllianceCollective> for Runtime {
type MaxMembers = AllianceMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions frame/alliance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl pallet_collective::Config<AllianceCollective> for Test {
type MaxMembers = MaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = ();
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
}

parameter_types! {
Expand Down
5 changes: 4 additions & 1 deletion frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ pub mod pallet {

/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;

/// Origin allowed to set collective members
type SetMembersOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
girazoki marked this conversation as resolved.
Show resolved Hide resolved
}

#[pallet::genesis_config]
Expand Down Expand Up @@ -389,7 +392,7 @@ pub mod pallet {
prime: Option<T::AccountId>,
old_count: MemberCount,
) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
T::SetMembersOrigin::ensure_origin(origin)?;
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
if new_members.len() > T::MaxMembers::get() as usize {
log::error!(
target: LOG_TARGET,
Expand Down
5 changes: 4 additions & 1 deletion frame/collective/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use frame_support::{
traits::{ConstU32, ConstU64, GenesisBuild, StorageVersion},
Hashable,
};
use frame_system::{EventRecord, Phase};
use frame_system::{EventRecord, Phase, EnsureRoot};
use sp_core::H256;
use sp_runtime::{
testing::Header,
Expand Down Expand Up @@ -127,6 +127,7 @@ impl Config<Instance1> for Test {
type MaxMembers = MaxMembers;
type DefaultVote = PrimeDefaultVote;
type WeightInfo = ();
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
}
impl Config<Instance2> for Test {
type RuntimeOrigin = RuntimeOrigin;
Expand All @@ -137,6 +138,7 @@ impl Config<Instance2> for Test {
type MaxMembers = MaxMembers;
type DefaultVote = MoreThanMajorityThenPrimeDefaultVote;
type WeightInfo = ();
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
}
impl mock_democracy::Config for Test {
type RuntimeEvent = RuntimeEvent;
Expand All @@ -151,6 +153,7 @@ impl Config for Test {
type MaxMembers = MaxMembers;
type DefaultVote = PrimeDefaultVote;
type WeightInfo = ();
type SetMembersOrigin = EnsureRoot<Self::AccountId>;
}

pub fn new_test_ext() -> sp_io::TestExternalities {
Expand Down
1 change: 1 addition & 0 deletions frame/utility/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ impl pallet_collective::Config<CouncilCollective> for Test {
type MaxMembers = MaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = ();
type SetMembersOrigin = frame_system::EnsureRoot<Self::AccountId>;
}

impl example::Config for Test {}
Expand Down