Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed Jan 10, 2025
1 parent 7ee3a74 commit f799f1b
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 24 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ missing_panics_doc = "allow"
module_name_repetitions = "allow"
unreadable_literal = "allow"
similar_names = "allow"
too_long_first_doc_paragraph = "allow"

[workspace]
resolver = "2"
Expand Down
2 changes: 2 additions & 0 deletions engine-hashchain/src/bloom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//!
//! Reimplemented here since there is a large mismatch in types and dependencies.
#![allow(clippy::expl_impl_clone_on_copy, clippy::non_canonical_clone_impl)]
// NOTE: `fixed_hash` crate has clippy issue
#![allow(unexpected_cfgs)]

use aurora_engine_sdk::keccak;
use aurora_engine_types::borsh::{BorshDeserialize, BorshSerialize};
Expand Down
1 change: 0 additions & 1 deletion engine-hashchain/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::too_long_first_doc_paragraph)]

pub mod bloom;
pub mod error;
Expand Down
1 change: 0 additions & 1 deletion engine-modexp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
clippy::cast_lossless,
clippy::many_single_char_names
)]
#![allow(clippy::too_long_first_doc_paragraph)]

mod arith;
mod maybe_std;
Expand Down
6 changes: 4 additions & 2 deletions engine-precompiles/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ impl SHA256 {
}

