Conpanion for Substrate#7127 (#1865)

* Conpanion for Substrate#7127

* Use sp_session::OneSessionHandler

* .

* Fix pallet_session::OneSessionHandler

* OneSessionHandler is in frame_support now

* "Update Substrate"

Co-authored-by: parity-processbot <>
This commit is contained in:
Liu-Cheng Xu
2021-02-03 01:05:42 +08:00
committed by GitHub
parent d4fdbf7db9
commit d353c76e26
9 changed files with 152 additions and 150 deletions
+140 -140
View File
File diff suppressed because it is too large Load Diff
+3 -5
View File
@@ -31,7 +31,7 @@ use primitives::v1::{BlockNumber, ValidatorId, AssignmentId};
use sp_runtime::{Perquintill, Perbill, FixedPointNumber}; use sp_runtime::{Perquintill, Perbill, FixedPointNumber};
use frame_system::limits; use frame_system::limits;
use frame_support::{ use frame_support::{
parameter_types, traits::{Currency}, parameter_types, traits::{Currency, OneSessionHandler},
weights::{Weight, constants::WEIGHT_PER_SECOND, DispatchClass}, weights::{Weight, constants::WEIGHT_PER_SECOND, DispatchClass},
}; };
use pallet_transaction_payment::{TargetedFeeAdjustment, Multiplier}; use pallet_transaction_payment::{TargetedFeeAdjustment, Multiplier};
@@ -136,8 +136,7 @@ impl<T> sp_runtime::BoundToRuntimeAppPublic for ParachainSessionKeyPlaceholder<T
type Public = ValidatorId; type Public = ValidatorId;
} }
impl<T: pallet_session::Config> impl<T: pallet_session::Config> OneSessionHandler<T::AccountId> for ParachainSessionKeyPlaceholder<T>
pallet_session::OneSessionHandler<T::AccountId> for ParachainSessionKeyPlaceholder<T>
{ {
type Key = ValidatorId; type Key = ValidatorId;
@@ -165,8 +164,7 @@ impl<T> sp_runtime::BoundToRuntimeAppPublic for AssignmentSessionKeyPlaceholder<
type Public = AssignmentId; type Public = AssignmentId;
} }
impl<T: pallet_session::Config> impl<T: pallet_session::Config> OneSessionHandler<T::AccountId> for AssignmentSessionKeyPlaceholder<T>
pallet_session::OneSessionHandler<T::AccountId> for AssignmentSessionKeyPlaceholder<T>
{ {
type Key = AssignmentId; type Key = AssignmentId;
@@ -271,7 +271,7 @@ mod tests {
}; };
use keyring::Sr25519Keyring; use keyring::Sr25519Keyring;
use runtime_parachains::{initializer, configuration, inclusion, session_info, scheduler, dmp, ump, hrmp}; use runtime_parachains::{initializer, configuration, inclusion, session_info, scheduler, dmp, ump, hrmp};
use pallet_session::OneSessionHandler; use frame_support::traits::OneSessionHandler;
impl_outer_origin! { impl_outer_origin! {
pub enum Origin for Test { pub enum Origin for Test {
+1
View File
@@ -626,6 +626,7 @@ parameter_types! {
impl pallet_im_online::Config for Runtime { impl pallet_im_online::Config for Runtime {
type AuthorityId = ImOnlineId; type AuthorityId = ImOnlineId;
type Event = Event; type Event = Event;
type ValidatorSet = Historical;
type ReportUnresponsiveness = Offences; type ReportUnresponsiveness = Offences;
type SessionDuration = SessionDuration; type SessionDuration = SessionDuration;
type UnsignedPriority = ImOnlineUnsignedPriority; type UnsignedPriority = ImOnlineUnsignedPriority;
@@ -23,7 +23,7 @@ use sp_std::prelude::*;
use frame_support::weights::Weight; use frame_support::weights::Weight;
use primitives::v1::ValidatorId; use primitives::v1::ValidatorId;
use frame_support::{ use frame_support::{
decl_storage, decl_module, decl_error, traits::Randomness, decl_storage, decl_module, decl_error, traits::{OneSessionHandler, Randomness},
}; };
use parity_scale_codec::{Encode, Decode}; use parity_scale_codec::{Encode, Decode};
use crate::{ use crate::{
@@ -237,7 +237,7 @@ impl<T: Config> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
type Public = ValidatorId; type Public = ValidatorId;
} }
impl<T: pallet_session::Config + Config> pallet_session::OneSessionHandler<T::AccountId> for Module<T> { impl<T: pallet_session::Config + Config> OneSessionHandler<T::AccountId> for Module<T> {
type Key = ValidatorId; type Key = ValidatorId;
fn on_genesis_session<'a, I: 'a>(_validators: I) fn on_genesis_session<'a, I: 'a>(_validators: I)
@@ -22,7 +22,7 @@
use primitives::v1::{AssignmentId, AuthorityDiscoveryId, SessionIndex, SessionInfo}; use primitives::v1::{AssignmentId, AuthorityDiscoveryId, SessionIndex, SessionInfo};
use frame_support::{ use frame_support::{
decl_storage, decl_module, decl_error, decl_storage, decl_module, decl_error,
weights::Weight, traits::OneSessionHandler, weights::Weight,
}; };
use crate::{configuration, paras, scheduler}; use crate::{configuration, paras, scheduler};
use sp_std::vec::Vec; use sp_std::vec::Vec;
@@ -141,7 +141,7 @@ impl<T: Config> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
type Public = AssignmentId; type Public = AssignmentId;
} }
impl<T: pallet_session::Config + Config> pallet_session::OneSessionHandler<T::AccountId> for Module<T> { impl<T: pallet_session::Config + Config> OneSessionHandler<T::AccountId> for Module<T> {
type Key = AssignmentId; type Key = AssignmentId;
fn on_genesis_session<'a, I: 'a>(_validators: I) fn on_genesis_session<'a, I: 'a>(_validators: I)
+1
View File
@@ -671,6 +671,7 @@ parameter_types! {
impl pallet_im_online::Config for Runtime { impl pallet_im_online::Config for Runtime {
type AuthorityId = ImOnlineId; type AuthorityId = ImOnlineId;
type Event = Event; type Event = Event;
type ValidatorSet = Historical;
type SessionDuration = SessionDuration; type SessionDuration = SessionDuration;
type ReportUnresponsiveness = Offences; type ReportUnresponsiveness = Offences;
type UnsignedPriority = ImOnlineUnsignedPriority; type UnsignedPriority = ImOnlineUnsignedPriority;
+1
View File
@@ -326,6 +326,7 @@ parameter_types! {
impl pallet_im_online::Config for Runtime { impl pallet_im_online::Config for Runtime {
type AuthorityId = ImOnlineId; type AuthorityId = ImOnlineId;
type Event = Event; type Event = Event;
type ValidatorSet = Historical;
type ReportUnresponsiveness = Offences; type ReportUnresponsiveness = Offences;
type SessionDuration = SessionDuration; type SessionDuration = SessionDuration;
type UnsignedPriority = StakingUnsignedPriority; type UnsignedPriority = StakingUnsignedPriority;
+1
View File
@@ -406,6 +406,7 @@ parameter_types! {
impl pallet_im_online::Config for Runtime { impl pallet_im_online::Config for Runtime {
type AuthorityId = ImOnlineId; type AuthorityId = ImOnlineId;
type Event = Event; type Event = Event;
type ValidatorSet = Historical;
type ReportUnresponsiveness = Offences; type ReportUnresponsiveness = Offences;
type SessionDuration = SessionDuration; type SessionDuration = SessionDuration;
type UnsignedPriority = StakingUnsignedPriority; type UnsignedPriority = StakingUnsignedPriority;