Skip to content

Commit 6c79b58

Browse files
authored
Use same fmt and clippy configs as in Polkadot (#3004)
* Copy rustfmt.toml from Polkadot master Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Format with new config Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Add Polkadot clippy config Signed-off-by: Oliver Tale-Yazdi <[email protected]> * Update Cargo.lock Looks like paritytech/polkadot#7611 did not correctly update the lockfile. Maybe a different Rust Version?! Signed-off-by: Oliver Tale-Yazdi <[email protected]> --------- Signed-off-by: Oliver Tale-Yazdi <[email protected]>
1 parent 61480a1 commit 6c79b58

File tree

60 files changed

+332
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+332
-232
lines changed

cumulus/.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ rustflags = [
2929
"-Aclippy::needless_option_as_deref", # false positives
3030
"-Aclippy::derivable_impls", # false positives
3131
"-Aclippy::stable_sort_primitive", # prefer stable sort
32+
"-Aclippy::extra-unused-type-parameters", # stylistic
3233
]

cumulus/.rustfmt.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ reorder_imports = true
1111
# Consistency
1212
newline_style = "Unix"
1313

14+
# Format comments
15+
comment_width = 100
16+
wrap_comments = true
17+
1418
# Misc
15-
binop_separator = "Back"
1619
chain_width = 80
17-
match_arm_blocks = false
20+
spaces_around_ranges = false
21+
binop_separator = "Back"
22+
reorder_impl_items = false
1823
match_arm_leading_pipes = "Preserve"
24+
match_arm_blocks = false
1925
match_block_trailing_comma = true
20-
reorder_impl_items = false
21-
spaces_around_ranges = false
2226
trailing_comma = "Vertical"
2327
trailing_semicolon = false
2428
use_field_init_shorthand = true

cumulus/client/cli/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ pub struct RunCmd {
307307
}
308308

309309
impl RunCmd {
310-
/// Create a [`NormalizedRunCmd`] which merges the `collator` cli argument into `validator` to have only one.
310+
/// Create a [`NormalizedRunCmd`] which merges the `collator` cli argument into `validator` to
311+
/// have only one.
311312
pub fn normalize(&self) -> NormalizedRunCmd {
312313
let mut new_base = self.base.clone();
313314

cumulus/client/collator/src/service.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ where
175175

176176
/// Fetch the collation info from the runtime.
177177
///
178-
/// Returns `Ok(Some(_))` on success, `Err(_)` on error or `Ok(None)` if the runtime api isn't implemented by the runtime.
178+
/// Returns `Ok(Some(_))` on success, `Err(_)` on error or `Ok(None)` if the runtime api isn't
179+
/// implemented by the runtime.
179180
pub fn fetch_collation_info(
180181
&self,
181182
block_hash: Block::Hash,

cumulus/client/consensus/common/src/lib.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ pub struct ParachainCandidate<B> {
5353
pub proof: sp_trie::StorageProof,
5454
}
5555

56-
/// A specific parachain consensus implementation that can be used by a collator to produce candidates.
56+
/// A specific parachain consensus implementation that can be used by a collator to produce
57+
/// candidates.
5758
///
58-
/// The collator will call [`Self::produce_candidate`] every time there is a free core for the parachain
59-
/// this collator is collating for. It is the job of the consensus implementation to decide if this
60-
/// specific collator should build a candidate for the given relay chain block. The consensus
61-
/// implementation could, for example, check whether this specific collator is part of a staked set.
59+
/// The collator will call [`Self::produce_candidate`] every time there is a free core for the
60+
/// parachain this collator is collating for. It is the job of the consensus implementation to
61+
/// decide if this specific collator should build a candidate for the given relay chain block. The
62+
/// consensus implementation could, for example, check whether this specific collator is part of a
63+
/// staked set.
6264
#[async_trait::async_trait]
6365
pub trait ParachainConsensus<B: BlockT>: Send + Sync + dyn_clone::DynClone {
6466
/// Produce a new candidate at the given parent block and relay-parent blocks.
@@ -94,8 +96,8 @@ impl<B: BlockT> ParachainConsensus<B> for Box<dyn ParachainConsensus<B> + Send +
9496
/// Parachain specific block import.
9597
///
9698
/// This is used to set `block_import_params.fork_choice` to `false` as long as the block origin is
97-
/// not `NetworkInitialSync`. The best block for parachains is determined by the relay chain. Meaning
98-
/// we will update the best block, as it is included by the relay-chain.
99+
/// not `NetworkInitialSync`. The best block for parachains is determined by the relay chain.
100+
/// Meaning we will update the best block, as it is included by the relay-chain.
99101
pub struct ParachainBlockImport<Block: BlockT, BI, BE> {
100102
inner: BI,
101103
monitor: Option<SharedData<LevelMonitor<Block, BE>>>,
@@ -232,8 +234,8 @@ pub struct PotentialParent<B: BlockT> {
232234
/// a set of [`PotentialParent`]s which could be potential parents of a new block with this
233235
/// relay-parent according to the search parameters.
234236
///
235-
/// A parachain block is a potential parent if it is either the last included parachain block, the pending
236-
/// parachain block (when `max_depth` >= 1), or all of the following hold:
237+
/// A parachain block is a potential parent if it is either the last included parachain block, the
238+
/// pending parachain block (when `max_depth` >= 1), or all of the following hold:
237239
/// * its parent is a potential parent
238240
/// * its relay-parent is within `ancestry_lookback` of the targeted relay-parent.
239241
/// * the block number is within `max_depth` blocks of the included block

cumulus/client/consensus/common/src/parachain_consensus.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ where
176176
///
177177
/// # Note
178178
///
179-
/// This will access the backend of the parachain and thus, this future should be spawned as blocking
180-
/// task.
179+
/// This will access the backend of the parachain and thus, this future should be spawned as
180+
/// blocking task.
181181
pub async fn run_parachain_consensus<P, R, Block, B>(
182182
para_id: ParaId,
183183
parachain: Arc<P>,

cumulus/client/consensus/proposer/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ pub trait ProposerInterface<Block: BlockT> {
6262
/// `ParachainInherentData`.
6363
///
6464
/// Also specify any required inherent digests, the maximum proposal duration,
65-
/// and the block size limit in bytes. See the documentation on [`sp_consensus::Proposer::propose`]
66-
/// for more details on how to interpret these parameters.
65+
/// and the block size limit in bytes. See the documentation on
66+
/// [`sp_consensus::Proposer::propose`] for more details on how to interpret these parameters.
6767
///
6868
/// The `InherentData` and `Digest` are left deliberately general in order to accommodate
6969
/// all possible collator selection algorithms or inherent creation mechanisms,

cumulus/client/consensus/relay-chain/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
//!
2424
//! 1. Each node that sees itself as a collator is free to build a parachain candidate.
2525
//!
26-
//! 2. This parachain candidate is send to the parachain validators that are part of the relay chain.
26+
//! 2. This parachain candidate is send to the parachain validators that are part of the relay
27+
//! chain.
2728
//!
2829
//! 3. The parachain validators validate at most X different parachain candidates, where X is the
2930
//! total number of parachain validators.

cumulus/client/network/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ impl Decode for BlockAnnounceData {
8787
impl BlockAnnounceData {
8888
/// Validate that the receipt, statement and announced header match.
8989
///
90-
/// This will not check the signature, for this you should use [`BlockAnnounceData::check_signature`].
90+
/// This will not check the signature, for this you should use
91+
/// [`BlockAnnounceData::check_signature`].
9192
fn validate(&self, encoded_header: Vec<u8>) -> Result<(), Validation> {
9293
let candidate_hash =
9394
if let CompactStatement::Seconded(h) = self.statement.unchecked_payload() {
@@ -192,9 +193,9 @@ pub type BlockAnnounceValidator<Block, RCInterface> =
192193

193194
/// Parachain specific block announce validator.
194195
///
195-
/// This is not required when the collation mechanism itself is sybil-resistant, as it is a spam protection
196-
/// mechanism used to prevent nodes from dealing with unbounded numbers of blocks. For sybil-resistant
197-
/// collation mechanisms, this will only slow things down.
196+
/// This is not required when the collation mechanism itself is sybil-resistant, as it is a spam
197+
/// protection mechanism used to prevent nodes from dealing with unbounded numbers of blocks. For
198+
/// sybil-resistant collation mechanisms, this will only slow things down.
198199
///
199200
/// This block announce validator is required if the parachain is running
200201
/// with the relay chain provided consensus to make sure each node only
@@ -472,8 +473,8 @@ impl AssumeSybilResistance {
472473
/// announcements which come tagged with seconded messages.
473474
///
474475
/// This is useful for backwards compatibility when upgrading nodes: old nodes will continue
475-
/// to broadcast announcements with seconded messages, so these announcements shouldn't be rejected
476-
/// and the peers not punished.
476+
/// to broadcast announcements with seconded messages, so these announcements shouldn't be
477+
/// rejected and the peers not punished.
477478
pub fn allow_seconded_messages() -> Self {
478479
AssumeSybilResistance(true)
479480
}

cumulus/client/pov-recovery/src/lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919
//! A parachain needs to build PoVs that are send to the relay chain to progress. These PoVs are
2020
//! erasure encoded and one piece of it is stored by each relay chain validator. As the relay chain
2121
//! decides on which PoV per parachain to include and thus, to progess the parachain it can happen
22-
//! that the block corresponding to this PoV isn't propagated in the parachain network. This can have
23-
//! several reasons, either a malicious collator that managed to include its own PoV and doesn't want
24-
//! to share it with the rest of the network or maybe a collator went down before it could distribute
25-
//! the block in the network. When something like this happens we can use the PoV recovery algorithm
26-
//! implemented in this crate to recover a PoV and to propagate it with the rest of the network.
22+
//! that the block corresponding to this PoV isn't propagated in the parachain network. This can
23+
//! have several reasons, either a malicious collator that managed to include its own PoV and
24+
//! doesn't want to share it with the rest of the network or maybe a collator went down before it
25+
//! could distribute the block in the network. When something like this happens we can use the PoV
26+
//! recovery algorithm implemented in this crate to recover a PoV and to propagate it with the rest
27+
//! of the network.
2728
//!
2829
//! It works in the following way:
2930
//!
3031
//! 1. For every included relay chain block we note the backed candidate of our parachain. If the
3132
//! block belonging to the PoV is already known, we do nothing. Otherwise we start
32-
//! a timer that waits for a randomized time inside a specified interval before starting to recover
33-
//! the PoV.
33+
//! a timer that waits for a randomized time inside a specified interval before starting to
34+
//! recover the PoV.
3435
//!
3536
//! 2. If between starting and firing the timer the block is imported, we skip the recovery of the
3637
//! PoV.
@@ -39,8 +40,8 @@
3940
//!
4041
//! 4a. After it is recovered, we restore the block and import it.
4142
//!
42-
//! 4b. Since we are trying to recover pending candidates, availability is not guaranteed. If the block
43-
//! PoV is not yet available, we retry.
43+
//! 4b. Since we are trying to recover pending candidates, availability is not guaranteed. If the
44+
//! block PoV is not yet available, we retry.
4445
//!
4546
//! If we need to recover multiple PoV blocks (which should hopefully not happen in real life), we
4647
//! make sure that the blocks are imported in the correct order.

0 commit comments

Comments
 (0)