diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index 635e22c5d58aa..b19fbd57c5030 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -153,7 +153,15 @@ impl Pallet { /// /// The storage will be applied immediately. /// And aura consensus log will be appended to block's log. + /// + /// This is a no-op if `new` is empty. pub fn change_authorities(new: BoundedVec) { + if new.is_empty() { + log::warn!(target: LOG_TARGET, "Ignoring empty authority change."); + + return + } + >::put(&new); let log = DigestItem::Consensus( diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 16b2b2119793a..28ae4bfdc9dad 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -572,6 +572,8 @@ impl Pallet { /// /// Typically, this is not handled directly by the user, but by higher-level validator-set /// manager logic like `pallet-session`. + /// + /// This doesn't do anything if `authorities` is empty. pub fn enact_epoch_change( authorities: WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities>, next_authorities: WeakBoundedVec<(AuthorityId, BabeAuthorityWeight), T::MaxAuthorities>, @@ -580,6 +582,12 @@ impl Pallet { // by the session module to be called before this. debug_assert!(Self::initialized().is_some()); + if authorities.is_empty() { + log::warn!(target: LOG_TARGET, "Ignoring empty epoch change."); + + return + } + // Update epoch index let epoch_index = EpochIndex::::get() .checked_add(1)