Skip to content

Commit

Permalink
Add sudo module to polkadot-runtime (paritytech#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr authored and gavofyork committed Jan 7, 2020
1 parent 3143e2c commit cc53599
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions runtime/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ system = { package = "frame-system", git = "https://github.com/paritytech/substr
system_rpc_runtime_api = { package = "frame-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sudo = { package = "pallet-sudo", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }

runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
Expand Down Expand Up @@ -126,4 +127,5 @@ std = [
"sp-session/std",
"randomness-collective-flip/std",
"runtime-common/std",
"sudo/std",
]
8 changes: 8 additions & 0 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ impl claims::Trait for Runtime {
type Prefix = Prefix;
}

impl sudo::Trait for Runtime {
type Event = Event;
type Proposal = Call;
}

construct_runtime! {
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -534,6 +539,9 @@ construct_runtime! {
ImOnline: im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: authority_discovery::{Module, Call, Config},

// Sudo. Usable initially.
Sudo: sudo,

// Governance stuff; uncallable initially.
Democracy: democracy::{Module, Call, Storage, Config, Event<T>},
Council: collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
Expand Down
10 changes: 8 additions & 2 deletions service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ fn staging_testnet_config_genesis() -> polkadot::GenesisConfig {
claims: Some(polkadot::ClaimsConfig {
claims: vec![],
vesting: vec![],
}),
sudo: Some(polkadot::SudoConfig {
key: endowed_accounts[0].clone(),
})
}
}
Expand Down Expand Up @@ -275,7 +278,7 @@ pub fn get_authority_keys_from_seed(seed: &str) -> (
/// Helper function to create GenesisConfig for testing
pub fn testnet_genesis(
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
_root_key: AccountId,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> polkadot::GenesisConfig {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
Expand Down Expand Up @@ -354,7 +357,10 @@ pub fn testnet_genesis(
claims: Some(polkadot::ClaimsConfig {
claims: vec![],
vesting: vec![],
})
}),
sudo: Some(polkadot::SudoConfig {
key: root_key,
}),
}
}

Expand Down

0 comments on commit cc53599

Please sign in to comment.