diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index 0b9ceb4fe7760..ad9599d4b0243 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -22,7 +22,7 @@ use crate::{ authorities, standalone::SealVerificationError, AuthorityId, CompatibilityMode, Error, LOG_TARGET, }; -use codec::{Codec, Decode, Encode}; +use codec::Codec; use log::{debug, info, trace}; use prometheus_endpoint::Registry; use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider}; @@ -44,7 +44,7 @@ use sp_runtime::{ traits::{Block as BlockT, Header, NumberFor}, DigestItem, }; -use std::{fmt::Debug, hash::Hash, marker::PhantomData, sync::Arc}; +use std::{fmt::Debug, marker::PhantomData, sync::Arc}; /// check a header has been signed by the right key. If the slot is too far in the future, an error /// will be returned. If it's successful, returns the pre-header and the digest item @@ -60,9 +60,9 @@ fn check_header( check_for_equivocation: CheckForEquivocation, ) -> Result, Error> where + P::Public: Codec, P::Signature: Codec, C: sc_client_api::backend::AuxStore, - P::Public: Encode + Decode + PartialEq + Clone, { let check_result = crate::standalone::check_header_slot_and_seal::(slot_now, header, authorities); @@ -101,11 +101,11 @@ where /// A verifier for Aura blocks. pub struct AuraVerifier { client: Arc, - phantom: PhantomData

