From 9083fedc560178324414ee330e379348bf8cd13c Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 7 May 2025 16:07:46 +0200 Subject: [PATCH 1/3] more expressive logs --- runtimes/common/src/session.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtimes/common/src/session.rs b/runtimes/common/src/session.rs index 13d8dde99..55b72ff04 100644 --- a/runtimes/common/src/session.rs +++ b/runtimes/common/src/session.rs @@ -60,7 +60,12 @@ where frame_support::pallet_prelude::DispatchClass::Mandatory, ); - if collators.is_empty() || !has_collator_keys { + if !has_collator_keys { + log::error!("💥 keeping old session because of missing collator keys!"); + return None; + } + + if collators.is_empty() { // we never want to pass an empty set of collators. This would brick the chain. log::error!("💥 keeping old session because of empty collator set!"); return None; From 535b36be4de61dafd1d8ccad175f17ff567ef6b4 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 9 May 2025 11:01:39 +0200 Subject: [PATCH 2/3] right weight calculation --- runtimes/common/src/session.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/common/src/session.rs b/runtimes/common/src/session.rs index 55b72ff04..5f08193ad 100644 --- a/runtimes/common/src/session.rs +++ b/runtimes/common/src/session.rs @@ -56,7 +56,7 @@ where SystemPallet::::register_extra_weight_unchecked( ::DbWeight::get() - .reads(2u64.saturating_add(collators.len().saturated_into::())), + .reads(1u64.saturating_add(collators.len().saturated_into::())), frame_support::pallet_prelude::DispatchClass::Mandatory, ); From 234920a857e334a0ebb33fa52c60964ab6b76c12 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 9 May 2025 11:02:20 +0200 Subject: [PATCH 3/3] Generic instance --- runtimes/common/src/session.rs | 10 +++++----- runtimes/peregrine/src/system/mod.rs | 2 +- runtimes/spiritnet/src/system/mod.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/runtimes/common/src/session.rs b/runtimes/common/src/session.rs index 5f08193ad..27154aa1b 100644 --- a/runtimes/common/src/session.rs +++ b/runtimes/common/src/session.rs @@ -18,7 +18,7 @@ pub use frame_support::weights::constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use frame_system::Pallet as SystemPallet; -use pallet_membership::{Config as MembershipConfig, Instance3, Pallet as MembershipPallet}; +use pallet_membership::{Config as MembershipConfig, Pallet as MembershipPallet}; use pallet_session::SessionManager as SessionManagerTrait; pub use sp_consensus_aura::sr25519::AuthorityId; use sp_core::Get; @@ -31,15 +31,15 @@ use crate::constants::staking::DefaultBlocksPerRound; type AccountIdOf = ::AccountId; /// The session manager for the collator set. -pub struct SessionManager(PhantomData); +pub struct SessionManager(PhantomData, PhantomData); -impl SessionManagerTrait> for SessionManager +impl SessionManagerTrait> for SessionManager where - Runtime: MembershipConfig + pallet_session::Config, + Runtime: MembershipConfig + pallet_session::Config, ::ValidatorId: From>, { fn new_session(new_index: SessionIndex) -> Option>> { - let collators = MembershipPallet::::members().to_vec(); + let collators = MembershipPallet::::members().to_vec(); log::debug!( "assembling new collators for new session {} at #{:?} with {:?}", diff --git a/runtimes/peregrine/src/system/mod.rs b/runtimes/peregrine/src/system/mod.rs index 48be7b9e8..334d5439a 100644 --- a/runtimes/peregrine/src/system/mod.rs +++ b/runtimes/peregrine/src/system/mod.rs @@ -148,7 +148,7 @@ impl pallet_session::Config for Runtime { type ValidatorIdOf = ConvertInto; type ShouldEndSession = FixedLengthSession; type NextSessionRotation = FixedLengthSession; - type SessionManager = SessionManager; + type SessionManager = SessionManager; type SessionHandler = ::KeyTypeIdProviders; type Keys = SessionKeys; type WeightInfo = weights::pallet_session::WeightInfo; diff --git a/runtimes/spiritnet/src/system/mod.rs b/runtimes/spiritnet/src/system/mod.rs index 65a232cc8..2305b0ae4 100644 --- a/runtimes/spiritnet/src/system/mod.rs +++ b/runtimes/spiritnet/src/system/mod.rs @@ -148,7 +148,7 @@ impl pallet_session::Config for Runtime { type ValidatorIdOf = ConvertInto; type ShouldEndSession = FixedLengthSession; type NextSessionRotation = FixedLengthSession; - type SessionManager = SessionManager; + type SessionManager = SessionManager; type SessionHandler = ::KeyTypeIdProviders; type Keys = SessionKeys; type WeightInfo = weights::pallet_session::WeightInfo;