[Trivial] Use 'into_inner' for WeakBoundedVec (#1664)

Prevents authority set clone
This commit is contained in:
Davide Galassi
2023-09-21 20:25:48 +02:00
committed by GitHub
parent 93bb4926b3
commit cb7559f698
3 changed files with 9 additions and 12 deletions
+4 -5
View File
@@ -590,7 +590,6 @@ impl<T: Config> Pallet<T> {
if authorities.is_empty() {
log::warn!(target: LOG_TARGET, "Ignoring empty epoch change.");
return
}
@@ -664,7 +663,7 @@ impl<T: Config> Pallet<T> {
let next_randomness = NextRandomness::<T>::get();
let next_epoch = NextEpochDescriptor {
authorities: next_authorities.to_vec(),
authorities: next_authorities.into_inner(),
randomness: next_randomness,
};
Self::deposit_consensus(ConsensusLog::NextEpochData(next_epoch));
@@ -700,7 +699,7 @@ impl<T: Config> Pallet<T> {
epoch_index: EpochIndex::<T>::get(),
start_slot: Self::current_epoch_start(),
duration: T::EpochDuration::get(),
authorities: Self::authorities().to_vec(),
authorities: Self::authorities().into_inner(),
randomness: Self::randomness(),
config: EpochConfig::<T>::get()
.expect("EpochConfig is initialized in genesis; we never `take` or `kill` it; qed"),
@@ -725,7 +724,7 @@ impl<T: Config> Pallet<T> {
epoch_index: next_epoch_index,
start_slot,
duration: T::EpochDuration::get(),
authorities: NextAuthorities::<T>::get().to_vec(),
authorities: NextAuthorities::<T>::get().into_inner(),
randomness: NextRandomness::<T>::get(),
config: NextEpochConfig::<T>::get().unwrap_or_else(|| {
EpochConfig::<T>::get().expect(
@@ -778,7 +777,7 @@ impl<T: Config> Pallet<T> {
// we use the same values as genesis because we haven't collected any
// randomness yet.
let next = NextEpochDescriptor {
authorities: Self::authorities().to_vec(),
authorities: Self::authorities().into_inner(),
randomness: Self::randomness(),
};
+1 -1
View File
@@ -95,7 +95,7 @@ fn first_block_epoch_zero_start() {
let consensus_log = sp_consensus_babe::ConsensusLog::NextEpochData(
sp_consensus_babe::digests::NextEpochDescriptor {
authorities: Babe::authorities().to_vec(),
authorities: Babe::authorities().into_inner(),
randomness: Babe::randomness(),
},
);
+4 -6
View File
@@ -129,18 +129,16 @@ pub mod pallet {
if let Some(pending_change) = <PendingChange<T>>::get() {
// emit signal if we're at the block that scheduled the change
if block_number == pending_change.scheduled_at {
let next_authorities = pending_change.next_authorities.to_vec();
if let Some(median) = pending_change.forced {
Self::deposit_log(ConsensusLog::ForcedChange(
median,
ScheduledChange {
delay: pending_change.delay,
next_authorities: pending_change.next_authorities.to_vec(),
},
ScheduledChange { delay: pending_change.delay, next_authorities },
))
} else {
Self::deposit_log(ConsensusLog::ScheduledChange(ScheduledChange {
delay: pending_change.delay,
next_authorities: pending_change.next_authorities.to_vec(),
next_authorities,
}));
}
}
@@ -149,7 +147,7 @@ pub mod pallet {
if block_number == pending_change.scheduled_at + pending_change.delay {
Self::set_grandpa_authorities(&pending_change.next_authorities);
Self::deposit_event(Event::NewAuthorities {
authority_set: pending_change.next_authorities.to_vec(),
authority_set: pending_change.next_authorities.into_inner(),
});
<PendingChange<T>>::kill();
}