, create_inherent_data_providers: CIDP, check_for_equivocation: CheckForEquivocation, telemetry: Option, compatibility_mode: CompatibilityMode, + _phantom: PhantomData P>, } impl AuraVerifier { @@ -122,14 +122,13 @@ impl AuraVerifier { check_for_equivocation, telemetry, compatibility_mode, - phantom: PhantomData, + _phantom: PhantomData, } } } impl AuraVerifier where - P: Send + Sync + 'static, CIDP: Send, { async fn check_inherents( @@ -168,9 +167,9 @@ impl Verifier for AuraVerifier + Send + Sync + sc_client_api::backend::AuxStore, C::Api: BlockBuilderApi + AuraApi> + ApiExt, - P: Pair + Send + Sync + 'static, - P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static, - P::Signature: Encode + Decode, + P: Pair, + P::Public: Codec + Debug, + P::Signature: Codec, CIDP: CreateInherentDataProviders + Send + Sync, CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync, { @@ -365,9 +364,9 @@ where + Send + Sync + 'static, - P: Pair + Send + Sync + 'static, - P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode, - P::Signature: Encode + Decode, + P: Pair + 'static, + P::Public: Codec + Debug, + P::Signature: Codec, S: sp_core::traits::SpawnEssentialNamed, CIDP: CreateInherentDataProviders + Sync + Send + 'static, CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync, diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index 1dc364283d5b6..a611006716c69 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -30,12 +30,11 @@ //! //! NOTE: Aura itself is designed to be generic over the crypto used. #![forbid(missing_docs, unsafe_code)] -use std::{fmt::Debug, hash::Hash, marker::PhantomData, pin::Pin, sync::Arc}; +use std::{fmt::Debug, marker::PhantomData, pin::Pin, sync::Arc}; +use codec::Codec; use futures::prelude::*; -use codec::{Codec, Decode, Encode}; - use sc_client_api::{backend::AuxStore, BlockOf}; use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy, StateAction}; use sc_consensus_slots::{ @@ -48,7 +47,7 @@ use sp_application_crypto::AppPublic; use sp_blockchain::HeaderBackend; use sp_consensus::{BlockOrigin, Environment, Error as ConsensusError, Proposer, SelectChain}; use sp_consensus_slots::Slot; -use sp_core::crypto::{Pair, Public}; +use sp_core::crypto::Pair; use sp_inherents::CreateInherentDataProviders; use sp_keystore::KeystorePtr; use sp_runtime::traits::{Block as BlockT, Header, Member, NumberFor}; @@ -172,9 +171,9 @@ pub fn start_aura( }: StartAuraParams>, ) -> Result, ConsensusError> where - P: Pair + Send + Sync, - P::Public: AppPublic + Hash + Member + Encode + Decode, - P::Signature: TryFrom> + Hash + Member + Encode + Decode, + P: Pair, + P::Public: AppPublic + Member, + P::Signature: TryFrom> + Member + Codec, B: BlockT, C: ProvideRuntimeApi + BlockOf + AuxStore + HeaderBackend + Send + Sync, C::Api: AuraApi>, @@ -281,9 +280,9 @@ where C::Api: AuraApi>, PF: Environment + Send + Sync + 'static, PF::Proposer: Proposer>, - P: Pair + Send + Sync, - P::Public: AppPublic + Hash + Member + Encode + Decode, - P::Signature: TryFrom> + Hash + Member + Encode + Decode, + P: Pair, + P::Public: AppPublic + Member, + P::Signature: TryFrom> + Member + Codec, I: BlockImport> + Send + Sync + 'static, Error: std::error::Error + Send + From + 'static, SO: SyncOracle + Send + Sync + Clone, @@ -303,7 +302,7 @@ where block_proposal_slot_portion, max_block_proposal_slot_portion, compatibility_mode, - _key_type: PhantomData::

, + _phantom: PhantomData:: P>, } } @@ -320,7 +319,7 @@ struct AuraWorker { max_block_proposal_slot_portion: Option, telemetry: Option, compatibility_mode: CompatibilityMode, - _key_type: PhantomData

, + _phantom: PhantomData P>, } #[async_trait::async_trait] @@ -333,9 +332,9 @@ where E: Environment + Send + Sync, E::Proposer: Proposer>, I: BlockImport> + Send + Sync + 'static, - P: Pair + Send + Sync, - P::Public: AppPublic + Public + Member + Encode + Decode + Hash, - P::Signature: TryFrom> + Member + Encode + Decode + Hash + Debug, + P: Pair, + P::Public: AppPublic + Member, + P::Signature: TryFrom> + Member + Codec, SO: SyncOracle + Send + Clone + Sync, L: sc_consensus::JustificationSyncLink, BS: BackoffAuthoringBlocksStrategy> + Send + Sync + 'static, @@ -806,10 +805,10 @@ mod tests { force_authoring: false, backoff_authoring_blocks: Some(BackoffAuthoringOnFinalizedHeadLagging::default()), telemetry: None, - _key_type: PhantomData::, block_proposal_slot_portion: SlotProportion::new(0.5), max_block_proposal_slot_portion: None, compatibility_mode: Default::default(), + _phantom: PhantomData:: AuthorityPair>, }; let head = Header::new( @@ -856,10 +855,10 @@ mod tests { force_authoring: false, backoff_authoring_blocks: Option::<()>::None, telemetry: None, - _key_type: PhantomData::, block_proposal_slot_portion: SlotProportion::new(0.5), max_block_proposal_slot_portion: None, compatibility_mode: Default::default(), + _phantom: PhantomData:: AuthorityPair>, }; let head = client.expect_header(client.info().genesis_hash).unwrap(); diff --git a/client/consensus/common/src/import_queue.rs b/client/consensus/common/src/import_queue.rs index 11ebbd4036a20..bffc06df07076 100644 --- a/client/consensus/common/src/import_queue.rs +++ b/client/consensus/common/src/import_queue.rs @@ -95,7 +95,7 @@ pub struct IncomingBlock { /// Verify a justification of a block #[async_trait::async_trait] -pub trait Verifier: Send + Sync { +pub trait Verifier: Send { /// Verify the given block data and return the `BlockImportParams` to /// continue the block import process. async fn verify( diff --git a/primitives/core/src/crypto.rs b/primitives/core/src/crypto.rs index 72f996b336832..061d60d94f131 100644 --- a/primitives/core/src/crypto.rs +++ b/primitives/core/src/crypto.rs @@ -486,7 +486,7 @@ pub trait ByteArray: AsRef<[u8]> + AsMut<[u8]> + for<'a> TryFrom<&'a [u8], Error } /// Trait suitable for typical cryptographic key public type. -pub trait Public: ByteArray + Derive + CryptoType + PartialEq + Eq + Clone + Send + Sync {} +pub trait Public: CryptoType + ByteArray + Derive + PartialEq + Eq + Clone + Send {} /// An opaque 32-byte cryptographic identifier. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, TypeInfo)] @@ -834,7 +834,7 @@ impl sp_std::str::FromStr for SecretUri { /// /// For now it just specifies how to create a key from a phrase and derivation path. #[cfg(feature = "full_crypto")] -pub trait Pair: CryptoType + Sized + Clone + Send + Sync + 'static { +pub trait Pair: CryptoType + Sized { /// The type which is used to encode a public key. type Public: Public + Hash;