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

frame: remove finality-tracker #7228

Merged
4 commits merged into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ members = [
"frame/example",
"frame/example-offchain-worker",
"frame/executive",
"frame/finality-tracker",
"frame/grandpa",
"frame/identity",
"frame/im-online",
Expand Down Expand Up @@ -133,7 +132,6 @@ members = [
"primitives/debug-derive",
"primitives/storage",
"primitives/externalities",
"primitives/finality-tracker",
"primitives/finality-grandpa",
"primitives/inherents",
"primitives/keyring",
Expand Down
7 changes: 1 addition & 6 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
config: grandpa_config,
link: grandpa_link,
network,
inherent_data_providers,
telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()),
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry,
Expand All @@ -215,11 +214,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?
);
} else {
sc_finality_grandpa::setup_disabled_grandpa(
client,
&inherent_data_providers,
network,
)?;
sc_finality_grandpa::setup_disabled_grandpa(network)?;
}

network_starter.start_network();
Expand Down
1 change: 0 additions & 1 deletion bin/node/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ sp-consensus = { version = "0.8.0", path = "../../../primitives/consensus/common
sp-transaction-pool = { version = "2.0.0", path = "../../../primitives/transaction-pool" }
sc-basic-authorship = { version = "0.8.0", path = "../../../client/basic-authorship" }
sp-inherents = { version = "2.0.0", path = "../../../primitives/inherents" }
sp-finality-tracker = { version = "2.0.0", default-features = false, path = "../../../primitives/finality-tracker" }
sp-timestamp = { version = "2.0.0", default-features = false, path = "../../../primitives/timestamp" }
sp-tracing = { version = "2.0.0", path = "../../../primitives/tracing" }
hash-db = "0.15.2"
Expand Down
1 change: 0 additions & 1 deletion bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ grandpa-primitives = { version = "2.0.0", package = "sp-finality-grandpa", path
sp-core = { version = "2.0.0", path = "../../../primitives/core" }
sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" }
sp-timestamp = { version = "2.0.0", default-features = false, path = "../../../primitives/timestamp" }
sp-finality-tracker = { version = "2.0.0", default-features = false, path = "../../../primitives/finality-tracker" }
sp-inherents = { version = "2.0.0", path = "../../../primitives/inherents" }
sp-keyring = { version = "2.0.0", path = "../../../primitives/keyring" }
sp-io = { version = "2.0.0", path = "../../../primitives/io" }
Expand Down
15 changes: 6 additions & 9 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ pub fn new_full_base(
config,
link: grandpa_link,
network: network.clone(),
inherent_data_providers: inherent_data_providers.clone(),
telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(),
prometheus_registry,
Expand All @@ -331,16 +330,16 @@ pub fn new_full_base(
grandpa::run_grandpa_voter(grandpa_config)?
);
} else {
grandpa::setup_disabled_grandpa(
client.clone(),
&inherent_data_providers,
network.clone(),
)?;
grandpa::setup_disabled_grandpa(network.clone())?;
}

network_starter.start_network();
Ok(NewFullBase {
task_manager, inherent_data_providers, client, network, network_status_sinks,
task_manager,
inherent_data_providers,
client,
network,
network_status_sinks,
transaction_pool,
})
}
Expand Down Expand Up @@ -476,7 +475,6 @@ mod tests {
traits::Verify,
};
use sp_timestamp;
use sp_finality_tracker;
use sp_keyring::AccountKeyring;
use sc_service_test::TestNetNode;
use crate::service::{new_full_base, new_light_base, NewFullBase};
Expand Down Expand Up @@ -535,7 +533,6 @@ mod tests {
let mut inherent_data = inherent_data_providers
.create_inherent_data()
.expect("Creates inherent data.");
inherent_data.replace_data(sp_finality_tracker::INHERENT_IDENTIFIER, &1u64);

let parent_id = BlockId::number(service.client().chain_info().best_number);
let parent_header = service.client().header(&parent_id).unwrap().unwrap();
Expand Down
2 changes: 0 additions & 2 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pallet-contracts-primitives = { version = "2.0.0", default-features = false, pat
pallet-contracts-rpc-runtime-api = { version = "0.8.0", default-features = false, path = "../../../frame/contracts/rpc/runtime-api/" }
pallet-democracy = { version = "2.0.0", default-features = false, path = "../../../frame/democracy" }
pallet-elections-phragmen = { version = "2.0.0", default-features = false, path = "../../../frame/elections-phragmen" }
pallet-finality-tracker = { version = "2.0.0", default-features = false, path = "../../../frame/finality-tracker" }
pallet-grandpa = { version = "2.0.0", default-features = false, path = "../../../frame/grandpa" }
pallet-im-online = { version = "2.0.0", default-features = false, path = "../../../frame/im-online" }
pallet-indices = { version = "2.0.0", default-features = false, path = "../../../frame/indices" }
Expand Down Expand Up @@ -105,7 +104,6 @@ std = [
"pallet-democracy/std",
"pallet-elections-phragmen/std",
"frame-executive/std",
"pallet-finality-tracker/std",
"pallet-grandpa/std",
"pallet-im-online/std",
"pallet-indices/std",
Expand Down
7 changes: 0 additions & 7 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,12 +810,6 @@ parameter_types! {
pub const ReportLatency: BlockNumber = 1000;
}

impl pallet_finality_tracker::Trait for Runtime {
type OnFinalizationStalled = ();
type WindowSize = WindowSize;
type ReportLatency = ReportLatency;
}

parameter_types! {
pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain
pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain
Expand Down Expand Up @@ -918,7 +912,6 @@ construct_runtime!(
TechnicalCommittee: pallet_collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
Elections: pallet_elections_phragmen::{Module, Call, Storage, Event<T>, Config<T>},
TechnicalMembership: pallet_membership::<Instance1>::{Module, Call, Storage, Event<T>, Config<T>},
FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent},
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned},
Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},
Expand Down
1 change: 0 additions & 1 deletion bin/node/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pallet-timestamp = { version = "2.0.0", path = "../../../frame/timestamp" }
pallet-transaction-payment = { version = "2.0.0", path = "../../../frame/transaction-payment" }
pallet-treasury = { version = "2.0.0", path = "../../../frame/treasury" }
sp-api = { version = "2.0.0", path = "../../../primitives/api" }
sp-finality-tracker = { version = "2.0.0", default-features = false, path = "../../../primitives/finality-tracker" }
sp-timestamp = { version = "2.0.0", default-features = false, path = "../../../primitives/timestamp" }
sp-block-builder = { version = "2.0.0", path = "../../../primitives/block-builder" }
sc-block-builder = { version = "0.8.0", path = "../../../client/block-builder" }
Expand Down
5 changes: 2 additions & 3 deletions bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,9 @@ impl BenchDb {
let mut inherent_data = InherentData::new();
let timestamp = 1 * MinimumPeriod::get();

inherent_data.put_data(sp_timestamp::INHERENT_IDENTIFIER, &timestamp)
inherent_data
.put_data(sp_timestamp::INHERENT_IDENTIFIER, &timestamp)
.expect("Put timestamp failed");
inherent_data.put_data(sp_finality_tracker::INHERENT_IDENTIFIER, &0)
.expect("Put finality tracker failed");

client.runtime_api()
.inherent_extrinsics_with_context(
Expand Down
1 change: 0 additions & 1 deletion client/finality-grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ sp-inherents = { version = "2.0.0", path = "../../primitives/inherents" }
sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" }
sc-network = { version = "0.8.0", path = "../network" }
sc-network-gossip = { version = "0.8.0", path = "../network-gossip" }
sp-finality-tracker = { version = "2.0.0", path = "../../primitives/finality-tracker" }
sp-finality-grandpa = { version = "2.0.0", path = "../../primitives/finality-grandpa" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.8.0"}
sc-block-builder = { version = "0.8.0", path = "../block-builder" }
Expand Down
6 changes: 3 additions & 3 deletions client/finality-grandpa/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,9 +1157,9 @@ where
let status = client.info();

if number <= status.finalized_number && client.hash(number)? == Some(hash) {
// This can happen after a forced change (triggered by the finality tracker when finality is stalled), since
// the voter will be restarted at the median last finalized block, which can be lower than the local best
// finalized block.
// This can happen after a forced change (triggered manually from the runtime when
// finality is stalled), since the voter will be restarted at the median last finalized
// block, which can be lower than the local best finalized block.
warn!(target: "afg", "Re-finalized block #{:?} ({:?}) in the canonical chain, current best finalized is #{:?}",
hash,
number,
Expand Down
46 changes: 2 additions & 44 deletions client/finality-grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions client/finality-grandpa/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ fn run_to_completion_with<F>(
},
link: link,
network: net_service,
inherent_data_providers: InherentDataProviders::new(),
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
Expand Down Expand Up @@ -499,7 +498,6 @@ fn finalize_3_voters_1_full_observer() {
},
link: link,
network: net_service,
inherent_data_providers: InherentDataProviders::new(),
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
Expand Down Expand Up @@ -663,7 +661,6 @@ fn transition_3_voters_twice_1_full_observer() {
},
link: link,
network: net_service,
inherent_data_providers: InherentDataProviders::new(),
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
Expand Down Expand Up @@ -1088,7 +1085,6 @@ fn voter_persists_its_votes() {
},
link,
network: this.net.lock().peers[0].network_service().clone(),
inherent_data_providers: InherentDataProviders::new(),
telemetry_on_connect: None,
voting_rule: VotingRulesBuilder::default().build(),
prometheus_registry: None,
Expand Down Expand Up @@ -1434,7 +1430,6 @@ fn voter_catches_up_to_latest_round_when_behind() {
},
link,
network: net.lock().peer(peer_id).network_service().clone(),
inherent_data_providers: InherentDataProviders::new(),
telemetry_on_connect: None,
voting_rule: (),
prometheus_registry: None,
Expand Down
Loading