mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
Apply some clippy lints (#11154)
* Apply some clippy hints * Revert clippy ci changes * Update client/cli/src/commands/generate.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/cli/src/commands/inspect_key.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/db/src/bench.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/service/src/client/block_rules.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/transactions.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/network/src/protocol.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Revert due to missing `or_default` function. * Fix compilation and simplify code * Undo change that corrupts benchmark. * fix clippy * Update client/service/test/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/state-db/src/noncanonical.rs remove leftovers! * Update client/tracing/src/logging/directives.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/fork-tree/src/lib.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * added needed ref * Update frame/referenda/src/benchmarking.rs * Simplify byte-vec creation * let's just not overlap the ranges * Correction * cargo fmt * Update utils/frame/benchmarking-cli/src/shared/stats.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update utils/frame/benchmarking-cli/src/pallet/command.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Giles Cope <gilescope@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a990473cf9
commit
b581604aa7
@@ -183,8 +183,8 @@ impl<T: Config> ListScenario<T> {
|
||||
Default::default(),
|
||||
)?;
|
||||
Staking::<T>::nominate(
|
||||
RawOrigin::Signed(origin_controller2.clone()).into(),
|
||||
vec![T::Lookup::unlookup(account("random_validator", 0, SEED))].clone(),
|
||||
RawOrigin::Signed(origin_controller2).into(),
|
||||
vec![T::Lookup::unlookup(account("random_validator", 0, SEED))],
|
||||
)?;
|
||||
|
||||
// find a destination weight that will trigger the worst case scenario
|
||||
@@ -239,10 +239,10 @@ benchmarks! {
|
||||
// the weight the nominator will start at.
|
||||
let scenario = ListScenario::<T>::new(origin_weight, true)?;
|
||||
|
||||
let max_additional = scenario.dest_weight.clone() - origin_weight;
|
||||
let max_additional = scenario.dest_weight - origin_weight;
|
||||
|
||||
let stash = scenario.origin_stash1.clone();
|
||||
let controller = scenario.origin_controller1.clone();
|
||||
let controller = scenario.origin_controller1;
|
||||
let original_bonded: BalanceOf<T>
|
||||
= Ledger::<T>::get(&controller).map(|l| l.active).ok_or("ledger not created after")?;
|
||||
|
||||
@@ -271,7 +271,7 @@ benchmarks! {
|
||||
|
||||
let stash = scenario.origin_stash1.clone();
|
||||
let controller = scenario.origin_controller1.clone();
|
||||
let amount = origin_weight - scenario.dest_weight.clone();
|
||||
let amount = origin_weight - scenario.dest_weight;
|
||||
let ledger = Ledger::<T>::get(&controller).ok_or("ledger not created before")?;
|
||||
let original_bonded: BalanceOf<T> = ledger.active;
|
||||
|
||||
@@ -315,7 +315,7 @@ benchmarks! {
|
||||
// destination position because we are doing a removal from the list but no insert.
|
||||
let scenario = ListScenario::<T>::new(origin_weight, true)?;
|
||||
let controller = scenario.origin_controller1.clone();
|
||||
let stash = scenario.origin_stash1.clone();
|
||||
let stash = scenario.origin_stash1;
|
||||
assert!(T::VoterList::contains(&stash));
|
||||
|
||||
let ed = T::Currency::minimum_balance();
|
||||
@@ -450,7 +450,7 @@ benchmarks! {
|
||||
// destination position because we are doing a removal from the list but no insert.
|
||||
let scenario = ListScenario::<T>::new(origin_weight, true)?;
|
||||
let controller = scenario.origin_controller1.clone();
|
||||
let stash = scenario.origin_stash1.clone();
|
||||
let stash = scenario.origin_stash1;
|
||||
assert!(T::VoterList::contains(&stash));
|
||||
|
||||
whitelist_account!(controller);
|
||||
@@ -518,7 +518,7 @@ benchmarks! {
|
||||
// destination position because we are doing a removal from the list but no insert.
|
||||
let scenario = ListScenario::<T>::new(origin_weight, true)?;
|
||||
let controller = scenario.origin_controller1.clone();
|
||||
let stash = scenario.origin_stash1.clone();
|
||||
let stash = scenario.origin_stash1;
|
||||
assert!(T::VoterList::contains(&stash));
|
||||
add_slashing_spans::<T>(&stash, s);
|
||||
|
||||
@@ -561,10 +561,10 @@ benchmarks! {
|
||||
let validator_controller = <Bonded<T>>::get(&validator).unwrap();
|
||||
let balance_before = T::Currency::free_balance(&validator_controller);
|
||||
for (_, controller) in &nominators {
|
||||
let balance = T::Currency::free_balance(&controller);
|
||||
let balance = T::Currency::free_balance(controller);
|
||||
ensure!(balance.is_zero(), "Controller has balance, but should be dead.");
|
||||
}
|
||||
}: payout_stakers(RawOrigin::Signed(caller), validator.clone(), current_era)
|
||||
}: payout_stakers(RawOrigin::Signed(caller), validator, current_era)
|
||||
verify {
|
||||
let balance_after = T::Currency::free_balance(&validator_controller);
|
||||
ensure!(
|
||||
@@ -572,7 +572,7 @@ benchmarks! {
|
||||
"Balance of validator controller should have increased after payout.",
|
||||
);
|
||||
for (_, controller) in &nominators {
|
||||
let balance = T::Currency::free_balance(&controller);
|
||||
let balance = T::Currency::free_balance(controller);
|
||||
ensure!(!balance.is_zero(), "Payout not given to controller.");
|
||||
}
|
||||
}
|
||||
@@ -594,7 +594,7 @@ benchmarks! {
|
||||
let balance_before = T::Currency::free_balance(&validator);
|
||||
let mut nominator_balances_before = Vec::new();
|
||||
for (stash, _) in &nominators {
|
||||
let balance = T::Currency::free_balance(&stash);
|
||||
let balance = T::Currency::free_balance(stash);
|
||||
nominator_balances_before.push(balance);
|
||||
}
|
||||
}: payout_stakers(RawOrigin::Signed(caller), validator.clone(), current_era)
|
||||
@@ -605,7 +605,7 @@ benchmarks! {
|
||||
"Balance of validator stash should have increased after payout.",
|
||||
);
|
||||
for ((stash, _), balance_before) in nominators.iter().zip(nominator_balances_before.iter()) {
|
||||
let balance_after = T::Currency::free_balance(&stash);
|
||||
let balance_after = T::Currency::free_balance(stash);
|
||||
ensure!(
|
||||
balance_before < &balance_after,
|
||||
"Balance of nominator stash should have increased after payout.",
|
||||
@@ -626,7 +626,7 @@ benchmarks! {
|
||||
|
||||
// setup a worst case list scenario.
|
||||
let scenario = ListScenario::<T>::new(origin_weight, true)?;
|
||||
let dest_weight = scenario.dest_weight.clone();
|
||||
let dest_weight = scenario.dest_weight;
|
||||
|
||||
// rebond an amount that will give the user dest_weight
|
||||
let rebond_amount = dest_weight - origin_weight;
|
||||
@@ -644,7 +644,7 @@ benchmarks! {
|
||||
};
|
||||
|
||||
let stash = scenario.origin_stash1.clone();
|
||||
let controller = scenario.origin_controller1.clone();
|
||||
let controller = scenario.origin_controller1;
|
||||
let mut staking_ledger = Ledger::<T>::get(controller.clone()).unwrap();
|
||||
|
||||
for _ in 0 .. l {
|
||||
@@ -691,7 +691,7 @@ benchmarks! {
|
||||
// destination position because we are doing a removal from the list but no insert.
|
||||
let scenario = ListScenario::<T>::new(origin_weight, true)?;
|
||||
let controller = scenario.origin_controller1.clone();
|
||||
let stash = scenario.origin_stash1.clone();
|
||||
let stash = scenario.origin_stash1;
|
||||
|
||||
add_slashing_spans::<T>(&stash, s);
|
||||
let l = StakingLedger {
|
||||
@@ -895,7 +895,7 @@ benchmarks! {
|
||||
// destination position because we are doing a removal from the list but no insert.
|
||||
let scenario = ListScenario::<T>::new(origin_weight, true)?;
|
||||
let controller = scenario.origin_controller1.clone();
|
||||
let stash = scenario.origin_stash1.clone();
|
||||
let stash = scenario.origin_stash1;
|
||||
assert!(T::VoterList::contains(&stash));
|
||||
|
||||
Staking::<T>::set_staking_configs(
|
||||
@@ -909,7 +909,7 @@ benchmarks! {
|
||||
)?;
|
||||
|
||||
let caller = whitelisted_caller();
|
||||
}: _(RawOrigin::Signed(caller), controller.clone())
|
||||
}: _(RawOrigin::Signed(caller), controller)
|
||||
verify {
|
||||
assert!(!T::VoterList::contains(&stash));
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ pub use weights::WeightInfo;
|
||||
|
||||
pub use pallet::{pallet::*, *};
|
||||
|
||||
pub(crate) const LOG_TARGET: &'static str = "runtime::staking";
|
||||
pub(crate) const LOG_TARGET: &str = "runtime::staking";
|
||||
|
||||
// syntactic sugar for logging.
|
||||
#[macro_export]
|
||||
@@ -784,7 +784,7 @@ impl<Balance: AtLeast32BitUnsigned + Clone, T: Get<&'static PiecewiseLinear<'sta
|
||||
era_duration_millis: u64,
|
||||
) -> (Balance, Balance) {
|
||||
let (validator_payout, max_payout) = inflation::compute_total_payout(
|
||||
&T::get(),
|
||||
T::get(),
|
||||
total_staked,
|
||||
total_issuance,
|
||||
// Duration of era; more than u64::MAX is rewarded as u64::MAX.
|
||||
|
||||
@@ -123,8 +123,9 @@ impl<T: Config> Pallet<T> {
|
||||
.claimed_rewards
|
||||
.retain(|&x| x >= current_era.saturating_sub(history_depth));
|
||||
match ledger.claimed_rewards.binary_search(&era) {
|
||||
Ok(_) => Err(Error::<T>::AlreadyClaimed
|
||||
.with_weight(T::WeightInfo::payout_stakers_alive_staked(0)))?,
|
||||
Ok(_) =>
|
||||
return Err(Error::<T>::AlreadyClaimed
|
||||
.with_weight(T::WeightInfo::payout_stakers_alive_staked(0))),
|
||||
Err(pos) => ledger.claimed_rewards.insert(pos, era),
|
||||
}
|
||||
|
||||
@@ -146,8 +147,8 @@ impl<T: Config> Pallet<T> {
|
||||
let validator_reward_points = era_reward_points
|
||||
.individual
|
||||
.get(&ledger.stash)
|
||||
.map(|points| *points)
|
||||
.unwrap_or_else(|| Zero::zero());
|
||||
.copied()
|
||||
.unwrap_or_else(Zero::zero);
|
||||
|
||||
// Nothing to do if they have no reward points.
|
||||
if validator_reward_points.is_zero() {
|
||||
@@ -260,8 +261,7 @@ impl<T: Config> Pallet<T> {
|
||||
0
|
||||
});
|
||||
|
||||
let era_length =
|
||||
session_index.checked_sub(current_era_start_session_index).unwrap_or(0); // Must never happen.
|
||||
let era_length = session_index.saturating_sub(current_era_start_session_index); // Must never happen.
|
||||
|
||||
match ForceEra::<T>::get() {
|
||||
// Will be set to `NotForcing` again if a new era has been triggered.
|
||||
@@ -1036,7 +1036,7 @@ impl<T: Config> ElectionDataProvider for Pallet<T> {
|
||||
);
|
||||
Self::do_add_nominator(
|
||||
&v,
|
||||
Nominations { targets: t.try_into().unwrap(), submitted_in: 0, suppressed: false },
|
||||
Nominations { targets: t, submitted_in: 0, suppressed: false },
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -580,7 +580,7 @@ pub mod pallet {
|
||||
status
|
||||
);
|
||||
assert!(
|
||||
T::Currency::free_balance(&stash) >= balance,
|
||||
T::Currency::free_balance(stash) >= balance,
|
||||
"Stash does not have enough balance to bond."
|
||||
);
|
||||
frame_support::assert_ok!(<Pallet<T>>::bond(
|
||||
@@ -779,18 +779,18 @@ pub mod pallet {
|
||||
let stash = ensure_signed(origin)?;
|
||||
|
||||
if <Bonded<T>>::contains_key(&stash) {
|
||||
Err(Error::<T>::AlreadyBonded)?
|
||||
return Err(Error::<T>::AlreadyBonded.into())
|
||||
}
|
||||
|
||||
let controller = T::Lookup::lookup(controller)?;
|
||||
|
||||
if <Ledger<T>>::contains_key(&controller) {
|
||||
Err(Error::<T>::AlreadyPaired)?
|
||||
return Err(Error::<T>::AlreadyPaired.into())
|
||||
}
|
||||
|
||||
// Reject a bond which is considered to be _dust_.
|
||||
if value < T::Currency::minimum_balance() {
|
||||
Err(Error::<T>::InsufficientBond)?
|
||||
return Err(Error::<T>::InsufficientBond.into())
|
||||
}
|
||||
|
||||
frame_system::Pallet::<T>::inc_consumers(&stash).map_err(|_| Error::<T>::BadState)?;
|
||||
@@ -862,7 +862,7 @@ pub mod pallet {
|
||||
debug_assert_eq!(T::VoterList::sanity_check(), Ok(()));
|
||||
}
|
||||
|
||||
Self::deposit_event(Event::<T>::Bonded(stash.clone(), extra));
|
||||
Self::deposit_event(Event::<T>::Bonded(stash, extra));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -1183,7 +1183,7 @@ pub mod pallet {
|
||||
let old_controller = Self::bonded(&stash).ok_or(Error::<T>::NotStash)?;
|
||||
let controller = T::Lookup::lookup(controller)?;
|
||||
if <Ledger<T>>::contains_key(&controller) {
|
||||
Err(Error::<T>::AlreadyPaired)?
|
||||
return Err(Error::<T>::AlreadyPaired.into())
|
||||
}
|
||||
if controller != old_controller {
|
||||
<Bonded<T>>::insert(&stash, &controller);
|
||||
@@ -1466,8 +1466,8 @@ pub mod pallet {
|
||||
ensure_root(origin)?;
|
||||
if let Some(current_era) = Self::current_era() {
|
||||
HistoryDepth::<T>::mutate(|history_depth| {
|
||||
let last_kept = current_era.checked_sub(*history_depth).unwrap_or(0);
|
||||
let new_last_kept = current_era.checked_sub(new_history_depth).unwrap_or(0);
|
||||
let last_kept = current_era.saturating_sub(*history_depth);
|
||||
let new_last_kept = current_era.saturating_sub(new_history_depth);
|
||||
for era_index in last_kept..new_last_kept {
|
||||
Self::clear_era_information(era_index);
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ fn slash_nominators<T: Config>(
|
||||
|
||||
let mut era_slash =
|
||||
<Pallet<T> as Store>::NominatorSlashInEra::get(¶ms.slash_era, stash)
|
||||
.unwrap_or_else(|| Zero::zero());
|
||||
.unwrap_or_else(Zero::zero);
|
||||
|
||||
era_slash += own_slash_difference;
|
||||
|
||||
@@ -646,7 +646,7 @@ pub(crate) fn apply_slash<T: Config>(
|
||||
|
||||
for &(ref nominator, nominator_slash) in &unapplied_slash.others {
|
||||
do_slash::<T>(
|
||||
&nominator,
|
||||
nominator,
|
||||
nominator_slash,
|
||||
&mut reward_payout,
|
||||
&mut slashed_imbalance,
|
||||
|
||||
@@ -85,7 +85,7 @@ pub fn create_stash_controller<T: Config>(
|
||||
amount,
|
||||
destination,
|
||||
)?;
|
||||
return Ok((stash, controller))
|
||||
Ok((stash, controller))
|
||||
}
|
||||
|
||||
/// Create a stash and controller pair with fixed balance.
|
||||
@@ -127,7 +127,7 @@ pub fn create_stash_and_dead_controller<T: Config>(
|
||||
amount,
|
||||
destination,
|
||||
)?;
|
||||
return Ok((stash, controller))
|
||||
Ok((stash, controller))
|
||||
}
|
||||
|
||||
/// create `max` validators.
|
||||
|
||||
Reference in New Issue
Block a user