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

collation-generation + collator-protocol: collate on multiple assigned cores #3795

Merged
merged 31 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8f5d259
DistributeCollation includes CoreIndex
sandreim Mar 19, 2024
dc84796
SubmitCollationParams includes CoreIndex
sandreim Mar 19, 2024
665ef06
collator-protocol updates
sandreim Mar 19, 2024
78ee8b2
collation-generation pull support for chained collations
sandreim Mar 19, 2024
a61d64a
adjust validator buffer capacity for elastic scaling
sandreim Mar 20, 2024
1cbb090
fmt
sandreim Mar 20, 2024
493a7a2
Per core index tracking of multiple collations
sandreim Mar 20, 2024
8497413
fix tests
sandreim Mar 20, 2024
0dbc63a
enable collator-protocol elastic scaling extension for adder colaltor
sandreim Mar 22, 2024
3906d34
Use backing state to get candidates pending availability
sandreim Mar 22, 2024
eb7d842
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Mar 22, 2024
d344a2d
use ok_or
sandreim Mar 22, 2024
16e1cb4
subsystem-util request_para_backing_state
sandreim Mar 22, 2024
91f9c40
Use the exposed claim queue
sandreim Mar 22, 2024
154f3dd
refactor
sandreim Mar 22, 2024
60ec79f
remove type annotation
sandreim Mar 22, 2024
a6c4afe
remove more merge damage
sandreim Mar 22, 2024
62c13dc
make tests compile
sandreim Mar 22, 2024
ddf057e
happy clippy is good clippy
sandreim Mar 22, 2024
13b149f
lookahead use core_index in SubmitCollationParams
sandreim Mar 25, 2024
64a53f4
taplo fix
sandreim Mar 25, 2024
732440b
enable elastic scaling in undying collator (also enables in zombienet…
sandreim Mar 25, 2024
f80897d
Collation generation test fixes and new tests
sandreim Mar 25, 2024
7d8e6b5
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Mar 25, 2024
83af4e1
bring test-runtime up to date
sandreim Mar 25, 2024
9721b69
review feedback
sandreim Mar 25, 2024
4eb804e
await await
sandreim Mar 25, 2024
8b70bc2
review feedback
sandreim Mar 27, 2024
16607dd
prdoc
sandreim Mar 27, 2024
ba80669
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Mar 27, 2024
69a63cc
nice new syntax
sandreim Mar 27, 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
39 changes: 28 additions & 11 deletions cumulus/client/consensus/aura/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use polkadot_node_subsystem::messages::{
CollationGenerationMessage, RuntimeApiMessage, RuntimeApiRequest,
};
use polkadot_overseer::Handle as OverseerHandle;
use polkadot_primitives::{CollatorPair, Id as ParaId, OccupiedCoreAssumption};
use polkadot_primitives::{CollatorPair, CoreIndex, Id as ParaId, OccupiedCoreAssumption};

use futures::{channel::oneshot, prelude::*};
use sc_client_api::{backend::AuxStore, BlockBackend, BlockOf};
Expand Down Expand Up @@ -184,7 +184,15 @@ where
while let Some(relay_parent_header) = import_notifications.next().await {
let relay_parent = relay_parent_header.hash();

if !is_para_scheduled(relay_parent, params.para_id, &mut params.overseer_handle).await {
// TODO: Currently we use just the first core here, but for elastic scaling
sandreim marked this conversation as resolved.
Show resolved Hide resolved
// we iterate and build on all of the cores returned.
let core_index = if let Some(core_index) =
cores_scheduled_for_para(relay_parent, params.para_id, &mut params.overseer_handle)
.await
.get(0)
{
*core_index
} else {
tracing::trace!(
target: crate::LOG_TARGET,
?relay_parent,
Expand All @@ -193,7 +201,7 @@ where
);

continue
}
};

let max_pov_size = match params
.relay_client
Expand Down Expand Up @@ -396,6 +404,7 @@ where
parent_head: parent_header.encode().into(),
validation_code_hash,
result_sender: None,
core_index,
},
),
"SubmitCollation",
Expand Down Expand Up @@ -480,14 +489,12 @@ async fn max_ancestry_lookback(
}
}

// Checks if there exists a scheduled core for the para at the provided relay parent.
//
// Falls back to `false` in case of an error.
async fn is_para_scheduled(
// Return all the cores assigned to the para at the provided relay parent.
async fn cores_scheduled_for_para(
relay_parent: PHash,
para_id: ParaId,
overseer_handle: &mut OverseerHandle,
) -> bool {
) -> Vec<CoreIndex> {
let (tx, rx) = oneshot::channel();
let request = RuntimeApiRequest::AvailabilityCores(tx);
overseer_handle
Expand All @@ -503,17 +510,27 @@ async fn is_para_scheduled(
?relay_parent,
"Failed to query availability cores runtime API",
);
return false
return Vec::new()
},
Err(oneshot::Canceled) => {
tracing::error!(
target: crate::LOG_TARGET,
?relay_parent,
"Sender for availability cores runtime request dropped",
);
return false
return Vec::new()
},
};

cores.iter().any(|core| core.para_id() == Some(para_id))
cores
.iter()
.enumerate()
.filter_map(|(index, core)| {
if core.para_id() == Some(para_id) {
Some(CoreIndex(index as u32))
} else {
None
}
})
.collect()
}
2 changes: 2 additions & 0 deletions polkadot/node/collation-generation/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub enum Error {
Util(#[from] polkadot_node_subsystem_util::Error),
#[error(transparent)]
Erasure(#[from] polkadot_erasure_coding::Error),
#[error("Parachain backing state not available in runtime.")]
MissingParaBackingState,
}

pub type Result<T> = std::result::Result<T, Error>;
Loading
Loading