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

deprecate AsyncBackingParams #7254

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1323f44
remove async backing params from:
alindima Jan 16, 2025
6fabe52
add collator support
alindima Jan 17, 2025
8d1592f
statement-distribution support
alindima Jan 17, 2025
89390f3
remove runtime helper
alindima Jan 17, 2025
da21202
fix in runtime
alindima Jan 20, 2025
d607fb4
fix warn
alindima Jan 20, 2025
1ddac49
nasty bugfix
alindima Jan 20, 2025
ec1249b
update testnet genesis values
alindima Jan 20, 2025
73bdce6
updatee zn tests
alindima Jan 20, 2025
1586c68
Merge remote-tracking branch 'origin/master' into alindima/remove-asy…
alindima Jan 20, 2025
785036f
fmt
alindima Jan 20, 2025
9f5abda
fix provisioner tests
alindima Jan 21, 2025
bb1a773
collator bugfix
alindima Jan 21, 2025
87dbad5
fix candidate-validation tests
alindima Jan 21, 2025
c5987d6
fix prospective-parachains tests
alindima Jan 22, 2025
63a6cc2
collator-side collator protocol: don't allow v1 protocol version
alindima Jan 22, 2025
0347d41
fix collator side
alindima Jan 23, 2025
32be29e
Merge remote-tracking branch 'origin/master' into alindima/remove-asy…
alindima Jan 23, 2025
9c10088
fix compilation
alindima Jan 23, 2025
6290188
fix collator protocol validator side tests
alindima Jan 23, 2025
fbeb5d9
replace unstable usage of repeat_n
alindima Jan 23, 2025
c997d65
fixes
alindima Jan 23, 2025
42a9c00
start fixing statement-distribution tests
alindima Jan 23, 2025
888dddc
Merge remote-tracking branch 'origin/master' into alindima/remove-asy…
alindima Jan 23, 2025
4fcbeb0
clippy
alindima Jan 24, 2025
5cdf6c5
Merge remote-tracking branch 'origin/master' into alindima/remove-asy…
alindima Jan 24, 2025
a8014e4
fix statement-distribution tests
alindima Jan 24, 2025
dfe8812
fix
alindima Jan 24, 2025
8debfe0
small fixes
alindima Jan 24, 2025
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
57 changes: 37 additions & 20 deletions cumulus/client/consensus/aura/src/collators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@

use crate::collator::SlotClaim;
use codec::Codec;
use cumulus_client_consensus_common::{
self as consensus_common, load_abridged_host_configuration, ParentSearchParams,
};
use cumulus_client_consensus_common::{self as consensus_common, ParentSearchParams};
use cumulus_primitives_aura::{AuraUnincludedSegmentApi, Slot};
use cumulus_primitives_core::{relay_chain::Hash as ParaHash, BlockT, ClaimQueueOffset};
use cumulus_relay_chain_interface::RelayChainInterface;
use polkadot_node_subsystem::messages::RuntimeApiRequest;
use polkadot_node_subsystem_util::runtime::ClaimQueueSnapshot;
use polkadot_primitives::{
AsyncBackingParams, CoreIndex, Hash as RelayHash, Id as ParaId, OccupiedCoreAssumption,
ValidationCodeHash,
CoreIndex, Hash as RelayHash, Id as ParaId, OccupiedCoreAssumption, ValidationCodeHash,
DEFAULT_SCHEDULING_LOOKAHEAD,
};
use sc_consensus_aura::{standalone as aura_internal, AuraApi};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_api::{ApiExt, ProvideRuntimeApi, RuntimeApiInfo};
use sp_core::Pair;
use sp_keystore::KeystorePtr;
use sp_timestamp::Timestamp;
Expand Down Expand Up @@ -101,26 +100,43 @@ async fn check_validation_code_or_log(
}
}

