mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 14:11:09 +00:00
Technical Committee (#3041)
* Add copy of council seats as elections module. * Split council into collective and elections modules. Make collective instanceable. * Propagate changes to the runtime and fix origin/event * insert_ref and put_ref to avoid copies. * Add tests * Fix up collective's tests * One more test * Fix elections module tests * Missed merge line * Minor fix * Test fixes * Line widths * Line widths * Rntime version * Remove comment * Deduplicate * Bump runtime again * Fix test
This commit is contained in:
@@ -19,8 +19,8 @@
|
||||
use primitives::{ed25519, sr25519, Pair, crypto::UncheckedInto};
|
||||
use node_primitives::{AccountId, AuraId, Balance};
|
||||
use node_runtime::{
|
||||
AuraConfig, BalancesConfig, ContractsConfig, CouncilSeatsConfig, DemocracyConfig,
|
||||
GrandpaConfig, IndicesConfig, SessionConfig, StakingConfig, SudoConfig,
|
||||
GrandpaConfig, BalancesConfig, ContractsConfig, ElectionsConfig, DemocracyConfig, CouncilConfig,
|
||||
AuraConfig, IndicesConfig, SessionConfig, StakingConfig, SudoConfig, TechnicalCommitteeConfig,
|
||||
SystemConfig, TimestampConfig, WASM_BINARY, Perbill, SessionKeys, StakerStatus, DAYS, DOLLARS,
|
||||
MILLICENTS, SECS_PER_BLOCK,
|
||||
};
|
||||
@@ -130,8 +130,16 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
invulnerables: initial_authorities.iter().map(|x| x.1.clone()).collect(),
|
||||
}),
|
||||
democracy: Some(DemocracyConfig::default()),
|
||||
council_seats: Some(CouncilSeatsConfig {
|
||||
active_council: vec![],
|
||||
collective_Instance1: Some(CouncilConfig {
|
||||
members: vec![],
|
||||
phantom: Default::default(),
|
||||
}),
|
||||
collective_Instance2: Some(TechnicalCommitteeConfig {
|
||||
members: vec![],
|
||||
phantom: Default::default(),
|
||||
}),
|
||||
elections: Some(ElectionsConfig {
|
||||
members: vec![],
|
||||
presentation_duration: 1 * DAYS,
|
||||
term_duration: 28 * DAYS,
|
||||
desired_seats: 0,
|
||||
@@ -228,7 +236,7 @@ pub fn testnet_genesis(
|
||||
const ENDOWMENT: Balance = 10_000_000 * DOLLARS;
|
||||
const STASH: Balance = 100 * DOLLARS;
|
||||
|
||||
let council_desired_seats = (endowed_accounts.len() / 2 - initial_authorities.len()) as u32;
|
||||
let desired_seats = (endowed_accounts.len() / 2 - initial_authorities.len()) as u32;
|
||||
|
||||
GenesisConfig {
|
||||
system: Some(SystemConfig {
|
||||
@@ -257,13 +265,21 @@ pub fn testnet_genesis(
|
||||
invulnerables: initial_authorities.iter().map(|x| x.1.clone()).collect(),
|
||||
}),
|
||||
democracy: Some(DemocracyConfig::default()),
|
||||
council_seats: Some(CouncilSeatsConfig {
|
||||
active_council: endowed_accounts.iter()
|
||||
collective_Instance1: Some(CouncilConfig {
|
||||
members: vec![],
|
||||
phantom: Default::default(),
|
||||
}),
|
||||
collective_Instance2: Some(TechnicalCommitteeConfig {
|
||||
members: vec![],
|
||||
phantom: Default::default(),
|
||||
}),
|
||||
elections: Some(ElectionsConfig {
|
||||
members: endowed_accounts.iter()
|
||||
.filter(|&endowed| initial_authorities.iter().find(|&(_, controller, ..)| controller == endowed).is_none())
|
||||
.map(|a| (a.clone(), 1000000)).collect(),
|
||||
presentation_duration: 10,
|
||||
term_duration: 1000000,
|
||||
desired_seats: council_desired_seats,
|
||||
desired_seats: desired_seats,
|
||||
}),
|
||||
timestamp: Some(TimestampConfig {
|
||||
minimum_period: 2, // 2*2=4 second block time.
|
||||
|
||||
@@ -343,7 +343,9 @@ mod tests {
|
||||
invulnerables: vec![alice(), bob(), charlie()],
|
||||
}),
|
||||
democracy: Some(Default::default()),
|
||||
council_seats: Some(Default::default()),
|
||||
collective_Instance1: Some(Default::default()),
|
||||
collective_Instance2: Some(Default::default()),
|
||||
elections: Some(Default::default()),
|
||||
timestamp: Some(Default::default()),
|
||||
contracts: Some(ContractsConfig {
|
||||
current_schedule: Default::default(),
|
||||
|
||||
@@ -20,8 +20,9 @@ aura = { package = "srml-aura", path = "../../srml/aura", default-features = fal
|
||||
authorship = { package = "srml-authorship", path = "../../srml/authorship", default-features = false }
|
||||
balances = { package = "srml-balances", path = "../../srml/balances", default-features = false }
|
||||
contracts = { package = "srml-contracts", path = "../../srml/contracts", default-features = false }
|
||||
council = { package = "srml-council", path = "../../srml/council", default-features = false }
|
||||
collective = { package = "srml-collective", path = "../../srml/collective", default-features = false }
|
||||
democracy = { package = "srml-democracy", path = "../../srml/democracy", default-features = false }
|
||||
elections = { package = "srml-elections", path = "../../srml/elections", default-features = false }
|
||||
executive = { package = "srml-executive", path = "../../srml/executive", default-features = false }
|
||||
finality-tracker = { package = "srml-finality-tracker", path = "../../srml/finality-tracker", default-features = false }
|
||||
grandpa = { package = "srml-grandpa", path = "../../srml/grandpa", default-features = false }
|
||||
@@ -56,8 +57,9 @@ std = [
|
||||
"authorship/std",
|
||||
"balances/std",
|
||||
"contracts/std",
|
||||
"council/std",
|
||||
"collective/std",
|
||||
"democracy/std",
|
||||
"elections/std",
|
||||
"executive/std",
|
||||
"finality-tracker/std",
|
||||
"grandpa/std",
|
||||
|
||||
@@ -40,9 +40,7 @@ use runtime_primitives::traits::{
|
||||
BlakeTwo256, Block as BlockT, DigestFor, NumberFor, StaticLookup, Convert,
|
||||
};
|
||||
use version::RuntimeVersion;
|
||||
use council::{motions as council_motions, VoteIndex};
|
||||
#[cfg(feature = "std")]
|
||||
use council::seats as council_seats;
|
||||
use elections::VoteIndex;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use version::NativeVersion;
|
||||
use substrate_primitives::OpaqueMetadata;
|
||||
@@ -71,8 +69,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
// and set impl_version to equal spec_version. If only runtime
|
||||
// implementation changes and behavior does not, then leave spec_version as
|
||||
// is and increment impl_version.
|
||||
spec_version: 107,
|
||||
impl_version: 107,
|
||||
spec_version: 108,
|
||||
impl_version: 108,
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
@@ -265,14 +263,22 @@ impl democracy::Trait for Runtime {
|
||||
type VotingPeriod = VotingPeriod;
|
||||
type EmergencyVotingPeriod = EmergencyVotingPeriod;
|
||||
type MinimumDeposit = MinimumDeposit;
|
||||
type ExternalOrigin = council_motions::EnsureProportionAtLeast<_1, _2, AccountId>;
|
||||
type ExternalMajorityOrigin = council_motions::EnsureProportionAtLeast<_2, _3, AccountId>;
|
||||
type EmergencyOrigin = council_motions::EnsureProportionAtLeast<_1, _1, AccountId>;
|
||||
type CancellationOrigin = council_motions::EnsureProportionAtLeast<_2, _3, AccountId>;
|
||||
type VetoOrigin = council_motions::EnsureMember<AccountId>;
|
||||
type ExternalOrigin = collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilInstance>;
|
||||
type ExternalMajorityOrigin = collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilInstance>;
|
||||
type ExternalPushOrigin = collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalInstance>;
|
||||
type EmergencyOrigin = collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilInstance>;
|
||||
type CancellationOrigin = collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilInstance>;
|
||||
type VetoOrigin = collective::EnsureMember<AccountId, CouncilInstance>;
|
||||
type CooloffPeriod = CooloffPeriod;
|
||||
}
|
||||
|
||||
type CouncilInstance = collective::Instance1;
|
||||
impl collective::Trait<CouncilInstance> for Runtime {
|
||||
type Origin = Origin;
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const CandidacyBond: Balance = 10 * DOLLARS;
|
||||
pub const VotingBond: Balance = 1 * DOLLARS;
|
||||
@@ -281,28 +287,30 @@ parameter_types! {
|
||||
pub const CarryCount: u32 = 6;
|
||||
// one additional vote should go by before an inactive voter can be reaped.
|
||||
pub const InactiveGracePeriod: VoteIndex = 1;
|
||||
pub const CouncilVotingPeriod: BlockNumber = 2 * DAYS;
|
||||
pub const ElectionsVotingPeriod: BlockNumber = 2 * DAYS;
|
||||
pub const DecayRatio: u32 = 0;
|
||||
}
|
||||
|
||||
impl council::Trait for Runtime {
|
||||
impl elections::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type BadPresentation = ();
|
||||
type BadReaper = ();
|
||||
type BadVoterIndex = ();
|
||||
type LoserCandidate = ();
|
||||
type OnMembersChanged = CouncilMotions;
|
||||
type ChangeMembers = Council;
|
||||
type CandidacyBond = CandidacyBond;
|
||||
type VotingBond = VotingBond;
|
||||
type VotingFee = VotingFee;
|
||||
type PresentSlashPerVoter = PresentSlashPerVoter;
|
||||
type CarryCount = CarryCount;
|
||||
type InactiveGracePeriod = InactiveGracePeriod;
|
||||
type CouncilVotingPeriod = CouncilVotingPeriod;
|
||||
type VotingPeriod = ElectionsVotingPeriod;
|
||||
type DecayRatio = DecayRatio;
|
||||
}
|
||||
|
||||
impl council::motions::Trait for Runtime {
|
||||
type TechnicalInstance = collective::Instance2;
|
||||
impl collective::Trait<TechnicalInstance> for Runtime {
|
||||
type Origin = Origin;
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
@@ -317,8 +325,8 @@ parameter_types! {
|
||||
|
||||
impl treasury::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type ApproveOrigin = council_motions::EnsureMembers<_4, AccountId>;
|
||||
type RejectOrigin = council_motions::EnsureMembers<_2, AccountId>;
|
||||
type ApproveOrigin = collective::EnsureMembers<_4, AccountId, CouncilInstance>;
|
||||
type RejectOrigin = collective::EnsureMembers<_2, AccountId, CouncilInstance>;
|
||||
type Event = Event;
|
||||
type MintedForSpending = ();
|
||||
type ProposalRejection = ();
|
||||
@@ -406,9 +414,9 @@ construct_runtime!(
|
||||
Session: session::{Module, Call, Storage, Event, Config<T>},
|
||||
Staking: staking::{default, OfflineWorker},
|
||||
Democracy: democracy::{Module, Call, Storage, Config, Event<T>},
|
||||
Council: council::{Module, Call, Storage, Event<T>},
|
||||
CouncilMotions: council_motions::{Module, Call, Storage, Event<T>, Origin<T>},
|
||||
CouncilSeats: council_seats::{Config<T>},
|
||||
Council: collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
|
||||
TechnicalCommittee: collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
|
||||
Elections: elections::{Module, Call, Storage, Event<T>, Config<T>},
|
||||
FinalityTracker: finality_tracker::{Module, Call, Inherent},
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
|
||||
Treasury: treasury::{Module, Call, Storage, Event<T>},
|
||||
|
||||
Reference in New Issue
Block a user