From dc5d5bd48d2e129dd00e20689dbdd0e0893059c1 Mon Sep 17 00:00:00 2001 From: franfran Date: Tue, 11 Oct 2022 20:33:25 +0200 Subject: [PATCH 1/2] derive & borrow self --- crates/revm/src/instructions/opcode.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/revm/src/instructions/opcode.rs b/crates/revm/src/instructions/opcode.rs index e69678a3f1..5893d7f5c5 100644 --- a/crates/revm/src/instructions/opcode.rs +++ b/crates/revm/src/instructions/opcode.rs @@ -1,6 +1,7 @@ use crate::gas; use crate::SpecId; +#[derive(Debug, Clone, Copy, Eq, PartialEq)] pub struct OpCode(u8); pub const STOP: u8 = 0x00; @@ -164,7 +165,7 @@ impl OpCode { } #[inline(always)] - pub const fn u8(self) -> u8 { + pub const fn u8(&self) -> u8 { self.0 } } From ad95a6d0692f80344cc5f422345c1e6231d94017 Mon Sep 17 00:00:00 2001 From: rakita Date: Fri, 14 Oct 2022 13:36:39 +0200 Subject: [PATCH 2/2] clippy --- crates/revm/src/db/in_memory_db.rs | 4 ++-- crates/revm/src/evm_impl.rs | 2 +- crates/revm_precompiles/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/revm/src/db/in_memory_db.rs b/crates/revm/src/db/in_memory_db.rs index bda56aba09..b9b547986f 100644 --- a/crates/revm/src/db/in_memory_db.rs +++ b/crates/revm/src/db/in_memory_db.rs @@ -9,8 +9,8 @@ use sha3::{Digest, Keccak256}; pub type InMemoryDB = CacheDB; -impl InMemoryDB { - pub fn default() -> Self { +impl Default for InMemoryDB { + fn default() -> Self { CacheDB::new(EmptyDB {}) } } diff --git a/crates/revm/src/evm_impl.rs b/crates/revm/src/evm_impl.rs index 372da1a419..b573eb74af 100644 --- a/crates/revm/src/evm_impl.rs +++ b/crates/revm/src/evm_impl.rs @@ -300,7 +300,7 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB, if crate::USE_GAS { let zero_data_len = input.iter().filter(|v| **v == 0).count() as u64; - let non_zero_data_len = (input.len() as u64 - zero_data_len) as u64; + let non_zero_data_len = input.len() as u64 - zero_data_len; let (accessed_accounts, accessed_slots) = { if SPEC::enabled(BERLIN) { let mut accessed_slots = 0_u64; diff --git a/crates/revm_precompiles/src/lib.rs b/crates/revm_precompiles/src/lib.rs index b68e49b642..8f4692cb3b 100644 --- a/crates/revm_precompiles/src/lib.rs +++ b/crates/revm_precompiles/src/lib.rs @@ -100,7 +100,7 @@ pub enum SpecId { impl SpecId { pub const fn enabled(self, spec_id: u8) -> bool { - spec_id as u8 >= self as u8 + spec_id >= self as u8 } }