mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 09:51:02 +00:00
[runtime] follow up relay chain cleanups (#4657)
* fix miscalculation of remaining weight * rename a var * move out enforcing filtering by dropping inherents * prepare for dispute statement validity check being split off * refactor * refactor, only check disputes we actually want to include * more refactor and documentation * refactor and minimize inherent checks * chore: warnings * fix a few tests * fix dedup regression * fix * more asserts in tests * remove some asserts * chore: fmt * skip signatures checks, some more * undo unwatend changes * Update runtime/parachains/src/paras_inherent/mod.rs Co-authored-by: sandreim <54316454+sandreim@users.noreply.github.com> * cleanups, checking CheckedDisputeStatments makes no sense * integrity, if called create_inherent_inner, it shall do the checks, and not rely on enter_inner * review comments * use from impl rather than into * remove outdated comment * adjust tests accordingly * assure no weight is lost * address review comments * remove unused import * split error into two and document * use assurance, O(n) * Revert "adjust tests accordingly" This reverts commit 3cc9a3c449f82db38cea22c48f4a21876603374b. * fix comment * fix sorting * comment Co-authored-by: sandreim <54316454+sandreim@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
883b490cae
commit
b7a05fd40b
@@ -21,10 +21,8 @@
|
||||
//! to included.
|
||||
|
||||
use crate::{
|
||||
configuration, disputes, dmp, hrmp, paras,
|
||||
paras_inherent::{sanitize_bitfields, DisputedBitfield},
|
||||
scheduler::CoreAssignment,
|
||||
shared, ump,
|
||||
configuration, disputes, dmp, hrmp, paras, paras_inherent::DisputedBitfield,
|
||||
scheduler::CoreAssignment, shared, ump,
|
||||
};
|
||||
use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
|
||||
use frame_support::pallet_prelude::*;
|
||||
@@ -58,7 +56,7 @@ pub struct AvailabilityBitfieldRecord<N> {
|
||||
|
||||
/// Determines if all checks should be applied or if a subset was already completed
|
||||
/// in a code path that will be executed afterwards or was already executed before.
|
||||
#[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
||||
#[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
||||
pub(crate) enum FullCheck {
|
||||
/// Yes, do a full check, skip nothing.
|
||||
Yes,
|
||||
@@ -214,8 +212,18 @@ pub mod pallet {
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T> {
|
||||
/// Validator indices are out of order or contains duplicates.
|
||||
UnsortedOrDuplicateValidatorIndices,
|
||||
/// Dispute statement sets are out of order or contain duplicates.
|
||||
UnsortedOrDuplicateDisputeStatementSet,
|
||||
/// Backed candidates are out of order (core index) or contain duplicates.
|
||||
UnsortedOrDuplicateBackedCandidates,
|
||||
/// A different relay parent was provided compared to the on-chain stored one.
|
||||
UnexpectedRelayParent,
|
||||
/// Availability bitfield has unexpected size.
|
||||
WrongBitfieldSize,
|
||||
/// Bitfield consists of zeros only.
|
||||
BitfieldAllZeros,
|
||||
/// Multiple bitfields submitted by same validator or validators out of order by index.
|
||||
BitfieldDuplicateOrUnordered,
|
||||
/// Validator index out of bounds.
|
||||
@@ -311,11 +319,12 @@ impl<T: Config> Pallet<T> {
|
||||
/// Extract the freed cores based on cores that became available.
|
||||
///
|
||||
/// Updates storage items `PendingAvailability` and `AvailabilityBitfields`.
|
||||
pub(crate) fn update_pending_availability_and_get_freed_cores<F, const ON_CHAIN_USE: bool>(
|
||||
pub(crate) fn update_pending_availability_and_get_freed_cores<F>(
|
||||
expected_bits: usize,
|
||||
validators: &[ValidatorId],
|
||||
signed_bitfields: UncheckedSignedAvailabilityBitfields,
|
||||
core_lookup: F,
|
||||
enact_candidate: bool,
|
||||
) -> Vec<(CoreIndex, CandidateHash)>
|
||||
where
|
||||
F: Fn(CoreIndex) -> Option<ParaId>,
|
||||
@@ -387,7 +396,7 @@ impl<T: Config> Pallet<T> {
|
||||
},
|
||||
};
|
||||
|
||||
if ON_CHAIN_USE {
|
||||
if enact_candidate {
|
||||
let receipt = CommittedCandidateReceipt {
|
||||
descriptor: pending_availability.descriptor,
|
||||
commitments,
|
||||
@@ -420,29 +429,31 @@ impl<T: Config> Pallet<T> {
|
||||
signed_bitfields: UncheckedSignedAvailabilityBitfields,
|
||||
disputed_bitfield: DisputedBitfield,
|
||||
core_lookup: impl Fn(CoreIndex) -> Option<ParaId>,
|
||||
) -> Vec<(CoreIndex, CandidateHash)> {
|
||||
full_check: FullCheck,
|
||||
) -> Result<Vec<(CoreIndex, CandidateHash)>, crate::inclusion::Error<T>> {
|
||||
let validators = shared::Pallet::<T>::active_validator_keys();
|
||||
let session_index = shared::Pallet::<T>::session_index();
|
||||
let parent_hash = frame_system::Pallet::<T>::parent_hash();
|
||||
|
||||
let checked_bitfields = sanitize_bitfields::<T>(
|
||||
let checked_bitfields = crate::paras_inherent::assure_sanity_bitfields::<T>(
|
||||
signed_bitfields,
|
||||
disputed_bitfield,
|
||||
expected_bits,
|
||||
parent_hash,
|
||||
session_index,
|
||||
&validators[..],
|
||||
FullCheck::Yes,
|
||||
);
|
||||
full_check,
|
||||
)?;
|
||||
|
||||
let freed_cores = Self::update_pending_availability_and_get_freed_cores::<_, true>(
|
||||
let freed_cores = Self::update_pending_availability_and_get_freed_cores::<_>(
|
||||
expected_bits,
|
||||
&validators[..],
|
||||
checked_bitfields,
|
||||
core_lookup,
|
||||
true,
|
||||
);
|
||||
|
||||
freed_cores
|
||||
Ok(freed_cores)
|
||||
}
|
||||
|
||||
/// Process candidates that have been backed. Provide the relay storage root, a set of candidates
|
||||
|
||||
Reference in New Issue
Block a user