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

Ignore empty authority changes #13010

Merged
merged 1 commit into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions frame/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,15 @@ impl<T: Config> Pallet<T> {
///
/// 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<T::AuthorityId, T::MaxAuthorities>) {
if new.is_empty() {
log::warn!(target: LOG_TARGET, "Ignoring empty authority change.");

return
}

<Authorities<T>>::put(&new);

let log = DigestItem::Consensus(
Expand Down
8 changes: 8 additions & 0 deletions frame/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ impl<T: Config> Pallet<T> {
///
/// 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>,
Expand All @@ -580,6 +582,12 @@ impl<T: Config> Pallet<T> {
// 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::<T>::get()
.checked_add(1)
Expand Down