Unverified Commit 18de14db authored by ferrell-code's avatar ferrell-code Committed by GitHub
Browse files

Parachains scheduler.rs to FrameV2 (#3529)



* migration

* migrate runtimes

* storage visability

* Remove unused Call part

* Remove Call part import from parachain mock runtime

* Remove Call part import from test-runtime
Co-authored-by: Keith Yeung's avatarKeith Yeung <kungfukeith11@gmail.com>
parent d0ac4abb
Pipeline #150305 passed with stages
in 43 minutes and 31 seconds
......@@ -1477,7 +1477,7 @@ construct_runtime! {
ParasShared: parachains_shared::{Pallet, Call, Storage} = 52,
ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>} = 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,
......
......@@ -135,7 +135,7 @@ pub mod pallet {
let total_weight = configuration::Pallet::<T>::initializer_initialize(now) +
shared::Pallet::<T>::initializer_initialize(now) +
paras::Pallet::<T>::initializer_initialize(now) +
scheduler::Module::<T>::initializer_initialize(now) +
scheduler::Pallet::<T>::initializer_initialize(now) +
inclusion::Pallet::<T>::initializer_initialize(now) +
session_info::Pallet::<T>::initializer_initialize(now) +
T::DisputesHandler::initializer_initialize(now) +
......@@ -156,7 +156,7 @@ pub mod pallet {
T::DisputesHandler::initializer_finalize();
session_info::Pallet::<T>::initializer_finalize();
inclusion::Pallet::<T>::initializer_finalize();
scheduler::Module::<T>::initializer_finalize();
scheduler::Pallet::<T>::initializer_finalize();
paras::Pallet::<T>::initializer_finalize();
shared::Pallet::<T>::initializer_finalize();
configuration::Pallet::<T>::initializer_finalize();
......@@ -234,7 +234,7 @@ impl<T: Config> Pallet<T> {
};
let outgoing_paras = paras::Pallet::<T>::initializer_on_new_session(&notification);
scheduler::Module::<T>::initializer_on_new_session(&notification);
scheduler::Pallet::<T>::initializer_on_new_session(&notification);
inclusion::Pallet::<T>::initializer_on_new_session(&notification);
session_info::Pallet::<T>::initializer_on_new_session(&notification);
T::DisputesHandler::initializer_on_new_session(&notification);
......
......@@ -49,7 +49,7 @@ frame_support::construct_runtime!(
Configuration: configuration::{Pallet, Call, Storage, Config<T>},
ParasShared: shared::{Pallet, Call, Storage},
ParaInclusion: inclusion::{Pallet, Call, Storage, Event<T>},
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},
......
......@@ -148,11 +148,11 @@ decl_module! {
// Process new availability bitfields, yielding any availability cores whose
// work has now concluded.
let expected_bits = <scheduler::Module<T>>::availability_cores().len();
let expected_bits = <scheduler::Pallet<T>>::availability_cores().len();
let freed_concluded = <inclusion::Pallet<T>>::process_bitfields(
expected_bits,
signed_bitfields,
<scheduler::Module<T>>::core_para,
<scheduler::Pallet<T>>::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 = <scheduler::Module<T>>::availability_timeout_predicate();
let availability_pred = <scheduler::Pallet<T>>::availability_timeout_predicate();
let freed_timeout = if let Some(pred) = availability_pred {
<inclusion::Pallet<T>>::collect_pending(pred)
} else {
......@@ -177,8 +177,8 @@ decl_module! {
freed.sort_unstable_by_key(|pair| pair.0); // sort by core index
<scheduler::Module<T>>::clear();
<scheduler::Module<T>>::schedule(
<scheduler::Pallet<T>>::clear();
<scheduler::Pallet<T>>::schedule(
freed,
<frame_system::Pallet<T>>::block_number(),
);
......@@ -202,12 +202,12 @@ decl_module! {
let occupied = <inclusion::Pallet<T>>::process_candidates(
parent_storage_root,
backed_candidates,
<scheduler::Module<T>>::scheduled(),
<scheduler::Module<T>>::group_validators,
<scheduler::Pallet<T>>::scheduled(),
<scheduler::Pallet<T>>::group_validators,
)?;
// Note which of the scheduled cores were actually occupied by a backed candidate.
<scheduler::Module<T>>::occupied(&occupied);
<scheduler::Pallet<T>>::occupied(&occupied);
// Give some time slice to dispatch pending upward messages.
<ump::Pallet<T>>::process_pending_upward_messages();
......
......@@ -42,23 +42,23 @@ pub fn validator_groups<T: initializer::Config>() -> (
) {
let now = <frame_system::Pallet<T>>::block_number() + One::one();
let groups = <scheduler::Module<T>>::validator_groups();
let rotation_info = <scheduler::Module<T>>::group_rotation_info(now);
let groups = <scheduler::Pallet<T>>::validator_groups();
let rotation_info = <scheduler::Pallet<T>>::group_rotation_info(now);
(groups, rotation_info)
}
/// Implementation for the `availability_cores` function of the runtime API.
pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T::BlockNumber>> {
let cores = <scheduler::Module<T>>::availability_cores();
let cores = <scheduler::Pallet<T>>::availability_cores();
let parachains = <paras::Pallet<T>>::parachains();
let config = <configuration::Pallet<T>>::config();
let now = <frame_system::Pallet<T>>::block_number() + One::one();
<scheduler::Module<T>>::clear();
<scheduler::Module<T>>::schedule(Vec::new(), now);
<scheduler::Pallet<T>>::clear();
<scheduler::Pallet<T>>::schedule(Vec::new(), now);
let rotation_info = <scheduler::Module<T>>::group_rotation_info(now);
let rotation_info = <scheduler::Pallet<T>>::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<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
};
let group_responsible_for = |backed_in_number, core_index| {
match <scheduler::Module<T>>::group_assigned_to_core(core_index, backed_in_number) {
match <scheduler::Pallet<T>>::group_assigned_to_core(core_index, backed_in_number) {
Some(g) => g,
None => {
log::warn!(
......@@ -106,7 +106,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
let backed_in_number = pending_availability.backed_in_number().clone();
OccupiedCore {
next_up_on_available: <scheduler::Module<T>>::next_up_on_available(
next_up_on_available: <scheduler::Pallet<T>>::next_up_on_available(
CoreIndex(i as u32)
),
occupied_since: backed_in_number,
......@@ -114,7 +114,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
backed_in_number,
config.chain_availability_period,
),
next_up_on_time_out: <scheduler::Module<T>>::next_up_on_time_out(
next_up_on_time_out: <scheduler::Pallet<T>>::next_up_on_time_out(
CoreIndex(i as u32)
),
availability: pending_availability.availability_votes().clone(),
......@@ -134,7 +134,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
let backed_in_number = pending_availability.backed_in_number().clone();
OccupiedCore {
next_up_on_available: <scheduler::Module<T>>::next_up_on_available(
next_up_on_available: <scheduler::Pallet<T>>::next_up_on_available(
CoreIndex(i as u32)
),
occupied_since: backed_in_number,
......@@ -142,7 +142,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
backed_in_number,
config.thread_availability_period,
),
next_up_on_time_out: <scheduler::Module<T>>::next_up_on_time_out(
next_up_on_time_out: <scheduler::Pallet<T>>::next_up_on_time_out(
CoreIndex(i as u32)
),
availability: pending_availability.availability_votes().clone(),
......@@ -160,7 +160,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
}).collect();
// This will overwrite only `Free` cores if the scheduler module is working as intended.
for scheduled in <scheduler::Module<T>>::scheduled() {
for scheduled in <scheduler::Pallet<T>>::scheduled() {
core_states[scheduled.core.0 as usize] = CoreState::Scheduled(ScheduledCore {
para_id: scheduled.para_id,
collator: scheduled.required_collator().map(|c| c.clone()),
......
This diff is collapsed.
......@@ -93,8 +93,8 @@ impl<T: Config> Pallet<T> {
let assignment_keys = AssignmentKeysUnsafe::<T>::get();
let active_set = <shared::Pallet<T>>::active_validator_indices();
let validator_groups = <scheduler::Module<T>>::validator_groups();
let n_cores = <scheduler::Module<T>>::availability_cores().len() as u32;
let validator_groups = <scheduler::Pallet<T>>::validator_groups();
let n_cores = <scheduler::Pallet<T>>::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;
......
......@@ -226,7 +226,7 @@ construct_runtime! {
ParasShared: parachains_shared::{Pallet, Call, Storage},
ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>},
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},
......
......@@ -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},
ParaSessionInfo: parachains_session_info::{Pallet, Storage},
Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event<T>},
......
......@@ -1067,7 +1067,7 @@ construct_runtime! {
ParasShared: parachains_shared::{Pallet, Call, Storage} = 43,
ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>} = 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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment