Skip to content

Commit

Permalink
feedback: Add more descriptive comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthDesai committed Sep 6, 2024
1 parent fc5f31b commit 734c1b7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pallets/collator-assignment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,11 @@ pub mod pallet {
collators_per_parathread: u32,
) -> (Vec<ChainNumCollators>, bool) {
let core_count = core_allocation_configuration.core_count;
let ideal_number_of_bulk_paras = core_allocation_configuration
let max_number_of_bulk_paras = core_allocation_configuration
.max_parachain_percentage
.mul(core_count);

let enough_cores_for_bulk_paras =
bulk_paras.len() <= ideal_number_of_bulk_paras as usize;
let enough_cores_for_bulk_paras = bulk_paras.len() <= max_number_of_bulk_paras as usize;

// Currently, we are sorting both bulk and pool paras by tip, even when for example
// only number of bulk paras are restricted due to core availability since we deduct tip from
Expand All @@ -205,9 +204,9 @@ pub mod pallet {
});
}

bulk_paras.truncate(ideal_number_of_bulk_paras as usize);
bulk_paras.truncate(max_number_of_bulk_paras as usize);
// We are not truncating pool paras, since their workload is not continuous one core
// can be shared by many parachain during the session.
// can be shared by many paras during the session.

let (ordered_chains, sorted_chains_based_on_tip) = Self::order_paras(
bulk_paras,
Expand All @@ -219,6 +218,8 @@ pub mod pallet {
);

// We should charge tip if either this method or the order_para method has sorted chains based on tip
// So in other words: if parachain demand exceeds the `max_number_of_bulk_paras` OR
// if `num_collators` is not enough to satisfy collation need of all paras.
(
ordered_chains,
sorted_chains_based_on_tip || !enough_cores_for_bulk_paras,
Expand Down

0 comments on commit 734c1b7

Please sign in to comment.