Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
grandpa: remove light-client specific block import pipeline (#7546)
Browse files Browse the repository at this point in the history
* grandpa: remove light-client specific block import

* consensus, network: remove finality proofs
  • Loading branch information
andresilva authored Nov 23, 2020
1 parent 0fcbef2 commit f16acff
Show file tree
Hide file tree
Showing 44 changed files with 96 additions and 2,512 deletions.
102 changes: 0 additions & 102 deletions .maintain/monitoring/grafana-dashboards/substrate-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -756,108 +756,6 @@
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": null,
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 6,
"w": 6,
"x": 0,
"y": 12
},
"hiddenSeries": false,
"id": 23,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"dataLinks": []
},
"percentage": false,
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "[[metric_namespace]]_sync_extra_finality_proofs_active{instance=\"[[instance]]\",network=\"[[network]]\"}",
"legendFormat": "{{instance}} active",
"refId": "A"
},
{
"expr": "[[metric_namespace]]_sync_extra_finality_proofs_failed{instance=\"[[instance]]\",network=\"[[network]]\"}",
"legendFormat": "{{instance}} failed",
"refId": "B"
},
{
"expr": "[[metric_namespace]]_sync_extra_finality_proofs_importing{instance=\"[[instance]]\",network=\"[[network]]\"}",
"legendFormat": "{{instance}} importing",
"refId": "C"
},
{
"expr": "[[metric_namespace]]_sync_extra_finality_proofs_pending{instance=\"[[instance]]\",network=\"[[network]]\"}",
"legendFormat": "{{instance}} pending",
"refId": "D"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Sync Proof",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
Expand Down
30 changes: 9 additions & 21 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use sp_inherents::InherentDataProviders;
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, SharedVoterState};
use sc_finality_grandpa::SharedVoterState;

// Our native executor instance.
native_executor_instance!(
Expand Down Expand Up @@ -64,7 +64,6 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
sc_consensus_aura::slot_duration(&*client)?,
aura_block_import.clone(),
Some(Box::new(grandpa_block_import.clone())),
None,
client.clone(),
inherent_data_providers.clone(),
&task_manager.spawn_handle(),
Expand All @@ -87,9 +86,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
other: (block_import, grandpa_link),
} = new_partial(&config)?;

let finality_proof_provider =
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());

let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
Expand All @@ -99,8 +95,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
import_queue,
on_demand: None,
block_announce_validator_builder: None,
finality_proof_request_builder: None,
finality_proof_provider: Some(finality_proof_provider.clone()),
})?;

if config.offchain_worker.enabled {
Expand Down Expand Up @@ -229,6 +223,8 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
let (client, backend, keystore_container, mut task_manager, on_demand) =
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;

let select_chain = sc_consensus::LongestChain::new(backend.clone());

let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
config.transaction_pool.clone(),
config.prometheus_registry(),
Expand All @@ -237,29 +233,23 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
on_demand.clone(),
));

let grandpa_block_import = sc_finality_grandpa::light_block_import(
client.clone(), backend.clone(), &(client.clone() as Arc<_>),
Arc::new(on_demand.checker().clone()) as Arc<_>,
let (grandpa_block_import, _) = sc_finality_grandpa::block_import(
client.clone(),
&(client.clone() as Arc<_>),
select_chain.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 = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
grandpa_block_import,
None,
Some(Box::new(finality_proof_import)),
grandpa_block_import.clone(),
Some(Box::new(grandpa_block_import)),
client.clone(),
InherentDataProviders::new(),
&task_manager.spawn_handle(),
config.prometheus_registry(),
sp_consensus::NeverCanAuthor,
)?;

let finality_proof_provider =
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());

let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
Expand All @@ -269,8 +259,6 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
import_queue,
on_demand: Some(on_demand.clone()),
block_announce_validator_builder: None,
finality_proof_request_builder: Some(finality_proof_request_builder),
finality_proof_provider: Some(finality_proof_provider),
})?;

