Revert "Update Node Template: 7d7e74fb7"

This reverts commit cd271e0972.
main
Shawn Tabrizi 2019-09-30 22:55:03 +02:00
parent 5cd3d42aed
commit 09d2defac5
7 changed files with 1074 additions and 1184 deletions

1806
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,10 @@
[build-dependencies]
vergen = '3'
[profile.release]
panic = 'unwind'
[workspace]
members = ['runtime']
[dependencies]
derive_more = '0.14.0'
@ -13,17 +18,17 @@ trie-root = '0.15.2'
[dependencies.babe]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-babe'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.babe-primitives]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-babe-primitives'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.basic-authorship]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-basic-authorship'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.codec]
package = 'parity-scale-codec'
@ -36,22 +41,22 @@ version = '3.0'
[dependencies.grandpa]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-finality-grandpa'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.grandpa-primitives]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-finality-grandpa-primitives'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.inherents]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-inherents'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.network]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-network'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.node-template-runtime]
path = 'runtime'
@ -59,32 +64,32 @@ path = 'runtime'
[dependencies.primitives]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-primitives'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.sr-io]
git = 'https://github.com/paritytech/substrate.git'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.substrate-cli]
git = 'https://github.com/paritytech/substrate.git'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.substrate-client]
git = 'https://github.com/paritytech/substrate.git'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.substrate-executor]
git = 'https://github.com/paritytech/substrate.git'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.substrate-service]
git = 'https://github.com/paritytech/substrate.git'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.transaction-pool]
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-transaction-pool'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[package]
authors = ['Anonymous']
@ -92,11 +97,6 @@ build = 'build.rs'
edition = '2018'
name = 'node-template'
version = '2.0.0'
[profile.release]
panic = 'unwind'
[workspace]
members = ['runtime']
[[bin]]
name = 'node-template'

View File

@ -3,9 +3,133 @@ authors = ['Anonymous']
edition = '2018'
name = 'node-template-runtime'
version = '2.0.0'
[dependencies.babe]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-babe'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.babe-primitives]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-babe-primitives'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.balances]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-balances'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.client]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-client'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '1.0.0'
[dependencies.executive]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-executive'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.grandpa]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-grandpa'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.indices]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-indices'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.offchain-primitives]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-offchain-primitives'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.primitives]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-primitives'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.rstd]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-std'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.runtime-io]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-io'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.safe-mix]
default-features = false
version = '1.0'
[dependencies.serde]
features = ['derive']
optional = true
version = '1.0'
[dependencies.sr-primitives]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.substrate-session]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.sudo]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-sudo'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.support]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-support'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.system]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-system'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.timestamp]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-timestamp'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[dependencies.version]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-version'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
[build-dependencies.wasm-builder-runner]
package = 'substrate-wasm-builder-runner'
version = '1.0.2'
[features]
default = ['std']
no_std = []
std = [
'codec/std',
'client/std',
@ -29,126 +153,3 @@ std = [
'offchain-primitives/std',
'substrate-session/std',
]
[build-dependencies.wasm-builder-runner]
package = 'substrate-wasm-builder-runner'
version = '1.0.2'
[dependencies.babe]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-babe'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.babe-primitives]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-babe-primitives'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.balances]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-balances'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.client]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-client'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '1.0.0'
[dependencies.executive]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-executive'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.grandpa]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-grandpa'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.indices]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-indices'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.offchain-primitives]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-offchain-primitives'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.primitives]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-primitives'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.rstd]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-std'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.runtime-io]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-io'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.safe-mix]
default-features = false
version = '1.0'
[dependencies.serde]
features = ['derive']
optional = true
version = '1.0'
[dependencies.sr-primitives]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.substrate-session]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.sudo]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-sudo'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.support]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-support'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.system]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-system'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.timestamp]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-timestamp'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'
[dependencies.version]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-version'
rev = '7d7e74fb77b6bee2ce9d6ebafcae09caff2d0e50'

View File

