mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-21 01:41:03 +00:00
pallet-aura: Allow multiple blocks per slot (#14024)
* pallet-aura: Allow multiple blocks per slot * run fmt * rework as associated type * fix fallout * fmt * use constbool * fmt
This commit is contained in:
@@ -81,6 +81,20 @@ pub mod pallet {
|
||||
/// Blocks authored by a disabled validator will lead to a panic as part of this module's
|
||||
/// initialization.
|
||||
type DisabledValidators: DisabledValidators;
|
||||
|
||||
/// Whether to allow block authors to create multiple blocks per slot.
|
||||
///
|
||||
/// If this is `true`, the pallet will allow slots to stay the same across sequential
|
||||
/// blocks. If this is `false`, the pallet will require that subsequent blocks always have
|
||||
/// higher slots than previous ones.
|
||||
///
|
||||
/// Regardless of the setting of this storage value, the pallet will always enforce the
|
||||
/// invariant that slots don't move backwards as the chain progresses.
|
||||
///
|
||||
/// The typical value for this should be 'false' unless this pallet is being augmented by
|
||||
/// another pallet which enforces some limitation on the number of blocks authors can create
|
||||
/// using the same slot.
|
||||
type AllowMultipleBlocksPerSlot: Get<bool>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
@@ -92,7 +106,12 @@ pub mod pallet {
|
||||
if let Some(new_slot) = Self::current_slot_from_digests() {
|
||||
let current_slot = CurrentSlot::<T>::get();
|
||||
|
||||
assert!(current_slot < new_slot, "Slot must increase");
|
||||
if T::AllowMultipleBlocksPerSlot::get() {
|
||||
assert!(current_slot <= new_slot, "Slot must not decrease");
|
||||
} else {
|
||||
assert!(current_slot < new_slot, "Slot must increase");
|
||||
}
|
||||
|
||||
CurrentSlot::<T>::put(new_slot);
|
||||
|
||||
if let Some(n_authorities) = <Authorities<T>>::decode_len() {
|
||||
|
||||
Reference in New Issue
Block a user