Skip to content

Commit

Permalink
Resolve lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Apr 25, 2024
1 parent db854cf commit 8125d3e
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions client/db/src/kv/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ mod tests {
// happened in case of fork or equivocation.
let eth_tx_hash = H256::random();
let mut metadata = vec![];
for hash in vec![next_canon_block_hash, orphan_block_hash].iter() {
for hash in [next_canon_block_hash, orphan_block_hash] {
metadata.push(crate::kv::TransactionMetadata::<OpaqueBlock> {
substrate_block_hash: *hash,
substrate_block_hash: hash,
ethereum_block_hash: ethhash,
ethereum_index: 0u32,
});
Expand Down
2 changes: 1 addition & 1 deletion client/db/src/kv/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn open_kvdb_rocksdb<Block: BlockT, C: HeaderBackend<Block>>(
// write database version only after the database is successfully opened
#[cfg(not(test))]
super::upgrade::update_version(path).map_err(|_| "Cannot update db version".to_string())?;
return Ok(sp_database::as_database(db));
Ok(sp_database::as_database(db))
}

#[cfg(not(feature = "rocksdb"))]
Expand Down
1 change: 1 addition & 0 deletions client/db/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ where
let transaction_index = transaction_index as i32;
log_count += receipt_logs.len();
for (log_index, log) in receipt_logs.iter().enumerate() {
#[allow(clippy::get_first)]
logs.push(Log {
address: log.address.as_bytes().to_owned(),
topic_1: log.topics.get(0).map(|l| l.as_bytes().to_owned()),
Expand Down
5 changes: 3 additions & 2 deletions client/rpc/src/eth/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ where
self.max_stored_filters
)));
}
let last_key = match {
let next_back = {
let mut iter = locked.iter();
iter.next_back()
} {
};
let last_key = match next_back {
Some((k, _)) => *k,
None => U256::zero(),
};
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ where
for tx in self.pool.ready() {
// since transactions in `ready()` need to be ordered by nonce
// it's fine to continue with current iterator.
if tx.provides().get(0) == Some(&current_tag) {
if tx.provides().first() == Some(&current_tag) {
current_nonce = current_nonce.saturating_add(1.into());
current_tag = (address, current_nonce).encode();
}
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
Err(e) => return Err(e),
};

match accounts.get(0) {
match accounts.first() {
Some(account) => *account,
None => return Err(internal_err("no signer available")),
}
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/eth_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl EthSubscriptionResult {
receipts: Vec<ethereum::ReceiptV3>,
params: &FilteredParams,
) -> Vec<Log> {
let block_hash = Some(H256::from(keccak_256(&rlp::encode(&block.header))));
let block_hash = H256::from(keccak_256(&rlp::encode(&block.header)));
let mut logs: Vec<Log> = vec![];
let mut log_index: u32 = 0;
for (receipt_index, receipt) in receipts.into_iter().enumerate() {
Expand All @@ -145,12 +145,12 @@ impl EthSubscriptionResult {
None
};
for log in receipt_logs {
if Self::add_log(block_hash.unwrap(), &log, &block, params) {
if Self::add_log(block_hash, &log, &block, params) {
logs.push(Log {
address: log.address,
topics: log.topics,
data: Bytes(log.data),
block_hash,
block_hash: Some(block_hash),
block_number: Some(block.header.number),
transaction_hash,
transaction_index: Some(U256::from(receipt_index)),
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::{collections::HashMap, marker::PhantomData, sync::Arc};
use std::{marker::PhantomData, sync::Arc};

use ethereum::TransactionV2;
use ethereum_types::{H160, H256, U256};
Expand Down Expand Up @@ -86,7 +86,7 @@ where
};
pending
.entry(from_address)
.or_insert_with(HashMap::new)
.or_default()
.insert(nonce, T::get(hash, from_address, txn));
}
let mut queued = TransactionMap::<T>::new();
Expand All @@ -103,7 +103,7 @@ where
};
queued
.entry(from_address)
.or_insert_with(HashMap::new)
.or_default()
.insert(nonce, T::get(hash, from_address, txn));
}
Ok(TxPoolResult { pending, queued })
Expand Down
5 changes: 4 additions & 1 deletion frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,10 @@ pub mod pallet {
frame_system::Pallet::<T>::inc_account_nonce(&account_id);
}

T::Currency::deposit_creating(&account_id, account.balance.unique_saturated_into());
let _ = T::Currency::deposit_creating(
&account_id,
account.balance.unique_saturated_into(),
);

Pallet::<T>::create_account(*address, account.code.clone());

Expand Down
6 changes: 3 additions & 3 deletions frame/evm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mod proof_size_test {
assert_eq!(
ACCOUNT_BASIC_PROOF_SIZE,
frame_system::Account::<Test>::storage_info()
.get(0)
.first()
.expect("item")
.max_size
.expect("size") as u64
Expand All @@ -147,7 +147,7 @@ mod proof_size_test {
assert_eq!(
ACCOUNT_STORAGE_PROOF_SIZE,
AccountStorages::<Test>::storage_info()
.get(0)
.first()
.expect("item")
.max_size
.expect("size") as u64
Expand All @@ -159,7 +159,7 @@ mod proof_size_test {
assert_eq!(
ACCOUNT_CODES_METADATA_PROOF_SIZE,
AccountCodesMetadata::<Test>::storage_info()
.get(0)
.first()
.expect("item")
.max_size
.expect("size") as u64
Expand Down
1 change: 1 addition & 0 deletions precompiles/src/testing/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ macro_rules! mock_account {
(# $name:ident, $convert:expr) => {
impl From<$name> for MockAccount {
fn from(value: $name) -> MockAccount {
#[allow(clippy::redundant_closure_call)]
$convert(value)
}
}
Expand Down
2 changes: 1 addition & 1 deletion template/node/src/rpc/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use sp_core::H256;
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::traits::Block as BlockT;
// Frontier
pub use fc_rpc::{EthBlockDataCacheTask, EthConfig, OverrideHandle, StorageOverride};
pub use fc_rpc::{EthBlockDataCacheTask, EthConfig, OverrideHandle};
pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
pub use fc_storage::overrides_handle;
use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi};
Expand Down
2 changes: 1 addition & 1 deletion template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ where
telemetry.as_ref().map(|x| x.handle()),
);

thread_local!(static TIMESTAMP: RefCell<u64> = RefCell::new(0));
thread_local!(static TIMESTAMP: RefCell<u64> = const { RefCell::new(0) });

/// Provide a mock duration starting at 0 in millisecond for timestamp inherent.
/// Each call will increment timestamp by slot_duration making Aura think time has passed.
Expand Down

0 comments on commit 8125d3e

Please sign in to comment.