Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 19 additions & 0 deletions Cargo.lock

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

14 changes: 11 additions & 3 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use node_template_runtime::{
opaque::Block, wasm_binary_unwrap, AccountId, AuraConfig, AuthorityDiscoveryConfig, BabeConfig,
Balance, BalancesConfig, CouncilConfig, DemocracyConfig, GenesisConfig, GrandpaConfig,
ImOnlineConfig, IndicesConfig, MaxNominations, NominationPoolsConfig, SessionConfig,
SessionKeys, Signature, StakerStatus, StakingConfig, SudoConfig, SystemConfig,
Balance, BalancesConfig, CouncilConfig, DemocracyConfig, ElectionsConfig, GenesisConfig,
GrandpaConfig, ImOnlineConfig, IndicesConfig, MaxNominations, NominationPoolsConfig,
SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig, SudoConfig, SystemConfig,
TechnicalCommitteeConfig, DOLLARS,
};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
Expand Down Expand Up @@ -260,6 +260,14 @@ pub fn testnet_genesis(
assets: Default::default(),
democracy: DemocracyConfig::default(),
indices: IndicesConfig { indices: vec![] },
elections: ElectionsConfig {
members: endowed_accounts
.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.map(|member| (member, STASH))
.collect(),
},
transaction_payment: Default::default(),
}
}
4 changes: 4 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
# third-party dependencies
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
static_assertions = "1.1.0"

# primitives
node-primitives = { version = "2.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
Expand Down Expand Up @@ -57,6 +58,7 @@ pallet-contracts-primitives = { version = "6.0.0", default-features = false, git
pallet-contracts-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-conviction-voting = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-democracy = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-elections-phragmen = { version = "5.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-election-provider-multi-phase = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-grandpa = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-im-online = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
Expand Down Expand Up @@ -116,6 +118,7 @@ std = [
"pallet-contracts-rpc-runtime-api/std",
"pallet-conviction-voting/std",
"pallet-democracy/std",
"pallet-elections-phragmen/std",
"pallet-election-provider-multi-phase/std",
"pallet-grandpa/std",
"pallet-im-online/std",
Expand Down Expand Up @@ -179,6 +182,7 @@ try-runtime = [
"pallet-collective/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-democracy/try-runtime",
"pallet-elections-phragmen/try-runtime",
"pallet-election-provider-multi-phase/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-im-online/try-runtime",
Expand Down
44 changes: 43 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use frame_election_provider_support::{
onchain, BalancingConfig, ElectionDataProvider, SequentialPhragmen, VoteWeight,
};
use frame_support::{
traits::{ConstU16, TotalIssuanceOf},
traits::{ConstU16, LockIdentifier, TotalIssuanceOf},
weights::DispatchClass,
PalletId,
};
Expand All @@ -47,6 +47,7 @@ use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use static_assertions::const_assert;

// A few exports that help ease life for downstream crates.
pub use frame_support::{
Expand Down Expand Up @@ -1076,6 +1077,46 @@ impl pallet_indices::Config for Runtime {
type WeightInfo = pallet_indices::weights::SubstrateWeight<Runtime>;
}

parameter_types! {
pub const CandidacyBond: Balance = 10 * DOLLARS;
// 1 storage item created, key size is 32 bytes, value size is 16+16.
pub const VotingBondBase: Balance = deposit(1, 64);
// additional data per vote is 32 bytes (account id).
pub const VotingBondFactor: Balance = deposit(0, 32);
pub const TermDuration: BlockNumber = 7 * DAYS;
pub const DesiredMembers: u32 = 13;
pub const DesiredRunnersUp: u32 = 7;
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
pub const MaxCandidates: u32 = 10;
pub const MaxVoters: u32 = 100;
}

// Make sure that there are no more than `MaxMembers` members elected via elections-phragmen.
const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());

// TODO - Update settings
impl pallet_elections_phragmen::Config for Runtime {
type Event = Event;
type PalletId = ElectionsPhragmenPalletId;
type Currency = Balances;
type ChangeMembers = Council;
// NOTE: this implies that council's genesis members cannot be set directly and must come from
// this module.
type InitializeMembers = Council;
type CurrencyToVote = U128CurrencyToVote;
type CandidacyBond = CandidacyBond;
type VotingBondBase = VotingBondBase;
type VotingBondFactor = VotingBondFactor;
type LoserCandidate = ();
type KickedMember = ();
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
type TermDuration = TermDuration;
type WeightInfo = pallet_elections_phragmen::weights::SubstrateWeight<Runtime>;
type MaxCandidates = MaxCandidates;
type MaxVoters = MaxVoters;
}

impl pallet_sudo::Config for Runtime {
type Event = Event;
type Call = Call;
Expand Down Expand Up @@ -1145,6 +1186,7 @@ construct_runtime!(
AssetTxPayment: pallet_asset_tx_payment,
Democracy: pallet_democracy,
Indices: pallet_indices,
Elections: pallet_elections_phragmen,
}
);

Expand Down