Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ macro_rules! new_full_start {
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
Ok(sc_transaction_pool::BasicPool::new(config, std::sync::Arc::new(pool_api)))
})?
.with_import_queue(|_config, client, mut select_chain, transaction_pool| {
.with_import_queue(|_config, client, mut select_chain, _transaction_pool| {
let select_chain = select_chain.take()
.ok_or_else(|| sc_service::Error::SelectChainRequired)?;

Expand All @@ -50,14 +50,13 @@ macro_rules! new_full_start {
grandpa_block_import.clone(), client.clone(),
);

let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _>(
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair>(
sc_consensus_aura::slot_duration(&*client)?,
aura_block_import,
Some(Box::new(grandpa_block_import.clone())),
None,
client,
inherent_data_providers.clone(),
Some(transaction_pool),
)?;

import_setup = Some((grandpa_block_import, grandpa_link));
Expand Down Expand Up @@ -210,14 +209,13 @@ pub fn new_light(config: Configuration<GenesisConfig>)
let finality_proof_request_builder =
finality_proof_import.create_finality_proof_request_builder();

let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, ()>(
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair>(
sc_consensus_aura::slot_duration(&*client)?,
grandpa_block_import,
None,
Some(Box::new(finality_proof_import)),
client,
inherent_data_providers.clone(),
None,
)?;

Ok((import_queue, finality_proof_request_builder))
Expand Down
25 changes: 7 additions & 18 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,21 +405,17 @@ fn find_pre_digest<B: BlockT, P: Pair>(header: &B::Header) -> Result<u64, Error<
///
/// This digest item will always return `Some` when used with `as_aura_seal`.
//
// FIXME #1018 needs misbehavior types. The `transaction_pool` parameter will be
// used to submit such misbehavior reports.
fn check_header<C, B: BlockT, P: Pair, T>(
fn check_header<C, B: BlockT, P: Pair>(
client: &C,
slot_now: u64,
mut header: B::Header,
hash: B::Hash,
authorities: &[AuthorityId<P>],
_transaction_pool: Option<&T>,
) -> Result<CheckedHeader<B::Header, (u64, DigestItemFor<B>)>, Error<B>> where
DigestItemFor<B>: CompatibleDigestItem<P>,
P::Signature: Decode,
C: sc_client_api::backend::AuxStore,
P::Public: Encode + Decode + PartialEq + Clone,
T: Send + Sync + 'static,
{
let seal = match header.digest_mut().pop() {
Some(x) => x,
Expand Down Expand Up @@ -469,14 +465,13 @@ fn check_header<C, B: BlockT, P: Pair, T>(
}

/// A verifier for Aura blocks.
pub struct AuraVerifier<C, P, T> {
pub struct AuraVerifier<C, P> {
client: Arc<C>,
phantom: PhantomData<P>,
inherent_data_providers: sp_inherents::InherentDataProviders,
transaction_pool: Option<Arc<T>>,
}

impl<C, P, T> AuraVerifier<C, P, T>
impl<C, P> AuraVerifier<C, P>
where P: Send + Sync + 'static
{
fn check_inherents<B: BlockT>(
Expand Down Expand Up @@ -531,7 +526,7 @@ impl<C, P, T> AuraVerifier<C, P, T>
}

#[forbid(deprecated)]
impl<B: BlockT, C, P, T> Verifier<B> for AuraVerifier<C, P, T> where
impl<B: BlockT, C, P> Verifier<B> for AuraVerifier<C, P> where
C: ProvideRuntimeApi<B> +
Send +
Sync +
Expand All @@ -543,7 +538,6 @@ impl<B: BlockT, C, P, T> Verifier<B> for AuraVerifier<C, P, T> where
P: Pair + Send + Sync + 'static,
P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static,
P::Signature: Encode + Decode,
T: Send + Sync + 'static,
{
fn verify(
&mut self,
Expand All @@ -565,13 +559,12 @@ impl<B: BlockT, C, P, T> Verifier<B> for AuraVerifier<C, P, T> where
// we add one to allow for some small drift.
// FIXME #1019 in the future, alter this queue to allow deferring of
// headers
let checked_header = check_header::<C, B, P, T>(
let checked_header = check_header::<C, B, P>(
&self.client,
slot_now + 1,
header,
hash,
&authorities[..],
self.transaction_pool.as_ref().map(|x| &**x),
).map_err(|e| e.to_string())?;
match checked_header {
CheckedHeader::Checked(pre_header, (slot_num, seal)) => {
Expand Down Expand Up @@ -795,14 +788,13 @@ impl<Block: BlockT, C, I, P> BlockImport<Block> for AuraBlockImport<Block, C, I,
}

/// Start an import queue for the Aura consensus algorithm.
pub fn import_queue<B, I, C, P, T>(
pub fn import_queue<B, I, C, P>(
slot_duration: SlotDuration,
block_import: I,
justification_import: Option<BoxJustificationImport<B>>,
finality_proof_import: Option<BoxFinalityProofImport<B>>,
client: Arc<C>,
inherent_data_providers: InherentDataProviders,
transaction_pool: Option<Arc<T>>,
) -> Result<AuraImportQueue<B, sp_api::TransactionFor<C, B>>, sp_consensus::Error> where
B: BlockT,
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B, Error = sp_blockchain::Error>,
Expand All @@ -812,7 +804,6 @@ pub fn import_queue<B, I, C, P, T>(
P: Pair + Send + Sync + 'static,
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode,
P::Signature: Encode + Decode,
T: Send + Sync + 'static,
{
register_aura_inherent_data_provider(&inherent_data_providers, slot_duration.get())?;
initialize_authorities_cache(&*client)?;
Expand All @@ -821,7 +812,6 @@ pub fn import_queue<B, I, C, P, T>(
client: client.clone(),
inherent_data_providers,
phantom: PhantomData,
transaction_pool,
};
Ok(BasicQueue::new(
verifier,
Expand Down Expand Up @@ -900,7 +890,7 @@ mod tests {
}

impl TestNetFactory for AuraTestNet {
type Verifier = AuraVerifier<PeersFullClient, AuthorityPair, ()>;
type Verifier = AuraVerifier<PeersFullClient, AuthorityPair>;
type PeerData = ();

/// Create new test network with peers and given config.
Expand All @@ -926,7 +916,6 @@ mod tests {
AuraVerifier {
client,
inherent_data_providers,
transaction_pool: Default::default(),
phantom: Default::default(),
}
},
Expand Down