grandpa: observer (#2244)

* grandpa: initial implementation of minimal grandpa worker

* grandpa: extract grandpa observer future to function

* grandpa: add test for observer

* grandpa: start observer if no local key is defined

* grandpa: add minor comments

* grandpa: observer: log invalid commit

* grandpa: observer: persist voter set state on authority change and pause

* grandpa: observer: use commit processing callback

* grandpa: keep run_grandpa to avoid breaking public api

* grandpa: use grandpa::process_commit_validation_result

* grandpa: use finality-grandpa 0.7.2
This commit is contained in:
André Silva
2019-04-17 15:50:39 +01:00
committed by Robert Habermeier
parent 96ef462c46
commit e31cd26a9e
7 changed files with 1028 additions and 625 deletions
+24 -1
View File
@@ -89,6 +89,7 @@ mod environment;
mod finality_proof;
mod import;
mod justification;
mod observer;
mod until_imported;
#[cfg(feature="service-integration")]
@@ -97,6 +98,7 @@ mod service_integration;
pub use service_integration::{LinkHalfForService, BlockImportForService};
pub use communication::Network;
pub use finality_proof::{prove_finality, check_finality_proof};
pub use observer::run_grandpa_observer;
use aux_schema::PersistentData;
use environment::{CompletedRound, CompletedRounds, Environment, HasVoted, SharedVoterSetState, VoterSetState};
@@ -433,7 +435,7 @@ fn register_finality_tracker_inherent_data_provider<B, E, Block: BlockT<Hash=H25
/// Run a GRANDPA voter as a task. Provide configuration and a link to a
/// block import worker that has already been instantiated with `block_import`.
pub fn run_grandpa<B, E, Block: BlockT<Hash=H256>, N, RA>(
pub fn run_grandpa_voter<B, E, Block: BlockT<Hash=H256>, N, RA>(
config: Config,
link: LinkHalf<B, E, Block, RA>,
network: N,
@@ -656,3 +658,24 @@ pub fn run_grandpa<B, E, Block: BlockT<Hash=H256>, N, RA>(
Ok(voter_work.select(on_exit).then(|_| Ok(())))
}
#[deprecated(since = "1.1", note = "Please switch to run_grandpa_voter.")]
pub fn run_grandpa<B, E, Block: BlockT<Hash=H256>, N, RA>(
config: Config,
link: LinkHalf<B, E, Block, RA>,
network: N,
inherent_data_providers: InherentDataProviders,
on_exit: impl Future<Item=(),Error=()> + Clone + Send + 'static,
) -> ::client::error::Result<impl Future<Item=(),Error=()> + Send + 'static> where
Block::Hash: Ord,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + 'static,
N: Network<Block> + Send + Sync + 'static,
N::In: Send + 'static,
NumberFor<Block>: BlockNumberOps,
DigestFor<Block>: Encode,
DigestItemFor<Block>: DigestItem<AuthorityId=AuthorityId>,
RA: Send + Sync + 'static,
{
run_grandpa_voter(config, link, network, inherent_data_providers, on_exit)
}