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
+2 -2
View File
@@ -82,8 +82,8 @@ pub struct ActivatedLeaf {
pub status: LeafStatus,
/// An associated [`jaeger::Span`].
///
/// NOTE: Each span should only be kept active as long as the leaf is considered active and should be dropped
/// when the leaf is deactivated.
/// NOTE: Each span should only be kept active as long as the leaf is considered active and
/// should be dropped when the leaf is deactivated.
pub span: Arc<jaeger::Span>,
}
+59 -50
View File
@@ -16,8 +16,8 @@
//! Message types for the overseer and subsystems.
//!
//! These messages are intended to define the protocol by which different subsystems communicate with each
//! other and signals that they receive from an overseer to coordinate their work.
//! These messages are intended to define the protocol by which different subsystems communicate
//! with each other and signals that they receive from an overseer to coordinate their work.
//! This is intended for use with the `polkadot-overseer` crate.
//!
//! Subsystems' APIs are defined separately from their implementation, leading to easier mocking.
@@ -62,12 +62,13 @@ pub enum CandidateBackingMessage {
/// Requests a set of backable candidates that could be backed in a child of the given
/// relay-parent, referenced by its hash.
GetBackedCandidates(Hash, Vec<CandidateHash>, oneshot::Sender<Vec<BackedCandidate>>),
/// Note that the Candidate Backing subsystem should second the given candidate in the context of the
/// given relay-parent (ref. by hash). This candidate must be validated.
/// Note that the Candidate Backing subsystem should second the given candidate in the context
/// of the given relay-parent (ref. by hash). This candidate must be validated.
Second(Hash, CandidateReceipt, PoV),
/// Note a validator's statement about a particular candidate. Disagreements about validity must be escalated
/// to a broader check by the Disputes Subsystem, though that escalation is deferred until the approval voting
/// stage to guarantee availability. Agreements are simply tallied until a quorum is reached.
/// Note a validator's statement about a particular candidate. Disagreements about validity
/// must be escalated to a broader check by the Disputes Subsystem, though that escalation is
/// deferred until the approval voting stage to guarantee availability. Agreements are simply
/// tallied until a quorum is reached.
Statement(Hash, SignedFullStatement),
}
@@ -143,8 +144,8 @@ pub enum CandidateValidationMessage {
/// Try to compile the given validation code and send back
/// the outcome.
///
/// The validation code is specified by the hash and will be queried from the runtime API at the
/// given relay-parent.
/// The validation code is specified by the hash and will be queried from the runtime API at
/// the given relay-parent.
PreCheck(
// Relay-parent
Hash,
@@ -157,16 +158,16 @@ pub enum CandidateValidationMessage {
#[derive(Debug, derive_more::From)]
pub enum CollatorProtocolMessage {
/// Signal to the collator protocol that it should connect to validators with the expectation
/// of collating on the given para. This is only expected to be called once, early on, if at all,
/// and only by the Collation Generation subsystem. As such, it will overwrite the value of
/// the previous signal.
/// of collating on the given para. This is only expected to be called once, early on, if at
/// all, and only by the Collation Generation subsystem. As such, it will overwrite the value
/// of the previous signal.
///
/// This should be sent before any `DistributeCollation` message.
CollateOn(ParaId),
/// Provide a collation to distribute to validators with an optional result sender.
///
/// The result sender should be informed when at least one parachain validator seconded the collation. It is also
/// completely okay to just drop the sender.
/// The result sender should be informed when at least one parachain validator seconded the
/// collation. It is also completely okay to just drop the sender.
DistributeCollation(CandidateReceipt, PoV, Option<oneshot::Sender<CollationSecondedSignal>>),
/// Report a collator as having provided an invalid collation. This should lead to disconnect
/// and blacklist of the collator.
@@ -174,7 +175,8 @@ pub enum CollatorProtocolMessage {
/// Get a network bridge update.
#[from]
NetworkBridgeUpdate(NetworkBridgeEvent<net_protocol::CollatorProtocolMessage>),
/// We recommended a particular candidate to be seconded, but it was invalid; penalize the collator.
/// We recommended a particular candidate to be seconded, but it was invalid; penalize the
/// collator.
///
/// The hash is the relay parent.
Invalid(Hash, CandidateReceipt),
@@ -198,14 +200,15 @@ impl Default for CollatorProtocolMessage {
pub enum DisputeCoordinatorMessage {
/// Import statements by validators about a candidate.
///
/// The subsystem will silently discard ancient statements or sets of only dispute-specific statements for
/// candidates that are previously unknown to the subsystem. The former is simply because ancient
/// data is not relevant and the latter is as a DoS prevention mechanism. Both backing and approval
/// statements already undergo anti-DoS procedures in their respective subsystems, but statements
/// cast specifically for disputes are not necessarily relevant to any candidate the system is
/// already aware of and thus present a DoS vector. Our expectation is that nodes will notify each
/// other of disputes over the network by providing (at least) 2 conflicting statements, of which one is either
/// a backing or validation statement.
/// The subsystem will silently discard ancient statements or sets of only dispute-specific
/// statements for candidates that are previously unknown to the subsystem. The former is
/// simply because ancient data is not relevant and the latter is as a DoS prevention
/// mechanism. Both backing and approval statements already undergo anti-DoS procedures in
/// their respective subsystems, but statements cast specifically for disputes are not
/// necessarily relevant to any candidate the system is already aware of and thus present a DoS
/// vector. Our expectation is that nodes will notify each other of disputes over the network
/// by providing (at least) 2 conflicting statements, of which one is either a backing or
/// validation statement.
///
/// This does not do any checking of the message signature.
ImportStatements {
@@ -222,16 +225,16 @@ pub enum DisputeCoordinatorMessage {
///
/// This is:
/// - we discarded the votes because
/// - they were ancient or otherwise invalid (result: `InvalidImport`)
/// - or we were not able to recover availability for an unknown candidate (result:
/// - they were ancient or otherwise invalid (result: `InvalidImport`)
/// - or we were not able to recover availability for an unknown candidate (result:
/// `InvalidImport`)
/// - or were known already (in that case the result will still be `ValidImport`)
/// - or were known already (in that case the result will still be `ValidImport`)
/// - or we recorded them because (`ValidImport`)
/// - we cast our own vote already on that dispute
/// - or we have approval votes on that candidate
/// - or other explicit votes on that candidate already recorded
/// - or recovered availability for the candidate
/// - or the imported statements are backing/approval votes, which are always accepted.
/// - we cast our own vote already on that dispute
/// - or we have approval votes on that candidate
/// - or other explicit votes on that candidate already recorded
/// - or recovered availability for the candidate
/// - or the imported statements are backing/approval votes, which are always accepted.
pending_confirmation: Option<oneshot::Sender<ImportStatementsResult>>,
},
/// Fetch a list of all recent disputes the coordinator is aware of.
@@ -246,15 +249,17 @@ pub enum DisputeCoordinatorMessage {
Vec<(SessionIndex, CandidateHash)>,
oneshot::Sender<Vec<(SessionIndex, CandidateHash, CandidateVotes)>>,
),
/// Sign and issue local dispute votes. A value of `true` indicates validity, and `false` invalidity.
/// Sign and issue local dispute votes. A value of `true` indicates validity, and `false`
/// invalidity.
IssueLocalStatement(SessionIndex, CandidateHash, CandidateReceipt, bool),
/// Determine the highest undisputed block within the given chain, based on where candidates
/// were included. If even the base block should not be finalized due to a dispute,
/// then `None` should be returned on the channel.
///
/// The block descriptions begin counting upwards from the block after the given `base_number`. The `base_number`
/// is typically the number of the last finalized block but may be slightly higher. This block
/// is inevitably going to be finalized so it is not accounted for by this function.
/// The block descriptions begin counting upwards from the block after the given `base_number`.
/// The `base_number` is typically the number of the last finalized block but may be slightly
/// higher. This block is inevitably going to be finalized so it is not accounted for by this
/// function.
DetermineUndisputedChain {
/// The lowest possible block to vote on.
base: (BlockNumber, Hash),
@@ -369,8 +374,8 @@ pub enum NetworkBridgeTxMessage {
/// authority discovery has failed to resolve.
failed: oneshot::Sender<usize>,
},
/// Alternative to `ConnectToValidators` in case you already know the `Multiaddrs` you want to be
/// connected to.
/// Alternative to `ConnectToValidators` in case you already know the `Multiaddrs` you want to
/// be connected to.
ConnectToResolvedValidators {
/// Each entry corresponds to the addresses of an already resolved validator.
validator_addrs: Vec<HashSet<Multiaddr>>,
@@ -576,8 +581,8 @@ pub enum RuntimeApiRequest {
OccupiedCoreAssumption,
RuntimeApiSender<Option<PersistedValidationData>>,
),
/// Get the persisted validation data for a particular para along with the current validation code
/// hash, matching the data hash against an expected one.
/// Get the persisted validation data for a particular para along with the current validation
/// code hash, matching the data hash against an expected one.
AssumedValidationData(
ParaId,
Hash,
@@ -595,10 +600,11 @@ pub enum RuntimeApiRequest {
/// will inform on how the validation data should be computed if the para currently
/// occupies a core.
ValidationCode(ParaId, OccupiedCoreAssumption, RuntimeApiSender<Option<ValidationCode>>),
/// Get validation code by its hash, either past, current or future code can be returned, as long as state is still
/// available.
/// Get validation code by its hash, either past, current or future code can be returned, as
/// long as state is still available.
ValidationCodeByHash(ValidationCodeHash, RuntimeApiSender<Option<ValidationCode>>),
/// Get a the candidate pending availability for a particular parachain by parachain / core index
/// Get a the candidate pending availability for a particular parachain by parachain / core
/// index
CandidatePendingAvailability(ParaId, RuntimeApiSender<Option<CommittedCandidateReceipt>>),
/// Get all events concerning candidates (backing, inclusion, time-out) in the parent of
/// the block in whose state this request is executed.
@@ -623,8 +629,9 @@ pub enum RuntimeApiRequest {
SubmitPvfCheckStatement(PvfCheckStatement, ValidatorSignature, RuntimeApiSender<()>),
/// Returns code hashes of PVFs that require pre-checking by validators in the active set.
PvfsRequirePrecheck(RuntimeApiSender<Vec<ValidationCodeHash>>),
/// Get the validation code used by the specified para, taking the given `OccupiedCoreAssumption`, which
/// will inform on how the validation data should be computed if the para currently occupies a core.
/// Get the validation code used by the specified para, taking the given
/// `OccupiedCoreAssumption`, which will inform on how the validation data should be computed
/// if the para currently occupies a core.
ValidationCodeHash(
ParaId,
OccupiedCoreAssumption,
@@ -686,13 +693,15 @@ pub enum StatementDistributionMessage {
NetworkBridgeUpdate(NetworkBridgeEvent<net_protocol::StatementDistributionMessage>),
}
/// This data becomes intrinsics or extrinsics which should be included in a future relay chain block.
/// This data becomes intrinsics or extrinsics which should be included in a future relay chain
/// block.
// It needs to be cloneable because multiple potential block authors can request copies.
#[derive(Debug, Clone)]
pub enum ProvisionableData {
/// This bitfield indicates the availability of various candidate blocks.
Bitfield(Hash, SignedAvailabilityBitfield),
/// The Candidate Backing subsystem believes that this candidate is valid, pending availability.
/// The Candidate Backing subsystem believes that this candidate is valid, pending
/// availability.
BackedCandidate(CandidateReceipt),
/// Misbehavior reports are self-contained proofs of validator misbehavior.
MisbehaviorReport(Hash, ValidatorIndex, Misbehavior),
@@ -716,11 +725,11 @@ pub struct ProvisionerInherentData {
/// In all cases, the Hash is that of the relay parent.
#[derive(Debug)]
pub enum ProvisionerMessage {
/// This message allows external subsystems to request the set of bitfields and backed candidates
/// associated with a particular potential block hash.
/// This message allows external subsystems to request the set of bitfields and backed
/// candidates associated with a particular potential block hash.
///
/// This is expected to be used by a proposer, to inject that information into the `InherentData`
/// where it can be assembled into the `ParaInherent`.
/// This is expected to be used by a proposer, to inject that information into the
/// `InherentData` where it can be assembled into the `ParaInherent`.
RequestInherentData(Hash, oneshot::Sender<ProvisionerInherentData>),
/// This data should become part of a relay chain block
ProvisionableData(Hash, ProvisionableData),
@@ -138,7 +138,7 @@ pub trait RuntimeApiSubsystemClient {
async fn on_chain_votes(&self, at: Hash)
-> Result<Option<ScrapedOnChainVotes<Hash>>, ApiError>;
/***** Added in v2 *****/
/***** Added in v2 **** */
/// Get the session info for the given session, if stored.
///
@@ -164,7 +164,8 @@ pub trait RuntimeApiSubsystemClient {
/// NOTE: This function is only available since parachain host version 2.
async fn pvfs_require_precheck(&self, at: Hash) -> Result<Vec<ValidationCodeHash>, ApiError>;
/// Fetch the hash of the validation code used by a para, making the given `OccupiedCoreAssumption`.
/// Fetch the hash of the validation code used by a para, making the given
/// `OccupiedCoreAssumption`.
///
/// NOTE: This function is only available since parachain host version 2.
async fn validation_code_hash(
@@ -174,7 +175,7 @@ pub trait RuntimeApiSubsystemClient {
assumption: OccupiedCoreAssumption,
) -> Result<Option<ValidationCodeHash>, ApiError>;
/***** Added in v3 *****/
/***** Added in v3 **** */
/// Returns all onchain disputes.
/// This is a staging method! Do not use on production runtimes!