/// Reads async backing parameters from the relay chain storage at the given relay parent.
async fn async_backing_params(
/// Fetch scheduling lookahead at given relay parent.
async fn scheduling_lookahead(
relay_parent: RelayHash,
relay_client: &impl RelayChainInterface,
) -> Option<AsyncBackingParams> {
match load_abridged_host_configuration(relay_parent, relay_client).await {
Ok(Some(config)) => Some(config.async_backing_params),
Ok(None) => {
) -> Option<u32> {
let runtime_api_version = relay_client
.version(relay_parent)
.await
.map_err(|e| {
tracing::error!(
target: crate::LOG_TARGET,
"Active config is missing in relay chain storage",
);
None
},
target: super::LOG_TARGET,
error = ?e,
"Failed to fetch relay chain runtime version.",
)
})
.ok()?;

let parachain_host_runtime_api_version = runtime_api_version
.api_version(
&<dyn polkadot_primitives::runtime_api::ParachainHost<polkadot_primitives::Block>>::ID,
)
.unwrap_or_default();

if parachain_host_runtime_api_version <
RuntimeApiRequest::SCHEDULING_LOOKAHEAD_RUNTIME_REQUIREMENT
{
return None
}

match relay_client.scheduling_lookahead(relay_parent).await {
Ok(scheduling_lookahead) => Some(scheduling_lookahead),
Err(err) => {
tracing::error!(
target: crate::LOG_TARGET,
?err,
?relay_parent,
"Failed to read active config from relay chain client",
"Failed to fetch scheduling lookahead from relay chain",
);
None
},
Expand Down Expand Up @@ -216,9 +232,10 @@ where
let parent_search_params = ParentSearchParams {
relay_parent,
para_id,
ancestry_lookback: crate::collators::async_backing_params(relay_parent, relay_client)
ancestry_lookback: scheduling_lookahead(relay_parent, relay_client)
.await
.map_or(0, |params| params.allowed_ancestry_len as usize),
.unwrap_or(DEFAULT_SCHEDULING_LOOKAHEAD)
.saturating_sub(1) as usize,
max_depth: PARENT_SEARCH_DEPTH,
ignore_alternative_branches: true,
};
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/consensus/common/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ impl RelayChainInterface for Relaychain {
) -> RelayChainResult<Vec<u8>> {
unimplemented!("Not needed for test")
}

async fn scheduling_lookahead(&self, _: PHash) -> RelayChainResult<u32> {
unimplemented!("Not needed for test")
}
}

fn sproof_with_best_parent(client: &Client) -> RelayStateSproofBuilder {
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ impl RelayChainInterface for DummyRelayChainInterface {
) -> RelayChainResult<Vec<u8>> {
unimplemented!("Not needed for test")
}

async fn scheduling_lookahead(&self, _: PHash) -> RelayChainResult<u32> {
unimplemented!("Not needed for test")
}
}

fn make_validator_and_api() -> (
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/pov-recovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ impl RelayChainInterface for Relaychain {
) -> RelayChainResult<Vec<u8>> {
unimplemented!("Not needed for test")
}

async fn scheduling_lookahead(&self, _: PHash) -> RelayChainResult<u32> {
unimplemented!("Not needed for test")
}
}

fn make_candidate_chain(candidate_number_range: Range<u32>) -> Vec<CommittedCandidateReceipt> {
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ impl RelayChainInterface for RelayChainInProcessInterface {
) -> RelayChainResult<BTreeMap<CoreIndex, VecDeque<ParaId>>> {
Ok(self.full_client.runtime_api().claim_queue(hash)?)
}

async fn scheduling_lookahead(&self, hash: PHash) -> RelayChainResult<u32> {
Ok(self.full_client.runtime_api().scheduling_lookahead(hash)?)
}
}

pub enum BlockCheckStatus {
Expand Down
7 changes: 7 additions & 0 deletions cumulus/client/relay-chain-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ pub trait RelayChainInterface: Send + Sync {
&self,
relay_parent: PHash,
) -> RelayChainResult<BTreeMap<CoreIndex, VecDeque<ParaId>>>;

/// Fetch the scheduling lookahead value.
async fn scheduling_lookahead(&self, relay_parent: PHash) -> RelayChainResult<u32>;
}

#[async_trait]
Expand Down Expand Up @@ -398,6 +401,10 @@ where
) -> RelayChainResult<BTreeMap<CoreIndex, VecDeque<ParaId>>> {
(**self).claim_queue(relay_parent).await
}

async fn scheduling_lookahead(&self, relay_parent: PHash) -> RelayChainResult<u32> {
(**self).scheduling_lookahead(relay_parent).await
}
}

/// Helper function to call an arbitrary runtime API using a `RelayChainInterface` client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
) -> Result<Option<Constraints>, ApiError> {
Ok(self.rpc_client.parachain_host_backing_constraints(at, para_id).await?)
}

async fn scheduling_lookahead(&self, at: Hash) -> Result<u32, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_scheduling_lookahead(at).await?)
}
}

#[async_trait::async_trait]
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/relay-chain-rpc-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,8 @@ impl RelayChainInterface for RelayChainRpcInterface {
> {
self.rpc_client.parachain_host_claim_queue(relay_parent).await
}

async fn scheduling_lookahead(&self, relay_parent: RelayHash) -> RelayChainResult<u32> {
self.rpc_client.parachain_host_scheduling_lookahead(relay_parent).await
}
}
8 changes: 8 additions & 0 deletions cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,14 @@ impl RelayChainRpcClient {
.await
}

pub async fn parachain_host_scheduling_lookahead(
&self,
at: RelayHash,
) -> Result<u32, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_scheduling_lookahead", at, None::<()>)
.await
}

pub async fn validation_code_hash(
&self,
at: RelayHash,
Expand Down
4 changes: 0 additions & 4 deletions cumulus/zombienet/tests/0008-elastic_authoring.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[settings]
timeout = 1000

[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params]
max_candidate_depth = 6
allowed_ancestry_len = 3

[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
num_cores = 4
Expand Down
4 changes: 0 additions & 4 deletions cumulus/zombienet/tests/0009-elastic_pov_recovery.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ requests = { memory = "2G", cpu = "1" }
limits = { memory = "4G", cpu = "2" }
requests = { memory = "2G", cpu = "1" }

[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params]
max_candidate_depth = 6
allowed_ancestry_len = 3

[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
num_cores = 4
Expand Down
Loading
Loading