frame: remove finality-tracker (#7228)

* frame: remove finality-tracker

* node: remove unused parameter types

* node: bump spec_version
This commit is contained in:
André Silva
2020-10-15 21:58:51 +01:00
committed by GitHub
parent 8e8a37f7a1
commit f3ea1624f6
22 changed files with 21 additions and 638 deletions
+2 -44
View File
@@ -72,7 +72,6 @@ use sp_api::ProvideRuntimeApi;
use sp_blockchain::{HeaderBackend, Error as ClientError, HeaderMetadata};
use sp_runtime::generic::BlockId;
use sp_runtime::traits::{NumberFor, Block as BlockT, DigestFor, Zero};
use sp_inherents::InherentDataProviders;
use sp_consensus::{SelectChain, BlockImport};
use sp_core::{
crypto::Public,
@@ -650,33 +649,6 @@ fn global_communication<BE, Block: BlockT, C, N>(
(global_in, global_out)
}
/// Register the finality tracker inherent data provider (which is used by
/// GRANDPA), if not registered already.
fn register_finality_tracker_inherent_data_provider<Block: BlockT, Client>(
client: Arc<Client>,
inherent_data_providers: &InherentDataProviders,
) -> Result<(), sp_consensus::Error> where
Client: HeaderBackend<Block> + 'static,
{
if !inherent_data_providers.has_provider(&sp_finality_tracker::INHERENT_IDENTIFIER) {
inherent_data_providers
.register_provider(sp_finality_tracker::InherentDataProvider::new(move || {
#[allow(deprecated)]
{
let info = client.info();
telemetry!(CONSENSUS_INFO; "afg.finalized";
"finalized_number" => ?info.finalized_number,
"finalized_hash" => ?info.finalized_hash,
);
Ok(info.finalized_number)
}
}))
.map_err(|err| sp_consensus::Error::InherentData(err))
} else {
Ok(())
}
}
/// Parameters used to run Grandpa.
pub struct GrandpaParams<Block: BlockT, C, N, SC, VR> {
/// Configuration for the GRANDPA service.
@@ -685,8 +657,6 @@ pub struct GrandpaParams<Block: BlockT, C, N, SC, VR> {
pub link: LinkHalf<Block, C, SC>,
/// The Network instance.
pub network: N,
/// The inherent data providers.
pub inherent_data_providers: InherentDataProviders,
/// If supplied, can be used to hook on telemetry connection established events.
pub telemetry_on_connect: Option<TracingUnboundedReceiver<()>>,
/// A voting rule used to potentially restrict target votes.
@@ -716,7 +686,6 @@ pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR>(
mut config,
link,
network,
inherent_data_providers,
telemetry_on_connect,
voting_rule,
prometheus_registry,
@@ -745,8 +714,6 @@ pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR>(
prometheus_registry.as_ref(),
);
register_finality_tracker_inherent_data_provider(client.clone(), &inherent_data_providers)?;
let conf = config.clone();
let telemetry_task = if let Some(telemetry_on_connect) = telemetry_on_connect {
let authorities = persistent_data.authority_set.clone();
@@ -1096,19 +1063,10 @@ where
/// discards all GRANDPA messages (otherwise, we end up banning nodes that send
/// us a `Neighbor` message, since there is no registered gossip validator for
/// the engine id defined in the message.)
pub fn setup_disabled_grandpa<Block: BlockT, Client, N>(
client: Arc<Client>,
inherent_data_providers: &InherentDataProviders,
network: N,
) -> Result<(), sp_consensus::Error> where
pub fn setup_disabled_grandpa<Block: BlockT, N>(network: N) -> Result<(), sp_consensus::Error>
where
N: NetworkT<Block> + Send + Clone + 'static,
Client: HeaderBackend<Block> + 'static,
{
register_finality_tracker_inherent_data_provider(
client,
inherent_data_providers,
)?;
// We register the GRANDPA protocol so that we don't consider it an anomaly
// to receive GRANDPA messages on the network. We don't process the
// messages.