Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

initializer for addition genesis config #1256

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions runtime/parachains/src/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
//!
//! This module can throw fatal errors if session-change notifications are received after initialization.

use sp_std::prelude::*;
use frame_support::weights::Weight;
use primitives::{
parachain::{ValidatorId},
};
use frame_support::{
decl_storage, decl_module, decl_error, traits::Randomness,
use crate::{
configuration::{self, HostConfiguration},
paras, scheduler,
};
use crate::{configuration::{self, HostConfiguration}, paras, scheduler};
use frame_support::weights::Weight;
use frame_support::{decl_error, decl_module, decl_storage, traits::Randomness};
use primitives::parachain::ValidatorId;
use sp_std::prelude::*;

/// Information about a session change that has just occurred.
#[derive(Default, Clone)]
Expand Down Expand Up @@ -105,7 +104,8 @@ impl<T: Trait> Module<T> {
///
/// Panics if the modules have already been initialized.
fn on_new_session<'a, I: 'a>(_changed: bool, validators: I, queued: I)
where I: Iterator<Item=(&'a T::AccountId, ValidatorId)>
where
I: Iterator<Item = (&'a T::AccountId, ValidatorId)>,
{
assert!(HasInitialized::get().is_none());

Expand Down Expand Up @@ -148,19 +148,29 @@ impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
type Key = ValidatorId;

fn on_genesis_session<'a, I: 'a>(_validators: I)
where I: Iterator<Item=(&'a T::AccountId, Self::Key)>
fn on_genesis_session<'a, I: 'a>(validators: I)
where
I: Iterator<Item = (&'a T::AccountId, Self::Key)>,
{
// host config as provided by the client using `fn build` based on the `GenesisConfig`

// `ValdiatorGroups` are created in `ParasScheduler::initializer_on_new_session(..)`
// `Paras` are rotated based on the block number in `Paras::initializer_on_new_session`(..)
// `Parathreads` are also removed in `Paras::initializer_on_new_session`

// a new session is started with session index 0 is started after the fn returns
// that code is part of the `add_extra_genesis` block in the `Session` pallet
// from there on all code fans out from `Self::on_new_session(..)`
}

fn on_new_session<'a, I: 'a>(changed: bool, validators: I, queued: I)
where I: Iterator<Item=(&'a T::AccountId, Self::Key)>
where
I: Iterator<Item = (&'a T::AccountId, Self::Key)>,
{
<Module<T>>::on_new_session(changed, validators, queued);
}

fn on_disabled(_i: usize) { }
fn on_disabled(_i: usize) {}
}

#[cfg(test)]
Expand Down