diff --git a/substrate/core/consensus/aura/src/lib.rs b/substrate/core/consensus/aura/src/lib.rs index fa878ef104..32d49614c4 100644 --- a/substrate/core/consensus/aura/src/lib.rs +++ b/substrate/core/consensus/aura/src/lib.rs @@ -68,7 +68,7 @@ use substrate_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS use slots::{CheckedHeader, SlotData, SlotWorker, SlotInfo, SlotCompatible, slot_now, check_equivocation}; pub use aura_primitives::*; -pub use consensus_common::{SyncOracle, ExtraVerification}; +pub use consensus_common::SyncOracle; pub use digest::CompatibleDigestItem; mod digest; @@ -446,14 +446,13 @@ fn check_header( } /// A verifier for Aura blocks. -pub struct AuraVerifier { +pub struct AuraVerifier { client: Arc, - extra: E, phantom: PhantomData

, inherent_data_providers: inherents::InherentDataProviders, } -impl AuraVerifier +impl AuraVerifier where P: Send + Sync + 'static { fn check_inherents( @@ -505,24 +504,11 @@ impl AuraVerifier } } -/// No-op extra verification. -#[derive(Debug, Clone, Copy)] -pub struct NothingExtra; - -impl ExtraVerification for NothingExtra { - type Verified = Result<(), String>; - - fn verify(&self, _: &B::Header, _: Option<&[B::Extrinsic]>) -> Self::Verified { - Ok(()) - } -} - #[forbid(deprecated)] -impl Verifier for AuraVerifier where +impl Verifier for AuraVerifier where C: ProvideRuntimeApi + Send + Sync + client::backend::AuxStore, C::Api: BlockBuilderApi, DigestItemFor: CompatibleDigestItem

