mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 08:21:05 +00:00
Remove client.backend (#2960)
* generalize tree_root to remove client.backend dependency * replace client.backend.blockchain.header with client.header * move used_state_cache_size into client info * Create intermediate Setup State. Fixes #1134 * remove client.backend from finality proof * update node-template * move memory backend into test helper mode * move test helper into client * starting the big refactor, remove unused functions * apply_finality * apply_finality * replacing more .backend from environment with client directly * remove .backend from grandpa by using traits * remove .backend from babe * remove .backend from tests where it is not needed * remove .backend from tests * fixing tests * fixing tests * fixing more tests * fixing tests * fix all forks test * fix style * fixing unnecessary allocation * remove old test. * fix service docs * apply suggestion * minor clean ups * turns out the test-helper features actually is being used! * fixing line length. * fix line length * minor cleaning * Apply suggestions from code review thanks, @Basti Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * address grumbles * simplify finalize block on client * move block back into inner function * Apply suggestions from code review Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com> * use as.ref instead of match * Update core/client/src/backend.rs Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
26202c66f7
commit
0cae7217d8
@@ -39,9 +39,8 @@ macro_rules! new_full_start {
|
||||
let builder = substrate_service::ServiceBuilder::new_full::<
|
||||
node_template_runtime::opaque::Block, node_template_runtime::RuntimeApi, crate::service::Executor
|
||||
>($config)?
|
||||
.with_select_chain(|_config, client| {
|
||||
#[allow(deprecated)]
|
||||
Ok(substrate_client::LongestChain::new(client.backend().clone()))
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(substrate_client::LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|config, client|
|
||||
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::ChainApi::new(client)))
|
||||
@@ -81,11 +80,16 @@ 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, mut tasks_to_spawn) = new_full_start!(config);
|
||||
|
||||
let service = builder.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
||||
.with_finality_proof_provider(|client|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _)
|
||||
.with_finality_proof_provider(|client, backend|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
|
||||
)?
|
||||
.build()?;
|
||||
|
||||
@@ -104,7 +108,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
}
|
||||
}
|
||||
|
||||
if service.config().roles.is_authority() {
|
||||
if is_authority {
|
||||
let proposer = basic_authorship::ProposerFactory {
|
||||
client: service.client(),
|
||||
transaction_pool: service.transaction_pool(),
|
||||
@@ -123,7 +127,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
env: proposer,
|
||||
sync_oracle: service.network(),
|
||||
inherent_data_providers: inherent_data_providers.clone(),
|
||||
force_authoring: service.config().force_authoring,
|
||||
force_authoring: force_authoring,
|
||||
time_source: babe_link,
|
||||
};
|
||||
|
||||
@@ -135,19 +139,19 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
service.spawn_essential_task(select);
|
||||
}
|
||||
|
||||
let config = grandpa::Config {
|
||||
let grandpa_config = grandpa::Config {
|
||||
// FIXME #1578 make this available through chainspec
|
||||
gossip_duration: Duration::from_millis(333),
|
||||
justification_period: 4096,
|
||||
name: Some(service.config().name.clone()),
|
||||
name: Some(name),
|
||||
keystore: Some(service.keystore()),
|
||||
};
|
||||
|
||||
match (service.config().roles.is_authority(), service.config().disable_grandpa) {
|
||||
match (is_authority, disable_grandpa) {
|
||||
(false, false) => {
|
||||
// start the lightweight GRANDPA observer
|
||||
service.spawn_task(Box::new(grandpa::run_grandpa_observer(
|
||||
config,
|
||||
grandpa_config,
|
||||
link_half,
|
||||
service.network(),
|
||||
service.on_exit(),
|
||||
@@ -155,8 +159,8 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
||||
},
|
||||
(true, false) => {
|
||||
// start the full GRANDPA voter
|
||||
let grandpa_config = grandpa::GrandpaParams {
|
||||
config: config,
|
||||
let voter_config = grandpa::GrandpaParams {
|
||||
config: grandpa_config,
|
||||
link: link_half,
|
||||
network: service.network(),
|
||||
inherent_data_providers: inherent_data_providers.clone(),
|
||||
@@ -166,7 +170,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(grandpa_config)?);
|
||||
service.spawn_essential_task(grandpa::run_grandpa_voter(voter_config)?);
|
||||
},
|
||||
(_, true) => {
|
||||
grandpa::setup_disabled_grandpa(
|
||||
@@ -187,21 +191,19 @@ 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, client| {
|
||||
#[allow(deprecated)]
|
||||
Ok(LongestChain::new(client.backend().clone()))
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.with_transaction_pool(|config, client|
|
||||
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client)))
|
||||
)?
|
||||
.with_import_queue_and_fprb(|_config, client, _select_chain, transaction_pool| {
|
||||
#[allow(deprecated)]
|
||||
let fetch_checker = client.backend().blockchain().fetcher()
|
||||
.with_import_queue_and_fprb(|_config, client, backend, _select_chain, transaction_pool| {
|
||||
let fetch_checker = backend.blockchain().fetcher()
|
||||
.upgrade()
|
||||
.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, _>(
|
||||
client.clone(), Arc::new(fetch_checker), client.clone()
|
||||
client.clone(), backend, Arc::new(fetch_checker), client.clone()
|
||||
)?;
|
||||
|
||||
let finality_proof_import = block_import.clone();
|
||||
@@ -223,8 +225,8 @@ pub fn new_light<C: Send + Default + 'static>(config: Configuration<C, GenesisCo
|
||||
Ok((import_queue, finality_proof_request_builder))
|
||||
})?
|
||||
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
||||
.with_finality_proof_provider(|client|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _)
|
||||
.with_finality_proof_provider(|client, backend|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
|
||||
)?
|
||||
.build()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user