@ -19,7 +19,7 @@ use wasm_builder_runner::{build_current_project_with_rustflags, WasmBuilderSourc
fn main() {
build_current_project_with_rustflags(
"wasm_binary.rs",
WasmBuilderSource::Crates("1.0.7"),
WasmBuilderSource::Crates("1.0.5"),
// This instructs LLD to export __heap_base as a global variable, which is used by the
// external memory allocator.
"-Clink-arg=--export=__heap_base",

View File

@ -14,11 +14,11 @@ use sr_primitives::{
ApplyResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
impl_opaque_keys, AnySignature
};
use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto};
use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, DigestFor, 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 grandpa::fg_primitives::{self, ScheduledChange};
use client::{
block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api},
runtime_api as client_api, impl_runtime_apis
@ -208,7 +208,7 @@ impl indices::Trait for Runtime {
}
parameter_types! {
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
pub const MinimumPeriod: u64 = 5000;
}
impl timestamp::Trait for Runtime {
@ -235,6 +235,7 @@ impl balances::Trait for Runtime {
type OnNewAccount = Indices;
/// The ubiquitous event type.
type Event = Event;
type TransactionPayment = ();
type DustRemoval = ();
type TransferPayment = ();
@ -267,7 +268,7 @@ construct_runtime!(
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
Indices: indices::{default, Config<T>},
Balances: balances::{default, Error},
Balances: balances,
Sudo: sudo,
// Used for the module template in `./template.rs`
TemplateModule: template::{Module, Call, Storage, Event<T>},
@ -356,25 +357,45 @@ impl_runtime_apis! {
}
impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_pending_change(digest: &DigestFor<Block>)
-> Option<ScheduledChange<NumberFor<Block>>>
{
Grandpa::pending_change(digest)
}
fn grandpa_forced_change(digest: &DigestFor<Block>)
-> Option<(NumberFor<Block>, ScheduledChange<NumberFor<Block>>)>
{
Grandpa::forced_change(digest)
}
fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> {
Grandpa::grandpa_authorities()
}
}
impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeConfiguration {
fn startup_data() -> 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.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
babe_primitives::BabeConfiguration {
median_required_blocks: 1000,
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: PRIMARY_PROBABILITY,
genesis_authorities: Babe::authorities(),
}
}
fn epoch() -> babe_primitives::Epoch {
babe_primitives::Epoch {
start_slot: Babe::epoch_start_slot(),
authorities: Babe::authorities(),
epoch_index: Babe::epoch_index(),
randomness: Babe::randomness(),
secondary_slots: true,
duration: EpochDuration::get(),
secondary_slots: Babe::secondary_slots().0,
}
}
}

View File

@ -3,10 +3,10 @@
use std::sync::Arc;
use std::time::Duration;
use substrate_client::LongestChain;
use babe;
use babe::{import_queue, start_babe, Config};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use futures::prelude::*;
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi, WASM_BINARY};
use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
use transaction_pool::{self, txpool::{Pool as TransactionPool}};
use inherents::InherentDataProviders;
@ -18,7 +18,7 @@ pub use substrate_executor::NativeExecutor;
native_executor_instance!(
pub Executor,
node_template_runtime::api::dispatch,
node_template_runtime::native_version,
node_template_runtime::native_version
);
construct_simple_protocol! {
@ -34,48 +34,45 @@ macro_rules! new_full_start {
($config:expr) => {{
let mut import_setup = None;
let inherent_data_providers = inherents::InherentDataProviders::new();
let mut tasks_to_spawn = None;
let builder = substrate_service::ServiceBuilder::new_full::<
node_template_runtime::opaque::Block, node_template_runtime::RuntimeApi, crate::service::Executor
>($config)?
.with_select_chain(|_config, backend| {
Ok(substrate_client::LongestChain::new(backend.clone()))
.with_select_chain(|_config, client| {
#[allow(deprecated)]
Ok(substrate_client::LongestChain::new(client.backend().clone()))
})?
.with_transaction_pool(|config, client|
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::ChainApi::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) =
let (block_import, link_half) =
grandpa::block_import::<_, _, _, node_template_runtime::RuntimeApi, _, _>(
client.clone(), &*client, select_chain
client.clone(), client.clone(), select_chain
)?;
let justification_import = grandpa_block_import.clone();
let justification_import = block_import.clone();
let (babe_block_import, babe_link) = babe::block_import(
let (import_queue, babe_link, babe_block_import, pruning_task) = babe::import_queue(
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(),
block_import,
Some(Box::new(justification_import)),
None,
client.clone(),
client,
inherent_data_providers.clone(),
Some(transaction_pool)
)?;
import_setup = Some((babe_block_import, grandpa_link, babe_link));
import_setup = Some((babe_block_import.clone(), link_half, babe_link));
tasks_to_spawn = Some(vec![Box::new(pruning_task)]);
Ok(import_queue)
})?;
(builder, import_setup, inherent_data_providers)
(builder, import_setup, inherent_data_providers, tasks_to_spawn)
}}
}
@ -84,24 +81,30 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
-> Result<impl AbstractService, ServiceError>
{
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, mut import_setup, inherent_data_providers, mut tasks_to_spawn) = 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_finality_proof_provider(|client|
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _)
)?
.build()?;
let (block_import, grandpa_link, babe_link) =
let (block_import, link_half, babe_link) =
import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
if is_authority {
// spawn any futures that were created in the previous setup steps
if let Some(tasks) = tasks_to_spawn.take() {
for task in tasks {
service.spawn_task(
task.select(service.on_exit())
.map(|_| ())
.map_err(|_| ())
);
}
}
if service.config().roles.is_authority() {
let proposer = basic_authorship::ProposerFactory {
client: service.client(),
transaction_pool: service.transaction_pool(),
@ -112,18 +115,19 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
.ok_or(ServiceError::SelectChainRequired)?;
let babe_config = babe::BabeParams {
config: Config::get_or_compute(&*client)?,
keystore: service.keystore(),
client,
select_chain,
env: proposer,
block_import,
env: proposer,
sync_oracle: service.network(),
inherent_data_providers: inherent_data_providers.clone(),
force_authoring,
babe_link,
force_authoring: service.config().force_authoring,
time_source: babe_link,
};
let babe = babe::start_babe(babe_config)?;
let babe = start_babe(babe_config)?;
let select = babe.select(service.on_exit()).then(|_| Ok(()));
// the BABE authoring task is considered infallible, i.e. if it
@ -131,29 +135,29 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
service.spawn_essential_task(select);
}
let grandpa_config = grandpa::Config {
let config = grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 512,
name: Some(name),
justification_period: 4096,
name: Some(service.config().name.clone()),
keystore: Some(service.keystore()),
};
match (is_authority, disable_grandpa) {
match (service.config().roles.is_authority(), service.config().disable_grandpa) {
(false, false) => {
// start the lightweight GRANDPA observer
service.spawn_task(Box::new(grandpa::run_grandpa_observer(
grandpa_config,
grandpa_link,
config,
link_half,
service.network(),
service.on_exit(),
)?));
},
(true, false) => {
// start the full GRANDPA voter
let voter_config = grandpa::GrandpaParams {
config: grandpa_config,
link: grandpa_link,
let grandpa_config = grandpa::GrandpaParams {
config: config,
link: link_half,
network: service.network(),
inherent_data_providers: inherent_data_providers.clone(),
on_exit: service.on_exit(),
@ -162,7 +166,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
// 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)?);
service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?);
},
(_, true) => {
grandpa::setup_disabled_grandpa(
@ -183,46 +187,44 @@ pub fn new_light<C: Send + Default + 'static>(config: Configuration<C, GenesisCo
let inherent_data_providers = InherentDataProviders::new();
ServiceBuilder::new_light::<Block, RuntimeApi, Executor>(config)?
.with_select_chain(|_config, backend| {
Ok(LongestChain::new(backend.clone()))
.with_select_chain(|_config, client| {
#[allow(deprecated)]
Ok(LongestChain::new(client.backend().clone()))
})?
.with_transaction_pool(|config, client|
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client)))
)?
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| {
let fetch_checker = fetcher
.with_import_queue_and_fprb(|_config, client, _select_chain, transaction_pool| {
#[allow(deprecated)]
let fetch_checker = client.backend().blockchain().fetcher()
.upgrade()
.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 block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
client.clone(), Arc::new(fetch_checker), client.clone()
)?;
let finality_proof_import = grandpa_block_import.clone();
let finality_proof_import = 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,
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
let (import_queue, ..) = import_queue(
Config::get_or_compute(&*client)?,
block_import,
None,
Some(Box::new(finality_proof_import)),
client.clone(),
client,
inherent_data_providers.clone(),
Some(transaction_pool)
)?;
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_finality_proof_provider(|client|
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _)
)?
.build()
}

Binary file not shown.