From 47a056b6a5c818c189d003336b3b063af1da512b Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 8 Oct 2019 12:06:39 +0900 Subject: [PATCH 01/20] Stuck on service --- Cargo.lock | 10 ++--- node-template/Cargo.toml | 5 +-- node-template/README.md | 14 ++++-- node-template/runtime/Cargo.toml | 10 ++--- node-template/runtime/src/lib.rs | 73 ++++++-------------------------- node-template/src/chain_spec.rs | 35 ++++++--------- node-template/src/service.rs | 2 - 7 files changed, 48 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca1270929fe4e..1728f7248f7c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2513,10 +2513,9 @@ dependencies = [ "substrate-basic-authorship 2.0.0", "substrate-cli 2.0.0", "substrate-client 2.0.0", - "substrate-consensus-babe 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", + "substrate-consensus-aura 2.0.0", + "substrate-consensus-aura-primitives 2.0.0", "substrate-executor 2.0.0", - "substrate-finality-grandpa 2.0.0", "substrate-finality-grandpa-primitives 2.0.0", "substrate-inherents 2.0.0", "substrate-network 2.0.0", @@ -2539,17 +2538,16 @@ dependencies = [ "sr-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", - "srml-babe 2.0.0", + "srml-aura 2.0.0", "srml-balances 2.0.0", "srml-executive 2.0.0", - "srml-grandpa 2.0.0", "srml-indices 2.0.0", "srml-sudo 2.0.0", "srml-support 2.0.0", "srml-system 2.0.0", "srml-timestamp 2.0.0", "substrate-client 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", + "substrate-consensus-aura-primitives 2.0.0", "substrate-offchain-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-session 2.0.0", diff --git a/node-template/Cargo.toml b/node-template/Cargo.toml index 2aa305486ce21..191f8c396c4bc 100644 --- a/node-template/Cargo.toml +++ b/node-template/Cargo.toml @@ -27,9 +27,8 @@ substrate-service = { path = "../core/service" } inherents = { package = "substrate-inherents", path = "../core/inherents" } transaction-pool = { package = "substrate-transaction-pool", path = "../core/transaction-pool" } network = { package = "substrate-network", path = "../core/network" } -babe = { package = "substrate-consensus-babe", path = "../core/consensus/babe" } -babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../core/consensus/babe/primitives" } -grandpa = { package = "substrate-finality-grandpa", path = "../core/finality-grandpa" } +consensus = { package = "substrate-consensus-aura", path = "../core/consensus/aura" } +aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../core/consensus/aura/primitives" } grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../core/finality-grandpa/primitives" } substrate-client = { path = "../core/client" } basic-authorship = { package = "substrate-basic-authorship", path = "../core/basic-authorship" } diff --git a/node-template/README.md b/node-template/README.md index 5a59652c1b352..c411dbeef5bcc 100644 --- a/node-template/README.md +++ b/node-template/README.md @@ -10,7 +10,7 @@ Install Rust: curl https://sh.rustup.rs -sSf | sh ``` -Install required tools: +Initialize your Wasm Build environment: ```bash ./scripts/init.sh @@ -19,17 +19,23 @@ Install required tools: Build Wasm and native code: ```bash -cargo build +cargo build --release ``` ## Run ### Single node development chain -You can start a development chain with: +Purge any existing developer chain state: ```bash -cargo run -- --dev +./target/release/node-template purge-chain --dev +``` + +Start a development chain with: + +```bash +./target/release/node-template --dev ``` Detailed logs may be shown by running the node with the following environment variables set: `RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev`. diff --git a/node-template/runtime/Cargo.toml b/node-template/runtime/Cargo.toml index 18948d503cdbe..2a4446a982d23 100644 --- a/node-template/runtime/Cargo.toml +++ b/node-template/runtime/Cargo.toml @@ -15,11 +15,10 @@ support = { package = "srml-support", path = "../../srml/support", default_featu primitives = { package = "substrate-primitives", path = "../../core/primitives", default_features = false } substrate-session = { path = "../../core/session", default-features = false } balances = { package = "srml-balances", path = "../../srml/balances", default_features = false } -babe = { package = "srml-babe", path = "../../srml/babe", default-features = false } -babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../core/consensus/babe/primitives", default-features = false } +aura = { package = "srml-aura", path = "../../srml/aura", default_features = false } +consensus-aura = { package = "substrate-consensus-aura-primitives", path = "../../core/consensus/aura/primitives", default_features = false } executive = { package = "srml-executive", path = "../../srml/executive", default_features = false } indices = { package = "srml-indices", path = "../../srml/indices", default_features = false } -grandpa = { package = "srml-grandpa", path = "../../srml/grandpa", default-features = false } system = { package = "srml-system", path = "../../srml/system", default_features = false } timestamp = { package = "srml-timestamp", path = "../../srml/timestamp", default_features = false } sudo = { package = "srml-sudo", path = "../../srml/sudo", default_features = false } @@ -39,11 +38,10 @@ std = [ "runtime-io/std", "support/std", "balances/std", - "babe/std", - "babe-primitives/std", + "aura/std", + "consensus-aura/std", "executive/std", "indices/std", - "grandpa/std", "primitives/std", "sr-primitives/std", "system/std", diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index 216cb0edc266a..1d86c0f058a6f 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -16,9 +16,6 @@ use sr_primitives::{ }; use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto}; use sr_primitives::weights::Weight; -use babe::{AuthorityId as BabeId}; -use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; -use grandpa::fg_primitives; use client::{ block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api}, runtime_api as client_api, impl_runtime_apis @@ -61,6 +58,9 @@ pub type Hash = primitives::H256; /// Digest item type. pub type DigestItem = generic::DigestItem; +/// The SR25519 pub key of an session that belongs to an Aura authority of the chain. +pub type AuraId = consensus_aura::sr25519::AuthorityId; + /// Used for the module template in `./template.rs` mod template; @@ -80,14 +80,10 @@ pub mod opaque { /// Opaque block identifier type. pub type BlockId = generic::BlockId; - pub type SessionHandlers = (Grandpa, Babe); - impl_opaque_keys! { pub struct SessionKeys { - #[id(key_types::GRANDPA)] - pub grandpa: GrandpaId, - #[id(key_types::BABE)] - pub babe: BabeId, + #[id(key_types::AURA)] + pub aura: AuraId, } } } @@ -102,20 +98,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { apis: RUNTIME_API_VERSIONS, }; -/// Constants for Babe. - -/// Since BABE is probabilistic this is the average expected block time that -/// we are targetting. Blocks will be produced at a minimum duration defined -/// by `SLOT_DURATION`, but some slots will not be allocated to any -/// authority and hence no block will be produced. We expect to have this -/// block time on average following the defined slot duration and the value -/// of `c` configured for BABE (where `1 - c` represents the probability of -/// a slot being empty). -/// This value is only used indirectly to define the unit constants below -/// that are expressed in blocks. The rest of the code should use -/// `SLOT_DURATION` instead (like the timestamp module for calculating the -/// minimum period). -/// pub const MILLISECS_PER_BLOCK: u64 = 6000; pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; @@ -181,19 +163,8 @@ impl system::Trait for Runtime { type Version = Version; } -parameter_types! { - pub const EpochDuration: u64 = EPOCH_DURATION_IN_BLOCKS as u64; - pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK; -} - -impl babe::Trait for Runtime { - type EpochDuration = EpochDuration; - type ExpectedBlockTime = ExpectedBlockTime; - type EpochChangeTrigger = babe::SameAuthoritiesForever; -} - -impl grandpa::Trait for Runtime { - type Event = Event; +impl aura::Trait for Runtime { + type AuthorityId = AuraId; } impl indices::Trait for Runtime { @@ -215,7 +186,7 @@ parameter_types! { impl timestamp::Trait for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; - type OnTimestampSet = Babe; + type OnTimestampSet = Aura; type MinimumPeriod = MinimumPeriod; } @@ -265,8 +236,7 @@ construct_runtime!( { System: system::{Module, Call, Storage, Config, Event}, Timestamp: timestamp::{Module, Call, Storage, Inherent}, - Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, - Grandpa: grandpa::{Module, Call, Storage, Config, Event}, + Aura: aura::{Module, Config, Inherent(Timestamp)}, Indices: indices::{default, Config}, Balances: balances::{default, Error}, Sudo: sudo, @@ -356,27 +326,12 @@ impl_runtime_apis! { } } - impl fg_primitives::GrandpaApi for Runtime { - fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { - Grandpa::grandpa_authorities() + impl consensus_aura::AuraApi for Runtime { + fn slot_duration() -> u64 { + Aura::slot_duration() } - } - - impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeConfiguration { - // The choice of `c` parameter (where `1 - c` represents the - // probability of a slot being empty), is done in accordance to the - // slot duration and expected target block time, for safely - // resisting network delays of maximum two seconds. - // - babe_primitives::BabeConfiguration { - slot_duration: Babe::slot_duration(), - epoch_length: EpochDuration::get(), - c: PRIMARY_PROBABILITY, - genesis_authorities: Babe::authorities(), - randomness: Babe::randomness(), - secondary_slots: true, - } + fn authorities() -> Vec { + Aura::authorities() } } diff --git a/node-template/src/chain_spec.rs b/node-template/src/chain_spec.rs index 9fdc6ee2ca6b3..b1827677be4a4 100644 --- a/node-template/src/chain_spec.rs +++ b/node-template/src/chain_spec.rs @@ -1,10 +1,9 @@ use primitives::{Pair, Public}; use node_template_runtime::{ - AccountId, BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig, + AccountId, AuraConfig, BalancesConfig, GenesisConfig, SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY, }; -use babe_primitives::{AuthorityId as BabeId}; -use grandpa_primitives::{AuthorityId as GrandpaId}; +use aura_primitives::sr25519::AuthorityPair as AuraPair; use substrate_service; // Note this is the URL for the telemetry server @@ -31,14 +30,11 @@ pub fn get_from_seed(seed: &str) -> ::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) { - ( - get_from_seed::(&format!("{}//stash", seed)), - get_from_seed::(seed), - get_from_seed::(seed), - get_from_seed::(seed), - ) +/// Helper function to generate an authority key for Aura +pub fn get_authority_key_from_seed(s: &str) -> AuraId { + AuraPair::from_string(&format!("//{}", s), None) + .expect("static values are valid; qed") + .public() } impl Alternative { @@ -49,7 +45,7 @@ impl Alternative { "Development", "dev", || testnet_genesis(vec![ - get_authority_keys_from_seed("Alice"), + get_authority_key_from_seed("Alice"), ], get_from_seed::("Alice"), vec![ @@ -69,8 +65,8 @@ impl Alternative { "Local Testnet", "local_testnet", || testnet_genesis(vec![ - get_authority_keys_from_seed("Alice"), - get_authority_keys_from_seed("Bob"), + get_authority_key_from_seed("Alice"), + get_authority_key_from_seed("Bob"), ], get_from_seed::("Alice"), vec![ @@ -106,7 +102,7 @@ impl Alternative { } } -fn testnet_genesis(initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId)>, +fn testnet_genesis(initial_authorities: Vec, root_key: AccountId, endowed_accounts: Vec, _enable_println: bool) -> GenesisConfig { @@ -125,11 +121,8 @@ 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(), - }), - grandpa: Some(GrandpaConfig { - authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(), - }), + aura: Some(AuraConfig { + authorities: initial_authorities.clone(), + }) } } diff --git a/node-template/src/service.rs b/node-template/src/service.rs index 24b22082c5de7..2addfb75678fa 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -3,8 +3,6 @@ use std::sync::Arc; use std::time::Duration; use substrate_client::LongestChain; -use babe; -use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use futures::prelude::*; use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi}; use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder}; From 4c4d5640554d50e8ce006502e4b3099bfbef540f Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 8 Oct 2019 12:43:06 +0200 Subject: [PATCH 02/20] Make service compile --- node-template/Cargo.toml | 2 +- node-template/src/chain_spec.rs | 2 +- node-template/src/service.rs | 153 +++++++------------------------- 3 files changed, 33 insertions(+), 124 deletions(-) diff --git a/node-template/Cargo.toml b/node-template/Cargo.toml index 191f8c396c4bc..2491c96c97bf2 100644 --- a/node-template/Cargo.toml +++ b/node-template/Cargo.toml @@ -27,7 +27,7 @@ substrate-service = { path = "../core/service" } inherents = { package = "substrate-inherents", path = "../core/inherents" } transaction-pool = { package = "substrate-transaction-pool", path = "../core/transaction-pool" } network = { package = "substrate-network", path = "../core/network" } -consensus = { package = "substrate-consensus-aura", path = "../core/consensus/aura" } +aura = { package = "substrate-consensus-aura", path = "../core/consensus/aura" } aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../core/consensus/aura/primitives" } grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../core/finality-grandpa/primitives" } substrate-client = { path = "../core/client" } diff --git a/node-template/src/chain_spec.rs b/node-template/src/chain_spec.rs index b1827677be4a4..00e573d0f4560 100644 --- a/node-template/src/chain_spec.rs +++ b/node-template/src/chain_spec.rs @@ -1,6 +1,6 @@ use primitives::{Pair, Public}; use node_template_runtime::{ - AccountId, AuraConfig, BalancesConfig, GenesisConfig, + AuraId, AccountId, AuraConfig, BalancesConfig, GenesisConfig, SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY, }; use aura_primitives::sr25519::AuthorityPair as AuraPair; diff --git a/node-template/src/service.rs b/node-template/src/service.rs index 2addfb75678fa..b3ec325f4e693 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -1,14 +1,12 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. -use std::sync::Arc; -use std::time::Duration; use substrate_client::LongestChain; use futures::prelude::*; use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi}; use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder}; use transaction_pool::{self, txpool::{Pool as TransactionPool}}; use inherents::InherentDataProviders; -use network::construct_simple_protocol; +use network::{construct_simple_protocol, config::DummyFinalityProofRequestBuilder}; use substrate_executor::native_executor_instance; pub use substrate_executor::NativeExecutor; @@ -30,7 +28,6 @@ construct_simple_protocol! { /// be able to perform chain operations. macro_rules! new_full_start { ($config:expr) => {{ - let mut import_setup = None; let inherent_data_providers = inherents::InherentDataProviders::new(); let builder = substrate_service::ServiceBuilder::new_full::< @@ -42,38 +39,19 @@ macro_rules! new_full_start { .with_transaction_pool(|config, client| Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client))) )? - .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::<_, _, _, node_template_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)), + .with_import_queue(|_config, client, _select_chain, transaction_pool| { + aura::import_queue::<_, _, aura_primitives::sr25519::AuthorityPair, _>( + aura::SlotDuration::get_or_compute(&*client)?, + Box::new(client.clone()), + None, None, - client.clone(), client, inherent_data_providers.clone(), - )?; - - import_setup = Some((babe_block_import, grandpa_link, babe_link)); - - Ok(import_queue) + Some(transaction_pool), + ).map_err(Into::into) })?; - (builder, import_setup, inherent_data_providers) + (builder, inherent_data_providers) }} } @@ -81,24 +59,15 @@ macro_rules! new_full_start { pub fn new_full(config: Configuration) -> Result { - let is_authority = config.roles.is_authority(); - let name = config.name.clone(); - let disable_grandpa = config.disable_grandpa; let force_authoring = config.force_authoring; - let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config); + let (builder, inherent_data_providers) = new_full_start!(config); let service = builder.with_network_protocol(|_| Ok(NodeProtocol::new()))? - .with_finality_proof_provider(|client, backend| - Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _) - )? + .with_opt_finality_proof_provider(|_, _| Ok(None))? .build()?; - let (block_import, grandpa_link, babe_link) = - import_setup.take() - .expect("Link Half and Block Import are present for Full Services or setup failed before. qed"); - if is_authority { let proposer = basic_authorship::ProposerFactory { client: service.client(), @@ -109,68 +78,25 @@ pub fn new_full(config: Configuration( + aura::SlotDuration::get_or_compute(&*client)?, + client.clone(), select_chain, - env: proposer, - block_import, - sync_oracle: service.network(), - inherent_data_providers: inherent_data_providers.clone(), + client, + 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); } - let grandpa_config = grandpa::Config { - // FIXME #1578 make this available through chainspec - gossip_duration: Duration::from_millis(333), - justification_period: 512, - name: Some(name), - keystore: Some(service.keystore()), - }; - - match (is_authority, disable_grandpa) { - (false, false) => { - // start the lightweight GRANDPA observer - service.spawn_task(Box::new(grandpa::run_grandpa_observer( - grandpa_config, - grandpa_link, - service.network(), - service.on_exit(), - )?)); - }, - (true, false) => { - // start the full GRANDPA voter - let voter_config = grandpa::GrandpaParams { - config: grandpa_config, - link: grandpa_link, - network: service.network(), - inherent_data_providers: inherent_data_providers.clone(), - on_exit: service.on_exit(), - telemetry_on_connect: Some(service.telemetry_on_connect_stream()), - }; - - // the GRANDPA voter task is considered infallible, i.e. - // if it fails we take down the service with it. - service.spawn_essential_task(grandpa::run_grandpa_voter(voter_config)?); - }, - (_, true) => { - grandpa::setup_disabled_grandpa( - service.client(), - &inherent_data_providers, - service.network(), - )?; - }, - } - Ok(service) } @@ -187,40 +113,23 @@ pub fn new_light(config: Configuration( - client.clone(), backend, 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, + .with_import_queue_and_fprb(|_config, client, _backend, _fetcher, _select_chain, _tx_pool| { + let finality_proof_request_builder = Box::new(DummyFinalityProofRequestBuilder::default()) as Box<_>; + let import_queue = aura::import_queue::<_, _, aura_primitives::sr25519::AuthorityPair, ()>( + aura::SlotDuration::get_or_compute(&*client)?, + Box::new(client.clone()), + None, None, - Some(Box::new(finality_proof_import)), - client.clone(), client, inherent_data_providers.clone(), + None, )?; Ok((import_queue, finality_proof_request_builder)) })? .with_network_protocol(|_| Ok(NodeProtocol::new()))? - .with_finality_proof_provider(|client, backend| - Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _) + .with_opt_finality_proof_provider(|_client, _backend| + Ok(None) )? .build() } From 3f0d86b13d065ae681175fb889df4d1faee8c357 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 10 Oct 2019 12:53:26 +0900 Subject: [PATCH 03/20] Remove Grandpa dependency --- Cargo.lock | 1 - node-template/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1728f7248f7c7..6165ba73566b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2516,7 +2516,6 @@ dependencies = [ "substrate-consensus-aura 2.0.0", "substrate-consensus-aura-primitives 2.0.0", "substrate-executor 2.0.0", - "substrate-finality-grandpa-primitives 2.0.0", "substrate-inherents 2.0.0", "substrate-network 2.0.0", "substrate-primitives 2.0.0", diff --git a/node-template/Cargo.toml b/node-template/Cargo.toml index 2491c96c97bf2..6e742583947d5 100644 --- a/node-template/Cargo.toml +++ b/node-template/Cargo.toml @@ -29,7 +29,6 @@ transaction-pool = { package = "substrate-transaction-pool", path = "../core/tra network = { package = "substrate-network", path = "../core/network" } aura = { package = "substrate-consensus-aura", path = "../core/consensus/aura" } aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../core/consensus/aura/primitives" } -grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../core/finality-grandpa/primitives" } substrate-client = { path = "../core/client" } basic-authorship = { package = "substrate-basic-authorship", path = "../core/basic-authorship" } node-template-runtime = { path = "runtime" } From fdb962554d8541546ec476453453938866b7d87d Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 11 Oct 2019 09:15:11 +0900 Subject: [PATCH 04/20] Update node-template/runtime/Cargo.toml Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- node-template/runtime/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-template/runtime/Cargo.toml b/node-template/runtime/Cargo.toml index a4176a351f7b1..789a8281885e3 100644 --- a/node-template/runtime/Cargo.toml +++ b/node-template/runtime/Cargo.toml @@ -16,7 +16,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives", substrate-session = { path = "../../core/session", default-features = false } balances = { package = "srml-balances", path = "../../srml/balances", default_features = false } aura = { package = "srml-aura", path = "../../srml/aura", default_features = false } -consensus-aura = { package = "substrate-consensus-aura-primitives", path = "../../core/consensus/aura/primitives", default_features = false } +aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../core/consensus/aura/primitives", default_features = false } executive = { package = "srml-executive", path = "../../srml/executive", default_features = false } indices = { package = "srml-indices", path = "../../srml/indices", default_features = false } randomness-collective-flip = { package = "srml-randomness-collective-flip", path = "../../srml/randomness-collective-flip", default_features = false } From 44082dd7f391664e4c90da9527a85397d1867fd0 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 11 Oct 2019 09:25:12 +0900 Subject: [PATCH 05/20] Fix build --- node-template/runtime/Cargo.toml | 2 +- node-template/runtime/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/node-template/runtime/Cargo.toml b/node-template/runtime/Cargo.toml index 789a8281885e3..7a4ce7bac33b1 100644 --- a/node-template/runtime/Cargo.toml +++ b/node-template/runtime/Cargo.toml @@ -40,7 +40,7 @@ std = [ "support/std", "balances/std", "aura/std", - "consensus-aura/std", + "aura-primitives/std", "executive/std", "indices/std", "primitives/std", diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index 11238ba35b193..f824072172ed5 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -59,7 +59,7 @@ pub type Hash = primitives::H256; pub type DigestItem = generic::DigestItem; /// The SR25519 pub key of an session that belongs to an Aura authority of the chain. -pub type AuraId = consensus_aura::sr25519::AuthorityId; +pub type AuraId = aura_primitives::sr25519::AuthorityId; /// Used for the module template in `./template.rs` mod template; @@ -327,7 +327,7 @@ impl_runtime_apis! { } } - impl consensus_aura::AuraApi for Runtime { + impl aura_primitives::AuraApi for Runtime { fn slot_duration() -> u64 { Aura::slot_duration() } From 39a51773dd875da74fb055e731241788f3c837fa Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 12 Oct 2019 08:00:17 +0900 Subject: [PATCH 06/20] Update crypto import --- node-template/runtime/src/lib.rs | 4 +--- node-template/src/chain_spec.rs | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index f824072172ed5..27b6b8c0c6780 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -20,6 +20,7 @@ use client::{ block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api}, runtime_api as client_api, impl_runtime_apis }; +use aura_primitives::sr25519::AuthorityId as AuraId; use version::RuntimeVersion; #[cfg(feature = "std")] use version::NativeVersion; @@ -58,9 +59,6 @@ pub type Hash = primitives::H256; /// Digest item type. pub type DigestItem = generic::DigestItem; -/// The SR25519 pub key of an session that belongs to an Aura authority of the chain. -pub type AuraId = aura_primitives::sr25519::AuthorityId; - /// Used for the module template in `./template.rs` mod template; diff --git a/node-template/src/chain_spec.rs b/node-template/src/chain_spec.rs index 00e573d0f4560..04b856b61b63a 100644 --- a/node-template/src/chain_spec.rs +++ b/node-template/src/chain_spec.rs @@ -1,9 +1,9 @@ use primitives::{Pair, Public}; use node_template_runtime::{ - AuraId, AccountId, AuraConfig, BalancesConfig, GenesisConfig, + AccountId, AuraConfig, BalancesConfig, GenesisConfig, SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY, }; -use aura_primitives::sr25519::AuthorityPair as AuraPair; +use aura_primitives::sr25519::{AuthorityId as AuraId, AuthorityPair as AuraPair}; use substrate_service; // Note this is the URL for the telemetry server From a689a66332ca0f58ac96c8b9ab555ab215b7cd30 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 13 Oct 2019 12:43:50 +0900 Subject: [PATCH 07/20] Update node-template/src/service.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/src/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-template/src/service.rs b/node-template/src/service.rs index b3ec325f4e693..f5778e6061fc0 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -115,7 +115,7 @@ pub fn new_light(config: Configuration; - let import_queue = aura::import_queue::<_, _, aura_primitives::sr25519::AuthorityPair, ()>( + let import_queue = aura::import_queue::<_, _, AuraPair, ()>( aura::SlotDuration::get_or_compute(&*client)?, Box::new(client.clone()), None, From 27ede16359b62101fe139e7bd5adfdc658a248f6 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 13 Oct 2019 12:44:08 +0900 Subject: [PATCH 08/20] Update node-template/src/service.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/src/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-template/src/service.rs b/node-template/src/service.rs index f5778e6061fc0..ecdc7c7ac971b 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -78,7 +78,7 @@ pub fn new_full(config: Configuration( + let aura = aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _>( aura::SlotDuration::get_or_compute(&*client)?, client.clone(), select_chain, From c042d0449a30fc826fe56a41979dfeec1749a6c3 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 13 Oct 2019 12:44:18 +0900 Subject: [PATCH 09/20] Update node-template/src/service.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/src/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-template/src/service.rs b/node-template/src/service.rs index ecdc7c7ac971b..e1ada99d78a74 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -40,7 +40,7 @@ macro_rules! new_full_start { Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client))) )? .with_import_queue(|_config, client, _select_chain, transaction_pool| { - aura::import_queue::<_, _, aura_primitives::sr25519::AuthorityPair, _>( + aura::import_queue::<_, _, AuraPair, _>( aura::SlotDuration::get_or_compute(&*client)?, Box::new(client.clone()), None, From 525aef9af46a4c600f9a894ff71a2b19407f5c36 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 13 Oct 2019 12:44:29 +0900 Subject: [PATCH 10/20] Update node-template/src/service.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/src/service.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node-template/src/service.rs b/node-template/src/service.rs index e1ada99d78a74..27646464522a7 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -9,6 +9,7 @@ use inherents::InherentDataProviders; use network::{construct_simple_protocol, config::DummyFinalityProofRequestBuilder}; use substrate_executor::native_executor_instance; pub use substrate_executor::NativeExecutor; +use aura_primitives::sr25519::{AuthorityPair as AuraPair}; // Our native executor instance. native_executor_instance!( From db5f17fc60b3ce57fd7382d8c955701c3fe0cffc Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 13 Oct 2019 12:44:56 +0900 Subject: [PATCH 11/20] Update node-template/runtime/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/runtime/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index 27b6b8c0c6780..0ad3a1cda3ca1 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -329,6 +329,7 @@ impl_runtime_apis! { fn slot_duration() -> u64 { Aura::slot_duration() } + fn authorities() -> Vec { Aura::authorities() } From 248ca5aef85f7e05e2f03978bdf0f404a0bba756 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 13 Oct 2019 12:50:29 +0900 Subject: [PATCH 12/20] Fix macro dependency --- node-template/src/cli.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/node-template/src/cli.rs b/node-template/src/cli.rs index 6a0b0dd706c2d..f0b429e0fa84f 100644 --- a/node-template/src/cli.rs +++ b/node-template/src/cli.rs @@ -5,6 +5,7 @@ use tokio::runtime::Runtime; pub use substrate_cli::{VersionInfo, IntoExit, error}; use substrate_cli::{informant, parse_and_prepare, ParseAndPrepare, NoCustom}; use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration}; +use aura_primitives::sr25519::{AuthorityPair as AuraPair}; use crate::chain_spec; use log::info; From d87ed073977763c17ac33bee1271e8181af6c82e Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 16 Oct 2019 15:52:56 +0900 Subject: [PATCH 13/20] Trying to add grandpa back --- Cargo.lock | 3 + node-template/Cargo.toml | 2 + node-template/runtime/Cargo.toml | 2 + node-template/runtime/src/lib.rs | 15 +++++ node-template/src/chain_spec.rs | 29 +++++---- node-template/src/service.rs | 101 +++++++++++++++++++++++++++---- 6 files changed, 128 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 885af034cc7b8..d42fbdb9ab9eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2530,6 +2530,8 @@ dependencies = [ "substrate-consensus-aura 2.0.0", "substrate-consensus-aura-primitives 2.0.0", "substrate-executor 2.0.0", + "substrate-finality-grandpa 2.0.0", + "substrate-finality-grandpa-primitives 2.0.0", "substrate-inherents 2.0.0", "substrate-network 2.0.0", "substrate-primitives 2.0.0", @@ -2554,6 +2556,7 @@ dependencies = [ "srml-aura 2.0.0", "srml-balances 2.0.0", "srml-executive 2.0.0", + "srml-grandpa 2.0.0", "srml-indices 2.0.0", "srml-randomness-collective-flip 2.0.0", "srml-sudo 2.0.0", diff --git a/node-template/Cargo.toml b/node-template/Cargo.toml index 6e742583947d5..2c01655dc2eae 100644 --- a/node-template/Cargo.toml +++ b/node-template/Cargo.toml @@ -29,6 +29,8 @@ transaction-pool = { package = "substrate-transaction-pool", path = "../core/tra network = { package = "substrate-network", path = "../core/network" } aura = { package = "substrate-consensus-aura", path = "../core/consensus/aura" } aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../core/consensus/aura/primitives" } +grandpa = { package = "substrate-finality-grandpa", path = "../core/finality-grandpa" } +grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../core/finality-grandpa/primitives" } substrate-client = { path = "../core/client" } basic-authorship = { package = "substrate-basic-authorship", path = "../core/basic-authorship" } node-template-runtime = { path = "runtime" } diff --git a/node-template/runtime/Cargo.toml b/node-template/runtime/Cargo.toml index 7a4ce7bac33b1..ef33c8bf2a040 100644 --- a/node-template/runtime/Cargo.toml +++ b/node-template/runtime/Cargo.toml @@ -17,6 +17,7 @@ substrate-session = { path = "../../core/session", default-features = false } balances = { package = "srml-balances", path = "../../srml/balances", default_features = false } aura = { package = "srml-aura", path = "../../srml/aura", default_features = false } aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../core/consensus/aura/primitives", default_features = false } +grandpa = { package = "srml-grandpa", path = "../../srml/grandpa", default_features = false } executive = { package = "srml-executive", path = "../../srml/executive", default_features = false } indices = { package = "srml-indices", path = "../../srml/indices", default_features = false } randomness-collective-flip = { package = "srml-randomness-collective-flip", path = "../../srml/randomness-collective-flip", default_features = false } @@ -41,6 +42,7 @@ std = [ "balances/std", "aura/std", "aura-primitives/std", + 'grandpa/std', "executive/std", "indices/std", "primitives/std", diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index 0ad3a1cda3ca1..ad87ea4449797 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -21,6 +21,8 @@ use client::{ runtime_api as client_api, impl_runtime_apis }; use aura_primitives::sr25519::AuthorityId as AuraId; +use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; +use grandpa::fg_primitives; use version::RuntimeVersion; #[cfg(feature = "std")] use version::NativeVersion; @@ -82,6 +84,8 @@ pub mod opaque { pub struct SessionKeys { #[id(key_types::AURA)] pub aura: AuraId, + #[id(key_types::GRANDPA)] + pub grandpa: GrandpaId, } } } @@ -165,6 +169,10 @@ impl aura::Trait for Runtime { type AuthorityId = AuraId; } +impl grandpa::Trait for Runtime { + type Event = Event; +} + impl indices::Trait for Runtime { /// The type for recording indexing into the account enumeration. If this ever overflows, there /// will be problems! @@ -235,6 +243,7 @@ construct_runtime!( System: system::{Module, Call, Storage, Config, Event}, Timestamp: timestamp::{Module, Call, Storage, Inherent}, Aura: aura::{Module, Config, Inherent(Timestamp)}, + Grandpa: grandpa::{Module, Call, Storage, Config, Event}, Indices: indices::{default, Config}, Balances: balances::{default, Error}, Sudo: sudo, @@ -341,4 +350,10 @@ impl_runtime_apis! { opaque::SessionKeys::generate(seed) } } + + impl fg_primitives::GrandpaApi for Runtime { + fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { + Grandpa::grandpa_authorities() + } + } } diff --git a/node-template/src/chain_spec.rs b/node-template/src/chain_spec.rs index 04b856b61b63a..738ef7d71c376 100644 --- a/node-template/src/chain_spec.rs +++ b/node-template/src/chain_spec.rs @@ -1,9 +1,10 @@ use primitives::{Pair, Public}; use node_template_runtime::{ - AccountId, AuraConfig, BalancesConfig, GenesisConfig, + AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY, }; use aura_primitives::sr25519::{AuthorityId as AuraId, AuthorityPair as AuraPair}; +use grandpa_primitives::{AuthorityId as GrandpaId}; use substrate_service; // Note this is the URL for the telemetry server @@ -31,10 +32,13 @@ pub fn get_from_seed(seed: &str) -> ::Pu } /// Helper function to generate an authority key for Aura -pub fn get_authority_key_from_seed(s: &str) -> AuraId { - AuraPair::from_string(&format!("//{}", s), None) - .expect("static values are valid; qed") - .public() +pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { + ( + AuraPair::from_string(&format!("//{}", s), None) + .expect("static values are valid; qed") + .public(), + get_from_seed::(s), + ) } impl Alternative { @@ -45,7 +49,7 @@ impl Alternative { "Development", "dev", || testnet_genesis(vec![ - get_authority_key_from_seed("Alice"), + get_authority_keys_from_seed("Alice"), ], get_from_seed::("Alice"), vec![ @@ -65,8 +69,8 @@ impl Alternative { "Local Testnet", "local_testnet", || testnet_genesis(vec![ - get_authority_key_from_seed("Alice"), - get_authority_key_from_seed("Bob"), + get_authority_keys_from_seed("Alice"), + get_authority_keys_from_seed("Bob"), ], get_from_seed::("Alice"), vec![ @@ -102,7 +106,7 @@ impl Alternative { } } -fn testnet_genesis(initial_authorities: Vec, +fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>, root_key: AccountId, endowed_accounts: Vec, _enable_println: bool) -> GenesisConfig { @@ -122,7 +126,10 @@ fn testnet_genesis(initial_authorities: Vec, key: root_key, }), aura: Some(AuraConfig { - authorities: initial_authorities.clone(), - }) + authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), + }), + grandpa: Some(GrandpaConfig { + authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), + }), } } diff --git a/node-template/src/service.rs b/node-template/src/service.rs index 27646464522a7..bc3418b67b4e6 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -1,15 +1,18 @@ //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. +use std::sync::Arc; +use std::time::Duration; use substrate_client::LongestChain; use futures::prelude::*; use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi}; use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder}; use transaction_pool::{self, txpool::{Pool as TransactionPool}}; use inherents::InherentDataProviders; -use network::{construct_simple_protocol, config::DummyFinalityProofRequestBuilder}; +use network::{construct_simple_protocol}; use substrate_executor::native_executor_instance; pub use substrate_executor::NativeExecutor; use aura_primitives::sr25519::{AuthorityPair as AuraPair}; +use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; // Our native executor instance. native_executor_instance!( @@ -29,6 +32,7 @@ construct_simple_protocol! { /// be able to perform chain operations. macro_rules! new_full_start { ($config:expr) => {{ + let mut import_setup = None; let inherent_data_providers = inherents::InherentDataProviders::new(); let builder = substrate_service::ServiceBuilder::new_full::< @@ -40,19 +44,31 @@ macro_rules! new_full_start { .with_transaction_pool(|config, client| Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client))) )? - .with_import_queue(|_config, client, _select_chain, transaction_pool| { - aura::import_queue::<_, _, AuraPair, _>( + .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::<_, _, _, node_template_runtime::RuntimeApi, _, _>( + client.clone(), &*client, select_chain + )?; + + let import_queue = aura::import_queue::<_, _, AuraPair, _>( aura::SlotDuration::get_or_compute(&*client)?, Box::new(client.clone()), - None, + Some(Box::new(grandpa_block_import)), None, client, inherent_data_providers.clone(), Some(transaction_pool), - ).map_err(Into::into) + )?; + + import_setup = Some(grandpa_link); + + Ok(import_queue) })?; - (builder, inherent_data_providers) + (builder, import_setup, inherent_data_providers) }} } @@ -62,11 +78,19 @@ pub fn new_full(config: Configuration(config: Configuration { + // start the lightweight GRANDPA observer + service.spawn_task(Box::new(grandpa::run_grandpa_observer( + grandpa_config, + grandpa_link, + service.network(), + service.on_exit(), + )?)); + }, + (true, false) => { + // start the full GRANDPA voter + let voter_config = grandpa::GrandpaParams { + config: grandpa_config, + link: grandpa_link, + network: service.network(), + inherent_data_providers: inherent_data_providers.clone(), + on_exit: service.on_exit(), + telemetry_on_connect: Some(service.telemetry_on_connect_stream()), + }; + + // the GRANDPA voter task is considered infallible, i.e. + // if it fails we take down the service with it. + service.spawn_essential_task(grandpa::run_grandpa_voter(voter_config)?); + }, + (_, true) => { + grandpa::setup_disabled_grandpa( + service.client(), + &inherent_data_providers, + service.network(), + )?; + }, + } + Ok(service) } @@ -114,13 +180,22 @@ pub fn new_light(config: Configuration; + .with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| { + let fetch_checker = fetcher + .map(|fetcher| fetcher.checker().clone()) + .ok_or_else(|| "Trying to start light import queue without active fetch checker")?; + let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>( + client.clone(), backend, 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 import_queue = aura::import_queue::<_, _, AuraPair, ()>( aura::SlotDuration::get_or_compute(&*client)?, Box::new(client.clone()), None, - None, + Some(Box::new(finality_proof_import)), client, inherent_data_providers.clone(), None, @@ -129,8 +204,8 @@ pub fn new_light(config: Configuration Date: Wed, 16 Oct 2019 20:31:46 +0900 Subject: [PATCH 14/20] Update node-template/src/chain_spec.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/src/chain_spec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-template/src/chain_spec.rs b/node-template/src/chain_spec.rs index 738ef7d71c376..8fc233abc9722 100644 --- a/node-template/src/chain_spec.rs +++ b/node-template/src/chain_spec.rs @@ -34,7 +34,7 @@ pub fn get_from_seed(seed: &str) -> ::Pu /// Helper function to generate an authority key for Aura pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { ( - AuraPair::from_string(&format!("//{}", s), None) + get_from_seed::(s), .expect("static values are valid; qed") .public(), get_from_seed::(s), From 0cdf8199e940b25f05466b14f5321ba251b90a65 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 16 Oct 2019 20:31:54 +0900 Subject: [PATCH 15/20] Update node-template/src/chain_spec.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/src/chain_spec.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/node-template/src/chain_spec.rs b/node-template/src/chain_spec.rs index 8fc233abc9722..84b24137c9f1f 100644 --- a/node-template/src/chain_spec.rs +++ b/node-template/src/chain_spec.rs @@ -35,7 +35,6 @@ pub fn get_from_seed(seed: &str) -> ::Pu pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { ( get_from_seed::(s), - .expect("static values are valid; qed") .public(), get_from_seed::(s), ) From 0da367c6f5b88b3efc53b93dead10a6cb8308542 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 16 Oct 2019 20:32:01 +0900 Subject: [PATCH 16/20] Update node-template/src/chain_spec.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/src/chain_spec.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/node-template/src/chain_spec.rs b/node-template/src/chain_spec.rs index 84b24137c9f1f..10dbe153a0b12 100644 --- a/node-template/src/chain_spec.rs +++ b/node-template/src/chain_spec.rs @@ -35,7 +35,6 @@ pub fn get_from_seed(seed: &str) -> ::Pu pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { ( get_from_seed::(s), - .public(), get_from_seed::(s), ) } From 6ea320525f6f8d2d6378fb81c86c64c80130c585 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 16 Oct 2019 20:32:14 +0900 Subject: [PATCH 17/20] Update node-template/src/service.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/src/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-template/src/service.rs b/node-template/src/service.rs index bc3418b67b4e6..9e12d60476782 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -55,7 +55,7 @@ macro_rules! new_full_start { let import_queue = aura::import_queue::<_, _, AuraPair, _>( aura::SlotDuration::get_or_compute(&*client)?, - Box::new(client.clone()), + Box::new(grandpa_block_import.clone()), Some(Box::new(grandpa_block_import)), None, client, From 1c1d577b5beb3d17e1bf56e285f105caa0ba43f2 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 16 Oct 2019 20:32:21 +0900 Subject: [PATCH 18/20] Update node-template/src/service.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: André Silva --- node-template/src/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-template/src/service.rs b/node-template/src/service.rs index 9e12d60476782..05ce10295817f 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -193,7 +193,7 @@ pub fn new_light(config: Configuration( aura::SlotDuration::get_or_compute(&*client)?, - Box::new(client.clone()), + Box::new(grandpa_block_import), None, Some(Box::new(finality_proof_import)), client, From 328bbe8172d168a856d52bf564ad6ace64ae6e8c Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 16 Oct 2019 20:38:09 +0900 Subject: [PATCH 19/20] Unused import --- node-template/src/chain_spec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-template/src/chain_spec.rs b/node-template/src/chain_spec.rs index 10dbe153a0b12..2996f5414a5ac 100644 --- a/node-template/src/chain_spec.rs +++ b/node-template/src/chain_spec.rs @@ -3,7 +3,7 @@ use node_template_runtime::{ AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY, }; -use aura_primitives::sr25519::{AuthorityId as AuraId, AuthorityPair as AuraPair}; +use aura_primitives::sr25519::{AuthorityId as AuraId}; use grandpa_primitives::{AuthorityId as GrandpaId}; use substrate_service; From 5607a05f715313cbeb716c22e23b3ef752812cf3 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 17 Oct 2019 01:46:29 +0900 Subject: [PATCH 20/20] Use grandpa block import --- node-template/src/service.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/node-template/src/service.rs b/node-template/src/service.rs index 05ce10295817f..64a453e298e05 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -56,14 +56,14 @@ macro_rules! new_full_start { 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)), + Some(Box::new(grandpa_block_import.clone())), None, client, inherent_data_providers.clone(), Some(transaction_pool), )?; - import_setup = Some(grandpa_link); + import_setup = Some((grandpa_block_import, grandpa_link)); Ok(import_queue) })?; @@ -83,9 +83,9 @@ pub fn new_full(config: Configuration(config: Configuration( aura::SlotDuration::get_or_compute(&*client)?, - client.clone(), - select_chain, client, + select_chain, + block_import, proposer, service.network(), inherent_data_providers.clone(),