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
+13 -16
View File
@@ -610,7 +610,7 @@ where
debug_message: Option<&'a mut Vec<u8>>,
) -> Result<(Self, E), ExecError> {
let (first_frame, executable, nonce) =
Self::new_frame(args, value, gas_meter, storage_meter, 0, &schedule)?;
Self::new_frame(args, value, gas_meter, storage_meter, 0, schedule)?;
let stack = Self {
origin,
schedule,
@@ -660,13 +660,10 @@ where
},
FrameArgs::Instantiate { sender, nonce, executable, salt } => {
let account_id =
<Contracts<T>>::contract_address(&sender, executable.code_hash(), &salt);
<Contracts<T>>::contract_address(&sender, executable.code_hash(), salt);
let trie_id = Storage::<T>::generate_trie_id(&account_id, nonce);
let contract = Storage::<T>::new_contract(
&account_id,
trie_id,
executable.code_hash().clone(),
)?;
let contract =
Storage::<T>::new_contract(&account_id, trie_id, *executable.code_hash())?;
(
account_id,
contract,
@@ -742,7 +739,7 @@ where
top_frame.nested_storage.charge_instantiate(
&self.origin,
&top_frame.account_id,
&mut top_frame.contract_info.get(&top_frame.account_id),
top_frame.contract_info.get(&top_frame.account_id),
)?;
}
@@ -1020,11 +1017,11 @@ where
code_hash: CodeHash<Self::T>,
input_data: Vec<u8>,
) -> Result<ExecReturnValue, ExecError> {
let executable = E::from_storage(code_hash, &self.schedule, self.gas_meter())?;
let executable = E::from_storage(code_hash, self.schedule, self.gas_meter())?;
let top_frame = self.top_frame_mut();
let contract_info = top_frame.contract_info().clone();
let account_id = top_frame.account_id.clone();
let value = top_frame.value_transferred.clone();
let value = top_frame.value_transferred;
let executable = self.push_frame(
FrameArgs::Call {
dest: account_id,
@@ -1045,7 +1042,7 @@ where
input_data: Vec<u8>,
salt: &[u8],
) -> Result<(AccountIdOf<T>, ExecReturnValue), ExecError> {
let executable = E::from_storage(code_hash, &self.schedule, self.gas_meter())?;
let executable = E::from_storage(code_hash, self.schedule, self.gas_meter())?;
let nonce = self.next_nonce();
let executable = self.push_frame(
FrameArgs::Instantiate {
@@ -1118,7 +1115,7 @@ where
fn caller(&self) -> &T::AccountId {
if let Some(caller) = &self.top_frame().delegate_caller {
&caller
caller
} else {
self.frames().nth(1).map(|f| &f.account_id).unwrap_or(&self.origin)
}
@@ -1180,7 +1177,7 @@ where
}
fn schedule(&self) -> &Schedule<Self::T> {
&self.schedule
self.schedule
}
fn gas_meter(&mut self) -> &mut GasMeter<Self::T> {
@@ -1205,7 +1202,7 @@ where
}
fn ecdsa_recover(&self, signature: &[u8; 65], message_hash: &[u8; 32]) -> Result<[u8; 33], ()> {
secp256k1_ecdsa_recover_compressed(&signature, &message_hash).map_err(|_| ())
secp256k1_ecdsa_recover_compressed(signature, message_hash).map_err(|_| ())
}
fn ecdsa_to_eth_address(&self, pk: &[u8; 33]) -> Result<[u8; 20], ()> {
@@ -1220,8 +1217,8 @@ where
fn set_code_hash(&mut self, hash: CodeHash<Self::T>) -> Result<(), DispatchError> {
E::add_user(hash)?;
let top_frame = self.top_frame_mut();
let prev_hash = top_frame.contract_info().code_hash.clone();
E::remove_user(prev_hash.clone());
let prev_hash = top_frame.contract_info().code_hash;
E::remove_user(prev_hash);
top_frame.contract_info().code_hash = hash;
Contracts::<Self::T>::deposit_event(Event::ContractCodeUpdated {
contract: top_frame.account_id.clone(),