Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup multi-collator parachain transition to async backing #3510

Merged
merged 8 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions cumulus/client/consensus/aura/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::Error as ConsensusError;
use sp_consensus_aura::AuraApi;
use sp_consensus_aura::{AuraApi, SlotDuration};
use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::traits::Block as BlockT;
Expand Down Expand Up @@ -81,7 +81,7 @@ where
P::Public: Debug + Codec,
P::Signature: Codec,
S: sp_core::traits::SpawnEssentialNamed,
CIDP: CreateInherentDataProviders<Block, ()> + Sync + Send + 'static,
CIDP: CreateInherentDataProviders<Block, SlotDuration> + Sync + Send + 'static,
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
{
sc_consensus_aura::import_queue::<P, _, _, _, _, _>(sc_consensus_aura::ImportQueueParams {
Expand Down
4 changes: 1 addition & 3 deletions cumulus/polkadot-parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,16 +1254,14 @@ where
let client2 = client.clone();

let aura_verifier = move || {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client2).unwrap();

Box::new(cumulus_client_consensus_aura::build_verifier::<
<AuraId as AppCrypto>::Pair,
_,
_,
_,
>(cumulus_client_consensus_aura::BuildVerifierParams {
client: client2.clone(),
create_inherent_data_providers: move |_, _| async move {
create_inherent_data_providers: move |_, slot_duration| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot =
Expand Down
4 changes: 1 addition & 3 deletions substrate/bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
telemetry.as_ref().map(|x| x.handle()),
)?;

let slot_duration = sc_consensus_aura::slot_duration(&*client)?;

let import_queue =
sc_consensus_aura::import_queue::<AuraPair, _, _, _, _, _>(ImportQueueParams {
block_import: grandpa_block_import.clone(),
justification_import: Some(Box::new(grandpa_block_import.clone())),
client: client.clone(),
create_inherent_data_providers: move |_, ()| async move {
create_inherent_data_providers: move |_, slot_duration| async move {
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();

let slot =
Expand Down
20 changes: 14 additions & 6 deletions substrate/client/consensus/aura/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::Error as ConsensusError;
use sp_consensus_aura::{inherents::AuraInherentData, AuraApi};
use sp_consensus_aura::{inherents::AuraInherentData, AuraApi, SlotDuration};
use sp_consensus_slots::Slot;
use sp_core::crypto::Pair;
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider as _};
Expand Down Expand Up @@ -141,7 +141,7 @@ where
where
C: ProvideRuntimeApi<B>,
C::Api: BlockBuilderApi<B>,
CIDP: CreateInherentDataProviders<B, ()>,
CIDP: CreateInherentDataProviders<B, SlotDuration>,
{
let inherent_res = self
.client
Expand All @@ -165,12 +165,12 @@ where
#[async_trait::async_trait]
impl<B: BlockT, C, P, CIDP> Verifier<B> for AuraVerifier<C, P, CIDP, NumberFor<B>>
where
C: ProvideRuntimeApi<B> + Send + Sync + sc_client_api::backend::AuxStore,
C: ProvideRuntimeApi<B> + Send + Sync + sc_client_api::backend::AuxStore + UsageProvider<B>,
C::Api: BlockBuilderApi<B> + AuraApi<B, AuthorityId<P>> + ApiExt<B>,
P: Pair,
P::Public: Codec + Debug,
P::Signature: Codec,
CIDP: CreateInherentDataProviders<B, ()> + Send + Sync,
CIDP: CreateInherentDataProviders<B, SlotDuration> + Send + Sync,
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
{
async fn verify(
Expand Down Expand Up @@ -199,9 +199,17 @@ where
)
.map_err(|e| format!("Could not fetch authorities at {:?}: {}", parent_hash, e))?;

let slot_duration = crate::slot_duration(self.client.as_ref()).unwrap();
info!(
target: LOG_TARGET,
"Checking slot duration {:?} {:?}",
slot_duration,
self.client.as_ref().usage_info().chain.best_hash,
);

let create_inherent_data_providers = self
.create_inherent_data_providers
.create_inherent_data_providers(parent_hash, ())
.create_inherent_data_providers(parent_hash, slot_duration)
.await
.map_err(|e| Error::<B>::Client(sp_blockchain::Error::Application(e)))?;

Expand Down Expand Up @@ -365,7 +373,7 @@ where
P::Public: Codec + Debug,
P::Signature: Codec,
S: sp_core::traits::SpawnEssentialNamed,
CIDP: CreateInherentDataProviders<Block, ()> + Sync + Send + 'static,
CIDP: CreateInherentDataProviders<Block, SlotDuration> + Sync + Send + 'static,
CIDP::InherentDataProviders: InherentDataProviderExt + Send + Sync,
{
let verifier = build_verifier::<P, _, _, _>(BuildVerifierParams {
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ mod tests {
Box<
dyn CreateInherentDataProviders<
TestBlock,
(),
SlotDuration,
InherentDataProviders = (InherentDataProvider,),
>,
>,
Expand Down
Loading