mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 04:01:10 +00:00
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:
committed by
GitHub
parent
6d0bb1a667
commit
214eb25f87
@@ -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,
|
||||
)
|
||||
|
||||
@@ -47,9 +47,7 @@ use sc_telemetry::TelemetryHandle;
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_application_crypto::{AppKey, AppPublic};
|
||||
use sp_blockchain::{HeaderBackend, Result as CResult};
|
||||
use sp_consensus::{
|
||||
BlockOrigin, CanAuthorWith, Environment, Error as ConsensusError, Proposer, SelectChain,
|
||||
};
|
||||
use sp_consensus::{BlockOrigin, Environment, Error as ConsensusError, Proposer, SelectChain};
|
||||
use sp_consensus_slots::Slot;
|
||||
use sp_core::crypto::{ByteArray, Pair, Public};
|
||||
use sp_inherents::CreateInherentDataProviders;
|
||||
@@ -108,7 +106,7 @@ fn slot_author<P: Pair>(slot: Slot, authorities: &[AuthorityId<P>]) -> Option<&A
|
||||
}
|
||||
|
||||
/// Parameters of [`start_aura`].
|
||||
pub struct StartAuraParams<C, SC, I, PF, SO, L, CIDP, BS, CAW> {
|
||||
pub struct StartAuraParams<C, SC, I, PF, SO, L, CIDP, BS> {
|
||||
/// The duration of a slot.
|
||||
pub slot_duration: SlotDuration,
|
||||
/// The client to interact with the chain.
|
||||
@@ -131,8 +129,6 @@ pub struct StartAuraParams<C, SC, I, PF, SO, L, CIDP, BS, CAW> {
|
||||
pub backoff_authoring_blocks: Option<BS>,
|
||||
/// The keystore used by the node.
|
||||
pub keystore: SyncCryptoStorePtr,
|
||||
/// Can we author a block with this node?
|
||||
pub can_author_with: CAW,
|
||||
/// The proportion of the slot dedicated to proposing.
|
||||
///
|
||||
/// The block proposing will be limited to this proportion of the slot from the starting of the
|
||||
@@ -147,7 +143,7 @@ pub struct StartAuraParams<C, SC, I, PF, SO, L, CIDP, BS, CAW> {
|
||||
}
|
||||
|
||||
/// Start the aura worker. The returned future should be run in a futures executor.
|
||||
pub fn start_aura<P, B, C, SC, I, PF, SO, L, CIDP, BS, CAW, Error>(
|
||||
pub fn start_aura<P, B, C, SC, I, PF, SO, L, CIDP, BS, Error>(
|
||||
StartAuraParams {
|
||||
slot_duration,
|
||||
client,
|
||||
@@ -160,11 +156,10 @@ pub fn start_aura<P, B, C, SC, I, PF, SO, L, CIDP, BS, CAW, Error>(
|
||||
force_authoring,
|
||||
backoff_authoring_blocks,
|
||||
keystore,
|
||||
can_author_with,
|
||||
block_proposal_slot_portion,
|
||||
max_block_proposal_slot_portion,
|
||||
telemetry,
|
||||
}: StartAuraParams<C, SC, I, PF, SO, L, CIDP, BS, CAW>,
|
||||
}: StartAuraParams<C, SC, I, PF, SO, L, CIDP, BS>,
|
||||
) -> Result<impl Future<Output = ()>, sp_consensus::Error>
|
||||
where
|
||||
P: Pair + Send + Sync,
|
||||
@@ -182,7 +177,6 @@ where
|
||||
CIDP: CreateInherentDataProviders<B, ()> + Send,
|
||||
CIDP::InherentDataProviders: InherentDataProviderExt + Send,
|
||||
BS: BackoffAuthoringBlocksStrategy<NumberFor<B>> + Send + Sync + 'static,
|
||||
CAW: CanAuthorWith<B> + Send,
|
||||
Error: std::error::Error + Send + From<sp_consensus::Error> + 'static,
|
||||
{
|
||||
let worker = build_aura_worker::<P, _, _, _, _, _, _, _, _>(BuildAuraWorkerParams {
|
||||
@@ -205,7 +199,6 @@ where
|
||||
SimpleSlotWorkerToSlotWorker(worker),
|
||||
sync_oracle,
|
||||
create_inherent_data_providers,
|
||||
can_author_with,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -568,9 +561,7 @@ mod tests {
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sc_network_test::{Block as TestBlock, *};
|
||||
use sp_application_crypto::key_types::AURA;
|
||||
use sp_consensus::{
|
||||
AlwaysCanAuthor, DisableProofRecording, NoNetwork as DummyOracle, Proposal,
|
||||
};
|
||||
use sp_consensus::{DisableProofRecording, NoNetwork as DummyOracle, Proposal};
|
||||
use sp_consensus_aura::sr25519::AuthorityPair;
|
||||
use sp_inherents::InherentData;
|
||||
use sp_keyring::sr25519::Keyring;
|
||||
@@ -633,7 +624,6 @@ mod tests {
|
||||
type AuraVerifier = import_queue::AuraVerifier<
|
||||
PeersFullClient,
|
||||
AuthorityPair,
|
||||
AlwaysCanAuthor,
|
||||
Box<
|
||||
dyn CreateInherentDataProviders<
|
||||
TestBlock,
|
||||
@@ -670,7 +660,6 @@ mod tests {
|
||||
|
||||
Ok((timestamp, slot))
|
||||
}),
|
||||
AlwaysCanAuthor,
|
||||
CheckForEquivocation::Yes,
|
||||
None,
|
||||
)
|
||||
@@ -738,7 +727,7 @@ mod tests {
|
||||
let slot_duration = slot_duration(&*client).expect("slot duration available");
|
||||
|
||||
aura_futures.push(
|
||||
start_aura::<AuthorityPair, _, _, _, _, _, _, _, _, _, _, _>(StartAuraParams {
|
||||
start_aura::<AuthorityPair, _, _, _, _, _, _, _, _, _, _>(StartAuraParams {
|
||||
slot_duration,
|
||||
block_import: client.clone(),
|
||||
select_chain,
|
||||
@@ -760,7 +749,6 @@ mod tests {
|
||||
BackoffAuthoringOnFinalizedHeadLagging::default(),
|
||||
),
|
||||
keystore,
|
||||
can_author_with: sp_consensus::AlwaysCanAuthor,
|
||||
block_proposal_slot_portion: SlotProportion::new(0.5),
|
||||
max_block_proposal_slot_portion: None,
|
||||
telemetry: None,
|
||||
|
||||
Reference in New Issue
Block a user