Sudo module (#1315)

* Sudo module

* Fix comment

* Fix errors

* Fix test

* Update hashes

* Final test fixes and build

* Final hex change
This commit is contained in:
Gav Wood
2018-12-21 13:43:34 +01:00
committed by GitHub
parent d67821a580
commit ef8b94656e
10 changed files with 184 additions and 8 deletions
+7 -1
View File
@@ -20,7 +20,7 @@ use primitives::{AuthorityId, ed25519};
use node_primitives::AccountId;
use node_runtime::{ConsensusConfig, CouncilSeatsConfig, CouncilVotingConfig, DemocracyConfig,
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, TreasuryConfig,
UpgradeKeyConfig, ContractConfig, GrandpaConfig, Permill, Perbill};
UpgradeKeyConfig, SudoConfig, ContractConfig, GrandpaConfig, Permill, Perbill};
pub use node_runtime::GenesisConfig;
use substrate_service;
@@ -132,6 +132,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
upgrade_key: Some(UpgradeKeyConfig {
key: endowed_accounts[0].clone(),
}),
sudo: Some(SudoConfig {
key: endowed_accounts[0].clone(),
}),
grandpa: Some(GrandpaConfig {
authorities: initial_authorities.clone().into_iter().map(|k| (k, 1)).collect(),
})
@@ -256,6 +259,9 @@ pub fn testnet_genesis(
upgrade_key: Some(UpgradeKeyConfig {
key: upgrade_key,
}),
sudo: Some(SudoConfig {
key: upgrade_key,
}),
grandpa: Some(GrandpaConfig {
authorities: initial_authorities.clone().into_iter().map(|k| (k, 1)).collect(),
})
+6 -5
View File
@@ -260,6 +260,7 @@ mod tests {
treasury: Some(Default::default()),
contract: Some(Default::default()),
upgrade_key: Some(Default::default()),
sudo: Some(Default::default()),
grandpa: Some(GrandpaConfig {
authorities: vec![ // set these so no GRANDPA events fire when session changes
(Alice.to_raw_public().into(), 1),
@@ -311,9 +312,9 @@ mod tests {
1,
GENESIS_HASH.into(),
if support_changes_trie {
hex!("1a7758d96d7353732f3054a3dacb18f04f42fc48f6706378d6f7be744c6022f1").into()
hex!("bc4bdc45ba03402f9b4c7ec09834065c57205b1742bf2469ab9fc54544d8d002").into()
} else {
hex!("1cf270c8a484df4931af562f7afdc9f44d99ae1bd35fe30fbd2cf3c1be2e933b").into()
hex!("6bfbf71fa08d99f2488e295807059269cbc43ea21af3316a92406974593a1fc2").into()
},
if support_changes_trie {
vec![changes_trie_log(
@@ -339,7 +340,7 @@ mod tests {
construct_block(
2,
block1(false).1,
hex!("a208e27269f8a17e7f7cf9513396d3579066df10a853e030345847ec96593c2e").into(),
hex!("24f8ac99a6d98e9b53f4f6ef6ffdd12ba53ea3f247200a8126fa69c4b5047fbc").into(),
vec![ // session changes here, so we add a grandpa change signal log.
Log::from(::grandpa::RawLog::AuthoritiesChangeSignal(0, vec![
(Keyring::One.to_raw_public().into(), 1),
@@ -368,7 +369,7 @@ mod tests {
construct_block(
1,
GENESIS_HASH.into(),
hex!("a506a69fefa4dc1be6838b68dc6e5799bd5fec545ef890cadac20edc0254d37a").into(),
hex!("7b7d3b509a444cdf214825d3354507823a4c91eafa493f0956448881a81ab797").into(),
vec![],
vec![
CheckedExtrinsic {
@@ -658,7 +659,7 @@ mod tests {
let b = construct_block(
1,
GENESIS_HASH.into(),
hex!("3af4e1ba0769122b1e92b138fecf7ce8bb2fe4f2a65fba3b423f87942f1ba8c8").into(),
hex!("bfc8051f91071149cca8b8dca6290fdb82eda6868d48cfed25f8ca38ed3a1049").into(),
vec![],
vec![
CheckedExtrinsic {
+2
View File
@@ -25,6 +25,7 @@ srml-staking = { path = "../../srml/staking", default-features = false }
srml-system = { path = "../../srml/system", default-features = false }
srml-timestamp = { path = "../../srml/timestamp", default-features = false }
srml-treasury = { path = "../../srml/treasury", default-features = false }
srml-sudo = { path = "../../srml/sudo", default-features = false }
srml-upgrade-key = { path = "../../srml/upgrade-key", default-features = false }
srml-grandpa = { path = "../../srml/grandpa", default-features = false }
sr-version = { path = "../../core/sr-version", default-features = false }
@@ -55,6 +56,7 @@ std = [
"srml-system/std",
"srml-timestamp/std",
"srml-treasury/std",
"srml-sudo/std",
"srml-upgrade-key/std",
"sr-version/std",
"node-primitives/std",
+9 -2
View File
@@ -47,6 +47,7 @@ extern crate srml_executive as executive;
extern crate srml_grandpa as grandpa;
extern crate srml_session as session;
extern crate srml_staking as staking;
extern crate srml_sudo as sudo;
extern crate srml_system as system;
extern crate srml_timestamp as timestamp;
extern crate srml_treasury as treasury;
@@ -96,8 +97,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node"),
impl_name: create_runtime_str!("substrate-node"),
authoring_version: 10,
spec_version: 10,
impl_version: 0,
spec_version: 11,
impl_version: 11,
apis: RUNTIME_API_VERSIONS,
};
@@ -205,6 +206,11 @@ impl upgrade_key::Trait for Runtime {
type Event = Event;
}
impl sudo::Trait for Runtime {
type Event = Event;
type Proposal = Call;
}
impl grandpa::Trait for Runtime {
type SessionKey = SessionKey;
type Log = Log;
@@ -233,6 +239,7 @@ construct_runtime!(
Treasury: treasury,
Contract: contract::{Module, Call, Config<T>, Event<T>},
UpgradeKey: upgrade_key,
Sudo: sudo,
}
);
+19
View File
@@ -520,6 +520,7 @@ dependencies = [
"srml-grandpa 0.1.0",
"srml-session 0.1.0",
"srml-staking 0.1.0",
"srml-sudo 0.1.0",
"srml-support 0.1.0",
"srml-system 0.1.0",
"srml-timestamp 0.1.0",
@@ -1282,6 +1283,24 @@ dependencies = [
"substrate-primitives 0.1.0",
]
[[package]]
name = "srml-sudo"
version = "0.1.0"
dependencies = [
"hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec-derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 0.1.0",
"sr-primitives 0.1.0",
"sr-std 0.1.0",
"srml-consensus 0.1.0",
"srml-support 0.1.0",
"srml-support-procedural 0.1.0",
"srml-system 0.1.0",
"substrate-primitives 0.1.0",
]
[[package]]
name = "srml-support"
version = "0.1.0"