mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 20:21:03 +00:00
Some changes for Statemint (#448)
* Make Aura and relay chain verifier buildable * AHHH * Ahhh2 * Ahhh3 * Move `ParachainBlockImport` * Updates because of Substrate * Revert "AHHH" This reverts commit 3f7c84327e1036ed71a8e2bd30f6416d32bae5a2. * Fix warning
This commit is contained in:
@@ -22,7 +22,7 @@ use sp_blockchain::Result as ClientResult;
|
||||
use sp_consensus::{
|
||||
error::Error as ConsensusError,
|
||||
import_queue::{BasicQueue, CacheKeyId, Verifier as VerifierT},
|
||||
BlockImport, BlockImportParams, BlockOrigin, ForkChoiceStrategy,
|
||||
BlockImport, BlockImportParams, BlockOrigin,
|
||||
};
|
||||
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
|
||||
use sp_runtime::{
|
||||
@@ -32,12 +32,23 @@ use sp_runtime::{
|
||||
};
|
||||
|
||||
/// A verifier that just checks the inherents.
|
||||
struct Verifier<Client, Block, CIDP> {
|
||||
pub struct Verifier<Client, Block, CIDP> {
|
||||
client: Arc<Client>,
|
||||
create_inherent_data_providers: CIDP,
|
||||
_marker: PhantomData<Block>,
|
||||
}
|
||||
|
||||
impl<Client, Block, CIDP> Verifier<Client, Block, CIDP> {
|
||||
/// Create a new instance.
|
||||
pub fn new(client: Arc<Client>, create_inherent_data_providers: CIDP) -> Self {
|
||||
Self {
|
||||
client,
|
||||
create_inherent_data_providers,
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<Client, Block, CIDP> VerifierT<Block> for Verifier<Client, Block, CIDP>
|
||||
where
|
||||
@@ -103,11 +114,6 @@ where
|
||||
block_import_params.body = body;
|
||||
block_import_params.justifications = justifications;
|
||||
|
||||
// Best block is determined by the relay chain, or if we are doing the intial sync
|
||||
// we import all blocks as new best.
|
||||
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(
|
||||
origin == BlockOrigin::NetworkInitialSync,
|
||||
));
|
||||
block_import_params.post_hash = post_hash;
|
||||
|
||||
Ok((block_import_params, None))
|
||||
@@ -129,15 +135,13 @@ where
|
||||
<Client as ProvideRuntimeApi<Block>>::Api: BlockBuilderApi<Block>,
|
||||
CIDP: CreateInherentDataProviders<Block, ()> + 'static,
|
||||
{
|
||||
let verifier = Verifier {
|
||||
client,
|
||||
create_inherent_data_providers,
|
||||
_marker: PhantomData,
|
||||
};
|
||||
let verifier = Verifier::new(client, create_inherent_data_providers);
|
||||
|
||||
Ok(BasicQueue::new(
|
||||
verifier,
|
||||
Box::new(block_import),
|
||||
Box::new(cumulus_client_consensus_common::ParachainBlockImport::new(
|
||||
block_import,
|
||||
)),
|
||||
None,
|
||||
spawner,
|
||||
registry,
|
||||
|
||||
@@ -33,7 +33,9 @@
|
||||
//!
|
||||
//! 5. After the parachain candidate got backed and included, all collators start at 1.
|
||||
|
||||
use cumulus_client_consensus_common::{ParachainCandidate, ParachainConsensus};
|
||||
use cumulus_client_consensus_common::{
|
||||
ParachainBlockImport, ParachainCandidate, ParachainConsensus,
|
||||
};
|
||||
use cumulus_primitives_core::{
|
||||
relay_chain::v1::{Block as PBlock, Hash as PHash, ParachainHost},
|
||||
ParaId, PersistedValidationData,
|
||||
@@ -43,15 +45,15 @@ use polkadot_service::ClientHandle;
|
||||
use sc_client_api::Backend;
|
||||
use sp_api::ProvideRuntimeApi;
|
||||
use sp_consensus::{
|
||||
BlockImport, BlockImportParams, BlockOrigin, EnableProofRecording, Environment,
|
||||
ForkChoiceStrategy, ProofRecording, Proposal, Proposer,
|
||||
BlockImport, BlockImportParams, BlockOrigin, EnableProofRecording, Environment, ProofRecording,
|
||||
Proposal, Proposer,
|
||||
};
|
||||
use sp_inherents::{CreateInherentDataProviders, InherentData, InherentDataProvider};
|
||||
use sp_runtime::traits::{Block as BlockT, HashFor, Header as HeaderT};
|
||||
use std::{marker::PhantomData, sync::Arc, time::Duration};
|
||||
|
||||
mod import_queue;
|
||||
pub use import_queue::import_queue;
|
||||
pub use import_queue::{import_queue, Verifier};
|
||||
|
||||
const LOG_TARGET: &str = "cumulus-consensus-relay-chain";
|
||||
|
||||
@@ -61,7 +63,7 @@ pub struct RelayChainConsensus<B, PF, BI, RClient, RBackend, CIDP> {
|
||||
_phantom: PhantomData<B>,
|
||||
proposer_factory: Arc<Mutex<PF>>,
|
||||
create_inherent_data_providers: Arc<CIDP>,
|
||||
block_import: Arc<futures::lock::Mutex<BI>>,
|
||||
block_import: Arc<futures::lock::Mutex<ParachainBlockImport<BI>>>,
|
||||
relay_chain_client: Arc<RClient>,
|
||||
relay_chain_backend: Arc<RBackend>,
|
||||
}
|
||||
@@ -103,7 +105,9 @@ where
|
||||
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(block_import)),
|
||||
block_import: Arc::new(futures::lock::Mutex::new(ParachainBlockImport::new(
|
||||
block_import,
|
||||
))),
|
||||
relay_chain_backend: polkadot_backend,
|
||||
relay_chain_client: polkadot_client,
|
||||
_phantom: PhantomData,
|
||||
@@ -204,8 +208,6 @@ where
|
||||
|
||||
let mut block_import_params = BlockImportParams::new(BlockOrigin::Own, header);
|
||||
block_import_params.body = Some(extrinsics);
|
||||
// Best block is determined by the relay chain.
|
||||
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(false));
|
||||
block_import_params.storage_changes = Some(storage_changes);
|
||||
|
||||
if let Err(err) = self
|
||||
|
||||
Reference in New Issue
Block a user