Use same fmt and clippy configs as in Substrate (#7611)

* Use same rustfmt.toml as Substrate

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* format format file

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Format with new config

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Add Substrate Clippy config

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Print Clippy version in CI

Otherwise its difficult to reproduce locally.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Make fmt happy

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update node/core/pvf/src/error.rs

Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>

* Update node/core/pvf/src/error.rs

Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2023-08-14 16:29:29 +02:00
committed by GitHub
parent ac435c96cf
commit 342d720573
203 changed files with 1880 additions and 1504 deletions
+10 -11
View File
@@ -30,10 +30,9 @@
//! The versioning is achieved with the `api_version` attribute. It can be
//! placed on:
//! * trait declaration - represents the base version of the API.
//! * method declaration (inside a trait declaration) - represents a versioned
//! method, which is not available in the base version.
//! * trait implementation - represents which version of the API is being
//! implemented.
//! * method declaration (inside a trait declaration) - represents a versioned method, which is not
//! available in the base version.
//! * trait implementation - represents which version of the API is being implemented.
//!
//! Let's see a quick example:
//!
@@ -90,14 +89,14 @@
//! # How versioned methods are used for `ParachainHost`
//!
//! Let's introduce two types of `ParachainHost` API implementation:
//! * stable - used on stable production networks like Polkadot and Kusama. There is only one
//! stable API at a single point in time.
//! * stable - used on stable production networks like Polkadot and Kusama. There is only one stable
//! API at a single point in time.
//! * staging - methods that are ready for production, but will be released on Rococo first. We can
//! batch together multiple changes and then release all of them to production, by making staging
//! production (bump base version). We can not change or remove any method in staging after a
//! release, as this would break Rococo. It should be ok to keep adding methods to staging
//! across several releases. For experimental methods, you have to keep them on a separate branch
//! until ready.
//! release, as this would break Rococo. It should be ok to keep adding methods to staging across
//! several releases. For experimental methods, you have to keep them on a separate branch until
//! ready.
//!
//! The stable version of `ParachainHost` is indicated by the base version of the API. Any staging
//! method must use `api_version` attribute so that it is assigned to a specific version of a
@@ -111,8 +110,8 @@
//! ```
//! indicates a function from the stable `v2` API.
//!
//! All staging API functions should use primitives from `vstaging`. They should be clearly separated
//! from the stable primitives.
//! All staging API functions should use primitives from `vstaging`. They should be clearly
//! separated from the stable primitives.
use crate::{
vstaging, BlockNumber, CandidateCommitments, CandidateEvent, CandidateHash,
+6 -4
View File
@@ -164,8 +164,8 @@ pub mod metric_definitions {
};
/// Counts the number of `imported`, `current` and `concluded_invalid` dispute statements sets
/// processed in `process_inherent_data`. The `current` label refers to the disputes statement sets of
/// the current session.
/// processed in `process_inherent_data`. The `current` label refers to the disputes statement
/// sets of the current session.
pub const PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED: CounterVecDefinition =
CounterVecDefinition {
name: "polkadot_parachain_inherent_data_dispute_sets_processed",
@@ -174,7 +174,8 @@ pub mod metric_definitions {
labels: &["category"],
};
/// Counts the number of `valid` and `invalid` bitfields signature checked in `process_inherent_data`.
/// Counts the number of `valid` and `invalid` bitfields signature checked in
/// `process_inherent_data`.
pub const PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS: CounterVecDefinition =
CounterVecDefinition {
name: "polkadot_parachain_create_inherent_bitfields_signature_checks",
@@ -183,7 +184,8 @@ pub mod metric_definitions {
labels: &["validity"],
};
/// Measures how much time does it take to verify a single validator signature of a dispute statement
/// Measures how much time does it take to verify a single validator signature of a dispute
/// statement
pub const PARACHAIN_VERIFY_DISPUTE_SIGNATURE: HistogramDefinition =
HistogramDefinition {
name: "polkadot_parachain_verify_dispute_signature",
+43 -36
View File
@@ -103,7 +103,8 @@ pub trait TypeIndex {
fn type_index(&self) -> usize;
}
/// Index of the validator is used as a lightweight replacement of the `ValidatorId` when appropriate.
/// Index of the validator is used as a lightweight replacement of the `ValidatorId` when
/// appropriate.
#[derive(Eq, Ord, PartialEq, PartialOrd, Copy, Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash))]
pub struct ValidatorIndex(pub u32);
@@ -589,25 +590,27 @@ impl Ord for CommittedCandidateReceipt {
}
}
/// The validation data provides information about how to create the inputs for validation of a candidate.
/// This information is derived from the chain state and will vary from para to para, although some
/// fields may be the same for every para.
/// The validation data provides information about how to create the inputs for validation of a
/// candidate. This information is derived from the chain state and will vary from para to para,
/// although some fields may be the same for every para.
///
/// Since this data is used to form inputs to the validation function, it needs to be persisted by the
/// availability system to avoid dependence on availability of the relay-chain state.
/// Since this data is used to form inputs to the validation function, it needs to be persisted by
/// the availability system to avoid dependence on availability of the relay-chain state.
///
/// Furthermore, the validation data acts as a way to authorize the additional data the collator needs
/// to pass to the validation function. For example, the validation function can check whether the incoming
/// messages (e.g. downward messages) were actually sent by using the data provided in the validation data
/// using so called MQC heads.
/// Furthermore, the validation data acts as a way to authorize the additional data the collator
/// needs to pass to the validation function. For example, the validation function can check whether
/// the incoming messages (e.g. downward messages) were actually sent by using the data provided in
/// the validation data using so called MQC heads.
///
/// Since the commitments of the validation function are checked by the relay-chain, secondary checkers
/// can rely on the invariant that the relay-chain only includes para-blocks for which these checks have
/// already been done. As such, there is no need for the validation data used to inform validators and
/// collators about the checks the relay-chain will perform to be persisted by the availability system.
/// Since the commitments of the validation function are checked by the relay-chain, secondary
/// checkers can rely on the invariant that the relay-chain only includes para-blocks for which
/// these checks have already been done. As such, there is no need for the validation data used to
/// inform validators and collators about the checks the relay-chain will perform to be persisted by
/// the availability system.
///
/// The `PersistedValidationData` should be relatively lightweight primarily because it is constructed
/// during inclusion for each candidate and therefore lies on the critical path of inclusion.
/// The `PersistedValidationData` should be relatively lightweight primarily because it is
/// constructed during inclusion for each candidate and therefore lies on the critical path of
/// inclusion.
#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Default))]
pub struct PersistedValidationData<H = Hash, N = BlockNumber> {
@@ -642,7 +645,8 @@ pub struct CandidateCommitments<N = BlockNumber> {
pub head_data: HeadData,
/// The number of messages processed from the DMQ.
pub processed_downward_messages: u32,
/// The mark which specifies the block number up to which all inbound HRMP messages are processed.
/// The mark which specifies the block number up to which all inbound HRMP messages are
/// processed.
pub hrmp_watermark: N,
}
@@ -677,7 +681,8 @@ pub type UncheckedSignedAvailabilityBitfield = UncheckedSigned<AvailabilityBitfi
/// A set of signed availability bitfields. Should be sorted by validator index, ascending.
pub type SignedAvailabilityBitfields = Vec<SignedAvailabilityBitfield>;
/// A set of unchecked signed availability bitfields. Should be sorted by validator index, ascending.
/// A set of unchecked signed availability bitfields. Should be sorted by validator index,
/// ascending.
pub type UncheckedSignedAvailabilityBitfields = Vec<UncheckedSignedAvailabilityBitfield>;
/// A backed (or backable, depending on context) candidate.
@@ -975,8 +980,9 @@ pub enum CoreState<H = Hash, N = BlockNumber> {
/// variant.
#[codec(index = 1)]
Scheduled(ScheduledCore),
/// The core is currently free and there is nothing scheduled. This can be the case for parathread
/// cores when there are no parathread blocks queued. Parachain cores will never be left idle.
/// The core is currently free and there is nothing scheduled. This can be the case for
/// parathread cores when there are no parathread blocks queued. Parachain cores will never be
/// left idle.
#[codec(index = 2)]
Free,
}
@@ -1079,8 +1085,8 @@ impl From<ValidityError> for u8 {
}
}
/// Abridged version of `HostConfiguration` (from the `Configuration` parachains host runtime module)
/// meant to be used by a parachain or PDK such as cumulus.
/// Abridged version of `HostConfiguration` (from the `Configuration` parachains host runtime
/// module) meant to be used by a parachain or PDK such as cumulus.
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct AbridgedHostConfiguration {
@@ -1156,17 +1162,18 @@ pub enum UpgradeRestriction {
#[derive(Copy, Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)]
pub enum UpgradeGoAhead {
/// Abort the upgrade process. There is something wrong with the validation code previously
/// submitted by the parachain. This variant can also be used to prevent upgrades by the governance
/// should an emergency emerge.
/// submitted by the parachain. This variant can also be used to prevent upgrades by the
/// governance should an emergency emerge.
///
/// The expected reaction on this variant is that the parachain will admit this message and
/// remove all the data about the pending upgrade. Depending on the nature of the problem (to
/// be examined offchain for now), it can try to send another validation code or just retry later.
/// be examined offchain for now), it can try to send another validation code or just retry
/// later.
#[codec(index = 0)]
Abort,
/// Apply the pending code change. The parablock that is built on a relay-parent that is descendant
/// of the relay-parent where the parachain observed this signal must use the upgraded validation
/// code.
/// Apply the pending code change. The parablock that is built on a relay-parent that is
/// descendant of the relay-parent where the parachain observed this signal must use the
/// upgraded validation code.
#[codec(index = 1)]
GoAhead,
}
@@ -1646,7 +1653,7 @@ pub const fn supermajority_threshold(n: usize) -> usize {
#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(PartialEq))]
pub struct SessionInfo {
/****** New in v2 *******/
/****** New in v2 ****** */
/// All the validators actively participating in parachain consensus.
/// Indices are into the broader validator set.
pub active_validator_indices: Vec<ValidatorIndex>,
@@ -1655,11 +1662,11 @@ pub struct SessionInfo {
/// The amount of sessions to keep for disputes.
pub dispute_period: SessionIndex,
/****** Old fields ******/
/****** Old fields ***** */
/// Validators in canonical ordering.
///
/// NOTE: There might be more authorities in the current session, than `validators` participating
/// in parachain consensus. See
/// NOTE: There might be more authorities in the current session, than `validators`
/// participating in parachain consensus. See
/// [`max_validators`](https://github.com/paritytech/polkadot/blob/a52dca2be7840b23c19c153cf7e110b1e3e475f8/runtime/parachains/src/configuration.rs#L148).
///
/// `SessionInfo::validators` will be limited to to `max_validators` when set.
@@ -1667,8 +1674,8 @@ pub struct SessionInfo {
/// Validators' authority discovery keys for the session in canonical ordering.
///
/// NOTE: The first `validators.len()` entries will match the corresponding validators in
/// `validators`, afterwards any remaining authorities can be found. This is any authorities not
/// participating in parachain consensus - see
/// `validators`, afterwards any remaining authorities can be found. This is any authorities
/// not participating in parachain consensus - see
/// [`max_validators`](https://github.com/paritytech/polkadot/blob/a52dca2be7840b23c19c153cf7e110b1e3e475f8/runtime/parachains/src/configuration.rs#L148)
pub discovery_keys: Vec<AuthorityDiscoveryId>,
/// The assignment keys for validators.
@@ -1679,8 +1686,8 @@ pub struct SessionInfo {
///
/// Therefore:
/// ```ignore
/// assignment_keys.len() == validators.len() && validators.len() <= discovery_keys.len()
/// ```
/// assignment_keys.len() == validators.len() && validators.len() <= discovery_keys.len()
/// ```
pub assignment_keys: Vec<AssignmentId>,
/// Validators in shuffled ordering - these are the validator groups as produced
/// by the `Scheduler` module for the session and are typically referred to by