* Add clippy config and remove .cargo from gitignore

* first fixes

* Clippyfied

* Add clippy CI job

* comment out rusty-cachier

* minor

* fix ci

* remove DAG from check-dependent-project

* add DAG to clippy

Co-authored-by: alvicsam <alvicsam@gmail.com>
This commit is contained in:
alexgparity
2022-11-30 09:34:06 +01:00
committed by GitHub
parent b76086c617
commit 9ea14e66c8
67 changed files with 338 additions and 351 deletions
@@ -282,8 +282,8 @@ impl State {
/// Constructs an infinite iterator from an array of `TrancheEntry` values. Any missing tranches
/// are filled with empty assignments, as they are needed to compute the approved tranches.
fn filled_tranche_iterator<'a>(
tranches: &'a [TrancheEntry],
fn filled_tranche_iterator(
tranches: &[TrancheEntry],
) -> impl Iterator<Item = (DelayTranche, &[(ValidatorIndex, Tick)])> {
let mut gap_end = None;
@@ -155,10 +155,10 @@ impl<'a> From<&'a SessionInfo> for Config {
Config {
assignment_keys: s.assignment_keys.clone(),
validator_groups: s.validator_groups.clone(),
n_cores: s.n_cores.clone(),
zeroth_delay_tranche_width: s.zeroth_delay_tranche_width.clone(),
relay_vrf_modulo_samples: s.relay_vrf_modulo_samples.clone(),
n_delay_tranches: s.n_delay_tranches.clone(),
n_cores: s.n_cores,
zeroth_delay_tranche_width: s.zeroth_delay_tranche_width,
relay_vrf_modulo_samples: s.relay_vrf_modulo_samples,
n_delay_tranches: s.n_delay_tranches,
}
}
}
@@ -415,11 +415,8 @@ pub(crate) async fn handle_new_head<Context, B: Backend>(
Err(error) => {
// It's possible that we've lost a race with finality.
let (tx, rx) = oneshot::channel();
ctx.send_message(ChainApiMessage::FinalizedBlockHash(
block_header.number.clone(),
tx,
))
.await;
ctx.send_message(ChainApiMessage::FinalizedBlockHash(block_header.number, tx))
.await;
let lost_to_finality = match rx.await {
Ok(Ok(Some(h))) if h != block_hash => true,
@@ -621,10 +621,7 @@ impl CurrentlyCheckingSet {
.candidate_hash_map
.remove(&approval_state.candidate_hash)
.unwrap_or_default();
approvals_cache.put(
approval_state.candidate_hash.clone(),
approval_state.approval_outcome.clone(),
);
approvals_cache.put(approval_state.candidate_hash, approval_state.approval_outcome);
return (out, approval_state)
}
}
@@ -768,7 +765,7 @@ async fn run<B, Context>(
where
B: Backend,
{
if let Err(err) = db_sanity_check(subsystem.db.clone(), subsystem.db_config.clone()) {
if let Err(err) = db_sanity_check(subsystem.db.clone(), subsystem.db_config) {
gum::warn!(target: LOG_TARGET, ?err, "Could not run approval vote DB sanity check");
}
@@ -1278,7 +1275,7 @@ async fn get_approval_signatures_for_candidate<Context>(
Some(e) => e,
};
let relay_hashes = entry.block_assignments.iter().map(|(relay_hash, _)| relay_hash);
let relay_hashes = entry.block_assignments.keys();
let mut candidate_indices = HashSet::new();
// Retrieve `CoreIndices`/`CandidateIndices` as required by approval-distribution:
@@ -2502,7 +2499,7 @@ async fn issue_approval<Context>(
};
let candidate_hash = match block_entry.candidate(candidate_index as usize) {
Some((_, h)) => h.clone(),
Some((_, h)) => *h,
None => {
gum::warn!(
target: LOG_TARGET,
+1 -1
View File
@@ -61,7 +61,7 @@ const PRUNE_BY_TIME_PREFIX: &[u8; 13] = b"prune_by_time";
// We have some keys we want to map to empty values because existence of the key is enough. We use this because
// rocksdb doesn't support empty values.
const TOMBSTONE_VALUE: &[u8] = &*b" ";
const TOMBSTONE_VALUE: &[u8] = b" ";
/// Unavailable blocks are kept for 1 hour.
const KEEP_UNAVAILABLE_FOR: Duration = Duration::from_secs(60 * 60);
+2 -4
View File
@@ -482,9 +482,7 @@ impl TableContextTrait for TableContext {
}
fn is_member_of(&self, authority: &ValidatorIndex, group: &ParaId) -> bool {
self.groups
.get(group)
.map_or(false, |g| g.iter().position(|a| a == authority).is_some())
self.groups.get(group).map_or(false, |g| g.iter().any(|a| a == authority))
}
fn requisite_votes(&self, group: &ParaId) -> usize {
@@ -499,7 +497,7 @@ struct InvalidErasureRoot;
fn primitive_statement_to_table(s: &SignedFullStatement) -> TableSignedStatement {
let statement = match s.payload() {
Statement::Seconded(c) => TableStatement::Seconded(c.clone()),
Statement::Valid(h) => TableStatement::Valid(h.clone()),
Statement::Valid(h) => TableStatement::Valid(*h),
};
TableSignedStatement {
@@ -502,7 +502,7 @@ async fn validate_candidate_exhaustive(
let _timer = metrics.time_validate_candidate_exhaustive();
let validation_code_hash = validation_code.hash();
let para_id = candidate_receipt.descriptor.para_id.clone();
let para_id = candidate_receipt.descriptor.para_id;
gum::debug!(
target: LOG_TARGET,
?validation_code_hash,
@@ -513,7 +513,7 @@ async fn validate_candidate_exhaustive(
if let Err(e) = perform_basic_checks(
&candidate_receipt.descriptor,
persisted_validation_data.max_pov_size,
&*pov,
&pov,
&validation_code_hash,
) {
gum::info!(target: LOG_TARGET, ?para_id, "Invalid candidate (basic checks)");
@@ -381,6 +381,7 @@ async fn run<Context, B>(
) where
B: Backend,
{
#![allow(clippy::all)]
loop {
let res = run_until_error(
&mut ctx,
@@ -169,7 +169,7 @@ impl CandidateVoteState<CandidateVotes> {
}
/// Create a new `CandidateVoteState` from already existing votes.
pub fn new<'a>(votes: CandidateVotes, env: &CandidateEnvironment<'a>, now: Timestamp) -> Self {
pub fn new(votes: CandidateVotes, env: &CandidateEnvironment, now: Timestamp) -> Self {
let own_vote = OwnVoteState::new(&votes, env);
let n_validators = env.validators().len();
@@ -713,20 +713,22 @@ impl Initialized {
return Ok(ImportStatementsResult::InvalidImport)
}
let env =
match CandidateEnvironment::new(&*self.keystore, &self.rolling_session_window, session)
{
None => {
gum::warn!(
target: LOG_TARGET,
session,
"We are lacking a `SessionInfo` for handling import of statements."
);
let env = match CandidateEnvironment::new(
&self.keystore,
&self.rolling_session_window,
session,
) {
None => {
gum::warn!(
target: LOG_TARGET,
session,
"We are lacking a `SessionInfo` for handling import of statements."
);
return Ok(ImportStatementsResult::InvalidImport)
},
Some(env) => env,
};
return Ok(ImportStatementsResult::InvalidImport)
},
Some(env) => env,
};
let candidate_hash = candidate_receipt.hash();
@@ -1075,20 +1077,22 @@ impl Initialized {
"Issuing local statement for candidate!"
);
// Load environment:
let env =
match CandidateEnvironment::new(&*self.keystore, &self.rolling_session_window, session)
{
None => {
gum::warn!(
target: LOG_TARGET,
session,
"Missing info for session which has an active dispute",
);
let env = match CandidateEnvironment::new(
&self.keystore,
&self.rolling_session_window,
session,
) {
None => {
gum::warn!(
target: LOG_TARGET,
session,
"Missing info for session which has an active dispute",
);
return Ok(())
},
Some(env) => env,
};
return Ok(())
},
Some(env) => env,
};
let votes = overlay_db
.load_candidate_votes(session, &candidate_hash)?
@@ -1257,7 +1261,7 @@ fn make_dispute_message(
votes.invalid.iter().next().ok_or(DisputeMessageCreationError::NoOppositeVote)?;
let other_vote = SignedDisputeStatement::new_checked(
DisputeStatement::Invalid(*statement_kind),
our_vote.candidate_hash().clone(),
*our_vote.candidate_hash(),
our_vote.session_index(),
validators
.get(*validator_index)
@@ -1272,7 +1276,7 @@ fn make_dispute_message(
votes.valid.iter().next().ok_or(DisputeMessageCreationError::NoOppositeVote)?;
let other_vote = SignedDisputeStatement::new_checked(
DisputeStatement::Valid(*statement_kind),
our_vote.candidate_hash().clone(),
*our_vote.candidate_hash(),
our_vote.session_index(),
validators
.get(*validator_index)
@@ -235,7 +235,7 @@ impl Participation {
req: ParticipationRequest,
recent_head: Hash,
) -> FatalResult<()> {
if self.running_participations.insert(req.candidate_hash().clone()) {
if self.running_participations.insert(*req.candidate_hash()) {
let sender = ctx.sender().clone();
ctx.spawn(
"participation-worker",
@@ -204,7 +204,7 @@ impl Queues {
// Once https://github.com/rust-lang/rust/issues/62924 is there, we can use a simple:
// target.pop_first().
if let Some((comparator, _)) = target.iter().next() {
let comparator = comparator.clone();
let comparator = *comparator;
target
.remove(&comparator)
.map(|participation_request| (comparator, participation_request))
@@ -99,7 +99,7 @@ where
);
// Fetch the onchain disputes. We'll do a prioritization based on them.
let onchain = match get_onchain_disputes(sender, leaf.hash.clone()).await {
let onchain = match get_onchain_disputes(sender, leaf.hash).await {
Ok(r) => r,
Err(GetOnchainDisputesError::NotSupported(runtime_api_err, relay_parent)) => {
// Runtime version is checked before calling this method, so the error below should never happen!
+2 -2
View File
@@ -373,7 +373,7 @@ async fn send_inherent_data(
let disputes = match has_required_runtime(
from_job,
leaf.hash.clone(),
leaf.hash,
PRIORITIZED_SELECTION_RUNTIME_VERSION_REQUIREMENT,
)
.await
@@ -506,7 +506,7 @@ fn select_availability_bitfields(
bitfields.len()
);
selected.into_iter().map(|(_, b)| b).collect()
selected.into_values().collect()
}
/// Determine which cores are free, and then to the degree possible, pick a candidate appropriate to each free core.
+1 -3
View File
@@ -225,10 +225,8 @@ fn handle_job_finish(
result_tx: ResultSender,
) {
let (idle_worker, result) = match outcome {
Outcome::Ok { result_descriptor, duration_ms, idle_worker } => {
Outcome::Ok { result_descriptor, duration_ms: _, idle_worker } => {
// TODO: propagate the soft timeout
drop(duration_ms);
(Some(idle_worker), Ok(result_descriptor))
},
Outcome::InvalidCandidate { err, idle_worker } => (
+1 -1
View File
@@ -424,7 +424,7 @@ impl sp_core::traits::ReadRuntimeVersion for ReadRuntimeVersion {
use parity_scale_codec::Encode;
Ok(version.encode())
},
None => Err(format!("runtime version section is not found")),
None => Err("runtime version section is not found".to_string()),
}
}
}
+1 -1
View File
@@ -219,7 +219,7 @@ async fn send_request(
code: Arc<Vec<u8>>,
tmp_file: &Path,
) -> io::Result<()> {
framed_send(stream, &*code).await?;
framed_send(stream, &code).await?;
framed_send(stream, path_to_bytes(tmp_file)).await?;
Ok(())
}
+1 -1
View File
@@ -34,7 +34,7 @@ pub fn validate_candidate(
let code = sp_maybe_compressed_blob::decompress(code, 10 * 1024 * 1024)
.expect("Decompressing code failed");
let blob = prevalidate(&*code)?;
let blob = prevalidate(&code)?;
let artifact = prepare(blob)?;
let tmpdir = tempfile::tempdir()?;
let artifact_path = tmpdir.path().join("blob");
+1 -1
View File
@@ -268,7 +268,7 @@ where
let (sender, receiver) = oneshot::channel();
// TODO: make the cache great again https://github.com/paritytech/polkadot/issues/5546
let request = match self.query_cache(relay_parent.clone(), request) {
let request = match self.query_cache(relay_parent, request) {
Some(request) => request,
None => return,
};