Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Companion for substrate 14647 (#2941)
Browse files Browse the repository at this point in the history
* Companion for substrate 14647

* Futher cleanup

* Apply review suggestion

Co-authored-by: Sebastian Kunert <[email protected]>

* Apply suggestions from code review

Co-authored-by: Sebastian Kunert <[email protected]>

* update lockfile for {"polkadot", "substrate"}

---------

Co-authored-by: Sebastian Kunert <[email protected]>
Co-authored-by: parity-processbot <>
  • Loading branch information
davxy and skunert authored Jul 27, 2023
1 parent 7d51356 commit 2df9b9a
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 234 deletions.
392 changes: 196 additions & 196 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions client/consensus/aura/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//! This module also exposes some standalone functions for common operations when building
//! aura-based collators.

use codec::{Decode, Encode};
use codec::{Codec, Encode};
use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterface;
use cumulus_client_consensus_common::{
self as consensus_common, ParachainBlockImportMarker, ParachainCandidate,
Expand Down Expand Up @@ -55,7 +55,7 @@ use sp_runtime::{
};
use sp_state_machine::StorageChanges;
use sp_timestamp::Timestamp;
use std::{convert::TryFrom, error::Error, hash::Hash, sync::Arc, time::Duration};
use std::{convert::TryFrom, error::Error, sync::Arc, time::Duration};

/// Parameters for instantiating a [`Collator`].
pub struct Params<BI, CIDP, RClient, Proposer, CS> {
Expand Down Expand Up @@ -98,9 +98,9 @@ where
Proposer: ProposerInterface<Block, Transaction = BI::Transaction>,
Proposer::Transaction: Sync,
CS: CollatorServiceInterface<Block>,
P: Pair + Send + Sync,
P::Public: AppPublic + Hash + Member + Encode + Decode,
P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode,
P: Pair,
P::Public: AppPublic + Member,
P::Signature: TryFrom<Vec<u8>> + Member + Codec,
{
/// Instantiate a new instance of the `Aura` manager.
pub fn new(params: Params<BI, CIDP, RClient, Proposer, CS>) -> Self {
Expand Down Expand Up @@ -257,8 +257,8 @@ impl<Pub> SlotClaim<Pub> {
pub fn unchecked<P>(author_pub: Pub, slot: Slot, timestamp: Timestamp) -> Self
where
P: Pair<Public = Pub>,
P::Public: Encode + Decode,
P::Signature: Encode + Decode,
P::Public: Codec,
P::Signature: Codec,
{
SlotClaim { author_pub, timestamp, pre_digest: aura_internal::pre_digest::<P>(slot) }
}
Expand Down Expand Up @@ -294,8 +294,8 @@ where
C: ProvideRuntimeApi<B> + Send + Sync + 'static,
C::Api: AuraApi<B, P::Public>,
P: Pair,
P::Public: Encode + Decode,
P::Signature: Encode + Decode,
P::Public: Codec,
P::Signature: Codec,
{
// load authorities
let authorities = client.runtime_api().authorities(parent_hash).map_err(Box::new)?;
Expand Down Expand Up @@ -330,7 +330,7 @@ pub fn seal<B: BlockT, T, P>(
) -> Result<BlockImportParams<B, T>, Box<dyn Error>>
where
P: Pair,
P::Signature: Encode + Decode + TryFrom<Vec<u8>>,
P::Signature: Codec + TryFrom<Vec<u8>>,
P::Public: AppPublic,
{
let (pre_header, body) = pre_sealed.deconstruct();
Expand Down
10 changes: 5 additions & 5 deletions client/consensus/aura/src/collators/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//!
//! For more information about AuRa, the Substrate crate should be checked.

use codec::{Decode, Encode};
use codec::{Codec, Decode};
use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterface;
use cumulus_client_consensus_common::ParachainBlockImportMarker;
use cumulus_client_consensus_proposer::ProposerInterface;
Expand All @@ -45,7 +45,7 @@ use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
use sp_keystore::KeystorePtr;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Member};
use std::{convert::TryFrom, hash::Hash, sync::Arc, time::Duration};
use std::{convert::TryFrom, sync::Arc, time::Duration};

use crate::collator as collator_util;

Expand Down Expand Up @@ -87,9 +87,9 @@ pub async fn run<Block, P, BI, CIDP, Client, RClient, SO, Proposer, CS>(
Proposer: ProposerInterface<Block, Transaction = BI::Transaction>,
Proposer::Transaction: Sync,
CS: CollatorServiceInterface<Block>,
P: Pair + Send + Sync,
P::Public: AppPublic + Hash + Member + Encode + Decode,
P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode,
P: Pair,
P::Public: AppPublic + Member,
P::Signature: TryFrom<Vec<u8>> + Member + Codec,
{
let mut collation_requests = cumulus_client_collator::relay_chain_driven::init(
params.key,
Expand Down
14 changes: 7 additions & 7 deletions client/consensus/aura/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//! The main limitation is block propagation time - i.e. the new blocks created by an author
//! must be propagated to the next author before their turn.

use codec::{Decode, Encode};
use codec::{Codec, Encode};
use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterface;
use cumulus_client_consensus_common::{
self as consensus_common, ParachainBlockImportMarker, ParentSearchParams,
Expand Down Expand Up @@ -60,7 +60,7 @@ use sp_inherents::CreateInherentDataProviders;
use sp_keystore::KeystorePtr;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Member};
use sp_timestamp::Timestamp;
use std::{convert::TryFrom, hash::Hash, sync::Arc, time::Duration};
use std::{convert::TryFrom, sync::Arc, time::Duration};

use crate::collator::{self as collator_util, SlotClaim};

Expand Down Expand Up @@ -106,9 +106,9 @@ pub async fn run<Block, P, BI, CIDP, Client, Backend, RClient, SO, Proposer, CS>
Proposer: ProposerInterface<Block, Transaction = BI::Transaction>,
Proposer::Transaction: Sync,
CS: CollatorServiceInterface<Block>,
P: Pair + Send + Sync,
P::Public: AppPublic + Hash + Member + Encode + Decode,
P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode,
P: Pair,
P::Public: AppPublic + Member,
P::Signature: TryFrom<Vec<u8>> + Member + Codec,
{
// This is an arbitrary value which is likely guaranteed to exceed any reasonable
// limit, as it would correspond to 10 non-included blocks.
Expand Down Expand Up @@ -314,8 +314,8 @@ where
Client: ProvideRuntimeApi<Block>,
Client::Api: AuraApi<Block, P::Public> + AuraUnincludedSegmentApi<Block>,
P: Pair,
P::Public: Encode + Decode,
P::Signature: Encode + Decode,
P::Public: Codec,
P::Signature: Codec,
{
let runtime_api = client.runtime_api();
let authorities = runtime_api.authorities(parent_hash).ok()?;
Expand Down
16 changes: 8 additions & 8 deletions client/consensus/aura/src/equivocation_import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/// Equivocation resistance in general is a hard problem, as different nodes in the network
/// may see equivocations in a different order, and therefore may not agree on which blocks
/// should be thrown out and which ones should be kept.
use codec::{Decode, Encode};
use codec::Codec;
use cumulus_client_consensus_common::ParachainBlockImportMarker;
use lru::LruCache;

Expand Down Expand Up @@ -72,15 +72,15 @@ struct Verifier<P, Client, Block, CIDP> {
slot_duration: SlotDuration,
defender: NaiveEquivocationDefender,
telemetry: Option<TelemetryHandle>,
_marker: std::marker::PhantomData<(Block, P)>,
_phantom: std::marker::PhantomData<fn() -> (Block, P)>,
}

#[async_trait::async_trait]
impl<P, Client, Block, CIDP> VerifierT<Block> for Verifier<P, Client, Block, CIDP>
where
P: Pair,
P::Signature: Encode + Decode,
P::Public: Encode + Decode + PartialEq + Clone + Debug,
P::Signature: Codec,
P::Public: Codec + Debug,
Block: BlockT,
Client: ProvideRuntimeApi<Block> + Send + Sync,
<Client as ProvideRuntimeApi<Block>>::Api: BlockBuilderApi<Block> + AuraApi<Block, P::Public>,
Expand Down Expand Up @@ -223,9 +223,9 @@ pub fn fully_verifying_import_queue<P, Client, Block: BlockT, I, CIDP>(
telemetry: Option<TelemetryHandle>,
) -> BasicQueue<Block, I::Transaction>
where
P: Pair,
P::Signature: Encode + Decode,
P::Public: Encode + Decode + PartialEq + Clone + Debug,
P: Pair + 'static,
P::Signature: Codec,
P::Public: Codec + Debug,
I: BlockImport<Block, Error = ConsensusError>
+ ParachainBlockImportMarker
+ Send
Expand All @@ -242,7 +242,7 @@ where
defender: NaiveEquivocationDefender::default(),
slot_duration,
telemetry,
_marker: std::marker::PhantomData,
_phantom: std::marker::PhantomData,
};

BasicQueue::new(verifier, Box::new(block_import), None, spawner, registry)
Expand Down
6 changes: 3 additions & 3 deletions client/consensus/aura/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use sp_consensus_aura::AuraApi;
use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::traits::Block as BlockT;
use std::{fmt::Debug, hash::Hash, sync::Arc};
use std::{fmt::Debug, sync::Arc};
use substrate_prometheus_endpoint::Registry;

/// Parameters for [`import_queue`].
Expand Down Expand Up @@ -77,8 +77,8 @@ where
+ Send
+ Sync
+ 'static,
P: Pair + Send + Sync + 'static,
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Codec,
P: Pair + 'static,
P::Public: Debug + Codec,
P::Signature: Codec,
S: sp_core::traits::SpawnEssentialNamed,
CIDP: CreateInherentDataProviders<Block, ()> + Sync + Send + 'static,
Expand Down
10 changes: 5 additions & 5 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//!
//! For more information about AuRa, the Substrate crate should be checked.

use codec::{Decode, Encode};
use codec::Codec;
use cumulus_client_consensus_common::{
ParachainBlockImportMarker, ParachainCandidate, ParachainConsensus,
};
Expand All @@ -42,7 +42,7 @@ use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
use sp_keystore::KeystorePtr;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Member, NumberFor};
use std::{convert::TryFrom, hash::Hash, marker::PhantomData, sync::Arc};
use std::{convert::TryFrom, marker::PhantomData, sync::Arc};

mod import_queue;

Expand Down Expand Up @@ -134,9 +134,9 @@ where
Proof = <EnableProofRecording as ProofRecording>::Proof,
>,
Error: std::error::Error + Send + From<sp_consensus::Error> + 'static,
P: Pair + Send + Sync,
P::Public: AppPublic + Hash + Member + Encode + Decode,
P::Signature: TryFrom<Vec<u8>> + Hash + Member + Encode + Decode,
P: Pair + 'static,
P::Public: AppPublic + Member + Codec,
P::Signature: TryFrom<Vec<u8>> + Member + Codec,
{
let worker = sc_consensus_aura::build_aura_worker::<P, _, _, _, _, _, _, _, _>(
BuildAuraWorkerParams {
Expand Down

0 comments on commit 2df9b9a

Please sign in to comment.