From af91a35920df68687bd60c411205c31abf966414 Mon Sep 17 00:00:00 2001 From: gabriel-aranha-cw Date: Tue, 4 Feb 2025 17:16:18 -0300 Subject: [PATCH 1/3] chore: remove ethers keccak --- src/eth/primitives/block_number.rs | 4 ++-- src/eth/primitives/slot_index.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/eth/primitives/block_number.rs b/src/eth/primitives/block_number.rs index 584995e3d..fc0a7b903 100644 --- a/src/eth/primitives/block_number.rs +++ b/src/eth/primitives/block_number.rs @@ -2,10 +2,10 @@ use std::ops::Add; use std::ops::AddAssign; use std::str::FromStr; +use alloy_primitives::keccak256; use anyhow::anyhow; use display_json::DebugAsJson; use ethereum_types::U64; -use ethers_core::utils::keccak256; use fake::Dummy; use fake::Faker; @@ -24,7 +24,7 @@ impl BlockNumber { /// Calculates the keccak256 hash of the block number. pub fn hash(&self) -> Hash { - Hash::new(keccak256(<[u8; 8]>::from(*self))) + Hash::new(*keccak256(<[u8; 8]>::from(*self))) } /// Returns the previous block number. diff --git a/src/eth/primitives/slot_index.rs b/src/eth/primitives/slot_index.rs index 63dbc0e39..eb5f5ca84 100644 --- a/src/eth/primitives/slot_index.rs +++ b/src/eth/primitives/slot_index.rs @@ -1,9 +1,9 @@ use std::fmt::Display; use std::io::Read; +use alloy_primitives::keccak256; use display_json::DebugAsJson; use ethereum_types::U256; -use ethers_core::utils::keccak256; use fake::Dummy; use fake::Faker; @@ -33,7 +33,7 @@ impl SlotIndex { mapping_index_bytes[32..64].copy_from_slice(&slot_index_bytes); let hashed_bytes = keccak256(mapping_index_bytes); - Self::from(hashed_bytes) + Self::from(hashed_bytes.0) } } From c7e6f62387efa2f80f252fde4157035af7faedce Mon Sep 17 00:00:00 2001 From: gabriel-aranha-cw Date: Tue, 4 Feb 2025 17:26:14 -0300 Subject: [PATCH 2/3] chore: improve conversion --- src/eth/primitives/slot_index.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/eth/primitives/slot_index.rs b/src/eth/primitives/slot_index.rs index eb5f5ca84..559ac9636 100644 --- a/src/eth/primitives/slot_index.rs +++ b/src/eth/primitives/slot_index.rs @@ -33,7 +33,7 @@ impl SlotIndex { mapping_index_bytes[32..64].copy_from_slice(&slot_index_bytes); let hashed_bytes = keccak256(mapping_index_bytes); - Self::from(hashed_bytes.0) + Self::from(hashed_bytes) } } @@ -67,6 +67,12 @@ impl From for SlotIndex { } } +impl From> for SlotIndex { + fn from(value: FixedBytes<32>) -> Self { + Self::from(value.0) + } +} + // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- From 5b83a58e10583dbf85ada02e37128ee7887c5757 Mon Sep 17 00:00:00 2001 From: gabriel-aranha-cw Date: Tue, 4 Feb 2025 17:29:23 -0300 Subject: [PATCH 3/3] chore: lint --- src/eth/primitives/slot_index.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/eth/primitives/slot_index.rs b/src/eth/primitives/slot_index.rs index 559ac9636..5ac2e30c8 100644 --- a/src/eth/primitives/slot_index.rs +++ b/src/eth/primitives/slot_index.rs @@ -2,6 +2,7 @@ use std::fmt::Display; use std::io::Read; use alloy_primitives::keccak256; +use alloy_primitives::FixedBytes; use display_json::DebugAsJson; use ethereum_types::U256; use fake::Dummy;