From cc53599ffdc55c11bc4a523e2076eb780bccd090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 7 Jan 2020 19:07:54 +0100 Subject: [PATCH] Add sudo module to `polkadot-runtime` (#735) --- Cargo.lock | 16 ++++++++++++++++ runtime/polkadot/Cargo.toml | 2 ++ runtime/polkadot/src/lib.rs | 8 ++++++++ service/src/chain_spec.rs | 10 ++++++++-- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a1ad979f7679..72b6dd332c9f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3293,6 +3293,20 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pallet-sudo" +version = "2.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-master#c9ca968bcfcb7947c96543c4455a1966cd2c20b1" +dependencies = [ + "frame-support 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", + "frame-system 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", + "sp-runtime 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", + "sp-std 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", +] + [[package]] name = "pallet-timestamp" version = "2.0.0" @@ -3870,6 +3884,7 @@ dependencies = [ "pallet-session 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "pallet-staking 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "pallet-staking-reward-curve 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", + "pallet-sudo 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "pallet-timestamp 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "pallet-transaction-payment 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", "pallet-transaction-payment-rpc-runtime-api 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)", @@ -7526,6 +7541,7 @@ dependencies = [ "checksum pallet-session 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum pallet-staking 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum pallet-staking-reward-curve 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" +"checksum pallet-sudo 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum pallet-timestamp 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum pallet-transaction-payment 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" "checksum pallet-transaction-payment-rpc 2.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-master)" = "" diff --git a/runtime/polkadot/Cargo.toml b/runtime/polkadot/Cargo.toml index cc6aeb3a4a047..bcda43a85d812 100644 --- a/runtime/polkadot/Cargo.toml +++ b/runtime/polkadot/Cargo.toml @@ -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 } @@ -126,4 +127,5 @@ std = [ "sp-session/std", "randomness-collective-flip/std", "runtime-common/std", + "sudo/std", ] diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index b3ce8c545fc83..1eac790436f61 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -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, @@ -534,6 +539,9 @@ construct_runtime! { ImOnline: im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, AuthorityDiscovery: authority_discovery::{Module, Call, Config}, + // Sudo. Usable initially. + Sudo: sudo, + // Governance stuff; uncallable initially. Democracy: democracy::{Module, Call, Storage, Config, Event}, Council: collective::::{Module, Call, Storage, Origin, Event, Config}, diff --git a/service/src/chain_spec.rs b/service/src/chain_spec.rs index d00ead0a60665..a504ab970be1a 100644 --- a/service/src/chain_spec.rs +++ b/service/src/chain_spec.rs @@ -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(), }) } } @@ -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>, ) -> polkadot::GenesisConfig { let endowed_accounts: Vec = endowed_accounts.unwrap_or_else(|| { @@ -354,7 +357,10 @@ pub fn testnet_genesis( claims: Some(polkadot::ClaimsConfig { claims: vec![], vesting: vec![], - }) + }), + sudo: Some(polkadot::SudoConfig { + key: root_key, + }), } }