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

elastic scaling: add core selector to cumulus #5372

Merged
merged 33 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c6c166d
expose claim queue on cumulus
alindima Aug 14, 2024
d7c595e
add hardcoded claim queue offset and switch to using the claim queue …
alindima Aug 14, 2024
bcae16d
continue
alindima Aug 15, 2024
7b3594a
logs
alindima Aug 15, 2024
94bf1df
add runtime API to westend/rococo system parachains
alindima Aug 16, 2024
12aea2a
use ClaimQueueSnapshot
alindima Aug 16, 2024
f1e2721
rollback changes to rococo-parachain
alindima Aug 16, 2024
f9268dd
add prdoc
alindima Aug 16, 2024
b825c22
fix prdoc
alindima Aug 16, 2024
7e2dc9a
fix compilation
alindima Aug 16, 2024
48d19b9
fix prdoc again
alindima Aug 16, 2024
6d0fbc1
Merge remote-tracking branch 'origin/master' into alindima/cumulus-op…
alindima Aug 16, 2024
e829934
prdoc
alindima Aug 19, 2024
e4478d1
bootstrap weights
alindima Aug 19, 2024
920982f
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Aug 20, 2024
ebf5e93
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Aug 20, 2024
e5c366c
Merge remote-tracking branch 'origin/master' into alindima/cumulus-op…
alindima Sep 13, 2024
8305048
fix compilation
alindima Sep 13, 2024
982ce7f
address some comments
alindima Sep 13, 2024
dec01b7
unused imports
alindima Sep 13, 2024
4c6fb64
make the core selection logic generic
alindima Sep 16, 2024
6ab29d9
fix compilation
alindima Sep 16, 2024
2c0c003
Merge remote-tracking branch 'origin/master' into alindima/cumulus-op…
alindima Sep 16, 2024
e8c7e96
fix compilation again
alindima Sep 16, 2024
a2c4d9b
fix compilation take 3
alindima Sep 17, 2024
67b17fa
rollback weight generation
alindima Sep 17, 2024
b568cf4
fix compilation take 4
alindima Sep 17, 2024
010f7b9
remove unused
alindima Sep 17, 2024
08cd77d
Merge remote-tracking branch 'origin/master' into alindima/cumulus-op…
alindima Sep 19, 2024
b6d1fb1
feedback and prdoc
alindima Sep 20, 2024
99ff6dd
Merge remote-tracking branch 'origin/master' into alindima/cumulus-op…
alindima Sep 20, 2024
46fcf45
update prdoc
alindima Sep 20, 2024
c268696
Merge branch 'master' into alindima/cumulus-open-collator-set
alindima Sep 23, 2024
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cumulus/client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ cumulus-client-collator = { workspace = true, default-features = true }
polkadot-primitives = { workspace = true, default-features = true }
polkadot-node-primitives = { workspace = true, default-features = true }
polkadot-node-subsystem = { workspace = true, default-features = true }
polkadot-node-subsystem-util = { workspace = true, default-features = true }
polkadot-overseer = { workspace = true, default-features = true }

[features]
Expand Down
4 changes: 3 additions & 1 deletion cumulus/client/consensus/aura/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterfa
use cumulus_client_consensus_common::{self as consensus_common, ParachainBlockImportMarker};
use cumulus_client_consensus_proposer::ProposerInterface;
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
use cumulus_primitives_core::{CollectCollationInfo, PersistedValidationData};
use cumulus_primitives_core::{ClaimQueueOffset, CollectCollationInfo, PersistedValidationData};
use cumulus_relay_chain_interface::RelayChainInterface;

use polkadot_node_primitives::{PoV, SubmitCollationParams};
Expand Down Expand Up @@ -260,6 +260,8 @@ where
relay_parent,
params.para_id,
&mut params.relay_client,
// Use depth 0, to preserve behaviour.
ClaimQueueOffset(0),
)
.await
.get(0)
Expand Down
48 changes: 16 additions & 32 deletions cumulus/client/consensus/aura/src/collators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ use cumulus_client_consensus_common::{
self as consensus_common, load_abridged_host_configuration, ParentSearchParams,
};
use cumulus_primitives_aura::{AuraUnincludedSegmentApi, Slot};
use cumulus_primitives_core::{relay_chain::Hash as ParaHash, BlockT};
use cumulus_primitives_core::{relay_chain::Hash as ParaHash, BlockT, ClaimQueueOffset};
use cumulus_relay_chain_interface::RelayChainInterface;
use polkadot_node_subsystem_util::runtime::ClaimQueueSnapshot;
use polkadot_primitives::{
AsyncBackingParams, CoreIndex, CoreState, Hash as RelayHash, Id as ParaId,
OccupiedCoreAssumption, ValidationCodeHash,
AsyncBackingParams, CoreIndex, Hash as RelayHash, Id as ParaId, OccupiedCoreAssumption,
ValidationCodeHash,
};
use sc_consensus_aura::{standalone as aura_internal, AuraApi};
use sp_api::ProvideRuntimeApi;
Expand Down Expand Up @@ -126,50 +127,33 @@ async fn async_backing_params(
}
}

// Return all the cores assigned to the para at the provided relay parent.
// Return all the cores assigned to the para at the provided relay parent, using the claim queue
// offset. This assumes the relay chain runtime supports the claimqueue runtime API.
alindima marked this conversation as resolved.
Show resolved Hide resolved
// Will return an empty vec if the provided offset is higher than the claim queue length (which
// corresponds to the scheduling_lookahead on the relay chain).
async fn cores_scheduled_for_para(
sandreim marked this conversation as resolved.
Show resolved Hide resolved
relay_parent: RelayHash,
para_id: ParaId,
relay_client: &impl RelayChainInterface,
claim_queue_offset: ClaimQueueOffset,
) -> Vec<CoreIndex> {
// Get `AvailabilityCores` from runtime
let cores = match relay_client.availability_cores(relay_parent).await {
Ok(cores) => cores,
// Get `ClaimQueue` from runtime
let claim_queue: ClaimQueueSnapshot = match relay_client.claim_queue(relay_parent).await {
Ok(claim_queue) => claim_queue.into(),
Err(error) => {
tracing::error!(
target: crate::LOG_TARGET,
?error,
?relay_parent,
"Failed to query availability cores runtime API",
"Failed to query claim queue runtime API",
);
return Vec::new()
},
};

let max_candidate_depth = async_backing_params(relay_parent, relay_client)
.await
.map(|c| c.max_candidate_depth)
.unwrap_or(0);

cores
.iter()
.enumerate()
.filter_map(|(index, core)| {
let core_para_id = match core {
CoreState::Scheduled(scheduled_core) => Some(scheduled_core.para_id),
CoreState::Occupied(occupied_core) if max_candidate_depth > 0 => occupied_core
.next_up_on_available
.as_ref()
.map(|scheduled_core| scheduled_core.para_id),
CoreState::Free | CoreState::Occupied(_) => None,
};

if core_para_id == Some(para_id) {
Some(CoreIndex(index as u32))
} else {
None
}
})
claim_queue
alindima marked this conversation as resolved.
Show resolved Hide resolved
.iter_claims_at_depth(claim_queue_offset.0 as usize)
.filter_map(|(core_index, core_para_id)| (core_para_id == para_id).then_some(core_index))
.collect()
}

Expand Down
Loading
Loading