impl Precompile for SHA256 {
#[allow(clippy::manual_div_ceil)]
fn required_gas(input: &[u8]) -> Result<EthGas, ExitError> {
let input_len = u64::try_from(input.len()).map_err(utils::err_usize_conv)?;
Ok(
(input_len + consts::SHA256_WORD_LEN - 1).div_ceil(consts::SHA256_WORD_LEN)
(input_len + consts::SHA256_WORD_LEN - 1) / consts::SHA256_WORD_LEN
* costs::SHA256_PER_WORD
+ costs::SHA256_BASE,
)
Expand Down Expand Up @@ -105,10 +106,11 @@ impl RIPEMD160 {
}

impl Precompile for RIPEMD160 {
#[allow(clippy::manual_div_ceil)]
fn required_gas(input: &[u8]) -> Result<EthGas, ExitError> {
let input_len = u64::try_from(input.len()).map_err(utils::err_usize_conv)?;
Ok(
(input_len + consts::RIPEMD_WORD_LEN - 1).div_ceil(consts::RIPEMD_WORD_LEN)
(input_len + consts::RIPEMD_WORD_LEN - 1) / consts::RIPEMD_WORD_LEN
* costs::RIPEMD160_PER_WORD
+ costs::RIPEMD160_BASE,
)
Expand Down
3 changes: 2 additions & 1 deletion engine-precompiles/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ impl Identity {
}

impl Precompile for Identity {
#[allow(clippy::manual_div_ceil)]
fn required_gas(input: &[u8]) -> Result<EthGas, ExitError> {
let input_len = u64::try_from(input.len()).map_err(utils::err_usize_conv)?;
Ok(
(input_len + consts::IDENTITY_WORD_LEN - 1).div_ceil(consts::IDENTITY_WORD_LEN)
(input_len + consts::IDENTITY_WORD_LEN - 1) / consts::IDENTITY_WORD_LEN
* costs::IDENTITY_PER_WORD
+ costs::IDENTITY_BASE,
)
Expand Down
2 changes: 1 addition & 1 deletion engine-precompiles/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![forbid(unsafe_code)]
#![allow(clippy::too_long_first_doc_paragraph)]

pub mod account_ids;
pub mod alt_bn256;
pub mod blake2;
Expand Down
1 change: 0 additions & 1 deletion engine-sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
// All `as` conversions in this code base have been carefully reviewed and are safe.
#![allow(clippy::as_conversions)]
#![allow(clippy::too_long_first_doc_paragraph)]

#[cfg(feature = "contract")]
use crate::prelude::{Address, Vec, U256};
Expand Down
4 changes: 2 additions & 2 deletions engine-standalone-storage/src/engine_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum EngineStorageValue<'a> {
Vec(Vec<u8>),
}

impl<'a> AsRef<[u8]> for EngineStorageValue<'a> {
impl AsRef<[u8]> for EngineStorageValue<'_> {
fn as_ref(&self) -> &[u8] {
match self {
Self::Slice(slice) => slice,
Expand All @@ -20,7 +20,7 @@ impl<'a> AsRef<[u8]> for EngineStorageValue<'a> {
}
}

impl<'a> StorageIntermediate for EngineStorageValue<'a> {
impl StorageIntermediate for EngineStorageValue<'_> {
fn len(&self) -> usize {
self.as_ref().len()
}
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl Storage {

// move to the next key by skipping all other DB keys corresponding to the same engine key
while iter.valid()
&& iter.key().map_or(false, |db_key| {
&& iter.key().is_some_and(|db_key| {
db_key[0..engine_prefix_len] == engine_prefix
&& &db_key[engine_prefix_len..(db_key.len() - ENGINE_KEY_SUFFIX_LEN)]
== *engine_key
Expand Down
2 changes: 1 addition & 1 deletion engine-standalone-storage/src/promise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct NoScheduler<'a> {
pub promise_data: &'a [Option<Vec<u8>>],
}

impl<'a> PromiseHandler for NoScheduler<'a> {
impl PromiseHandler for NoScheduler<'_> {
type ReadOnly = Self;

fn promise_results_count(&self) -> u64 {
Expand Down
1 change: 0 additions & 1 deletion engine-standalone-tracing/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(clippy::too_long_first_doc_paragraph)]
pub mod sputnik;
pub mod types;

Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub struct OneShotAuroraRunner<'a> {
pub context: VMContext,
}

impl<'a> OneShotAuroraRunner<'a> {
impl OneShotAuroraRunner<'_> {
pub fn profiled_call(
self,
method_name: &str,
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/utils/one_inch/liquidity_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Helper<'a> {
pub signer: &'a mut utils::Signer,
}

impl<'a> Helper<'a> {
impl Helper<'_> {
pub(crate) fn create_mooniswap_deployer(
&mut self,
) -> (SubmitResult, ExecutionProfile, PoolDeployer) {
Expand Down
1 change: 0 additions & 1 deletion engine-transactions/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![forbid(unsafe_code)]
#![allow(clippy::too_long_first_doc_paragraph)]

use aurora_engine_types::types::{Address, Wei};
use aurora_engine_types::{vec, Vec, H160, U256};
Expand Down
1 change: 0 additions & 1 deletion engine-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(not(any(feature = "std", feature = "contracts-std")), no_std)]
#![allow(clippy::too_long_first_doc_paragraph)]

pub mod account_id;
pub mod parameters;
Expand Down
10 changes: 5 additions & 5 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ pub fn submit_with_alt_modexp<
let fixed_gas = silo::get_fixed_gas(&io);

// Check if the sender has rights to submit transactions or deploy code on SILO mode.
assert_access(&io, env, &fixed_gas, &transaction)?;
assert_access(&io, env, fixed_gas, &transaction)?;

// Validate the chain ID, if provided inside the signature:
if let Some(chain_id) = transaction.chain_id {
Expand All @@ -1050,7 +1050,7 @@ pub fn submit_with_alt_modexp<
check_nonce(&io, &sender, &transaction.nonce)?;

// Check that fixed gas is not greater than gasLimit from the transaction.
if fixed_gas.map_or(false, |gas| gas.as_u256() > transaction.gas_limit) {
if fixed_gas.is_some_and(|gas| gas.as_u256() > transaction.gas_limit) {
return Err(EngineErrorKind::FixedGasOverflow.into());
}

Expand Down Expand Up @@ -1739,7 +1739,7 @@ unsafe fn schedule_promise_callback<P: PromiseHandler>(
fn assert_access<I: IO + Copy, E: Env>(
io: &I,
env: &E,
fixed_gas: &Option<EthGas>,
fixed_gas: Option<EthGas>,
transaction: &NormalizedEthTransaction,
) -> Result<(), EngineError> {
if fixed_gas.is_some() {
Expand All @@ -1760,7 +1760,7 @@ fn assert_access<I: IO + Copy, E: Env>(
Ok(())
}

impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Backend for Engine<'env, I, E, M> {
impl<I: IO + Copy, E: Env, M: ModExpAlgorithm> Backend for Engine<'_, I, E, M> {
/// Returns the "effective" gas price (as defined by EIP-1559)
fn gas_price(&self) -> U256 {
self.gas_price
Expand Down Expand Up @@ -1958,7 +1958,7 @@ impl<'env, I: IO + Copy, E: Env, M: ModExpAlgorithm> Backend for Engine<'env, I,
}
}

impl<'env, J: IO + Copy, E: Env, M: ModExpAlgorithm> ApplyBackend for Engine<'env, J, E, M> {
impl<J: IO + Copy, E: Env, M: ModExpAlgorithm> ApplyBackend for Engine<'_, J, E, M> {
fn apply<A, I, L>(&mut self, values: A, _logs: L, delete_empty: bool)
where
A: IntoIterator<Item = Apply<I>>,
Expand Down
2 changes: 1 addition & 1 deletion engine/src/pausables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl PrecompileFlags {
/// Checks if the precompile belonging to the `address` is marked as paused.
#[must_use]
pub fn is_paused_by_address(&self, address: &Address) -> bool {
Self::from_address(address).map_or(false, |precompile_flag| self.contains(precompile_flag))
Self::from_address(address).is_some_and(|precompile_flag| self.contains(precompile_flag))
}
}

Expand Down
2 changes: 1 addition & 1 deletion engine/src/xcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ impl<'a, H> PromiseInterceptor<'a, H> {
}
}

impl<'a, H: PromiseHandler> PromiseHandler for PromiseInterceptor<'a, H> {
impl<H: PromiseHandler> PromiseHandler for PromiseInterceptor<'_, H> {
type ReadOnly = H::ReadOnly;

fn promise_results_count(&self) -> u64 {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.84.0"
channel = "1.81.0"
targets = ["wasm32-unknown-unknown"]

0 comments on commit f799f1b

Please sign in to comment.