mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Update to lastest Substrate master (#443)
This commit is contained in:
committed by
Robert Habermeier
parent
444a19ec5f
commit
4f4baa9b07
+38
-41
@@ -27,7 +27,7 @@ use polkadot_runtime::GenesisConfig;
|
||||
use polkadot_network::{gossip::{self as network_gossip, Known}, validation::ValidationNetwork};
|
||||
use service::{error::{Error as ServiceError}, Configuration, ServiceBuilder};
|
||||
use transaction_pool::txpool::{Pool as TransactionPool};
|
||||
use babe::{import_queue, start_babe, Config};
|
||||
use babe::{import_queue, start_babe};
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
use inherents::InherentDataProviders;
|
||||
use log::info;
|
||||
@@ -79,8 +79,6 @@ 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 = service::ServiceBuilder::new_full::<
|
||||
Block, RuntimeApi, polkadot_executor::Executor
|
||||
>($config)?
|
||||
@@ -90,33 +88,37 @@ macro_rules! new_full_start {
|
||||
.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, _| {
|
||||
let select_chain = select_chain.take()
|
||||
.ok_or_else(|| service::Error::SelectChainRequired)?;
|
||||
let (block_import, link_half) =
|
||||
let (grandpa_block_import, grandpa_link) =
|
||||
grandpa::block_import::<_, _, _, RuntimeApi, _, _>(
|
||||
client.clone(), client.clone(), select_chain
|
||||
client.clone(), &*client, select_chain
|
||||
)?;
|
||||
let justification_import = block_import.clone();
|
||||
let justification_import = grandpa_block_import.clone();
|
||||
|
||||
let (import_queue, babe_link, babe_block_import, pruning_task) = babe::import_queue(
|
||||
babe::Config::get_or_compute(&*client)?,
|
||||
block_import,
|
||||
Some(Box::new(justification_import)),
|
||||
None,
|
||||
client.clone(),
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
Some(transaction_pool)
|
||||
let (block_import, babe_link) = babe::block_import(
|
||||
babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
client.clone(),
|
||||
)?;
|
||||
|
||||
import_setup = Some((babe_block_import.clone(), link_half, babe_link));
|
||||
tasks_to_spawn = Some(vec![Box::new(pruning_task)]);
|
||||
let import_queue = babe::import_queue(
|
||||
babe_link.clone(),
|
||||
block_import.clone(),
|
||||
Some(Box::new(justification_import)),
|
||||
None,
|
||||
client.clone(),
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
)?;
|
||||
|
||||
import_setup = Some((block_import, grandpa_link, babe_link));
|
||||
Ok(import_queue)
|
||||
})?;
|
||||
|
||||
(builder, import_setup, inherent_data_providers, tasks_to_spawn)
|
||||
(builder, import_setup, inherent_data_providers)
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -144,7 +146,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
let disable_grandpa = config.disable_grandpa;
|
||||
let name = config.name.clone();
|
||||
|
||||
let (builder, mut import_setup, inherent_data_providers, mut tasks_to_spawn) = new_full_start!(config);
|
||||
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
|
||||
|
||||
let service = builder
|
||||
.with_network_protocol(|config| Ok(PolkadotProtocol::new(config.custom.collating_for.clone())))?
|
||||
@@ -156,17 +158,6 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
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");
|
||||
|
||||
// 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 is_collator {
|
||||
info!(
|
||||
"The node cannot start as an authority because it is also configured to run as a collator."
|
||||
@@ -185,7 +176,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
let gossip_validator_select_chain = select_chain.clone();
|
||||
|
||||
let is_known = move |block_hash: &Hash| {
|
||||
use client::BlockStatus;
|
||||
use consensus_common::BlockStatus;
|
||||
|
||||
match known_oracle.block_status(&BlockId::hash(*block_hash)) {
|
||||
Err(_) | Ok(BlockStatus::Unknown) | Ok(BlockStatus::Queued) => None,
|
||||
@@ -253,7 +244,6 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
let select_chain = service.select_chain().ok_or(ServiceError::SelectChainRequired)?;
|
||||
|
||||
let babe_config = babe::BabeParams {
|
||||
config: Config::get_or_compute(&*client)?,
|
||||
keystore: service.keystore(),
|
||||
client,
|
||||
select_chain,
|
||||
@@ -262,7 +252,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
sync_oracle: service.network(),
|
||||
inherent_data_providers: inherent_data_providers.clone(),
|
||||
force_authoring: force_authoring,
|
||||
time_source: babe_link,
|
||||
babe_link,
|
||||
};
|
||||
|
||||
let babe = start_babe(babe_config)?;
|
||||
@@ -332,28 +322,35 @@ pub fn new_light(config: Configuration<CustomConfiguration, GenesisConfig>)
|
||||
.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, transaction_pool| {
|
||||
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _| {
|
||||
let fetch_checker = fetcher
|
||||
.map(|fetcher| fetcher.checker().clone())
|
||||
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
||||
let block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
|
||||
let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
|
||||
client.clone(), backend, Arc::new(fetch_checker), client.clone()
|
||||
)?;
|
||||
|
||||
let finality_proof_import = block_import.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(),
|
||||
)?;
|
||||
|
||||
// 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,
|
||||
let import_queue = import_queue(
|
||||
babe_link,
|
||||
babe_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))
|
||||
|
||||
Reference in New Issue
Block a user