-
Notifications
You must be signed in to change notification settings - Fork 2.7k
*: Refactor authority discovery (key mngmt, runtime API) #3955
Changes from 1 commit
47b4f7c
4d80316
1be93d3
3551221
b516aee
404d9a9
e922805
38cf886
50e90a9
db05799
b7b49c4
1d72997
180f5ec
8aca3d7
f8cfff7
642ca6c
1f5241c
744c218
409d885
79de0c0
0b8f7dd
a6d8f6c
1a90903
a2c9df5
edff1f8
ae5108a
3b71b57
65756f9
0ae3bfe
fc5156c
4d36114
56d630c
b689a1f
89f5018
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,9 @@ use chain_spec::ChainSpecExtension; | |
| use primitives::{Pair, Public, crypto::UncheckedInto, sr25519}; | ||
| use serde::{Serialize, Deserialize}; | ||
| use node_runtime::{ | ||
| BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, DemocracyConfig, GrandpaConfig, | ||
| ImOnlineConfig, IndicesConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig, | ||
| SudoConfig, SystemConfig, TechnicalCommitteeConfig, WASM_BINARY, | ||
| AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, DemocracyConfig, | ||
| GrandpaConfig, ImOnlineConfig, IndicesConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig, SudoConfig, | ||
| SystemConfig, TechnicalCommitteeConfig, WASM_BINARY, | ||
| }; | ||
| use node_runtime::Block; | ||
| use node_runtime::constants::currency::*; | ||
|
|
@@ -32,6 +32,7 @@ use substrate_telemetry::TelemetryEndpoints; | |
| use grandpa_primitives::{AuthorityId as GrandpaId}; | ||
| use babe_primitives::{AuthorityId as BabeId}; | ||
| use im_online::sr25519::{AuthorityId as ImOnlineId}; | ||
| use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; | ||
| use sr_primitives::{Perbill, traits::{Verify, IdentifyAccount}}; | ||
|
|
||
| pub use node_primitives::{AccountId, Balance, Signature}; | ||
|
|
@@ -61,8 +62,13 @@ pub fn flaming_fir_config() -> Result<ChainSpec, String> { | |
| ChainSpec::from_json_bytes(&include_bytes!("../res/flaming-fir.json")[..]) | ||
| } | ||
|
|
||
| fn session_keys(grandpa: GrandpaId, babe: BabeId, im_online: ImOnlineId) -> SessionKeys { | ||
| SessionKeys { grandpa, babe, im_online, } | ||
| fn session_keys( | ||
| grandpa: GrandpaId, | ||
| babe: BabeId, | ||
| im_online: ImOnlineId, | ||
| authority_discovery: AuthorityDiscoveryId, | ||
| ) -> SessionKeys { | ||
| SessionKeys { grandpa, babe, im_online, authority_discovery} | ||
| } | ||
|
|
||
| fn staging_testnet_config_genesis() -> GenesisConfig { | ||
|
|
@@ -72,7 +78,7 @@ fn staging_testnet_config_genesis() -> GenesisConfig { | |
| // and | ||
| // for i in 1 2 3 4 ; do for j in session; do subkey --ed25519 inspect "$secret"//fir//$j//$i; done; done | ||
|
|
||
| let initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId, ImOnlineId)> = vec![( | ||
| let initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId)> = vec![( | ||
| // 5Fbsd6WXDGiLTxunqeK5BATNiocfCqu9bS1yArVjCgeBLkVy | ||
| hex!["9c7a2ee14e565db0c69f78c7b4cd839fbf52b607d867e9e9c5a79042898a0d12"].into(), | ||
| // 5EnCiV7wSHeNhjW3FSUwiJNkcc2SBkPLn5Nj93FmbLtBjQUq | ||
|
|
@@ -83,6 +89,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig { | |
| hex!["6e7e4eb42cbd2e0ab4cae8708ce5509580b8c04d11f6758dbf686d50fe9f9106"].unchecked_into(), | ||
| // 5EZaeQ8djPcq9pheJUhgerXQZt9YaHnMJpiHMRhwQeinqUW8 | ||
| hex!["6e7e4eb42cbd2e0ab4cae8708ce5509580b8c04d11f6758dbf686d50fe9f9106"].unchecked_into(), | ||
| // TODO: Is it safe to just copy like ImOnlineId did from BabeId? | ||
| // 5EZaeQ8djPcq9pheJUhgerXQZt9YaHnMJpiHMRhwQeinqUW8 | ||
| hex!["6e7e4eb42cbd2e0ab4cae8708ce5509580b8c04d11f6758dbf686d50fe9f9106"].unchecked_into(), | ||
| ),( | ||
| // 5ERawXCzCWkjVq3xz1W5KGNtVx2VdefvZ62Bw1FEuZW4Vny2 | ||
| hex!["68655684472b743e456907b398d3a44c113f189e56d1bbfd55e889e295dfde78"].into(), | ||
|
|
@@ -94,6 +103,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig { | |
| hex!["482dbd7297a39fa145c570552249c2ca9dd47e281f0c500c971b59c9dcdcd82e"].unchecked_into(), | ||
| // 5DhLtiaQd1L1LU9jaNeeu9HJkP6eyg3BwXA7iNMzKm7qqruQ | ||
| hex!["482dbd7297a39fa145c570552249c2ca9dd47e281f0c500c971b59c9dcdcd82e"].unchecked_into(), | ||
| // TODO: Is it safe to just copy like ImOnlineId did from BabeId? | ||
| // 5DhLtiaQd1L1LU9jaNeeu9HJkP6eyg3BwXA7iNMzKm7qqruQ | ||
| hex!["482dbd7297a39fa145c570552249c2ca9dd47e281f0c500c971b59c9dcdcd82e"].unchecked_into(), | ||
| ),( | ||
| // 5DyVtKWPidondEu8iHZgi6Ffv9yrJJ1NDNLom3X9cTDi98qp | ||
| hex!["547ff0ab649283a7ae01dbc2eb73932eba2fb09075e9485ff369082a2ff38d65"].into(), | ||
|
|
@@ -105,6 +117,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig { | |
| hex!["482a3389a6cf42d8ed83888cfd920fec738ea30f97e44699ada7323f08c3380a"].unchecked_into(), | ||
| // 5DhKqkHRkndJu8vq7pi2Q5S3DfftWJHGxbEUNH43b46qNspH | ||
| hex!["482a3389a6cf42d8ed83888cfd920fec738ea30f97e44699ada7323f08c3380a"].unchecked_into(), | ||
| // TODO: Is it safe to just copy like ImOnlineId did from BabeId? | ||
| // 5DhKqkHRkndJu8vq7pi2Q5S3DfftWJHGxbEUNH43b46qNspH | ||
| hex!["482a3389a6cf42d8ed83888cfd920fec738ea30f97e44699ada7323f08c3380a"].unchecked_into(), | ||
| ),( | ||
| // 5HYZnKWe5FVZQ33ZRJK1rG3WaLMztxWrrNDb1JRwaHHVWyP9 | ||
| hex!["f26cdb14b5aec7b2789fd5ca80f979cef3761897ae1f37ffb3e154cbcc1c2663"].into(), | ||
|
|
@@ -116,6 +131,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig { | |
| hex!["00299981a2b92f878baaf5dbeba5c18d4e70f2a1fcd9c61b32ea18daf38f4378"].unchecked_into(), | ||
| // 5C4vDQxA8LTck2xJEy4Yg1hM9qjDt4LvTQaMo4Y8ne43aU6x | ||
| hex!["00299981a2b92f878baaf5dbeba5c18d4e70f2a1fcd9c61b32ea18daf38f4378"].unchecked_into(), | ||
| // TODO: Is it safe to just copy like ImOnlineId did from BabeId? | ||
|
||
| // 5C4vDQxA8LTck2xJEy4Yg1hM9qjDt4LvTQaMo4Y8ne43aU6x | ||
| hex!["00299981a2b92f878baaf5dbeba5c18d4e70f2a1fcd9c61b32ea18daf38f4378"].unchecked_into(), | ||
| )]; | ||
|
|
||
| // generated with secret: subkey inspect "$secret"/fir | ||
|
|
@@ -164,19 +182,20 @@ pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId where | |
| } | ||
|
|
||
| /// Helper function to generate stash, controller and session key from seed | ||
| pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, GrandpaId, BabeId, ImOnlineId) { | ||
| pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId) { | ||
| ( | ||
| get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)), | ||
| get_account_id_from_seed::<sr25519::Public>(seed), | ||
| get_from_seed::<GrandpaId>(seed), | ||
| get_from_seed::<BabeId>(seed), | ||
| get_from_seed::<ImOnlineId>(seed), | ||
| get_from_seed::<AuthorityDiscoveryId>(seed), | ||
| ) | ||
| } | ||
|
|
||
| /// Helper function to create GenesisConfig for testing | ||
| pub fn testnet_genesis( | ||
| initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId, ImOnlineId)>, | ||
| initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId, ImOnlineId, AuthorityDiscoveryId)>, | ||
| root_key: AccountId, | ||
| endowed_accounts: Option<Vec<AccountId>>, | ||
| enable_println: bool, | ||
|
|
@@ -220,7 +239,8 @@ pub fn testnet_genesis( | |
| }), | ||
| session: Some(SessionConfig { | ||
| keys: initial_authorities.iter().map(|x| { | ||
| (x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone())) | ||
| // TODO: Again, is this safe to do? | ||
|
||
| (x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone())) | ||
| }).collect::<Vec<_>>(), | ||
| }), | ||
| staking: Some(StakingConfig { | ||
|
|
@@ -259,6 +279,9 @@ pub fn testnet_genesis( | |
| im_online: Some(ImOnlineConfig { | ||
| keys: vec![], | ||
| }), | ||
| authority_discovery: Some(AuthorityDiscoveryConfig { | ||
| keys: vec![], | ||
| }), | ||
| grandpa: Some(GrandpaConfig { | ||
| authorities: vec![], | ||
| }), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.