+ DigestItem>, - E: ExtraVerification, P: Pair + Send + Sync + 'static, P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + AsRef + 'static, P::Signature: Encode + Decode, @@ -543,11 +529,6 @@ impl Verifier for AuraVerifier 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 @@ -588,8 +569,6 @@ impl Verifier for AuraVerifier where trace!(target: "aura", "Checked {:?}; importing.", pre_header); telemetry!(CONSENSUS_TRACE; "aura.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()); @@ -618,7 +597,7 @@ impl Verifier for AuraVerifier where } } -impl Authorities for AuraVerifier where +impl Authorities for AuraVerifier where B: Block, C: ProvideRuntimeApi + ProvideCache, C::Api: AuthoritiesApi, @@ -697,21 +676,19 @@ fn register_aura_inherent_data_provider( } /// Start an import queue for the Aura consensus algorithm. -pub fn import_queue( +pub fn import_queue( slot_duration: SlotDuration, block_import: SharedBlockImport, justification_import: Option>, finality_proof_import: Option>, finality_proof_request_builder: Option>, client: Arc, - extra: E, inherent_data_providers: InherentDataProviders, ) -> Result, consensus_common::Error> where B: Block, C: 'static + ProvideRuntimeApi + ProvideCache + Send + Sync + AuxStore, C::Api: BlockBuilderApi + AuthoritiesApi, DigestItemFor: CompatibleDigestItem

+ DigestItem>, - E: 'static + ExtraVerification, P: Pair + Send + Sync + 'static, P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode + AsRef, P::Signature: Encode + Decode, @@ -722,7 +699,6 @@ pub fn import_queue( let verifier = Arc::new( AuraVerifier { client: client.clone(), - extra, inherent_data_providers, phantom: PhantomData, } @@ -794,7 +770,7 @@ mod tests { impl TestNetFactory for AuraTestNet { type Specialization = DummySpecialization; - type Verifier = AuraVerifier; + type Verifier = AuraVerifier; type PeerData = (); /// Create new test network with peers and given config. @@ -821,7 +797,6 @@ mod tests { assert_eq!(slot_duration.get(), SLOT_DURATION); Arc::new(AuraVerifier { client, - extra: NothingExtra, inherent_data_providers, phantom: Default::default(), }) diff --git a/substrate/core/consensus/babe/src/lib.rs b/substrate/core/consensus/babe/src/lib.rs index f28c23de54..d1585947ce 100644 --- a/substrate/core/consensus/babe/src/lib.rs +++ b/substrate/core/consensus/babe/src/lib.rs @@ -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( } /// A verifier for Babe blocks. -pub struct BabeVerifier { +pub struct BabeVerifier { client: Arc, - extra: E, inherent_data_providers: inherents::InherentDataProviders, threshold: u64, } -impl BabeVerifier { +impl BabeVerifier { fn check_inherents( &self, block: B, @@ -554,23 +552,10 @@ impl BabeVerifier { } } -/// No-op extra verification. -#[derive(Debug, Clone, Copy)] -pub struct NothingExtra; - -impl ExtraVerification for NothingExtra { - type Verified = Result<(), String>; - - fn verify(&self, _: &B::Header, _: Option<&[B::Extrinsic]>) -> Self::Verified { - Ok(()) - } -} - -impl Verifier for BabeVerifier where +impl Verifier for BabeVerifier where C: ProvideRuntimeApi + Send + Sync + AuxStore, C::Api: BlockBuilderApi, DigestItemFor: CompatibleDigestItem + DigestItem, - E: ExtraVerification, Self: Authorities, { fn verify( @@ -601,11 +586,6 @@ impl Verifier for BabeVerifier 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 Verifier for BabeVerifier 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 Verifier for BabeVerifier where } } -impl Authorities for BabeVerifier where +impl Authorities for BabeVerifier where B: Block, C: ProvideRuntimeApi + ProvideCache, C::Api: AuthoritiesApi, @@ -851,7 +829,7 @@ mod tests { impl TestNetFactory for BabeTestNet { type Specialization = DummySpecialization; - type Verifier = BabeVerifier; + type Verifier = BabeVerifier; 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(), }) diff --git a/substrate/core/consensus/common/src/lib.rs b/substrate/core/consensus/common/src/lib.rs index 140aa57901..6d43b6624a 100644 --- a/substrate/core/consensus/common/src/lib.rs +++ b/substrate/core/consensus/common/src/lib.rs @@ -126,20 +126,6 @@ impl SyncOracle for Arc { } } -/// Extra verification for blocks. -pub trait ExtraVerification: Send + Sync { - /// Future that resolves when the block is verified, or fails with error if - /// not. - type Verified: IntoFuture; - - /// Do additional verification for this block. - fn verify( - &self, - header: &B::Header, - body: Option<&[B::Extrinsic]>, - ) -> Self::Verified; -} - /// A list of all well known keys in the cache. pub mod well_known_cache_keys { /// The type representing cache keys. diff --git a/substrate/node-template/src/service.rs b/substrate/node-template/src/service.rs index 25e7db8dec..1de7bb4767 100644 --- a/substrate/node-template/src/service.rs +++ b/substrate/node-template/src/service.rs @@ -13,7 +13,7 @@ use substrate_service::{ error::{Error as ServiceError}, }; use basic_authorship::ProposerFactory; -use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration, NothingExtra}; +use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration}; use futures::prelude::*; use substrate_client::{self as client, LongestChain}; use primitives::{ed25519::Pair, Pair as PairT}; @@ -99,14 +99,13 @@ construct_service_factory! { Self::Block, > { |config: &mut FactoryFullConfiguration , client: Arc>, _select_chain: Self::SelectChain| { - import_queue::<_, _, _, Pair>( + import_queue::<_, _, Pair>( SlotDuration::get_or_compute(&*client)?, client.clone(), None, None, None, client, - NothingExtra, config.custom.inherent_data_providers.clone(), ).map_err(Into::into) } @@ -115,14 +114,13 @@ construct_service_factory! { Self::Block, > { |config: &mut FactoryFullConfiguration, client: Arc>| { - import_queue::<_, _, _, Pair>( + import_queue::<_, _, Pair>( SlotDuration::get_or_compute(&*client)?, client.clone(), None, None, None, client, - NothingExtra, config.custom.inherent_data_providers.clone(), ).map_err(Into::into) } diff --git a/substrate/node/cli/src/service.rs b/substrate/node/cli/src/service.rs index 1458392b0f..4fe74e4f9a 100644 --- a/substrate/node/cli/src/service.rs +++ b/substrate/node/cli/src/service.rs @@ -22,7 +22,7 @@ use std::sync::Arc; use std::time::Duration; use client::{self, LongestChain}; -use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration, NothingExtra}; +use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration}; use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use node_executor; use primitives::{Pair as PairT, ed25519}; @@ -167,14 +167,13 @@ construct_service_factory! { config.custom.grandpa_import_setup = Some((block_import.clone(), link_half)); - import_queue::<_, _, _, ed25519::Pair>( + import_queue::<_, _, ed25519::Pair>( slot_duration, block_import, Some(justification_import), None, None, client, - NothingExtra, config.custom.inherent_data_providers.clone(), ).map_err(Into::into) }}, @@ -192,14 +191,13 @@ construct_service_factory! { let finality_proof_import = block_import.clone(); let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder(); - import_queue::<_, _, _, ed25519::Pair>( + import_queue::<_, _, ed25519::Pair>( SlotDuration::get_or_compute(&*client)?, block_import, None, Some(finality_proof_import), Some(finality_proof_request_builder), client, - NothingExtra, config.custom.inherent_data_providers.clone(), ).map_err(Into::into) }},