Skip to content

Commit 4cd07c5

Browse files
deprecate AsyncBackingParams (#7254)
Part of #5079. Removes all usage of the static async backing params, replacing them with dynamically computed equivalent values (based on the claim queue and scheduling lookahead). Adds a new runtime API for querying the scheduling lookahead value. If not present, falls back to 3 (the default value that is backwards compatible with values we have on production networks for allowed_ancestry_len) Also resolves most of #4447, removing code that handles async backing not yet being enabled. While doing this, I removed the support for collation protocol version 1 on collators, as it only worked for leaves not supporting async backing (which are none). I also unhooked the legacy v1 statement-distribution (for the same reason as above). That subsystem is basically dead code now, so I had to remove some of its tests as they would no longer pass (since the subsystem no longer sends messages to the legacy variant). I did not remove the entire legacy subsystem yet, as that would pollute this PR too much. We can remove the entire v1 and v2 validation protocols in a follow up PR. In another PR: remove test files with names `prospective_parachains` (it'd pollute this PR if we do now) TODO: - [x] add deprecation warnings - [x] prdoc --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent d283ad0 commit 4cd07c5

File tree

69 files changed

+1708
-4768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1708
-4768
lines changed

cumulus/client/consensus/aura/src/collators/mod.rs

+37-20
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,18 @@
2222
2323
use crate::collator::SlotClaim;
2424
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};
2826
use cumulus_primitives_aura::{AuraUnincludedSegmentApi, Slot};
2927
use cumulus_primitives_core::{relay_chain::Hash as ParaHash, BlockT, ClaimQueueOffset};
3028
use cumulus_relay_chain_interface::RelayChainInterface;
29+
use polkadot_node_subsystem::messages::RuntimeApiRequest;
3130
use polkadot_node_subsystem_util::runtime::ClaimQueueSnapshot;
3231
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,
3534
};
3635
use sc_consensus_aura::{standalone as aura_internal, AuraApi};
37-
use sp_api::{ApiExt, ProvideRuntimeApi};
36+
use sp_api::{ApiExt, ProvideRuntimeApi, RuntimeApiInfo};
3837
use sp_core::Pair;
3938
use sp_keystore::KeystorePtr;
4039
use sp_timestamp::Timestamp;
@@ -102,26 +101,43 @@ async fn check_validation_code_or_log(
102101
}
103102
}
104103

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(
107106
relay_parent: RelayHash,
108107
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| {
113113
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),
119135
Err(err) => {
120136
tracing::error!(
121137
target: crate::LOG_TARGET,
122138
?err,
123139
?relay_parent,
124-
"Failed to read active config from relay chain client",
140+
"Failed to fetch scheduling lookahead from relay chain",
125141
);
126142
None
127143
},
@@ -217,9 +233,10 @@ where
217233
let parent_search_params = ParentSearchParams {
218234
relay_parent,
219235
para_id,
220-
ancestry_lookback: crate::collators::async_backing_params(relay_parent, relay_client)
236+
ancestry_lookback: scheduling_lookahead(relay_parent, relay_client)
221237
.await
222-
.map_or(0, |params| params.allowed_ancestry_len as usize),
238+
.unwrap_or(DEFAULT_SCHEDULING_LOOKAHEAD)
239+
.saturating_sub(1) as usize,
223240
max_depth: PARENT_SEARCH_DEPTH,
224241
ignore_alternative_branches: true,
225242
};

cumulus/client/consensus/common/src/tests.rs

+4
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ impl RelayChainInterface for Relaychain {
284284
) -> RelayChainResult<Vec<u8>> {
285285
unimplemented!("Not needed for test")
286286
}
287+
288+
async fn scheduling_lookahead(&self, _: PHash) -> RelayChainResult<u32> {
289+
unimplemented!("Not needed for test")
290+
}
287291
}
288292

289293
fn sproof_with_best_parent(client: &Client) -> RelayStateSproofBuilder {

cumulus/client/network/src/tests.rs

+4
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,10 @@ impl RelayChainInterface for DummyRelayChainInterface {
347347
) -> RelayChainResult<Vec<u8>> {
348348
unimplemented!("Not needed for test")
349349
}
350+
351+
async fn scheduling_lookahead(&self, _: PHash) -> RelayChainResult<u32> {
352+
unimplemented!("Not needed for test")
353+
}
350354
}
351355

