From 6ac7234e116f5db8161ec7afa1022faf59d339c4 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Tue, 30 Jul 2024 15:12:15 +0200 Subject: [PATCH] handle transition to async-backing --- bin/collator/src/parachain/service.rs | 61 ++++++++++++++++----------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/bin/collator/src/parachain/service.rs b/bin/collator/src/parachain/service.rs index a92eaf5325..f5b33b3595 100644 --- a/bin/collator/src/parachain/service.rs +++ b/bin/collator/src/parachain/service.rs @@ -957,11 +957,9 @@ where sc_client_api::StateBackend, Executor: sc_executor::NativeExecutionDispatch + 'static, { - let client2 = client.clone(); + let verifier_client = 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::< AuraPair, _, @@ -969,17 +967,24 @@ where _, >( cumulus_client_consensus_aura::BuildVerifierParams { - client: client2.clone(), - create_inherent_data_providers: move |_, _| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); - - Ok((slot, timestamp)) + client: verifier_client.clone(), + create_inherent_data_providers: move |parent_hash, _| { + let cidp_client = verifier_client.clone(); + async move { + let slot_duration = cumulus_client_consensus_aura::slot_duration_at( + &*cidp_client, + parent_hash, + )?; + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); + + Ok((slot, timestamp)) + } }, telemetry: telemetry_handle, }, @@ -1041,8 +1046,7 @@ where sc_client_api::StateBackend, Executor: sc_executor::NativeExecutionDispatch + 'static, { - let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?; - + let cidp_client = client.clone(); cumulus_client_consensus_aura::import_queue::< AuraPair, _, @@ -1053,16 +1057,23 @@ where >(cumulus_client_consensus_aura::ImportQueueParams { block_import, client, - create_inherent_data_providers: move |_, _| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - - let slot = - sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( - *timestamp, - slot_duration, - ); + create_inherent_data_providers: move |parent_hash, _| { + let cidp_client = cidp_client.clone(); + async move { + let slot_duration = sc_consensus_aura::standalone::slot_duration_at( + &*cidp_client, + parent_hash, + )?; + let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); + + let slot = + sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration( + *timestamp, + slot_duration, + ); - Ok((slot, timestamp)) + Ok((slot, timestamp)) + } }, registry: config.prometheus_registry(), spawner: &task_manager.spawn_essential_handle(),