Refactoring: Remove ExtraVerification in the import queue (#2844)

* Remove ExtraVerification in the import queue

* Fix Babe

* Fix node-template
This commit is contained in:
Pierre Krieger
2019-06-12 14:56:31 +02:00
committed by Robert Habermeier
parent 3496f11404
commit ce302390dd
5 changed files with 18 additions and 84 deletions
+5 -28
View File
@@ -31,7 +31,6 @@ use digest::CompatibleDigestItem;
pub use digest::{BabePreDigest, BABE_VRF_PREFIX};
pub use babe_primitives::*;
pub use consensus_common::SyncOracle;
use consensus_common::ExtraVerification;
use runtime_primitives::{generic, generic::BlockId, Justification};
use runtime_primitives::traits::{
Block, Header, Digest, DigestItemFor, DigestItem, ProvideRuntimeApi, AuthorityIdFor,
@@ -522,14 +521,13 @@ fn check_header<B: Block + Sized, C: AuxStore>(
}
/// A verifier for Babe blocks.
pub struct BabeVerifier<C, E> {
pub struct BabeVerifier<C> {
client: Arc<C>,
extra: E,
inherent_data_providers: inherents::InherentDataProviders,
threshold: u64,
}
impl<C, E> BabeVerifier<C, E> {
impl<C> BabeVerifier<C> {
fn check_inherents<B: Block>(
&self,
block: B,
@@ -554,23 +552,10 @@ impl<C, E> BabeVerifier<C, E> {
}
}
/// No-op extra verification.
#[derive(Debug, Clone, Copy)]
pub struct NothingExtra;
impl<B: Block> ExtraVerification<B> for NothingExtra {
type Verified = Result<(), String>;
fn verify(&self, _: &B::Header, _: Option<&[B::Extrinsic]>) -> Self::Verified {
Ok(())
}
}
impl<B: Block, C, E> Verifier<B> for BabeVerifier<C, E> where
impl<B: Block, C> Verifier<B> for BabeVerifier<C> where
C: ProvideRuntimeApi + Send + Sync + AuxStore,
C::Api: BlockBuilderApi<B>,
DigestItemFor<B>: CompatibleDigestItem + DigestItem<AuthorityId=Public>,
E: ExtraVerification<B>,
Self: Authorities<B>,
{
fn verify(
@@ -601,11 +586,6 @@ impl<B: Block, C, E> Verifier<B> for BabeVerifier<C, E> where
let authorities = self.authorities(&BlockId::Hash(parent_hash))
.map_err(|e| format!("Could not fetch authorities at {:?}: {:?}", parent_hash, e))?;
let extra_verification = self.extra.verify(
&header,
body.as_ref().map(|x| &x[..]),
);
// we add one to allow for some small drift.
// FIXME #1019 in the future, alter this queue to allow deferring of
// headers
@@ -645,8 +625,6 @@ impl<B: Block, C, E> Verifier<B> for BabeVerifier<C, E> where
"babe.checked_and_importing";
"pre_header" => ?pre_header);
extra_verification.into_future().wait()?;
let new_authorities = pre_header.digest()
.log(DigestItem::as_authorities_change)
.map(|digest| digest.to_vec());
@@ -676,7 +654,7 @@ impl<B: Block, C, E> Verifier<B> for BabeVerifier<C, E> where
}
}
impl<B, C, E> Authorities<B> for BabeVerifier<C, E> where
impl<B, C> Authorities<B> for BabeVerifier<C> where
B: Block,
C: ProvideRuntimeApi + ProvideCache<B>,
C::Api: AuthoritiesApi<B>,
@@ -851,7 +829,7 @@ mod tests {
impl TestNetFactory for BabeTestNet {
type Specialization = DummySpecialization;
type Verifier = BabeVerifier<PeersFullClient, NothingExtra>;
type Verifier = BabeVerifier<PeersFullClient>;
type PeerData = ();
/// Create new test network with peers and given config.
@@ -880,7 +858,6 @@ mod tests {
assert_eq!(config.get(), SLOT_DURATION);
Arc::new(BabeVerifier {
client,
extra: NothingExtra,
inherent_data_providers,
threshold: config.threshold(),
})