Remove CanAuthorWith trait (#12213)

* Remove CanAuthorWith trait

CanAuthotWith trait removed. Also all dependencies, parameters, type
paramers were removed. This is related to removal of native runtime.

* Remove commented code

* Fix code formatting

* trigger CI job

* trigger CI job

* trigger CI job

* trigger CI job

* trigger CI job

* trigger CI job

* trigger CI job
This commit is contained in:
Michal Kucharczyk
2022-09-13 14:19:26 +02:00
committed by GitHub
parent 6d0bb1a667
commit 214eb25f87
9 changed files with 45 additions and 227 deletions
@@ -35,7 +35,7 @@ use sp_blockchain::{
well_known_cache_keys::{self, Id as CacheKeyId},
HeaderBackend,
};
use sp_consensus::{CanAuthorWith, Error as ConsensusError};
use sp_consensus::Error as ConsensusError;
use sp_consensus_aura::{
digests::CompatibleDigestItem, inherents::AuraInherentData, AuraApi, ConsensusLog,
AURA_ENGINE_ID,
@@ -109,27 +109,24 @@ where
}
/// A verifier for Aura blocks.
pub struct AuraVerifier<C, P, CAW, CIDP> {
pub struct AuraVerifier<C, P, CIDP> {
client: Arc<C>,
phantom: PhantomData<P>,
create_inherent_data_providers: CIDP,
can_author_with: CAW,
check_for_equivocation: CheckForEquivocation,
telemetry: Option<TelemetryHandle>,
}
impl<C, P, CAW, CIDP> AuraVerifier<C, P, CAW, CIDP> {
impl<C, P, CIDP> AuraVerifier<C, P, CIDP> {
pub(crate) fn new(
client: Arc<C>,
create_inherent_data_providers: CIDP,
can_author_with: CAW,
check_for_equivocation: CheckForEquivocation,
telemetry: Option<TelemetryHandle>,
) -> Self {
Self {
client,
create_inherent_data_providers,
can_author_with,
check_for_equivocation,
telemetry,
phantom: PhantomData,
@@ -137,10 +134,9 @@ impl<C, P, CAW, CIDP> AuraVerifier<C, P, CAW, CIDP> {
}
}
impl<C, P, CAW, CIDP> AuraVerifier<C, P, CAW, CIDP>
impl<C, P, CIDP> AuraVerifier<C, P, CIDP>
where
P: Send + Sync + 'static,
CAW: Send + Sync + 'static,
CIDP: Send,
{
async fn check_inherents<B: BlockT>(
@@ -154,19 +150,8 @@ where
where
C: ProvideRuntimeApi<B>,
C::Api: BlockBuilderApi<B>,
CAW: CanAuthorWith<B>,
CIDP: CreateInherentDataProviders<B, ()>,
{
if let Err(e) = self.can_author_with.can_author_with(&block_id) {
debug!(
target: "aura",
"Skipping `check_inherents` as authoring version is not compatible: {}",
e,
);
return Ok(())
}
let inherent_res = self
.client
.runtime_api()
@@ -187,14 +172,13 @@ where
}
#[async_trait::async_trait]
impl<B: BlockT, C, P, CAW, CIDP> Verifier<B> for AuraVerifier<C, P, CAW, CIDP>
impl<B: BlockT, C, P, CIDP> Verifier<B> for AuraVerifier<C, P, CIDP>
where
C: ProvideRuntimeApi<B> + Send + Sync + sc_client_api::backend::AuxStore + BlockOf,
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B>,
P: Pair + Send + Sync + 'static,
P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static,
P::Signature: Encode + Decode,
CAW: CanAuthorWith<B> + Send + Sync + 'static,
CIDP: CreateInherentDataProviders<B, ()> + Send + Sync,
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
{
@@ -338,7 +322,7 @@ impl Default for CheckForEquivocation {
}
/// Parameters of [`import_queue`].
pub struct ImportQueueParams<'a, Block, I, C, S, CAW, CIDP> {
pub struct ImportQueueParams<'a, Block, I, C, S, CIDP> {
/// The block import to use.
pub block_import: I,
/// The justification import.
@@ -351,8 +335,6 @@ pub struct ImportQueueParams<'a, Block, I, C, S, CAW, CIDP> {
pub spawner: &'a S,
/// The prometheus registry.
pub registry: Option<&'a Registry>,
/// Can we author with the current node?
pub can_author_with: CAW,
/// Should we check for equivocation?
pub check_for_equivocation: CheckForEquivocation,
/// Telemetry instance used to report telemetry metrics.
@@ -360,7 +342,7 @@ pub struct ImportQueueParams<'a, Block, I, C, S, CAW, CIDP> {
}
/// Start an import queue for the Aura consensus algorithm.
pub fn import_queue<P, Block, I, C, S, CAW, CIDP>(
pub fn import_queue<P, Block, I, C, S, CIDP>(
ImportQueueParams {
block_import,
justification_import,
@@ -368,10 +350,9 @@ pub fn import_queue<P, Block, I, C, S, CAW, CIDP>(
create_inherent_data_providers,
spawner,
registry,
can_author_with,
check_for_equivocation,
telemetry,
}: ImportQueueParams<Block, I, C, S, CAW, CIDP>,
}: ImportQueueParams<Block, I, C, S, CIDP>,
) -> Result<DefaultImportQueue<Block, C>, sp_consensus::Error>
where
Block: BlockT,
@@ -392,14 +373,12 @@ where
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode,
P::Signature: Encode + Decode,
S: sp_core::traits::SpawnEssentialNamed,
CAW: CanAuthorWith<Block> + Send + Sync + 'static,
CIDP: CreateInherentDataProviders<Block, ()> + Sync + Send + 'static,
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
{
let verifier = build_verifier::<P, _, _, _>(BuildVerifierParams {
let verifier = build_verifier::<P, _, _>(BuildVerifierParams {
client,
create_inherent_data_providers,
can_author_with,
check_for_equivocation,
telemetry,
});
@@ -408,13 +387,11 @@ where
}
/// Parameters of [`build_verifier`].
pub struct BuildVerifierParams<C, CIDP, CAW> {
pub struct BuildVerifierParams<C, CIDP> {
/// The client to interact with the chain.
pub client: Arc<C>,
/// Something that can create the inherent data providers.
pub create_inherent_data_providers: CIDP,
/// Can we author with the current node?
pub can_author_with: CAW,
/// Should we check for equivocation?
pub check_for_equivocation: CheckForEquivocation,
/// Telemetry instance used to report telemetry metrics.
@@ -422,19 +399,17 @@ pub struct BuildVerifierParams<C, CIDP, CAW> {
}
/// Build the [`AuraVerifier`]
pub fn build_verifier<P, C, CIDP, CAW>(
pub fn build_verifier<P, C, CIDP>(
BuildVerifierParams {
client,
create_inherent_data_providers,
can_author_with,
check_for_equivocation,
telemetry,
}: BuildVerifierParams<C, CIDP, CAW>,
) -> AuraVerifier<C, P, CAW, CIDP> {
AuraVerifier::<_, P, _, _>::new(
}: BuildVerifierParams<C, CIDP>,
) -> AuraVerifier<C, P, CIDP> {
AuraVerifier::<_, P, _>::new(
client,
create_inherent_data_providers,
can_author_with,
check_for_equivocation,
telemetry,
)