mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 22:45:40 +00:00
Single ParachainBlockImport instance (#1782)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
//! Parachain specific wrapper for the AuRa import queue.
|
||||
|
||||
use codec::Codec;
|
||||
use cumulus_client_consensus_common::ParachainBlockImport;
|
||||
use sc_client_api::{backend::AuxStore, BlockOf, UsageProvider};
|
||||
use sc_consensus::{import_queue::DefaultImportQueue, BlockImport};
|
||||
use sc_consensus_aura::AuraVerifier;
|
||||
@@ -33,10 +34,10 @@ use sp_runtime::traits::Block as BlockT;
|
||||
use std::{fmt::Debug, hash::Hash, sync::Arc};
|
||||
use substrate_prometheus_endpoint::Registry;
|
||||
|
||||
/// Parameters of [`import_queue`].
|
||||
/// Parameters for [`import_queue`].
|
||||
pub struct ImportQueueParams<'a, I, C, CIDP, S> {
|
||||
/// The block import to use.
|
||||
pub block_import: I,
|
||||
pub block_import: ParachainBlockImport<I>,
|
||||
/// The client to interact with the chain.
|
||||
pub client: Arc<C>,
|
||||
/// The inherent data providers, to create the inherent data.
|
||||
@@ -83,7 +84,7 @@ where
|
||||
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
|
||||
{
|
||||
sc_consensus_aura::import_queue::<P, _, _, _, _, _>(sc_consensus_aura::ImportQueueParams {
|
||||
block_import: cumulus_client_consensus_common::ParachainBlockImport::new(block_import),
|
||||
block_import,
|
||||
justification_import: None,
|
||||
client,
|
||||
create_inherent_data_providers,
|
||||
|
||||
@@ -71,6 +71,22 @@ impl<B, CIDP, W> Clone for AuraConsensus<B, CIDP, W> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parameters of [`AuraConsensus::build`].
|
||||
pub struct BuildAuraConsensusParams<PF, BI, CIDP, Client, BS, SO> {
|
||||
pub proposer_factory: PF,
|
||||
pub create_inherent_data_providers: CIDP,
|
||||
pub block_import: ParachainBlockImport<BI>,
|
||||
pub para_client: Arc<Client>,
|
||||
pub backoff_authoring_blocks: Option<BS>,
|
||||
pub sync_oracle: SO,
|
||||
pub keystore: SyncCryptoStorePtr,
|
||||
pub force_authoring: bool,
|
||||
pub slot_duration: SlotDuration,
|
||||
pub telemetry: Option<TelemetryHandle>,
|
||||
pub block_proposal_slot_portion: SlotProportion,
|
||||
pub max_block_proposal_slot_portion: Option<SlotProportion>,
|
||||
}
|
||||
|
||||
impl<B, CIDP> AuraConsensus<B, CIDP, ()>
|
||||
where
|
||||
B: BlockT,
|
||||
@@ -117,7 +133,7 @@ where
|
||||
let worker = sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(
|
||||
BuildAuraWorkerParams {
|
||||
client: para_client,
|
||||
block_import: ParachainBlockImport::new(block_import),
|
||||
block_import,
|
||||
justification_sync_link: (),
|
||||
proposer_factory,
|
||||
sync_oracle,
|
||||
@@ -216,19 +232,3 @@ where
|
||||
Some(ParachainCandidate { block: res.block, proof: res.storage_proof })
|
||||
}
|
||||
}
|
||||
|
||||
/// Parameters of [`AuraConsensus::build`].
|
||||
pub struct BuildAuraConsensusParams<PF, BI, CIDP, Client, BS, SO> {
|
||||
pub proposer_factory: PF,
|
||||
pub create_inherent_data_providers: CIDP,
|
||||
pub block_import: BI,
|
||||
pub para_client: Arc<Client>,
|
||||
pub backoff_authoring_blocks: Option<BS>,
|
||||
pub sync_oracle: SO,
|
||||
pub keystore: SyncCryptoStorePtr,
|
||||
pub force_authoring: bool,
|
||||
pub slot_duration: SlotDuration,
|
||||
pub telemetry: Option<TelemetryHandle>,
|
||||
pub block_proposal_slot_portion: SlotProportion,
|
||||
pub max_block_proposal_slot_portion: Option<SlotProportion>,
|
||||
}
|
||||
|
||||
@@ -83,6 +83,12 @@ impl<I> ParachainBlockImport<I> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Clone> Clone for ParachainBlockImport<I> {
|
||||
fn clone(&self) -> Self {
|
||||
ParachainBlockImport(self.0.clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<Block, I> BlockImport<Block> for ParachainBlockImport<I>
|
||||
where
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
||||
use cumulus_client_consensus_common::ParachainBlockImport;
|
||||
|
||||
use sc_consensus::{
|
||||
import_queue::{BasicQueue, Verifier as VerifierT},
|
||||
BlockImport, BlockImportParams,
|
||||
@@ -103,7 +105,7 @@ where
|
||||
/// Start an import queue for a Cumulus collator that does not uses any special authoring logic.
|
||||
pub fn import_queue<Client, Block: BlockT, I, CIDP>(
|
||||
client: Arc<Client>,
|
||||
block_import: I,
|
||||
block_import: ParachainBlockImport<I>,
|
||||
create_inherent_data_providers: CIDP,
|
||||
spawner: &impl sp_core::traits::SpawnEssentialNamed,
|
||||
registry: Option<&substrate_prometheus_endpoint::Registry>,
|
||||
@@ -117,11 +119,5 @@ where
|
||||
{
|
||||
let verifier = Verifier::new(client, create_inherent_data_providers);
|
||||
|
||||
Ok(BasicQueue::new(
|
||||
verifier,
|
||||
Box::new(cumulus_client_consensus_common::ParachainBlockImport::new(block_import)),
|
||||
None,
|
||||
spawner,
|
||||
registry,
|
||||
))
|
||||
Ok(BasicQueue::new(verifier, Box::new(block_import), None, spawner, registry))
|
||||
}
|
||||
|
||||
@@ -90,16 +90,14 @@ where
|
||||
para_id: ParaId,
|
||||
proposer_factory: PF,
|
||||
create_inherent_data_providers: CIDP,
|
||||
block_import: BI,
|
||||
block_import: ParachainBlockImport<BI>,
|
||||
relay_chain_interface: RCInterface,
|
||||
) -> Self {
|
||||
Self {
|
||||
para_id,
|
||||
proposer_factory: Arc::new(Mutex::new(proposer_factory)),
|
||||
create_inherent_data_providers: Arc::new(create_inherent_data_providers),
|
||||
block_import: Arc::new(futures::lock::Mutex::new(ParachainBlockImport::new(
|
||||
block_import,
|
||||
))),
|
||||
block_import: Arc::new(futures::lock::Mutex::new(block_import)),
|
||||
relay_chain_interface,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
@@ -222,7 +220,7 @@ pub struct BuildRelayChainConsensusParams<PF, BI, CIDP, RCInterface> {
|
||||
pub para_id: ParaId,
|
||||
pub proposer_factory: PF,
|
||||
pub create_inherent_data_providers: CIDP,
|
||||
pub block_import: BI,
|
||||
pub block_import: ParachainBlockImport<BI>,
|
||||
pub relay_chain_interface: RCInterface,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user