if config.offchain_worker.enabled {
Expand Down
37 changes: 11 additions & 26 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

use std::sync::Arc;
use sc_consensus_babe;
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use node_primitives::Block;
use node_runtime::RuntimeApi;
use sc_service::{
Expand Down Expand Up @@ -57,10 +56,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
sc_consensus_babe::BabeLink<Block>,
),
(
grandpa::SharedVoterState,
Arc<GrandpaFinalityProofProvider<FullBackend, Block>>,
),
grandpa::SharedVoterState,
)
>, ServiceError> {
let (client, backend, keystore_container, task_manager) =
Expand Down Expand Up @@ -93,7 +89,6 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
babe_link.clone(),
block_import.clone(),
Some(Box::new(justification_import)),
None,
client.clone(),
select_chain.clone(),
inherent_data_providers.clone(),
Expand All @@ -110,10 +105,10 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
let justification_stream = grandpa_link.justification_stream();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty();
let finality_proof_provider =
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
let rpc_setup = shared_voter_state.clone();

let rpc_setup = (shared_voter_state.clone(), finality_proof_provider.clone());
let finality_proof_provider =
grandpa::FinalityProofProvider::new_for_service(backend.clone(), client.clone());

let babe_config = babe_link.config().clone();
let shared_epoch_changes = babe_link.epoch_changes().clone();
Expand Down Expand Up @@ -181,7 +176,7 @@ pub fn new_full_base(
other: (rpc_extensions_builder, import_setup, rpc_setup),
} = new_partial(&config)?;

let (shared_voter_state, finality_proof_provider) = rpc_setup;
let shared_voter_state = rpc_setup;

let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
Expand All @@ -192,8 +187,6 @@ pub fn new_full_base(
import_queue,
on_demand: None,
block_announce_validator_builder: None,
finality_proof_request_builder: None,
finality_proof_provider: Some(finality_proof_provider.clone()),
})?;

if config.offchain_worker.enabled {
Expand Down Expand Up @@ -363,14 +356,12 @@ pub fn new_light_base(config: Configuration) -> Result<(
on_demand.clone(),
));

