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:
Falco Hirschenberger
2022-04-30 23:28:27 +02:00
committed by GitHub
parent a990473cf9
commit b581604aa7
368 changed files with 1927 additions and 2236 deletions
+18 -18
View File
@@ -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));
}