352356
fn make_validator_and_api() -> (

cumulus/client/pov-recovery/src/tests.rs

+4
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,10 @@ impl RelayChainInterface for Relaychain {
503503
) -> RelayChainResult<Vec<u8>> {
504504
unimplemented!("Not needed for test")
505505
}
506+
507+
async fn scheduling_lookahead(&self, _: PHash) -> RelayChainResult<u32> {
508+
unimplemented!("Not needed for test")
509+
}
506510
}
507511

508512
fn make_candidate_chain(candidate_number_range: Range<u32>) -> Vec<CommittedCandidateReceipt> {

cumulus/client/relay-chain-inprocess-interface/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ impl RelayChainInterface for RelayChainInProcessInterface {
316316
) -> RelayChainResult<BTreeMap<CoreIndex, VecDeque<ParaId>>> {
317317
Ok(self.full_client.runtime_api().claim_queue(hash)?)
318318
}
319+
320+
async fn scheduling_lookahead(&self, hash: PHash) -> RelayChainResult<u32> {
321+
Ok(self.full_client.runtime_api().scheduling_lookahead(hash)?)
322+
}
319323
}
320324

321325
pub enum BlockCheckStatus {

cumulus/client/relay-chain-interface/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ pub trait RelayChainInterface: Send + Sync {
244244
&self,
245245
relay_parent: PHash,
246246
) -> RelayChainResult<BTreeMap<CoreIndex, VecDeque<ParaId>>>;
247+
248+
/// Fetch the scheduling lookahead value.
249+
async fn scheduling_lookahead(&self, relay_parent: PHash) -> RelayChainResult<u32>;
247250
}
248251

249252
#[async_trait]
@@ -398,6 +401,10 @@ where
398401
) -> RelayChainResult<BTreeMap<CoreIndex, VecDeque<ParaId>>> {
399402
(**self).claim_queue(relay_parent).await
400403
}
404+
405+
async fn scheduling_lookahead(&self, relay_parent: PHash) -> RelayChainResult<u32> {
406+
(**self).scheduling_lookahead(relay_parent).await
407+
}
401408
}
402409

403410
/// Helper function to call an arbitrary runtime API using a `RelayChainInterface` client.

cumulus/client/relay-chain-minimal-node/src/blockchain_rpc_client.rs

+4
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
464464
) -> Result<Option<Constraints>, ApiError> {
465465
Ok(self.rpc_client.parachain_host_backing_constraints(at, para_id).await?)
466466
}
467+
468+
async fn scheduling_lookahead(&self, at: Hash) -> Result<u32, sp_api::ApiError> {
469+
Ok(self.rpc_client.parachain_host_scheduling_lookahead(at).await?)
470+
}
467471
}
468472

469473
#[async_trait::async_trait]

cumulus/client/relay-chain-rpc-interface/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,8 @@ impl RelayChainInterface for RelayChainRpcInterface {
282282
> {
283283
self.rpc_client.parachain_host_claim_queue(relay_parent).await
284284
}
285+
286+
async fn scheduling_lookahead(&self, relay_parent: RelayHash) -> RelayChainResult<u32> {
287+
self.rpc_client.parachain_host_scheduling_lookahead(relay_parent).await
288+
}
285289
}

cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs

+8
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,14 @@ impl RelayChainRpcClient {
706706
.await
707707
}
708708

709+
pub async fn parachain_host_scheduling_lookahead(
710+
&self,
711+
at: RelayHash,
712+
) -> Result<u32, RelayChainError> {
713+
self.call_remote_runtime_function("ParachainHost_scheduling_lookahead", at, None::<()>)
714+
.await
715+
}
716+
709717
pub async fn validation_code_hash(
710718
&self,
711719
at: RelayHash,

cumulus/zombienet/tests/0008-elastic_authoring.toml

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
[settings]
22
timeout = 1000
33

4-
[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params]
5-
max_candidate_depth = 6
6-
allowed_ancestry_len = 3
7-
84
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
95
max_validators_per_core = 1
106
num_cores = 4

cumulus/zombienet/tests/0009-elastic_pov_recovery.toml

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ requests = { memory = "2G", cpu = "1" }
99
limits = { memory = "4G", cpu = "2" }
1010
requests = { memory = "2G", cpu = "1" }
1111

12-
[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params]
13-
max_candidate_depth = 6
14-
allowed_ancestry_len = 3
15-
1612
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
1713
max_validators_per_core = 1
1814
num_cores = 4

0 commit comments

Comments
 (0)