Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
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
201 changes: 118 additions & 83 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "pol
substrate-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
srml-system-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
srml-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
polkadot-runtime = { path = "../runtime" }

8 changes: 7 additions & 1 deletion rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

use std::sync::Arc;

use polkadot_primitives::{Block, AccountId, Nonce};
use polkadot_primitives::{Block, AccountId, Nonce, Balance};
use sr_primitives::traits::ProvideRuntimeApi;
use transaction_pool::txpool::{ChainApi, Pool};
use polkadot_runtime::UncheckedExtrinsic;

/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpc_core::IoHandler<substrate_rpc::Metadata>;
Expand All @@ -33,13 +34,18 @@ pub fn create<C, P>(client: Arc<C>, pool: Arc<Pool<P>>) -> RpcExtension where
C: client::blockchain::HeaderBackend<Block>,
C: Send + Sync + 'static,
C::Api: srml_system_rpc::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: srml_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UncheckedExtrinsic>,
P: ChainApi + Sync + Send + 'static,
{
use srml_system_rpc::{System, SystemApi};
use srml_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};

let mut io = jsonrpc_core::IoHandler::default();
io.extend_with(
SystemApi::to_delegate(System::new(client.clone(), pool))
);
io.extend_with(
TransactionPaymentApi::to_delegate(TransactionPayment::new(client))
);
io
}
2 changes: 2 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ authorship = { package = "srml-authorship", git = "https://github.com/paritytech
babe = { package = "srml-babe", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
balances = { package = "srml-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
transaction-payment = { package = "srml-transaction-payment", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
srml-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
collective = { package = "srml-collective", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
democracy = { package = "srml-democracy", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
elections-phragmen = { package = "srml-elections-phragmen", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
Expand Down Expand Up @@ -92,6 +93,7 @@ std = [
"authorship/std",
"balances/std",
"transaction-payment/std",
"srml-transaction-payment-rpc-runtime-api/std",
"collective/std",
"elections-phragmen/std",
"democracy/std",
Expand Down
19 changes: 18 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use srml_support::{
};
use im_online::sr25519::AuthorityId as ImOnlineId;
use system::offchain::TransactionSubmitter;
use srml_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;

#[cfg(feature = "std")]
pub use staking::StakerStatus;
Expand Down Expand Up @@ -379,6 +380,9 @@ impl collective::Trait<CouncilCollective> for Runtime {
parameter_types! {
pub const CandidacyBond: Balance = 100 * DOLLARS;
pub const VotingBond: Balance = 5 * DOLLARS;
pub const TermDuration: BlockNumber = 10 * MINUTES;
pub const DesiredMembers: u32 = 13;
pub const DesiredRunnersUp: u32 = 7;
}

impl elections_phragmen::Trait for Runtime {
Expand All @@ -388,6 +392,9 @@ impl elections_phragmen::Trait for Runtime {
type CurrencyToVote = CurrencyToVoteHandler;
type CandidacyBond = CandidacyBond;
type VotingBond = VotingBond;
type TermDuration = TermDuration;
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
type LoserCandidate = Treasury;
type BadReport = Treasury;
type KickedMember = Treasury;
Expand Down Expand Up @@ -576,7 +583,7 @@ construct_runtime!(
Democracy: democracy::{Module, Call, Storage, Config, Event<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>},
ElectionsPhragmen: elections_phragmen::{Module, Call, Storage, Event<T>, Config<T>},
ElectionsPhragmen: elections_phragmen::{Module, Call, Storage, Event<T>},
TechnicalMembership: membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
Treasury: treasury::{Module, Call, Storage, Event<T>},

Expand Down Expand Up @@ -742,4 +749,14 @@ impl_runtime_apis! {
System::account_nonce(account)
}
}

impl srml_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
Block,
Balance,
UncheckedExtrinsic,
> for Runtime {
fn query_info(uxt: UncheckedExtrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
TransactionPayment::query_info(uxt, len)
}
}
}
28 changes: 4 additions & 24 deletions service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
use primitives::{Pair, Public, crypto::UncheckedInto, sr25519};
use polkadot_primitives::{AccountId, AccountPublic, parachain::ValidatorId};
use polkadot_runtime::{
GenesisConfig, CouncilConfig, ElectionsPhragmenConfig, DemocracyConfig, SystemConfig,
SessionConfig, StakingConfig, BalancesConfig, SessionKeys, TechnicalCommitteeConfig,
SudoConfig, IndicesConfig, StakerStatus, WASM_BINARY,
ClaimsConfig, ParachainsConfig, RegistrarConfig
GenesisConfig, CouncilConfig, DemocracyConfig, SystemConfig, SessionConfig, StakingConfig,
BalancesConfig, SessionKeys, TechnicalCommitteeConfig, SudoConfig, IndicesConfig, StakerStatus,
WASM_BINARY, ClaimsConfig, ParachainsConfig, RegistrarConfig
};
use polkadot_runtime::constants::{currency::DOTS, time::*};
use polkadot_runtime::constants::currency::DOTS;
use sr_primitives::{traits::IdentifyAccount, Perbill};
use telemetry::TelemetryEndpoints;
use hex_literal::hex;
Expand Down Expand Up @@ -138,12 +137,6 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
members: vec![],
phantom: Default::default(),
}),
elections_phragmen: Some(ElectionsPhragmenConfig {
members: vec![],
term_duration: 49 * DAYS,
desired_members: 7,
desired_runners_up: 3,
}),
membership_Instance1: Some(Default::default()),
babe: Some(Default::default()),
grandpa: Some(Default::default()),
Expand Down Expand Up @@ -239,8 +232,6 @@ pub fn testnet_genesis(
const ENDOWMENT: u128 = 1_000_000 * DOTS;
const STASH: u128 = 100 * DOTS;

let desired_members = (endowed_accounts.len() / 2 - initial_authorities.len()) as u32;

GenesisConfig {
system: Some(SystemConfig {
code: WASM_BINARY.to_vec(),
Expand Down Expand Up @@ -280,17 +271,6 @@ pub fn testnet_genesis(
members: vec![],
phantom: Default::default(),
}),
elections_phragmen: Some(ElectionsPhragmenConfig {
members: endowed_accounts.iter()
.filter(|&endowed| initial_authorities.iter()
.find(|&(_, controller, _, _, _, _)| controller == endowed)
.is_none()
).cloned()
.collect(),
term_duration: 1 * DAYS,
desired_runners_up: desired_members / 2,
desired_members,
}),
membership_Instance1: Some(Default::default()),
babe: Some(Default::default()),
grandpa: Some(Default::default()),
Expand Down