Switch node template to use AuRa (#3790)

* Stuck on service

* Make service compile

* Remove Grandpa dependency

* Update node-template/runtime/Cargo.toml

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Fix build

* Update crypto import

* Update node-template/src/service.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update node-template/src/service.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update node-template/src/service.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update node-template/src/service.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update node-template/runtime/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Fix macro dependency

* Trying to add grandpa back

* Update node-template/src/chain_spec.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update node-template/src/chain_spec.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update node-template/src/chain_spec.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update node-template/src/service.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Update node-template/src/service.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Unused import

* Use grandpa block import
This commit is contained in:
Shawn Tabrizi
2019-10-18 19:58:31 +09:00
committed by André Silva
parent bf1786b628
commit c1a24fb537
8 changed files with 83 additions and 126 deletions
+10 -12
View File
@@ -1,9 +1,9 @@
use primitives::{Pair, Public};
use node_template_runtime::{
AccountId, BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY,
};
use babe_primitives::{AuthorityId as BabeId};
use aura_primitives::sr25519::{AuthorityId as AuraId};
use grandpa_primitives::{AuthorityId as GrandpaId};
use substrate_service;
@@ -31,13 +31,11 @@ pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Pu
.public()
}
/// Helper function to generate stash, controller and session key from seed
pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, GrandpaId, BabeId) {
/// Helper function to generate an authority key for Aura
pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
(
get_from_seed::<AccountId>(&format!("{}//stash", seed)),
get_from_seed::<AccountId>(seed),
get_from_seed::<GrandpaId>(seed),
get_from_seed::<BabeId>(seed),
get_from_seed::<AuraId>(s),
get_from_seed::<GrandpaId>(s),
)
}
@@ -106,7 +104,7 @@ impl Alternative {
}
}
fn testnet_genesis(initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId)>,
fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
_enable_println: bool) -> GenesisConfig {
@@ -125,11 +123,11 @@ fn testnet_genesis(initial_authorities: Vec<(AccountId, AccountId, GrandpaId, Ba
sudo: Some(SudoConfig {
key: root_key,
}),
babe: Some(BabeConfig {
authorities: initial_authorities.iter().map(|x| (x.3.clone(), 1)).collect(),
aura: Some(AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
}),
grandpa: Some(GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
}),
}
}