mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 08:41:07 +00:00
Fix Clippy (#2522)
* Import Clippy config from Polkadot Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Auto clippy fix Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * No tabs in comments Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Prefer matches Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Dont drop references Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Trivial Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Refactor Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * add clippy to ci * Clippy reborrow Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update client/pov-recovery/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/pov-recovery/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Partially revert 'Prefer matches' Using matches! instead of match does give less compiler checks as per review from @chevdor. Partially reverts 8c0609677f3ea040f77fffd5be6facf7c3fec95c Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Update .cargo/config.toml Co-authored-by: Chevdor <chevdor@users.noreply.github.com> * Revert revert 💩 Should be fine to use matches! macro since it is an explicit whitelist, not wildcard matching. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: alvicsam <alvicsam@gmail.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Chevdor <chevdor@users.noreply.github.com> Co-authored-by: parity-processbot <>
This commit is contained in:
committed by
GitHub
parent
4dc50c8d89
commit
c312f0b9a6
@@ -93,7 +93,7 @@ impl PurgeChainCmd {
|
||||
io::stdin().read_line(&mut input)?;
|
||||
let input = input.trim();
|
||||
|
||||
match input.chars().nth(0) {
|
||||
match input.chars().next() {
|
||||
Some('y') | Some('Y') => {},
|
||||
_ => {
|
||||
println!("Aborted");
|
||||
@@ -103,7 +103,7 @@ impl PurgeChainCmd {
|
||||
}
|
||||
|
||||
for db_path in &db_paths {
|
||||
match fs::remove_dir_all(&db_path) {
|
||||
match fs::remove_dir_all(db_path) {
|
||||
Ok(_) => {
|
||||
println!("{:?} removed.", &db_path);
|
||||
},
|
||||
|
||||
+13
-17
@@ -270,16 +270,14 @@ where
|
||||
|
||||
let (header, extrinsics) = candidate.block.deconstruct();
|
||||
|
||||
let compact_proof = match candidate
|
||||
.proof
|
||||
.into_compact_proof::<HashFor<Block>>(last_head.state_root().clone())
|
||||
{
|
||||
Ok(proof) => proof,
|
||||
Err(e) => {
|
||||
tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e);
|
||||
return None
|
||||
},
|
||||
};
|
||||
let compact_proof =
|
||||
match candidate.proof.into_compact_proof::<HashFor<Block>>(*last_head.state_root()) {
|
||||
Ok(proof) => proof,
|
||||
Err(e) => {
|
||||
tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e);
|
||||
return None
|
||||
},
|
||||
};
|
||||
|
||||
// Create the parachain block data for the validators.
|
||||
let b = ParachainBlockData::<Block>::new(header, extrinsics, compact_proof);
|
||||
@@ -451,7 +449,7 @@ mod tests {
|
||||
.build()
|
||||
.expect("Builds overseer");
|
||||
|
||||
spawner.spawn("overseer", None, overseer.run().then(|_| async { () }).boxed());
|
||||
spawner.spawn("overseer", None, overseer.run().then(|_| async {}).boxed());
|
||||
|
||||
let collator_start = start_collator(StartCollatorParams {
|
||||
runtime_api: client.clone(),
|
||||
@@ -461,7 +459,7 @@ mod tests {
|
||||
spawner,
|
||||
para_id,
|
||||
key: CollatorPair::generate().0,
|
||||
parachain_consensus: Box::new(DummyParachainConsensus { client: client.clone() }),
|
||||
parachain_consensus: Box::new(DummyParachainConsensus { client }),
|
||||
});
|
||||
block_on(collator_start);
|
||||
|
||||
@@ -469,12 +467,10 @@ mod tests {
|
||||
.0
|
||||
.expect("message should be send by `start_collator` above.");
|
||||
|
||||
let config = match msg {
|
||||
CollationGenerationMessage::Initialize(config) => config,
|
||||
};
|
||||
let CollationGenerationMessage::Initialize(config) = msg;
|
||||
|
||||
let mut validation_data = PersistedValidationData::default();
|
||||
validation_data.parent_head = header.encode().into();
|
||||
let validation_data =
|
||||
PersistedValidationData { parent_head: header.encode().into(), ..Default::default() };
|
||||
let relay_parent = Default::default();
|
||||
|
||||
let collation = block_on((config.collator)(relay_parent, &validation_data))
|
||||
|
||||
@@ -51,7 +51,7 @@ pub struct ImportQueueParams<'a, I, C, CIDP, S> {
|
||||
}
|
||||
|
||||
/// Start an import queue for the Aura consensus algorithm.
|
||||
pub fn import_queue<'a, P, Block, I, C, S, CIDP>(
|
||||
pub fn import_queue<P, Block, I, C, S, CIDP>(
|
||||
ImportQueueParams {
|
||||
block_import,
|
||||
client,
|
||||
@@ -59,7 +59,7 @@ pub fn import_queue<'a, P, Block, I, C, S, CIDP>(
|
||||
spawner,
|
||||
registry,
|
||||
telemetry,
|
||||
}: ImportQueueParams<'a, I, C, CIDP, S>,
|
||||
}: ImportQueueParams<'_, I, C, CIDP, S>,
|
||||
) -> Result<DefaultImportQueue<Block, C>, sp_consensus::Error>
|
||||
where
|
||||
Block: BlockT,
|
||||
|
||||
@@ -22,7 +22,7 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
const LOG_TARGET: &'static str = "level-monitor";
|
||||
const LOG_TARGET: &str = "level-monitor";
|
||||
|
||||
/// Value good enough to be used with parachains using the current backend implementation
|
||||
/// that ships with Substrate. This value may change in the future.
|
||||
|
||||
@@ -325,7 +325,6 @@ async fn handle_new_block_imported<Block, P>(
|
||||
|
||||
match parachain.block_status(unset_hash) {
|
||||
Ok(BlockStatus::InChainWithState) => {
|
||||
drop(unset_best_header);
|
||||
let unset_best_header = unset_best_header_opt
|
||||
.take()
|
||||
.expect("We checked above that the value is set; qed");
|
||||
@@ -433,8 +432,11 @@ async fn handle_new_best_parachain_head<Block, P>(
|
||||
}
|
||||
}
|
||||
|
||||
async fn import_block_as_new_best<Block, P>(hash: Block::Hash, header: Block::Header, parachain: &P)
|
||||
where
|
||||
async fn import_block_as_new_best<Block, P>(
|
||||
hash: Block::Hash,
|
||||
header: Block::Header,
|
||||
mut parachain: &P,
|
||||
) where
|
||||
Block: BlockT,
|
||||
P: UsageProvider<Block> + Send + Sync + BlockBackend<Block>,
|
||||
for<'a> &'a P: BlockImport<Block>,
|
||||
@@ -456,7 +458,7 @@ where
|
||||
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true));
|
||||
block_import_params.import_existing = true;
|
||||
|
||||
if let Err(err) = (&*parachain).import_block(block_import_params).await {
|
||||
if let Err(err) = parachain.import_block(block_import_params).await {
|
||||
tracing::warn!(
|
||||
target: LOG_TARGET,
|
||||
block_hash = ?hash,
|
||||
|
||||
@@ -337,7 +337,7 @@ fn follow_new_best_with_dummy_recovery_works() {
|
||||
Some(recovery_chan_tx),
|
||||
);
|
||||
|
||||
let block = build_block(&*client.clone(), None, None);
|
||||
let block = build_block(&*client, None, None);
|
||||
let block_clone = block.clone();
|
||||
let client_clone = client.clone();
|
||||
|
||||
@@ -547,7 +547,6 @@ fn do_not_set_best_block_to_older_block() {
|
||||
let client = Arc::new(TestClientBuilder::with_backend(backend).build());
|
||||
|
||||
let blocks = (0..NUM_BLOCKS)
|
||||
.into_iter()
|
||||
.map(|_| build_and_import_block(client.clone(), true))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -559,7 +558,6 @@ fn do_not_set_best_block_to_older_block() {
|
||||
let consensus =
|
||||
run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}), None);
|
||||
|
||||
let client2 = client.clone();
|
||||
let work = async move {
|
||||
new_best_heads_sender
|
||||
.unbounded_send(blocks[NUM_BLOCKS - 2].header().clone())
|
||||
@@ -579,7 +577,7 @@ fn do_not_set_best_block_to_older_block() {
|
||||
});
|
||||
|
||||
// Build and import a new best block.
|
||||
build_and_import_block(client2.clone(), true);
|
||||
build_and_import_block(client, true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -607,7 +605,6 @@ fn prune_blocks_on_level_overflow() {
|
||||
let id0 = block0.header.hash();
|
||||
|
||||
let blocks1 = (0..LEVEL_LIMIT)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
build_and_import_block_ext(
|
||||
&*client,
|
||||
@@ -622,7 +619,6 @@ fn prune_blocks_on_level_overflow() {
|
||||
let id10 = blocks1[0].header.hash();
|
||||
|
||||
let blocks2 = (0..2)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
build_and_import_block_ext(
|
||||
&*client,
|
||||
@@ -720,7 +716,6 @@ fn restore_limit_monitor() {
|
||||
let id00 = block00.header.hash();
|
||||
|
||||
let blocks1 = (0..LEVEL_LIMIT + 1)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
build_and_import_block_ext(
|
||||
&*client,
|
||||
@@ -735,7 +730,6 @@ fn restore_limit_monitor() {
|
||||
let id10 = blocks1[0].header.hash();
|
||||
|
||||
let _ = (0..LEVEL_LIMIT)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
build_and_import_block_ext(
|
||||
&*client,
|
||||
|
||||
@@ -161,7 +161,7 @@ where
|
||||
relay_parent: PHash,
|
||||
validation_data: &PersistedValidationData,
|
||||
) -> Option<ParachainCandidate<B>> {
|
||||
let proposer_future = self.proposer_factory.lock().init(&parent);
|
||||
let proposer_future = self.proposer_factory.lock().init(parent);
|
||||
|
||||
let proposer = proposer_future
|
||||
.await
|
||||
@@ -171,7 +171,7 @@ where
|
||||
.ok()?;
|
||||
|
||||
let inherent_data =
|
||||
self.inherent_data(parent.hash(), &validation_data, relay_parent).await?;
|
||||
self.inherent_data(parent.hash(), validation_data, relay_parent).await?;
|
||||
|
||||
let Proposal { block, storage_changes, proof } = proposer
|
||||
.propose(
|
||||
|
||||
@@ -129,7 +129,7 @@ impl RelayChainInterface for DummyRelayChainInterface {
|
||||
para_id: 0u32.into(),
|
||||
relay_parent: PHash::random(),
|
||||
collator: CollatorPair::generate().0.public(),
|
||||
persisted_validation_data_hash: PHash::random().into(),
|
||||
persisted_validation_data_hash: PHash::random(),
|
||||
pov_hash: PHash::random(),
|
||||
erasure_root: PHash::random(),
|
||||
signature: sp_core::sr25519::Signature([0u8; 64]).into(),
|
||||
@@ -293,7 +293,7 @@ async fn make_gossip_message_and_header(
|
||||
para_id: 0u32.into(),
|
||||
relay_parent,
|
||||
collator: CollatorPair::generate().0.public(),
|
||||
persisted_validation_data_hash: PHash::random().into(),
|
||||
persisted_validation_data_hash: PHash::random(),
|
||||
pov_hash: PHash::random(),
|
||||
erasure_root: PHash::random(),
|
||||
signature: sp_core::sr25519::Signature([0u8; 64]).into(),
|
||||
@@ -484,7 +484,7 @@ async fn check_statement_seconded() {
|
||||
para_id: 0u32.into(),
|
||||
relay_parent: PHash::random(),
|
||||
collator: CollatorPair::generate().0.public(),
|
||||
persisted_validation_data_hash: PHash::random().into(),
|
||||
persisted_validation_data_hash: PHash::random(),
|
||||
pov_hash: PHash::random(),
|
||||
erasure_root: PHash::random(),
|
||||
signature: sp_core::sr25519::Signature([0u8; 64]).into(),
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
//! 4a. After it is recovered, we restore the block and import it.
|
||||
//!
|
||||
//! 4b. Since we are trying to recover pending candidates, availability is not guaranteed. If the block
|
||||
//! PoV is not yet available, we retry.
|
||||
//! PoV is not yet available, we retry.
|
||||
//!
|
||||
//! If we need to recover multiple PoV blocks (which should hopefully not happen in real life), we
|
||||
//! make sure that the blocks are imported in the correct order.
|
||||
@@ -190,7 +190,7 @@ impl<Block: BlockT> RecoveryQueue<Block> {
|
||||
/// Get the next hash for block recovery.
|
||||
pub async fn next_recovery(&mut self) -> Block::Hash {
|
||||
loop {
|
||||
if let Some(_) = self.signaling_queue.next().await {
|
||||
if self.signaling_queue.next().await.is_some() {
|
||||
if let Some(hash) = self.recovery_queue.pop_front() {
|
||||
return hash
|
||||
} else {
|
||||
@@ -309,10 +309,10 @@ where
|
||||
|
||||
/// Block is no longer waiting for recovery
|
||||
fn clear_waiting_recovery(&mut self, block_hash: &Block::Hash) {
|
||||
self.candidates.get_mut(block_hash).map(|candidate| {
|
||||
if let Some(candidate) = self.candidates.get_mut(block_hash) {
|
||||
// Prevents triggering an already enqueued recovery request
|
||||
candidate.waiting_recovery = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle a finalized block with the given `block_number`.
|
||||
|
||||
@@ -241,7 +241,7 @@ where
|
||||
self.full_client
|
||||
.import_notification_stream()
|
||||
.filter_map(|notification| async move {
|
||||
notification.is_new_best.then(|| notification.header)
|
||||
notification.is_new_best.then_some(notification.header)
|
||||
});
|
||||
Ok(Box::pin(notifications_stream))
|
||||
}
|
||||
@@ -428,7 +428,7 @@ mod tests {
|
||||
(
|
||||
client.clone(),
|
||||
block,
|
||||
RelayChainInProcessInterface::new(client, backend.clone(), dummy_network, mock_handle),
|
||||
RelayChainInProcessInterface::new(client, backend, dummy_network, mock_handle),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ mod tests {
|
||||
let hash = block.hash();
|
||||
|
||||
let ext = construct_transfer_extrinsic(
|
||||
&*client,
|
||||
&client,
|
||||
sp_keyring::Sr25519Keyring::Alice,
|
||||
sp_keyring::Sr25519Keyring::Bob,
|
||||
1000,
|
||||
|
||||
@@ -76,7 +76,7 @@ pub(crate) struct CollatorOverseerGenArgs<'a> {
|
||||
pub peer_set_protocol_names: PeerSetProtocolNames,
|
||||
}
|
||||
|
||||
fn build_overseer<'a>(
|
||||
fn build_overseer(
|
||||
connector: OverseerConnector,
|
||||
CollatorOverseerGenArgs {
|
||||
runtime_client,
|
||||
@@ -90,7 +90,7 @@ fn build_overseer<'a>(
|
||||
collator_pair,
|
||||
req_protocol_names,
|
||||
peer_set_protocol_names,
|
||||
}: CollatorOverseerGenArgs<'a>,
|
||||
}: CollatorOverseerGenArgs<'_>,
|
||||
) -> Result<
|
||||
(Overseer<SpawnGlue<sc_service::SpawnTaskHandle>, Arc<BlockChainRpcClient>>, OverseerHandle),
|
||||
RelayChainError,
|
||||
|
||||
@@ -441,7 +441,7 @@ where
|
||||
)
|
||||
.await
|
||||
.map_err(|e| format!("{e:?}"))?
|
||||
.ok_or_else(|| "Could not find parachain head in relay chain")?;
|
||||
.ok_or("Could not find parachain head in relay chain")?;
|
||||
|
||||
let target_block = B::Header::decode(&mut &validation_data.parent_head.0[..])
|
||||
.map_err(|e| format!("Failed to decode parachain head: {e}"))?;
|
||||
|
||||
Reference in New Issue
Block a user