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
@@ -277,15 +277,14 @@ where
}
module
};
let limits = module
let limits = *module
.import_section()
.unwrap()
.entries()
.iter()
.find_map(|e| if let External::Memory(mem) = e.external() { Some(mem) } else { None })
.unwrap()
.limits()
.clone();
.limits();
let code = module.to_bytes().unwrap();
let hash = T::Hashing::hash(&code);
let memory =
@@ -512,16 +511,10 @@ pub mod body {
DynInstr::RandomI32(low, high) => {
vec![Instruction::I32Const(rng.gen_range(*low..*high))]
},
DynInstr::RandomI32Repeated(num) => (&mut rng)
.sample_iter(Standard)
.take(*num)
.map(|val| Instruction::I32Const(val))
.collect(),
DynInstr::RandomI64Repeated(num) => (&mut rng)
.sample_iter(Standard)
.take(*num)
.map(|val| Instruction::I64Const(val))
.collect(),
DynInstr::RandomI32Repeated(num) =>
(&mut rng).sample_iter(Standard).take(*num).map(Instruction::I32Const).collect(),
DynInstr::RandomI64Repeated(num) =>
(&mut rng).sample_iter(Standard).take(*num).map(Instruction::I64Const).collect(),
DynInstr::RandomGetLocal(low, high) => {
vec![Instruction::GetLocal(rng.gen_range(*low..*high))]
},
@@ -138,7 +138,7 @@ where
Storage::<T>::write(&info.trie_id, &item.0, Some(item.1.clone()), None, false)
.map_err(|_| "Failed to write storage to restoration dest")?;
}
<ContractInfoOf<T>>::insert(&self.account_id, info.clone());
<ContractInfoOf<T>>::insert(&self.account_id, info);
Ok(())
}
@@ -253,7 +253,7 @@ benchmarks! {
)?;
let value = T::Currency::minimum_balance();
let origin = RawOrigin::Signed(instance.caller.clone());
let callee = instance.addr.clone();
let callee = instance.addr;
}: call(origin, callee, value, Weight::MAX, None, vec![])
// This constructs a contract that is maximal expensive to instrument.
@@ -1067,7 +1067,7 @@ benchmarks! {
)
.map_err(|_| "Failed to write to storage during setup.")?;
}
<ContractInfoOf<T>>::insert(&instance.account_id, info.clone());
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
@@ -1164,7 +1164,7 @@ benchmarks! {
)
.map_err(|_| "Failed to write to storage during setup.")?;
}
<ContractInfoOf<T>>::insert(&instance.account_id, info.clone());
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
@@ -1216,7 +1216,7 @@ benchmarks! {
)
.map_err(|_| "Failed to write to storage during setup.")?;
}
<ContractInfoOf<T>>::insert(&instance.account_id, info.clone());
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
@@ -1263,7 +1263,7 @@ benchmarks! {
)
.map_err(|_| "Failed to write to storage during setup.")?;
}
<ContractInfoOf<T>>::insert(&instance.account_id, info.clone());
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
@@ -1308,7 +1308,7 @@ benchmarks! {
)
.map_err(|_| "Failed to write to storage during setup.")?;
}
<ContractInfoOf<T>>::insert(&instance.account_id, info.clone());
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
@@ -1360,7 +1360,7 @@ benchmarks! {
)
.map_err(|_| "Failed to write to storage during setup.")?;
}
<ContractInfoOf<T>>::insert(&instance.account_id, info.clone());
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
@@ -1412,7 +1412,7 @@ benchmarks! {
)
.map_err(|_| "Failed to write to storage during setup.")?;
}
<ContractInfoOf<T>>::insert(&instance.account_id, info.clone());
<ContractInfoOf<T>>::insert(&instance.account_id, info);
let origin = RawOrigin::Signed(instance.caller.clone());
}: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![])
@@ -1577,7 +1577,7 @@ benchmarks! {
});
let instance = Contract::<T>::new(code, vec![])?;
let callee = instance.addr.clone();
let origin = RawOrigin::Signed(instance.caller.clone());
let origin = RawOrigin::Signed(instance.caller);
}: call(origin, callee, 0u32.into(), Weight::MAX, None, vec![])
seal_call_per_transfer_clone_kb {
@@ -1739,7 +1739,7 @@ benchmarks! {
.collect::<Vec<_>>();
for addr in &addresses {
if let Some(_) = ContractInfoOf::<T>::get(&addr) {
if ContractInfoOf::<T>::get(&addr).is_some() {
return Err("Expected that contract does not exist at this point.".into());
}
}
@@ -1747,7 +1747,7 @@ benchmarks! {
verify {
for addr in &addresses {
ContractInfoOf::<T>::get(&addr)
.ok_or_else(|| "Contract should have been instantiated")?;
.ok_or("Contract should have been instantiated")?;
}
}
@@ -1755,7 +1755,7 @@ benchmarks! {
let t in 0 .. 1;
let s in 0 .. (code::max_pages::<T>() - 1) * 64;
let callee_code = WasmModule::<T>::dummy();
let hash = callee_code.hash.clone();
let hash = callee_code.hash;
let hash_bytes = callee_code.hash.encode();
let hash_len = hash_bytes.len();
Contracts::<T>::store_code_raw(callee_code.code, whitelisted_caller())?;