mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 13:21:10 +00:00
Clippyfy (#6341)
* 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:
@@ -247,12 +247,9 @@ pub mod pallet {
|
||||
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
|
||||
fn build(&self) {
|
||||
// build `Claims`
|
||||
self.claims
|
||||
.iter()
|
||||
.map(|(a, b, _, _)| (a.clone(), b.clone()))
|
||||
.for_each(|(a, b)| {
|
||||
Claims::<T>::insert(a, b);
|
||||
});
|
||||
self.claims.iter().map(|(a, b, _, _)| (*a, *b)).for_each(|(a, b)| {
|
||||
Claims::<T>::insert(a, b);
|
||||
});
|
||||
// build `Total`
|
||||
Total::<T>::put(
|
||||
self.claims
|
||||
@@ -266,17 +263,16 @@ pub mod pallet {
|
||||
// build `Signing`
|
||||
self.claims
|
||||
.iter()
|
||||
.filter_map(|(a, _, _, s)| Some((a.clone(), s.clone()?)))
|
||||
.filter_map(|(a, _, _, s)| Some((*a, (*s)?)))
|
||||
.for_each(|(a, s)| {
|
||||
Signing::<T>::insert(a, s);
|
||||
});
|
||||
// build `Preclaims`
|
||||
self.claims
|
||||
.iter()
|
||||
.filter_map(|(a, _, i, _)| Some((i.clone()?, a.clone())))
|
||||
.for_each(|(i, a)| {
|
||||
self.claims.iter().filter_map(|(a, _, i, _)| Some((i.clone()?, *a))).for_each(
|
||||
|(i, a)| {
|
||||
Preclaims::<T>::insert(i, a);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +534,7 @@ impl<T: Config> Pallet<T> {
|
||||
}
|
||||
let mut v = b"\x19Ethereum Signed Message:\n".to_vec();
|
||||
v.extend(rev.into_iter().rev());
|
||||
v.extend_from_slice(&prefix[..]);
|
||||
v.extend_from_slice(prefix);
|
||||
v.extend_from_slice(what);
|
||||
v.extend_from_slice(extra);
|
||||
v
|
||||
@@ -645,7 +641,7 @@ where
|
||||
info: &DispatchInfoOf<Self::Call>,
|
||||
len: usize,
|
||||
) -> Result<Self::Pre, TransactionValidityError> {
|
||||
Ok(self.validate(who, call, info, len).map(|_| ())?)
|
||||
self.validate(who, call, info, len).map(|_| ())
|
||||
}
|
||||
|
||||
// <weight>
|
||||
|
||||
@@ -67,12 +67,10 @@ pub mod crowdloan_index_migration {
|
||||
|
||||
let leases = Leases::<T>::get(para_id).unwrap_or_default();
|
||||
let mut found_lease_deposit = false;
|
||||
for maybe_deposit in leases.iter() {
|
||||
if let Some((who, _amount)) = maybe_deposit {
|
||||
if *who == old_fund_account {
|
||||
found_lease_deposit = true;
|
||||
break
|
||||
}
|
||||
for (who, _amount) in leases.iter().flatten() {
|
||||
if *who == old_fund_account {
|
||||
found_lease_deposit = true;
|
||||
break
|
||||
}
|
||||
}
|
||||
if found_lease_deposit {
|
||||
@@ -112,11 +110,9 @@ pub mod crowdloan_index_migration {
|
||||
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 2));
|
||||
|
||||
let mut leases = Leases::<T>::get(para_id).unwrap_or_default();
|
||||
for maybe_deposit in leases.iter_mut() {
|
||||
if let Some((who, _amount)) = maybe_deposit {
|
||||
if *who == old_fund_account {
|
||||
*who = new_fund_account.clone();
|
||||
}
|
||||
for (who, _amount) in leases.iter_mut().flatten() {
|
||||
if *who == old_fund_account {
|
||||
*who = new_fund_account.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,13 +158,11 @@ pub mod crowdloan_index_migration {
|
||||
|
||||
let leases = Leases::<T>::get(para_id).unwrap_or_default();
|
||||
let mut new_account_found = false;
|
||||
for maybe_deposit in leases.iter() {
|
||||
if let Some((who, _amount)) = maybe_deposit {
|
||||
if *who == old_fund_account {
|
||||
panic!("Old fund account found after migration!");
|
||||
} else if *who == new_fund_account {
|
||||
new_account_found = true;
|
||||
}
|
||||
for (who, _amount) in leases.iter().flatten() {
|
||||
if *who == old_fund_account {
|
||||
panic!("Old fund account found after migration!");
|
||||
} else if *who == new_fund_account {
|
||||
new_account_found = true;
|
||||
}
|
||||
}
|
||||
if new_account_found {
|
||||
|
||||
@@ -31,18 +31,16 @@ pub mod slots_crowdloan_index_migration {
|
||||
for (para_id, leases) in Leases::<T>::iter() {
|
||||
let old_fund_account = old_fund_account_id::<T>(para_id);
|
||||
|
||||
for maybe_deposit in leases.iter() {
|
||||
if let Some((who, _amount)) = maybe_deposit {
|
||||
if *who == old_fund_account {
|
||||
let crowdloan =
|
||||
crowdloan::Funds::<T>::get(para_id).ok_or("no crowdloan found")?;
|
||||
log::info!(
|
||||
target: "runtime",
|
||||
"para_id={:?}, old_fund_account={:?}, fund_id={:?}, leases={:?}",
|
||||
para_id, old_fund_account, crowdloan.fund_index, leases,
|
||||
);
|
||||
break
|
||||
}
|
||||
for (who, _amount) in leases.iter().flatten() {
|
||||
if *who == old_fund_account {
|
||||
let crowdloan =
|
||||
crowdloan::Funds::<T>::get(para_id).ok_or("no crowdloan found")?;
|
||||
log::info!(
|
||||
target: "runtime",
|
||||
"para_id={:?}, old_fund_account={:?}, fund_id={:?}, leases={:?}",
|
||||
para_id, old_fund_account, crowdloan.fund_index, leases,
|
||||
);
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,11 +59,9 @@ pub mod slots_crowdloan_index_migration {
|
||||
let new_fund_account = crowdloan::Pallet::<T>::fund_account_id(fund.fund_index);
|
||||
|
||||
// look for places the old account is used, and replace with the new account.
|
||||
for maybe_deposit in leases.iter_mut() {
|
||||
if let Some((who, _amount)) = maybe_deposit {
|
||||
if *who == old_fund_account {
|
||||
*who = new_fund_account.clone();
|
||||
}
|
||||
for (who, _amount) in leases.iter_mut().flatten() {
|
||||
if *who == old_fund_account {
|
||||
*who = new_fund_account.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,11 +79,9 @@ pub mod slots_crowdloan_index_migration {
|
||||
let old_fund_account = old_fund_account_id::<T>(para_id);
|
||||
log::info!(target: "runtime", "checking para_id: {:?}", para_id);
|
||||
// check the old fund account doesn't exist anywhere.
|
||||
for maybe_deposit in leases.iter() {
|
||||
if let Some((who, _amount)) = maybe_deposit {
|
||||
if *who == old_fund_account {
|
||||
panic!("old fund account found after migration!");
|
||||
}
|
||||
for (who, _amount) in leases.iter().flatten() {
|
||||
if *who == old_fund_account {
|
||||
panic!("old fund account found after migration!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1112,7 +1112,7 @@ impl<T: Config> Pallet<T> {
|
||||
// it's sufficient to count the votes in the statement set after they
|
||||
set.statements.iter().for_each(|(statement, v_i, _signature)| {
|
||||
if Some(true) ==
|
||||
summary.new_participants.get(v_i.0 as usize).map(|b| b.as_ref().clone())
|
||||
summary.new_participants.get(v_i.0 as usize).map(|b| *b.as_ref())
|
||||
{
|
||||
match statement {
|
||||
// `summary.new_flags` contains the spam free votes.
|
||||
|
||||
@@ -751,10 +751,10 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
let ingress = <Self as Store>::HrmpIngressChannelsIndex::take(outgoing_para)
|
||||
.into_iter()
|
||||
.map(|sender| HrmpChannelId { sender, recipient: outgoing_para.clone() });
|
||||
.map(|sender| HrmpChannelId { sender, recipient: *outgoing_para });
|
||||
let egress = <Self as Store>::HrmpEgressChannelsIndex::take(outgoing_para)
|
||||
.into_iter()
|
||||
.map(|recipient| HrmpChannelId { sender: outgoing_para.clone(), recipient });
|
||||
.map(|recipient| HrmpChannelId { sender: *outgoing_para, recipient });
|
||||
let mut to_close = ingress.chain(egress).collect::<Vec<_>>();
|
||||
to_close.sort();
|
||||
to_close.dedup();
|
||||
@@ -1075,7 +1075,7 @@ impl<T: Config> Pallet<T> {
|
||||
channel.total_size += inbound.data.len() as u32;
|
||||
|
||||
// compute the new MQC head of the channel
|
||||
let prev_head = channel.mqc_head.clone().unwrap_or(Default::default());
|
||||
let prev_head = channel.mqc_head.unwrap_or(Default::default());
|
||||
let new_head = BlakeTwo256::hash_of(&(
|
||||
prev_head,
|
||||
inbound.sent_at,
|
||||
|
||||
@@ -102,7 +102,7 @@ impl<H, N> CandidatePendingAvailability<H, N> {
|
||||
|
||||
/// Get the core index.
|
||||
pub(crate) fn core_occupied(&self) -> CoreIndex {
|
||||
self.core.clone()
|
||||
self.core
|
||||
}
|
||||
|
||||
/// Get the candidate hash.
|
||||
@@ -383,7 +383,7 @@ impl<T: Config> Pallet<T> {
|
||||
let mut freed_cores = Vec::with_capacity(expected_bits);
|
||||
for (para_id, pending_availability) in assigned_paras_record
|
||||
.into_iter()
|
||||
.filter_map(|x| x)
|
||||
.flatten()
|
||||
.filter_map(|(id, p)| p.map(|p| (id, p)))
|
||||
{
|
||||
if pending_availability.availability_votes.count_ones() >= threshold {
|
||||
@@ -644,8 +644,7 @@ impl<T: Config> Pallet<T> {
|
||||
};
|
||||
|
||||
// one more sweep for actually writing to storage.
|
||||
let core_indices =
|
||||
core_indices_and_backers.iter().map(|&(ref c, _, _)| c.clone()).collect();
|
||||
let core_indices = core_indices_and_backers.iter().map(|&(ref c, _, _)| *c).collect();
|
||||
for (candidate, (core, backers, group)) in
|
||||
candidates.into_iter().zip(core_indices_and_backers)
|
||||
{
|
||||
|
||||
@@ -247,7 +247,7 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
let validators = shared::Pallet::<T>::initializer_on_new_session(
|
||||
session_index,
|
||||
random_seed.clone(),
|
||||
random_seed,
|
||||
&new_config,
|
||||
all_validators,
|
||||
);
|
||||
|
||||
@@ -513,7 +513,7 @@ impl<T: Config> Pallet<T> {
|
||||
METRICS.on_candidates_sanitized(backed_candidates.len() as u64);
|
||||
|
||||
// Process backed candidates according to scheduled cores.
|
||||
let parent_storage_root = parent_header.state_root().clone();
|
||||
let parent_storage_root = *parent_header.state_root();
|
||||
let inclusion::ProcessedCandidates::<<T::Header as HeaderT>::Hash> {
|
||||
core_indices: occupied,
|
||||
candidate_receipt_with_backing_validator_indices,
|
||||
@@ -711,7 +711,7 @@ impl<T: Config> Pallet<T> {
|
||||
let scheduled = <scheduler::Pallet<T>>::scheduled();
|
||||
|
||||
let relay_parent_number = now - One::one();
|
||||
let parent_storage_root = parent_header.state_root().clone();
|
||||
let parent_storage_root = *parent_header.state_root();
|
||||
|
||||
let check_ctx = CandidateCheckContext::<T>::new(now, relay_parent_number);
|
||||
let backed_candidates = sanitize_backed_candidates::<T, _>(
|
||||
@@ -1201,7 +1201,7 @@ fn compute_entropy<T: Config>(parent_hash: T::Hash) -> [u8; 32] {
|
||||
// known 2 epochs ago. it is marginally better than using the parent block
|
||||
// hash since it's harder to influence the VRF output than the block hash.
|
||||
let vrf_random = ParentBlockRandomness::<T>::random(&CANDIDATE_SEED_SUBJECT[..]).0;
|
||||
let mut entropy: [u8; 32] = CANDIDATE_SEED_SUBJECT.clone();
|
||||
let mut entropy: [u8; 32] = CANDIDATE_SEED_SUBJECT;
|
||||
if let Some(vrf_random) = vrf_random {
|
||||
entropy.as_mut().copy_from_slice(vrf_random.as_ref());
|
||||
} else {
|
||||
|
||||
@@ -107,7 +107,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
|
||||
<inclusion::Pallet<T>>::pending_availability(para_id)
|
||||
.expect("Occupied core always has pending availability; qed");
|
||||
|
||||
let backed_in_number = pending_availability.backed_in_number().clone();
|
||||
let backed_in_number = *pending_availability.backed_in_number();
|
||||
OccupiedCore {
|
||||
next_up_on_available: <scheduler::Pallet<T>>::next_up_on_available(
|
||||
CoreIndex(i as u32),
|
||||
@@ -135,7 +135,7 @@ pub fn availability_cores<T: initializer::Config>() -> Vec<CoreState<T::Hash, T:
|
||||
<inclusion::Pallet<T>>::pending_availability(para_id)
|
||||
.expect("Occupied core always has pending availability; qed");
|
||||
|
||||
let backed_in_number = pending_availability.backed_in_number().clone();
|
||||
let backed_in_number = *pending_availability.backed_in_number();
|
||||
OccupiedCore {
|
||||
next_up_on_available: <scheduler::Pallet<T>>::next_up_on_available(
|
||||
CoreIndex(i as u32),
|
||||
|
||||
@@ -483,7 +483,7 @@ impl<T: Config> Pallet<T> {
|
||||
Some(CoreAssignment {
|
||||
kind: AssignmentKind::Parachain,
|
||||
para_id: parachains[core_index],
|
||||
core: core.clone(),
|
||||
core,
|
||||
group_idx: Self::group_assigned_to_core(core, now).expect(
|
||||
"core is not out of bounds and we are guaranteed \
|
||||
to be after the most recent session start; qed",
|
||||
@@ -496,7 +496,7 @@ impl<T: Config> Pallet<T> {
|
||||
parathread_queue.take_next_on_core(core_offset).map(|entry| CoreAssignment {
|
||||
kind: AssignmentKind::Parathread(entry.claim.1, entry.retries),
|
||||
para_id: entry.claim.0,
|
||||
core: core.clone(),
|
||||
core,
|
||||
group_idx: Self::group_assigned_to_core(core, now).expect(
|
||||
"core is not out of bounds and we are guaranteed \
|
||||
to be after the most recent session start; qed",
|
||||
@@ -610,11 +610,9 @@ impl<T: Config> Pallet<T> {
|
||||
(at - session_start_block) / config.group_rotation_frequency.into();
|
||||
|
||||
let rotations_since_session_start =
|
||||
match <T::BlockNumber as TryInto<u32>>::try_into(rotations_since_session_start) {
|
||||
Ok(i) => i,
|
||||
Err(_) => 0, // can only happen if rotations occur only once every u32::max(),
|
||||
// so functionally no difference in behavior.
|
||||
};
|
||||
<T::BlockNumber as TryInto<u32>>::try_into(rotations_since_session_start).unwrap_or(0);
|
||||
// Error case can only happen if rotations occur only once every u32::max(),
|
||||
// so functionally no difference in behavior.
|
||||
|
||||
let group_idx =
|
||||
(core.0 as usize + rotations_since_session_start as usize) % validator_groups.len();
|
||||
|
||||
@@ -107,7 +107,7 @@ impl<XcmExecutor: xcm::latest::ExecuteXcm<C::RuntimeCall>, C: Config> UmpSink
|
||||
VersionedXcm,
|
||||
};
|
||||
|
||||
let id = upward_message_id(&data[..]);
|
||||
let id = upward_message_id(data);
|
||||
let maybe_msg_and_weight = VersionedXcm::<C::RuntimeCall>::decode_all_with_depth_limit(
|
||||
xcm::MAX_XCM_DECODE_DEPTH,
|
||||
&mut data,
|
||||
|
||||
Reference in New Issue
Block a user