mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Scheduler Module (#1162)
* scheduler module skeleton * update scheduler skeleton to match latest version of guide * better session change notification * add mock randomness and fix test compilation * shuffle validators into groups * finish implementing session change logic for scheduler * tweak core assignment type to track retries of parathread * reframe queued parathread core as offset * implement initialzation and finalization routines * implement parathread claim queuing * implement core_para * implement the group_validators routine and fix errors * add a reason for freeing cores * implement `schedule` function * add some docs to the scheduled function * implement `occupied` helper * implement availability predicate * fix some warnings * integrate scheduler into initializer * integrate scheduler into mock module * avoid conflict with Substrate's scheduler storage * add parathreads index to paras module * implement parathreads map in paras module * add is_parathread to paras * test adding parathread claim * test that you cannot add claims when no parathread cores exist * check session change parathread queue pruning * test validator shuffling * add allow_unused to scheduler items * add test for scheduling * add some more tests for scheduling logic * test core rotation * check parathread claim pruning after retries * add bound notes * Apply suggestions from code review Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Bernhard Schuster <bernhard@ahoi.io> * more suggestions from review * test availability predicate, add box to please compiler * add changes to guide Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com> Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
This commit is contained in:
committed by
GitHub
parent
053bfc2d0c
commit
04c8603042
@@ -30,7 +30,7 @@ use primitives::{
|
||||
};
|
||||
use frame_support::{
|
||||
impl_outer_origin, impl_outer_dispatch, parameter_types,
|
||||
weights::Weight,
|
||||
weights::Weight, traits::Randomness as RandomnessT,
|
||||
};
|
||||
|
||||
/// A test runtime struct.
|
||||
@@ -47,6 +47,14 @@ impl_outer_dispatch! {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TestRandomness;
|
||||
|
||||
impl RandomnessT<H256> for TestRandomness {
|
||||
fn random(_subject: &[u8]) -> H256 {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u32 = 250;
|
||||
pub const MaximumBlockWeight: Weight = 4 * 1024 * 1024;
|
||||
@@ -80,12 +88,16 @@ impl system::Trait for Test {
|
||||
type OnKilledAccount = ();
|
||||
}
|
||||
|
||||
impl crate::initializer::Trait for Test { }
|
||||
impl crate::initializer::Trait for Test {
|
||||
type Randomness = TestRandomness;
|
||||
}
|
||||
|
||||
impl crate::configuration::Trait for Test { }
|
||||
|
||||
impl crate::paras::Trait for Test { }
|
||||
|
||||
impl crate::scheduler::Trait for Test { }
|
||||
|
||||
pub type System = system::Module<Test>;
|
||||
|
||||
/// Mocked initializer.
|
||||
@@ -97,6 +109,9 @@ pub type Configuration = crate::configuration::Module<Test>;
|
||||
/// Mocked paras.
|
||||
pub type Paras = crate::paras::Module<Test>;
|
||||
|
||||
/// Mocked scheduler.
|
||||
pub type Scheduler = crate::scheduler::Module<Test>;
|
||||
|
||||
/// Create a new set of test externalities.
|
||||
pub fn new_test_ext(state: GenesisConfig) -> TestExternalities {
|
||||
let mut t = state.system.build_storage::<Test>().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user