Skip to content

Commit

Permalink
Remove senate instance of collective pallet (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayden Brewer committed Jul 13, 2023
1 parent 01f89a5 commit cbe8f03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
15 changes: 1 addition & 14 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use node_subtensor_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig,
SystemConfig, WASM_BINARY, SubtensorModuleConfig, TriumvirateConfig, TriumvirateMembersConfig,
SenateConfig, SenateMembersConfig
SystemConfig, WASM_BINARY, SubtensorModuleConfig, TriumvirateConfig, TriumvirateMembersConfig, SenateMembersConfig
};
use sc_service::ChainType;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
Expand Down Expand Up @@ -418,10 +417,6 @@ fn localnet_genesis(
],
phantom: Default::default()
},
senate: SenateConfig {
members: Default::default(),
phantom: Default::default(),
},
senate_members: SenateMembersConfig {
members: bounded_vec![
get_account_id_from_seed::<sr25519::Public>("Dave"),
Expand Down Expand Up @@ -475,10 +470,6 @@ fn testnet_genesis(
members: Default::default(),
phantom: Default::default()
},
senate: SenateConfig {
members: Default::default(),
phantom: Default::default(),
},
senate_members: SenateMembersConfig {
members: Default::default(),
phantom: Default::default()
Expand Down Expand Up @@ -531,10 +522,6 @@ fn finney_genesis(
members: Default::default(),
phantom: Default::default()
},
senate: SenateConfig {
members: Default::default(),
phantom: Default::default(),
},
senate_members: SenateMembersConfig {
members: Default::default(),
phantom: Default::default()
Expand Down
31 changes: 6 additions & 25 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl CanPropose<AccountId> for CanProposeToTriumvirate {

pub struct CanVoteToTriumvirate;
impl CanVote<AccountId> for CanVoteToTriumvirate {
fn can_vote(account: &AccountId) -> bool {
fn can_vote(_: &AccountId) -> bool {
//Senate::is_member(account)
false // Disable voting from pallet_collective::vote
}
Expand Down Expand Up @@ -370,11 +370,11 @@ impl MemberManagement<AccountId> for ManageSenateMembers {
}

fn is_member(account: &AccountId) -> bool {
Senate::is_member(account)
SenateMembers::members().contains(account)
}

fn members() -> Vec<AccountId> {
Senate::members()
SenateMembers::members().into()
}

fn max_members() -> u32 {
Expand All @@ -384,7 +384,7 @@ impl MemberManagement<AccountId> for ManageSenateMembers {

pub struct GetSenateMemberCount;
impl GetVotingMembers<MemberCount> for GetSenateMemberCount {
fn get_count() -> MemberCount {Senate::members().len() as u32}
fn get_count() -> MemberCount {SenateMembers::members().len() as u32}
}
impl Get<MemberCount> for GetSenateMemberCount {
fn get() -> MemberCount {SenateMaxMembers::get()}
Expand Down Expand Up @@ -435,24 +435,6 @@ impl pallet_membership::Config<TriumvirateMembership> for Runtime {
type WeightInfo = pallet_membership::weights::SubstrateWeight<Runtime>;
}

// This is a dummy collective instance for managing senate members
// Probably not the best solution, but fastest implementation
type SenateCollective = pallet_collective::Instance2;
impl pallet_collective::Config<SenateCollective> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = CouncilMotionDuration;
type MaxProposals = CouncilMaxProposals;
type MaxMembers = SenateMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureNever<AccountId>;
type CanPropose = ();
type CanVote = ();
type GetVotingMembers = ();
}

// We call our top K delegates membership Senate
type SenateMembership = pallet_membership::Instance2;
impl pallet_membership::Config<SenateMembership> for Runtime {
Expand All @@ -462,8 +444,8 @@ impl pallet_membership::Config<SenateMembership> for Runtime {
type SwapOrigin = EnsureRoot<AccountId>;
type ResetOrigin = EnsureRoot<AccountId>;
type PrimeOrigin = EnsureRoot<AccountId>;
type MembershipInitialized = Senate;
type MembershipChanged = Senate;
type MembershipInitialized = ();
type MembershipChanged = ();
type MaxMembers = SenateMaxMembers;
type WeightInfo = pallet_membership::weights::SubstrateWeight<Runtime>;
}
Expand Down Expand Up @@ -599,7 +581,6 @@ construct_runtime!(
SubtensorModule: pallet_subtensor,
Triumvirate: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
TriumvirateMembers: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},
Senate: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>},
SenateMembers: pallet_membership::<Instance2>::{Pallet, Call, Storage, Event<T>, Config<T>},
Utility: pallet_utility,
Sudo: pallet_sudo,
Expand Down

0 comments on commit cbe8f03

Please sign in to comment.