diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 3d0ab1ebd099..f590c10549c7 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1477,7 +1477,7 @@ construct_runtime! { ParasShared: parachains_shared::{Pallet, Call, Storage} = 52, ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 53, ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 54, - ParasScheduler: parachains_scheduler::{Pallet, Call, Storage} = 55, + ParaScheduler: parachains_scheduler::{Pallet, Storage} = 55, Paras: parachains_paras::{Pallet, Call, Storage, Event, Config} = 56, Initializer: parachains_initializer::{Pallet, Call, Storage} = 57, Dmp: parachains_dmp::{Pallet, Call, Storage} = 58, diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index 312df0d55546..c90bcb8dfa4e 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -135,7 +135,7 @@ pub mod pallet { let total_weight = configuration::Pallet::::initializer_initialize(now) + shared::Pallet::::initializer_initialize(now) + paras::Pallet::::initializer_initialize(now) + - scheduler::Module::::initializer_initialize(now) + + scheduler::Pallet::::initializer_initialize(now) + inclusion::Pallet::::initializer_initialize(now) + session_info::Module::::initializer_initialize(now) + T::DisputesHandler::initializer_initialize(now) + @@ -156,7 +156,7 @@ pub mod pallet { T::DisputesHandler::initializer_finalize(); session_info::Module::::initializer_finalize(); inclusion::Pallet::::initializer_finalize(); - scheduler::Module::::initializer_finalize(); + scheduler::Pallet::::initializer_finalize(); paras::Pallet::::initializer_finalize(); shared::Pallet::::initializer_finalize(); configuration::Pallet::::initializer_finalize(); @@ -234,7 +234,7 @@ impl Pallet { }; let outgoing_paras = paras::Pallet::::initializer_on_new_session(¬ification); - scheduler::Module::::initializer_on_new_session(¬ification); + scheduler::Pallet::::initializer_on_new_session(¬ification); inclusion::Pallet::::initializer_on_new_session(¬ification); session_info::Module::::initializer_on_new_session(¬ification); T::DisputesHandler::initializer_on_new_session(¬ification); diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index d44c2e2b649f..1130d271c332 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -49,7 +49,7 @@ frame_support::construct_runtime!( Configuration: configuration::{Pallet, Call, Storage, Config}, ParasShared: shared::{Pallet, Call, Storage}, ParaInclusion: inclusion::{Pallet, Call, Storage, Event}, - Scheduler: scheduler::{Pallet, Call, Storage}, + Scheduler: scheduler::{Pallet, Storage}, Initializer: initializer::{Pallet, Call, Storage}, Dmp: dmp::{Pallet, Call, Storage}, Ump: ump::{Pallet, Call, Storage, Event}, diff --git a/runtime/parachains/src/paras_inherent.rs b/runtime/parachains/src/paras_inherent.rs index 6cee5d4ae7e4..d679035c4b4f 100644 --- a/runtime/parachains/src/paras_inherent.rs +++ b/runtime/parachains/src/paras_inherent.rs @@ -148,11 +148,11 @@ decl_module! { // Process new availability bitfields, yielding any availability cores whose // work has now concluded. - let expected_bits = >::availability_cores().len(); + let expected_bits = >::availability_cores().len(); let freed_concluded = >::process_bitfields( expected_bits, signed_bitfields, - >::core_para, + >::core_para, )?; // Inform the disputes module of all included candidates. @@ -162,7 +162,7 @@ decl_module! { } // Handle timeouts for any availability core work. - let availability_pred = >::availability_timeout_predicate(); + let availability_pred = >::availability_timeout_predicate(); let freed_timeout = if let Some(pred) = availability_pred { >::collect_pending(pred) } else { @@ -177,8 +177,8 @@ decl_module! { freed.sort_unstable_by_key(|pair| pair.0); // sort by core index - >::clear(); - >::schedule( + >::clear(); + >::schedule( freed, >::block_number(), ); @@ -202,12 +202,12 @@ decl_module! { let occupied = >::process_candidates( parent_storage_root, backed_candidates, - >::scheduled(), - >::group_validators, + >::scheduled(), + >::group_validators, )?; // Note which of the scheduled cores were actually occupied by a backed candidate. - >::occupied(&occupied); + >::occupied(&occupied); // Give some time slice to dispatch pending upward messages. >::process_pending_upward_messages(); diff --git a/runtime/parachains/src/runtime_api_impl/v1.rs b/runtime/parachains/src/runtime_api_impl/v1.rs index 7c61cbd7a79d..cce143254b3a 100644 --- a/runtime/parachains/src/runtime_api_impl/v1.rs +++ b/runtime/parachains/src/runtime_api_impl/v1.rs @@ -42,23 +42,23 @@ pub fn validator_groups() -> ( ) { let now = >::block_number() + One::one(); - let groups = >::validator_groups(); - let rotation_info = >::group_rotation_info(now); + let groups = >::validator_groups(); + let rotation_info = >::group_rotation_info(now); (groups, rotation_info) } /// Implementation for the `availability_cores` function of the runtime API. pub fn availability_cores() -> Vec> { - let cores = >::availability_cores(); + let cores = >::availability_cores(); let parachains = >::parachains(); let config = >::config(); let now = >::block_number() + One::one(); - >::clear(); - >::schedule(Vec::new(), now); + >::clear(); + >::schedule(Vec::new(), now); - let rotation_info = >::group_rotation_info(now); + let rotation_info = >::group_rotation_info(now); let time_out_at = |backed_in_number, availability_period| { let time_out_at = backed_in_number + availability_period; @@ -81,7 +81,7 @@ pub fn availability_cores() -> Vec>::group_assigned_to_core(core_index, backed_in_number) { + match >::group_assigned_to_core(core_index, backed_in_number) { Some(g) => g, None => { log::warn!( @@ -106,7 +106,7 @@ pub fn availability_cores() -> Vec>::next_up_on_available( + next_up_on_available: >::next_up_on_available( CoreIndex(i as u32) ), occupied_since: backed_in_number, @@ -114,7 +114,7 @@ pub fn availability_cores() -> Vec>::next_up_on_time_out( + next_up_on_time_out: >::next_up_on_time_out( CoreIndex(i as u32) ), availability: pending_availability.availability_votes().clone(), @@ -134,7 +134,7 @@ pub fn availability_cores() -> Vec>::next_up_on_available( + next_up_on_available: >::next_up_on_available( CoreIndex(i as u32) ), occupied_since: backed_in_number, @@ -142,7 +142,7 @@ pub fn availability_cores() -> Vec>::next_up_on_time_out( + next_up_on_time_out: >::next_up_on_time_out( CoreIndex(i as u32) ), availability: pending_availability.availability_votes().clone(), @@ -160,7 +160,7 @@ pub fn availability_cores() -> Vec>::scheduled() { + for scheduled in >::scheduled() { core_states[scheduled.core.0 as usize] = CoreState::Scheduled(ScheduledCore { para_id: scheduled.para_id, collator: scheduled.required_collator().map(|c| c.clone()), diff --git a/runtime/parachains/src/scheduler.rs b/runtime/parachains/src/scheduler.rs index 97a8cc7098b2..1ac5359c0548 100644 --- a/runtime/parachains/src/scheduler.rs +++ b/runtime/parachains/src/scheduler.rs @@ -41,15 +41,13 @@ use primitives::v1::{ Id as ParaId, ValidatorIndex, CoreOccupied, CoreIndex, CollatorId, GroupIndex, ParathreadClaim, ParathreadEntry, GroupRotationInfo, ScheduledCore, }; -use frame_support::{ - decl_storage, decl_module, decl_error, - weights::Weight, -}; -use parity_scale_codec::{Encode, Decode}; +use frame_support::pallet_prelude::*; use sp_runtime::traits::{One, Saturating}; use crate::{configuration, paras, initializer::SessionChangeNotification}; +pub use pallet::*; + /// A queued parathread entry, pre-assigned to a core. #[derive(Encode, Decode, Default)] #[cfg_attr(test, derive(PartialEq, Debug))] @@ -150,66 +148,77 @@ impl CoreAssignment { } } -pub trait Config: frame_system::Config + configuration::Config + paras::Config { } - -decl_storage! { - trait Store for Module as ParaScheduler { - /// All the validator groups. One for each core. Indices are into `ActiveValidators` - not the - /// broader set of Polkadot validators, but instead just the subset used for parachains during - /// this session. - /// - /// Bound: The number of cores is the sum of the numbers of parachains and parathread multiplexers. - /// Reasonably, 100-1000. The dominant factor is the number of validators: safe upper bound at 10k. - ValidatorGroups get(fn validator_groups): Vec>; - - /// A queue of upcoming claims and which core they should be mapped onto. - /// - /// The number of queued claims is bounded at the `scheduling_lookahead` - /// multiplied by the number of parathread multiplexer cores. Reasonably, 10 * 50 = 500. - ParathreadQueue: ParathreadClaimQueue; - /// One entry for each availability core. Entries are `None` if the core is not currently occupied. Can be - /// temporarily `Some` if scheduled but not occupied. - /// The i'th parachain belongs to the i'th core, with the remaining cores all being - /// parathread-multiplexers. - /// - /// Bounded by the maximum of either of these two values: - /// * The number of parachains and parathread multiplexers - /// * The number of validators divided by `configuration.max_validators_per_core`. - AvailabilityCores get(fn availability_cores): Vec>; - /// An index used to ensure that only one claim on a parathread exists in the queue or is - /// currently being handled by an occupied core. - /// - /// Bounded by the number of parathread cores and scheduling lookahead. Reasonably, 10 * 50 = 500. - ParathreadClaimIndex: Vec; - /// The block number where the session start occurred. Used to track how many group rotations have occurred. - /// - /// Note that in the context of parachains modules the session change is signaled during - /// the block and enacted at the end of the block (at the finalization stage, to be exact). - /// Thus for all intents and purposes the effect of the session change is observed at the - /// block following the session change, block number of which we save in this storage value. - SessionStartBlock get(fn session_start_block): T::BlockNumber; - /// Currently scheduled cores - free but up to be occupied. - /// - /// Bounded by the number of cores: one for each parachain and parathread multiplexer. - /// - /// The value contained here will not be valid after the end of a block. Runtime APIs should be used to determine scheduled cores/ - /// for the upcoming block. - Scheduled get(fn scheduled): Vec; // sorted ascending by CoreIndex. - } -} -decl_error! { - pub enum Error for Module { } -} +#[frame_support::pallet] +pub mod pallet { + use super::*; + + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config + configuration::Config + paras::Config {} + + /// All the validator groups. One for each core. Indices are into `ActiveValidators` - not the + /// broader set of Polkadot validators, but instead just the subset used for parachains during + /// this session. + /// + /// Bound: The number of cores is the sum of the numbers of parachains and parathread multiplexers. + /// Reasonably, 100-1000. The dominant factor is the number of validators: safe upper bound at 10k. + #[pallet::storage] + #[pallet::getter(fn validator_groups)] + pub(crate) type ValidatorGroups = StorageValue<_, Vec>, ValueQuery>; + + /// A queue of upcoming claims and which core they should be mapped onto. + /// + /// The number of queued claims is bounded at the `scheduling_lookahead` + /// multiplied by the number of parathread multiplexer cores. Reasonably, 10 * 50 = 500. + #[pallet::storage] + pub(crate) type ParathreadQueue = StorageValue<_, ParathreadClaimQueue, ValueQuery>; + + /// One entry for each availability core. Entries are `None` if the core is not currently occupied. Can be + /// temporarily `Some` if scheduled but not occupied. + /// The i'th parachain belongs to the i'th core, with the remaining cores all being + /// parathread-multiplexers. + /// + /// Bounded by the maximum of either of these two values: + /// * The number of parachains and parathread multiplexers + /// * The number of validators divided by `configuration.max_validators_per_core`. + #[pallet::storage] + #[pallet::getter(fn availability_cores)] + pub(crate) type AvailabilityCores = StorageValue<_, Vec>, ValueQuery>; + + /// An index used to ensure that only one claim on a parathread exists in the queue or is + /// currently being handled by an occupied core. + /// + /// Bounded by the number of parathread cores and scheduling lookahead. Reasonably, 10 * 50 = 500. + #[pallet::storage] + pub(crate) type ParathreadClaimIndex = StorageValue<_, Vec, ValueQuery>; + + /// The block number where the session start occurred. Used to track how many group rotations have occurred. + /// + /// Note that in the context of parachains modules the session change is signaled during + /// the block and enacted at the end of the block (at the finalization stage, to be exact). + /// Thus for all intents and purposes the effect of the session change is observed at the + /// block following the session change, block number of which we save in this storage value. + #[pallet::storage] + #[pallet::getter(fn session_start_block)] + pub(crate) type SessionStartBlock = StorageValue<_, T::BlockNumber, ValueQuery>; + + /// Currently scheduled cores - free but up to be occupied. + /// + /// Bounded by the number of cores: one for each parachain and parathread multiplexer. + /// + /// The value contained here will not be valid after the end of a block. Runtime APIs should be used to determine scheduled cores/ + /// for the upcoming block. + #[pallet::storage] + #[pallet::getter(fn scheduled)] + pub(crate) type Scheduled = StorageValue<_, Vec, ValueQuery>; // sorted ascending by CoreIndex. -decl_module! { - /// The scheduler module. - pub struct Module for enum Call where origin: ::Origin { - type Error = Error; - } } -impl Module { +impl Pallet { /// Called by the initializer to initialize the scheduler module. pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { 0 @@ -227,7 +236,7 @@ impl Module { } = notification; let config = new_config; - let mut thread_queue = ParathreadQueue::get(); + let mut thread_queue = ParathreadQueue::::get(); let n_parachains = >::parachains().len() as u32; let n_cores = core::cmp::max( n_parachains + config.parathread_cores, @@ -237,7 +246,7 @@ impl Module { }, ); - AvailabilityCores::mutate(|cores| { + AvailabilityCores::::mutate(|cores| { // clear all occupied cores. for maybe_occupied in cores.iter_mut() { if let Some(CoreOccupied::Parathread(claim)) = maybe_occupied.take() { @@ -255,7 +264,7 @@ impl Module { // shuffle validators into groups. if n_cores == 0 || validators.is_empty() { - ValidatorGroups::set(Vec::new()); + ValidatorGroups::::set(Vec::new()); } else { let group_base_size = validators.len() / n_cores as usize; let n_larger_groups = validators.len() % n_cores as usize; @@ -278,12 +287,12 @@ impl Module { ); } - ValidatorGroups::set(groups); + ValidatorGroups::::set(groups); } // prune out all parathread claims with too many retries. // assign all non-pruned claims to new cores, if they've changed. - ParathreadClaimIndex::mutate(|claim_index| { + ParathreadClaimIndex::::mutate(|claim_index| { // wipe all parathread metadata if no parathread cores are configured. if config.parathread_cores == 0 { thread_queue = ParathreadClaimQueue { @@ -321,7 +330,7 @@ impl Module { ((thread_queue.queue.len()) as u32) % config.parathread_cores; } }); - ParathreadQueue::set(thread_queue); + ParathreadQueue::::set(thread_queue); let now = >::block_number() + One::one(); >::set(now); @@ -338,12 +347,12 @@ impl Module { let config = >::config(); let queue_max_size = config.parathread_cores * config.scheduling_lookahead; - ParathreadQueue::mutate(|queue| { + ParathreadQueue::::mutate(|queue| { if queue.queue.len() >= queue_max_size as usize { return } let para_id = claim.0; - let competes_with_another = ParathreadClaimIndex::mutate(|index| { + let competes_with_another = ParathreadClaimIndex::::mutate(|index| { match index.binary_search(¶_id) { Ok(_) => true, Err(i) => { @@ -367,7 +376,7 @@ impl Module { just_freed_cores: impl IntoIterator, now: T::BlockNumber, ) { - let mut cores = AvailabilityCores::get(); + let mut cores = AvailabilityCores::::get(); let config = >::config(); for (freed_index, freed_reason) in just_freed_cores { @@ -380,7 +389,7 @@ impl Module { FreedReason::Concluded => { // After a parathread candidate has successfully been included, // open it up for further claims! - ParathreadClaimIndex::mutate(|index| { + ParathreadClaimIndex::::mutate(|index| { if let Ok(i) = index.binary_search(&entry.claim.0) { index.remove(i); } @@ -389,7 +398,7 @@ impl Module { FreedReason::TimedOut => { // If a parathread candidate times out, it's not the collator's fault, // so we don't increment retries. - ParathreadQueue::mutate(|queue| { + ParathreadQueue::::mutate(|queue| { queue.enqueue_entry(entry, config.parathread_cores); }) } @@ -400,10 +409,10 @@ impl Module { } let parachains = >::parachains(); - let mut scheduled = Scheduled::get(); - let mut parathread_queue = ParathreadQueue::get(); + let mut scheduled = Scheduled::::get(); + let mut parathread_queue = ParathreadQueue::::get(); - if ValidatorGroups::get().is_empty() { return } + if ValidatorGroups::::get().is_empty() { return } { let mut prev_scheduled_in_order = scheduled.iter().enumerate().peekable(); @@ -491,9 +500,9 @@ impl Module { // insertions. } - Scheduled::set(scheduled); - ParathreadQueue::set(parathread_queue); - AvailabilityCores::set(cores); + Scheduled::::set(scheduled); + ParathreadQueue::::set(parathread_queue); + AvailabilityCores::::set(cores); } /// Note that the given cores have become occupied. Behavior undefined if any of the given cores were not scheduled @@ -504,8 +513,8 @@ impl Module { pub(crate) fn occupied(now_occupied: &[CoreIndex]) { if now_occupied.is_empty() { return } - let mut availability_cores = AvailabilityCores::get(); - Scheduled::mutate(|scheduled| { + let mut availability_cores = AvailabilityCores::::get(); + Scheduled::::mutate(|scheduled| { // The constraints on the function require that now_occupied is a sorted subset of the // `scheduled` cores, which are also sorted. @@ -527,13 +536,13 @@ impl Module { }) }); - AvailabilityCores::set(availability_cores); + AvailabilityCores::::set(availability_cores); } /// Get the para (chain or thread) ID assigned to a particular core or index, if any. Core indices /// out of bounds will return `None`, as will indices of unassigned cores. pub(crate) fn core_para(core_index: CoreIndex) -> Option { - let cores = AvailabilityCores::get(); + let cores = AvailabilityCores::::get(); match cores.get(core_index.0 as usize).and_then(|c| c.as_ref()) { None => None, Some(CoreOccupied::Parachain) => { @@ -546,7 +555,7 @@ impl Module { /// Get the validators in the given group, if the group index is valid for this session. pub(crate) fn group_validators(group_index: GroupIndex) -> Option> { - ValidatorGroups::get().get(group_index.0 as usize).map(|g| g.clone()) + ValidatorGroups::::get().get(group_index.0 as usize).map(|g| g.clone()) } /// Get the group assigned to a specific core by index at the current block number. Result undefined if the core index is unknown @@ -557,7 +566,7 @@ impl Module { if at < session_start_block { return None } - let validator_groups = ValidatorGroups::get(); + let validator_groups = ValidatorGroups::::get(); if core.0 as usize >= validator_groups.len() { return None } @@ -599,7 +608,7 @@ impl Module { config.thread_availability_period, ); - let availability_cores = AvailabilityCores::get(); + let availability_cores = AvailabilityCores::::get(); if blocks_since_last_rotation >= absolute_cutoff { None @@ -654,7 +663,7 @@ impl Module { collator: None, }) } else { - let queue = ParathreadQueue::get(); + let queue = ParathreadQueue::::get(); let core_offset = (core.0 as usize - parachains.len()) as u32; queue.get_next_on_core(core_offset).map(|entry| ScheduledCore { para_id: entry.claim.0, @@ -678,7 +687,7 @@ impl Module { collator: None, }) } else { - let queue = ParathreadQueue::get(); + let queue = ParathreadQueue::::get(); // This is the next scheduled para on this core. let core_offset = (core.0 as usize - parachains.len()) as u32; @@ -690,7 +699,7 @@ impl Module { .or_else(|| { // Or, if none, the claim currently occupying the core, // as it would be put back on the queue after timing out. - let cores = AvailabilityCores::get(); + let cores = AvailabilityCores::::get(); cores.get(core.0 as usize).and_then(|c| c.as_ref()).and_then(|o| { match o { CoreOccupied::Parathread(entry) => { @@ -708,9 +717,10 @@ impl Module { // Free all scheduled cores and return parathread claims to queue, with retries incremented. pub(crate) fn clear() { + let config = >::config(); - ParathreadQueue::mutate(|queue| { - for core_assignment in Scheduled::take() { + ParathreadQueue::::mutate(|queue| { + for core_assignment in Scheduled::::take() { if let AssignmentKind::Parathread(collator, retries) = core_assignment.kind { if !>::is_parathread(core_assignment.para_id) { continue } @@ -734,13 +744,10 @@ mod tests { use super::*; use primitives::v1::{BlockNumber, ValidatorId, CollatorId, SessionIndex}; - use frame_support::{ - assert_ok, - traits::{OnFinalize, OnInitialize}, - }; + use frame_support::assert_ok; use keyring::Sr25519Keyring; - use crate::mock::{new_test_ext, Configuration, Paras, ParasShared, System, Scheduler, MockGenesisConfig}; + use crate::mock::{new_test_ext, Configuration, Paras, ParasShared, System, Scheduler, MockGenesisConfig, Test}; use crate::initializer::SessionChangeNotification; use crate::configuration::HostConfiguration; use crate::paras::ParaGenesisArgs; @@ -840,7 +847,7 @@ mod tests { { Scheduler::add_parathread_claim(ParathreadClaim(thread_id, collator.clone())); - let queue = ParathreadQueue::get(); + let queue = ParathreadQueue::::get(); assert_eq!(queue.next_core_offset, 1); assert_eq!(queue.queue.len(), 1); assert_eq!(queue.queue[0], QueuedParathread { @@ -856,7 +863,7 @@ mod tests { { let collator2 = CollatorId::from(Sr25519Keyring::Bob.public()); Scheduler::add_parathread_claim(ParathreadClaim(thread_id, collator2.clone())); - let queue = ParathreadQueue::get(); + let queue = ParathreadQueue::::get(); assert_eq!(queue.next_core_offset, 1); assert_eq!(queue.queue.len(), 1); assert_eq!(queue.queue[0], QueuedParathread { @@ -872,7 +879,7 @@ mod tests { { let thread_id2 = ParaId::from(11); Scheduler::add_parathread_claim(ParathreadClaim(thread_id2, collator.clone())); - let queue = ParathreadQueue::get(); + let queue = ParathreadQueue::::get(); assert_eq!(queue.next_core_offset, 1); assert_eq!(queue.queue.len(), 1); assert_eq!(queue.queue[0], QueuedParathread { @@ -914,7 +921,7 @@ mod tests { assert!(Paras::is_parathread(thread_id)); Scheduler::add_parathread_claim(ParathreadClaim(thread_id, collator.clone())); - assert_eq!(ParathreadQueue::get(), Default::default()); + assert_eq!(ParathreadQueue::::get(), Default::default()); }); } @@ -947,7 +954,7 @@ mod tests { } // set up a queue as if n_cores was 4 and with some with many retries. - ParathreadQueue::put({ + ParathreadQueue::::put({ let mut queue = ParathreadClaimQueue::default(); // Will be pruned: too many retries. @@ -977,7 +984,7 @@ mod tests { queue }); - ParathreadClaimIndex::put(vec![thread_a, thread_b, thread_c, thread_d]); + ParathreadClaimIndex::::put(vec![thread_a, thread_b, thread_c, thread_d]); run_to_block( 10, @@ -991,7 +998,7 @@ mod tests { ); assert_eq!(Configuration::config(), default_config()); - let queue = ParathreadQueue::get(); + let queue = ParathreadQueue::::get(); assert_eq!( queue.queue, vec![ @@ -1013,7 +1020,7 @@ mod tests { ); assert_eq!(queue.next_core_offset, 2); - assert_eq!(ParathreadClaimIndex::get(), vec![thread_b, thread_c]); + assert_eq!(ParathreadClaimIndex::::get(), vec![thread_b, thread_c]); }) } @@ -1055,7 +1062,7 @@ mod tests { _ => None, }); - let groups = ValidatorGroups::get(); + let groups = ValidatorGroups::::get(); assert_eq!(groups.len(), 5); // first two groups have the overflow. @@ -1115,7 +1122,7 @@ mod tests { _ => None, }); - let groups = ValidatorGroups::get(); + let groups = ValidatorGroups::::get(); assert_eq!(groups.len(), 7); // Every validator gets its own group, even though there are 2 paras. @@ -1295,7 +1302,7 @@ mod tests { Scheduler::occupied(&[CoreIndex(0), CoreIndex(1), CoreIndex(2), CoreIndex(3)]); { - let cores = AvailabilityCores::get(); + let cores = AvailabilityCores::::get(); assert!(cores[0].is_some()); assert!(cores[1].is_some()); @@ -1371,8 +1378,8 @@ mod tests { // the prior claim on thread A concluded, but the claim on thread C was marked as // timed out. - let index = ParathreadClaimIndex::get(); - let parathread_queue = ParathreadQueue::get(); + let index = ParathreadClaimIndex::::get(); + let parathread_queue = ParathreadQueue::::get(); // thread A claim should have been wiped, but thread C claim should remain. assert_eq!(index, vec![thread_b, thread_c, thread_d, thread_e]); @@ -1436,7 +1443,7 @@ mod tests { Scheduler::occupied(&[CoreIndex(0), CoreIndex(1), CoreIndex(2)]); { - let cores = AvailabilityCores::get(); + let cores = AvailabilityCores::::get(); assert!(cores[0].is_some()); assert!(cores[1].is_some()); @@ -1474,7 +1481,7 @@ mod tests { }); // The freed cores should be `None` in `AvailabilityCores`. - let cores = AvailabilityCores::get(); + let cores = AvailabilityCores::::get(); assert!(cores[0].is_none()); assert!(cores[2].is_none()); } @@ -1661,7 +1668,7 @@ mod tests { // assign some availability cores. { - AvailabilityCores::mutate(|cores| { + AvailabilityCores::::mutate(|cores| { cores[0] = Some(CoreOccupied::Parachain); cores[1] = Some(CoreOccupied::Parathread(ParathreadEntry { claim: ParathreadClaim(thread_a, collator), @@ -1681,7 +1688,7 @@ mod tests { let now = System::block_number(); let would_be_timed_out = now - thread_availability_period; - for i in 0..AvailabilityCores::get().len() { + for i in 0..AvailabilityCores::::get().len() { // returns true for unoccupied cores. // And can time out both threads and chains at this stage. assert!(pred(CoreIndex(i as u32), would_be_timed_out)); @@ -1776,7 +1783,7 @@ mod tests { Scheduler::add_parathread_claim(thread_claim_b); - let queue = ParathreadQueue::get(); + let queue = ParathreadQueue::::get(); assert_eq!( queue.get_next_on_core(0).unwrap().claim, ParathreadClaim(thread_b, collator.clone()), @@ -1847,7 +1854,7 @@ mod tests { _ => panic!("with no chains, only core should be a thread core"), } - let queue = ParathreadQueue::get(); + let queue = ParathreadQueue::::get(); assert!(queue.get_next_on_core(0).is_none()); assert_eq!( Scheduler::next_up_on_time_out(CoreIndex(0)).unwrap(), @@ -1859,7 +1866,7 @@ mod tests { Scheduler::add_parathread_claim(thread_claim_b); - let queue = ParathreadQueue::get(); + let queue = ParathreadQueue::::get(); assert_eq!( queue.get_next_on_core(0).unwrap().claim, ParathreadClaim(thread_b, collator.clone()), @@ -2031,7 +2038,7 @@ mod tests { assert_eq!(Scheduler::scheduled().len(), 2); - let groups = ValidatorGroups::get(); + let groups = ValidatorGroups::::get(); assert_eq!(groups.len(), 5); assert_ok!(Paras::schedule_para_cleanup(chain_b)); diff --git a/runtime/parachains/src/session_info.rs b/runtime/parachains/src/session_info.rs index 49627c1e67a1..760e342f9f54 100644 --- a/runtime/parachains/src/session_info.rs +++ b/runtime/parachains/src/session_info.rs @@ -91,8 +91,8 @@ impl Module { let assignment_keys = AssignmentKeysUnsafe::get(); let active_set = >::active_validator_indices(); - let validator_groups = >::validator_groups(); - let n_cores = >::availability_cores().len() as u32; + let validator_groups = >::validator_groups(); + let n_cores = >::availability_cores().len() as u32; let zeroth_delay_tranche_width = config.zeroth_delay_tranche_width; let relay_vrf_modulo_samples = config.relay_vrf_modulo_samples; let n_delay_tranches = config.n_delay_tranches; diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 790248daf644..93085f946ed4 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -226,7 +226,7 @@ construct_runtime! { ParasShared: parachains_shared::{Pallet, Call, Storage}, ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event}, ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent}, - Scheduler: parachains_scheduler::{Pallet, Call, Storage}, + ParaScheduler: parachains_scheduler::{Pallet, Storage}, Paras: parachains_paras::{Pallet, Call, Storage, Event, Config}, Initializer: parachains_initializer::{Pallet, Call, Storage}, Dmp: parachains_dmp::{Pallet, Call, Storage}, diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 78d6e821e281..bc9b7a727575 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -541,7 +541,7 @@ construct_runtime! { Initializer: parachains_initializer::{Pallet, Call, Storage}, Paras: parachains_paras::{Pallet, Call, Storage, Origin, Event}, ParasShared: parachains_shared::{Pallet, Call, Storage}, - Scheduler: parachains_scheduler::{Pallet, Call, Storage}, + Scheduler: parachains_scheduler::{Pallet, Storage}, ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call}, SessionInfo: parachains_session_info::{Pallet, Call, Storage}, Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event}, diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index cdc849a10429..3bf2283e2f17 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1067,7 +1067,7 @@ construct_runtime! { ParasShared: parachains_shared::{Pallet, Call, Storage} = 43, ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event} = 44, ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 45, - ParasScheduler: parachains_scheduler::{Pallet, Call, Storage} = 46, + ParaScheduler: parachains_scheduler::{Pallet, Storage} = 46, Paras: parachains_paras::{Pallet, Call, Storage, Event, Config} = 47, Initializer: parachains_initializer::{Pallet, Call, Storage} = 48, Dmp: parachains_dmp::{Pallet, Call, Storage} = 49,