//! Upon new session, this pallet takes whatever assignation was in the PendingCollatorContainerChain
//! storage, and assigns it as the current CollatorContainerChain. In addition, it takes the next
//! queued set of parachains and collators and calculates the assignment for the next session, storing
//! The reason for the collator-assignment pallet to work with a one-session delay assignment is because
//! we want collators to know at least one session in advance the container chain/orchestrator that they
/// Should only be set on the last block of each session and should be killed on the on_initialize of the next block.
// which means even when we have some parathread cores empty we cannot schedule parachain there.
// TODO: parathreads should be treated a bit differently, they don't need to have the same amount of credits
// The order means priority: the first chain in the list will be the first one to get assigned collators.
// First all chains will be assigned `min_collators`, and then the first one will be assigned up to `max`,
// On sessions where there is no rotation, we try to keep all collators assigned to the same chains
fn get_all_collators_assigned_to_chains(for_session: ForSession) -> BTreeSet<T::AccountId> {
/// Only works on parachains because in relaychains it is not possible to know for sure if the next
/// block will be in the same session as the current one, as it depends on slots and validators can
/// Reads relay chain randomness in the last block of the session and stores it in pallet storage.
/// Relay randomness cannot be accessed in `on_initialize`, so `prepare_randomness` is executed in
/// Uses current block randomness. This randomness exists in `on_initialize` so we don't need to