Skip to content
This repository was archived by the owner on Feb 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Replace Babe consensus with Aura
Aura is better suited for development. See paritytech/substrate#3790
  • Loading branch information
Thomas Scholtes committed Oct 22, 2019
commit 22ecb1521fb0661bd4f19aed8d1d33d605b5c396
78 changes: 23 additions & 55 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ version = "3.1.3"
[dependencies.radicle_registry_runtime]
path = "../runtime"

[dependencies.babe]
path = "../substrate/core/consensus/babe"
package = "substrate-consensus-babe"
[dependencies.aura]
path = "../substrate/core/consensus/aura"
package = "substrate-consensus-aura"

[dependencies.babe-primitives]
path = "../substrate/core/consensus/babe/primitives"
package = "substrate-consensus-babe-primitives"
[dependencies.aura-primitives]
path = "../substrate/core/consensus/aura/primitives"
package = "substrate-consensus-aura-primitives"

[dependencies.basic-authorship]
path = "../substrate/core/basic-authorship"
Expand Down
17 changes: 7 additions & 10 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use babe_primitives::AuthorityId as BabeId;
use aura_primitives::sr25519::AuthorityId as AuraId;
use grandpa_primitives::AuthorityId as GrandpaId;
use primitives::{Pair, Public};
use radicle_registry_runtime::{
AccountId, BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig, IndicesConfig, SudoConfig,
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, IndicesConfig, SudoConfig,
SystemConfig, WASM_BINARY,
};
use substrate_service;
Expand Down Expand Up @@ -32,12 +32,12 @@ pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Pu
}

/// Helper function to generate stash, controller and session key from seed
pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, GrandpaId, BabeId) {
pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, GrandpaId, AuraId) {
(
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>(seed),
)
}

Expand Down Expand Up @@ -113,7 +113,7 @@ impl Alternative {
}

fn testnet_genesis(
initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId)>,
initial_authorities: Vec<(AccountId, AccountId, GrandpaId, AuraId)>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
_enable_println: bool,
Expand All @@ -135,11 +135,8 @@ fn testnet_genesis(
vesting: vec![],
}),
srml_sudo: Some(SudoConfig { key: root_key }),
srml_babe: Some(BabeConfig {
authorities: initial_authorities
.iter()
.map(|x| (x.3.clone(), 1))
.collect(),
srml_aura: Some(AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.3.clone())).collect(),
}),
srml_grandpa: Some(GrandpaConfig {
authorities: initial_authorities
Expand Down
1 change: 1 addition & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::chain_spec;
use crate::service;
use aura_primitives::sr25519::AuthorityPair as AuraPair;
use futures::{future, sync::oneshot, Future};
use log::info;
use std::cell::RefCell;
Expand Down
63 changes: 24 additions & 39 deletions node/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.

use babe;
use aura_primitives::sr25519::AuthorityPair as AuraPair;
use futures::prelude::*;
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use inherents::InherentDataProviders;
Expand Down Expand Up @@ -51,36 +51,29 @@ macro_rules! new_full_start {
transaction_pool::FullChainApi::new(client),
))
})?
.with_import_queue(|_config, client, mut select_chain, _transaction_pool| {
.with_import_queue(|_config, client, mut select_chain, transaction_pool| {
let select_chain = select_chain
.take()
.ok_or_else(|| substrate_service::Error::SelectChainRequired)?;

let (grandpa_block_import, grandpa_link) =
grandpa::block_import::<_, _, _, radicle_registry_runtime::RuntimeApi, _, _>(
client.clone(),
&*client,
select_chain,
)?;
let justification_import = grandpa_block_import.clone();

let (babe_block_import, babe_link) = babe::block_import(
babe::Config::get_or_compute(&*client)?,
grandpa_block_import,
client.clone(),
client.clone(),
)?;

let import_queue = babe::import_queue(
babe_link.clone(),
babe_block_import.clone(),
Some(Box::new(justification_import)),
let import_queue = aura::import_queue::<_, _, AuraPair, _>(
aura::SlotDuration::get_or_compute(&*client)?,
Box::new(grandpa_block_import.clone()),
Some(Box::new(grandpa_block_import.clone())),
None,
client.clone(),
client,
inherent_data_providers.clone(),
Some(transaction_pool),
)?;

import_setup = Some((babe_block_import, grandpa_link, babe_link));
import_setup = Some((grandpa_block_import, grandpa_link));

Ok(import_queue)
})?;
Expand All @@ -107,7 +100,7 @@ pub fn new_full<C: Send + Default + 'static>(
})?
.build()?;

let (block_import, grandpa_link, babe_link) = import_setup.take().expect(
let (block_import, grandpa_link) = import_setup.take().expect(
"Link Half and Block Import are present for Full Services or setup failed before. qed",
);

Expand All @@ -122,22 +115,21 @@ pub fn new_full<C: Send + Default + 'static>(
.select_chain()
.ok_or(ServiceError::SelectChainRequired)?;

let babe_config = babe::BabeParams {
keystore: service.keystore(),
let aura = aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _>(
aura::SlotDuration::get_or_compute(&*client)?,
client,
select_chain,
env: proposer,
block_import,
sync_oracle: service.network(),
inherent_data_providers: inherent_data_providers.clone(),
proposer,
service.network(),
inherent_data_providers.clone(),
force_authoring,
babe_link,
};
service.keystore(),
)?;

let babe = babe::start_babe(babe_config)?;
let select = babe.select(service.on_exit()).then(|_| Ok(()));
let select = aura.select(service.on_exit()).then(|_| Ok(()));

// the BABE authoring task is considered infallible, i.e. if it
// the AURA authoring task is considered essential, i.e. if it
// fails we take down the service with it.
service.spawn_essential_task(select);
}
Expand Down Expand Up @@ -169,6 +161,7 @@ pub fn new_full<C: Send + Default + 'static>(
inherent_data_providers: inherent_data_providers.clone(),
on_exit: service.on_exit(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
// voting_rule: grandpa::VotingRulesBuilder::default().build(),
};

// the GRANDPA voter task is considered infallible, i.e.
Expand Down Expand Up @@ -214,26 +207,18 @@ pub fn new_light<C: Send + Default + 'static>(
Arc::new(fetch_checker),
client.clone(),
)?;

let finality_proof_import = grandpa_block_import.clone();
let finality_proof_request_builder =
finality_proof_import.create_finality_proof_request_builder();

let (babe_block_import, babe_link) = babe::block_import(
babe::Config::get_or_compute(&*client)?,
grandpa_block_import,
client.clone(),
client.clone(),
)?;

let import_queue = babe::import_queue(
babe_link.clone(),
babe_block_import,
let import_queue = aura::import_queue::<_, _, AuraPair, ()>(
aura::SlotDuration::get_or_compute(&*client)?,
Box::new(grandpa_block_import),
None,
Some(Box::new(finality_proof_import)),
client.clone(),
client,
inherent_data_providers.clone(),
None,
)?;

Ok((import_queue, finality_proof_request_builder))
Expand Down
Loading