let grandpa_block_import = grandpa::light_block_import(
client.clone(), backend.clone(), &(client.clone() as Arc<_>),
Arc::new(on_demand.checker().clone()),
let (grandpa_block_import, _) = grandpa::block_import(
client.clone(),
&(client.clone() as Arc<_>),
select_chain.clone(),
)?;

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

let (babe_block_import, babe_link) = sc_consensus_babe::block_import(
sc_consensus_babe::Config::get_or_compute(&*client)?,
Expand All @@ -383,8 +374,7 @@ pub fn new_light_base(config: Configuration) -> Result<(
let import_queue = sc_consensus_babe::import_queue(
babe_link,
babe_block_import,
None,
Some(Box::new(finality_proof_import)),
Some(Box::new(justification_import)),
client.clone(),
select_chain.clone(),
inherent_data_providers.clone(),
Expand All @@ -393,9 +383,6 @@ pub fn new_light_base(config: Configuration) -> Result<(
sp_consensus::NeverCanAuthor,
)?;

let finality_proof_provider =
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());

let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
Expand All @@ -405,8 +392,6 @@ pub fn new_light_base(config: Configuration) -> Result<(
import_queue,
on_demand: Some(on_demand.clone()),
block_announce_validator_builder: None,
finality_proof_request_builder: Some(finality_proof_request_builder),
finality_proof_provider: Some(finality_proof_provider),
})?;
network_starter.start_network();

Expand Down
1 change: 0 additions & 1 deletion bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,6 @@ impl BenchContext {
clear_justification_requests: false,
needs_justification: false,
bad_justification: false,
needs_finality_proof: false,
is_new_best: true,
}
)
Expand Down
4 changes: 1 addition & 3 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use sp_consensus::{
BlockOrigin, Error as ConsensusError, SelectChain, SlotData, BlockCheckParams, ImportResult
};
use sp_consensus::import_queue::{
Verifier, BasicQueue, DefaultImportQueue, BoxJustificationImport, BoxFinalityProofImport,
Verifier, BasicQueue, DefaultImportQueue, BoxJustificationImport,
};
use sc_client_api::{backend::AuxStore, BlockOf};
use sp_blockchain::{
Expand Down Expand Up @@ -836,7 +836,6 @@ pub fn import_queue<B, I, C, P, S, CAW>(
slot_duration: SlotDuration,
block_import: I,
justification_import: Option<BoxJustificationImport<B>>,
finality_proof_import: Option<BoxFinalityProofImport<B>>,
client: Arc<C>,
inherent_data_providers: InherentDataProviders,
spawner: &S,
Expand Down Expand Up @@ -868,7 +867,6 @@ pub fn import_queue<B, I, C, P, S, CAW>(
verifier,
Box::new(block_import),
justification_import,
finality_proof_import,
spawner,
registry,
))
Expand Down
6 changes: 1 addition & 5 deletions client/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ use std::{
any::Any, borrow::Cow, convert::TryInto,
};
use sp_consensus::{ImportResult, CanAuthorWith};
use sp_consensus::import_queue::{
BoxJustificationImport, BoxFinalityProofImport,
};
use sp_consensus::import_queue::BoxJustificationImport;
use sp_core::crypto::Public;
use sp_application_crypto::AppKey;
use sp_keystore::{SyncCryptoStorePtr, SyncCryptoStore};
Expand Down Expand Up @@ -1484,7 +1482,6 @@ pub fn import_queue<Block: BlockT, Client, SelectChain, Inner, CAW>(
babe_link: BabeLink<Block>,
block_import: Inner,
justification_import: Option<BoxJustificationImport<Block>>,
finality_proof_import: Option<BoxFinalityProofImport<Block>>,
client: Arc<Client>,
select_chain: SelectChain,
inherent_data_providers: InherentDataProviders,
Expand Down Expand Up @@ -1516,7 +1513,6 @@ pub fn import_queue<Block: BlockT, Client, SelectChain, Inner, CAW>(
verifier,
Box::new(block_import),
justification_import,
finality_proof_import,
spawner,
registry,
))
Expand Down
8 changes: 2 additions & 6 deletions client/consensus/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ use sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging;
use sc_block_builder::{BlockBuilder, BlockBuilderProvider};
use sp_consensus::{
NoNetwork as DummyOracle, Proposal, RecordProof, AlwaysCanAuthor,
import_queue::{BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport},
import_queue::{BoxBlockImport, BoxJustificationImport},
};
use sc_network_test::*;
use sc_network_test::{Block as TestBlock, PeersClient};
use sc_network::config::{BoxFinalityProofRequestBuilder, ProtocolConfig};
use sc_network::config::ProtocolConfig;
use sp_runtime::{generic::DigestItem, traits::{Block as BlockT, DigestFor}};
use sc_client_api::{BlockchainEvents, backend::TransactionFor};
use log::debug;
Expand Down Expand Up @@ -272,8 +272,6 @@ impl TestNetFactory for BabeTestNet {
-> (
BlockImportAdapter<Transaction>,
Option<BoxJustificationImport<Block>>,
Option<BoxFinalityProofImport<Block>>,
Option<BoxFinalityProofRequestBuilder<Block>>,
Option<PeerData>,
)
{
Expand All @@ -295,8 +293,6 @@ impl TestNetFactory for BabeTestNet {
(
BlockImportAdapter::new_full(block_import),
None,
None,
None,
Some(PeerData { link, inherent_data_providers, block_import: data_block_import }),
)
}
Expand Down
Loading

0 comments on commit f16acff

Please sign in to comment.