diff --git a/Cargo.toml b/Cargo.toml index 8d57ebe..073893b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ homepage = "https://github.com/carver/eth-trie.rs" documentation = "https://docs.rs/eth_trie" [dependencies] +ethereum-types = "0.12.1" hashbrown = "0.14.0" keccak-hash = "0.10.0" log = "0.4.16" @@ -22,7 +23,6 @@ rlp = "0.5.1" rand = "0.8.3" hex = "0.4.2" criterion = "0.5.1" -ethereum-types = "0.14.1" uuid = { version = "1.4.1", features = ["serde", "v4"] } [[bench]] diff --git a/src/errors.rs b/src/errors.rs index 6ae58f2..c742bb5 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,7 +1,7 @@ use std::error::Error; use std::fmt; -use keccak_hash::H256; +use ethereum_types::H256; use rlp::DecoderError; use crate::nibbles::Nibbles; diff --git a/src/node.rs b/src/node.rs index ca7863b..98c389b 100644 --- a/src/node.rs +++ b/src/node.rs @@ -1,6 +1,6 @@ use std::sync::{Arc, RwLock}; -use keccak_hash::H256; +use ethereum_types::H256; use crate::nibbles::Nibbles; diff --git a/src/trie.rs b/src/trie.rs index c9ff828..22ae953 100644 --- a/src/trie.rs +++ b/src/trie.rs @@ -1,8 +1,8 @@ -use keccak_hash::KECCAK_NULL_RLP; use std::sync::{Arc, RwLock}; +use ethereum_types::H256; use hashbrown::{HashMap, HashSet}; -use keccak_hash::{keccak, H256}; +use keccak_hash::{keccak, KECCAK_NULL_RLP}; use log::warn; use rlp::{Prototype, Rlp, RlpStream}; @@ -225,7 +225,7 @@ where pub fn new(db: Arc) -> Self { Self { root: Node::Empty, - root_hash: KECCAK_NULL_RLP, + root_hash: KECCAK_NULL_RLP.as_fixed_bytes().into(), cache: HashMap::new(), passing_keys: HashSet::new(), @@ -388,7 +388,7 @@ where ) -> TrieResult>> { let proof_db = Arc::new(MemoryDB::new(true)); for node_encoded in proof.into_iter() { - let hash = keccak(&node_encoded); + let hash: H256 = keccak(&node_encoded).as_fixed_bytes().into(); if root_hash.eq(&hash) || node_encoded.len() >= HASHED_LENGTH { proof_db.insert(hash.as_bytes(), node_encoded).unwrap(); @@ -764,7 +764,7 @@ where let root_hash = match self.write_node(&self.root.clone()) { EncodedNode::Hash(hash) => hash, EncodedNode::Inline(encoded) => { - let hash = keccak(&encoded); + let hash: H256 = keccak(&encoded).as_fixed_bytes().into(); self.cache.insert(hash.as_bytes().to_vec(), encoded); hash } @@ -813,7 +813,7 @@ where if data.len() < HASHED_LENGTH { EncodedNode::Inline(data) } else { - let hash = keccak(&data); + let hash: H256 = keccak(&data).as_fixed_bytes().into(); self.cache.insert(hash.as_bytes().to_vec(), data); self.gen_keys.insert(hash.as_bytes().to_vec()); @@ -931,7 +931,8 @@ mod tests { use std::collections::{HashMap, HashSet}; use std::sync::Arc; - use keccak_hash::{H256, KECCAK_NULL_RLP}; + use ethereum_types::H256; + use keccak_hash::KECCAK_NULL_RLP; use super::{EthTrie, Trie}; use crate::db::{MemoryDB, DB};