|
22 | 22 |
|
23 | 23 | use crate::collator::SlotClaim;
|
24 | 24 | use codec::Codec;
|
25 |
| -use cumulus_client_consensus_common::{ |
26 |
| - self as consensus_common, load_abridged_host_configuration, ParentSearchParams, |
27 |
| -}; |
| 25 | +use cumulus_client_consensus_common::{self as consensus_common, ParentSearchParams}; |
28 | 26 | use cumulus_primitives_aura::{AuraUnincludedSegmentApi, Slot};
|
29 | 27 | use cumulus_primitives_core::{relay_chain::Hash as ParaHash, BlockT, ClaimQueueOffset};
|
30 | 28 | use cumulus_relay_chain_interface::RelayChainInterface;
|
| 29 | +use polkadot_node_subsystem::messages::RuntimeApiRequest; |
31 | 30 | use polkadot_node_subsystem_util::runtime::ClaimQueueSnapshot;
|
32 | 31 | use polkadot_primitives::{
|
33 |
| - AsyncBackingParams, CoreIndex, Hash as RelayHash, Id as ParaId, OccupiedCoreAssumption, |
34 |
| - ValidationCodeHash, |
| 32 | + CoreIndex, Hash as RelayHash, Id as ParaId, OccupiedCoreAssumption, ValidationCodeHash, |
| 33 | + DEFAULT_SCHEDULING_LOOKAHEAD, |
35 | 34 | };
|
36 | 35 | use sc_consensus_aura::{standalone as aura_internal, AuraApi};
|
37 |
| -use sp_api::{ApiExt, ProvideRuntimeApi}; |
| 36 | +use sp_api::{ApiExt, ProvideRuntimeApi, RuntimeApiInfo}; |
38 | 37 | use sp_core::Pair;
|
39 | 38 | use sp_keystore::KeystorePtr;
|
40 | 39 | use sp_timestamp::Timestamp;
|
@@ -102,26 +101,43 @@ async fn check_validation_code_or_log(
|
102 | 101 | }
|
103 | 102 | }
|
104 | 103 |
|
105 |
| -/// Reads async backing parameters from the relay chain storage at the given relay parent. |
106 |
| -async fn async_backing_params( |
| 104 | +/// Fetch scheduling lookahead at given relay parent. |
| 105 | +async fn scheduling_lookahead( |
107 | 106 | relay_parent: RelayHash,
|
108 | 107 | relay_client: &impl RelayChainInterface,
|
109 |
| -) -> Option<AsyncBackingParams> { |
110 |
| - match load_abridged_host_configuration(relay_parent, relay_client).await { |
111 |
| - Ok(Some(config)) => Some(config.async_backing_params), |
112 |
| - Ok(None) => { |
| 108 | +) -> Option<u32> { |
| 109 | + let runtime_api_version = relay_client |
| 110 | + .version(relay_parent) |
| 111 | + .await |
| 112 | + .map_err(|e| { |
113 | 113 | tracing::error!(
|
114 |
| - target: crate::LOG_TARGET, |
115 |
| - "Active config is missing in relay chain storage", |
116 |
| - ); |
117 |
| - None |
118 |
| - }, |
| 114 | + target: super::LOG_TARGET, |
| 115 | + error = ?e, |
| 116 | + "Failed to fetch relay chain runtime version.", |
| 117 | + ) |
| 118 | + }) |
| 119 | + .ok()?; |
| 120 | + |
| 121 | + let parachain_host_runtime_api_version = runtime_api_version |
| 122 | + .api_version( |
| 123 | + &<dyn polkadot_primitives::runtime_api::ParachainHost<polkadot_primitives::Block>>::ID, |
| 124 | + ) |
| 125 | + .unwrap_or_default(); |
| 126 | + |
| 127 | + if parachain_host_runtime_api_version < |
| 128 | + RuntimeApiRequest::SCHEDULING_LOOKAHEAD_RUNTIME_REQUIREMENT |
| 129 | + { |
| 130 | + return None |
| 131 | + } |
| 132 | + |
| 133 | + match relay_client.scheduling_lookahead(relay_parent).await { |
| 134 | + Ok(scheduling_lookahead) => Some(scheduling_lookahead), |
119 | 135 | Err(err) => {
|
120 | 136 | tracing::error!(
|
121 | 137 | target: crate::LOG_TARGET,
|
122 | 138 | ?err,
|
123 | 139 | ?relay_parent,
|
124 |
| - "Failed to read active config from relay chain client", |
| 140 | + "Failed to fetch scheduling lookahead from relay chain", |
125 | 141 | );
|
126 | 142 | None
|
127 | 143 | },
|
@@ -217,9 +233,10 @@ where
|
217 | 233 | let parent_search_params = ParentSearchParams {
|
218 | 234 | relay_parent,
|
219 | 235 | para_id,
|
220 |
| - ancestry_lookback: crate::collators::async_backing_params(relay_parent, relay_client) |
| 236 | + ancestry_lookback: scheduling_lookahead(relay_parent, relay_client) |
221 | 237 | .await
|
222 |
| - .map_or(0, |params| params.allowed_ancestry_len as usize), |
| 238 | + .unwrap_or(DEFAULT_SCHEDULING_LOOKAHEAD) |
| 239 | + .saturating_sub(1) as usize, |
223 | 240 | max_depth: PARENT_SEARCH_DEPTH,
|
224 | 241 | ignore_alternative_branches: true,
|
225 | 242 | };
|
|
0 commit comments