From 423e0221f7a9e42f50e2ce89eb14bbf3b7321ad3 Mon Sep 17 00:00:00 2001 From: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Date: Fri, 6 Sep 2024 13:19:50 -0700 Subject: [PATCH] trie: clean up reth-primitives imports (#10757) --- Cargo.lock | 1 + crates/trie/trie/Cargo.toml | 1 + crates/trie/trie/benches/hash_post_state.rs | 2 +- crates/trie/trie/benches/trie_root.rs | 3 ++- crates/trie/trie/src/hashed_cursor/mod.rs | 3 ++- crates/trie/trie/src/hashed_cursor/post_state.rs | 3 ++- crates/trie/trie/src/node_iter.rs | 2 +- crates/trie/trie/src/prefix_set.rs | 2 +- crates/trie/trie/src/progress.rs | 2 +- crates/trie/trie/src/proof.rs | 2 +- crates/trie/trie/src/state.rs | 3 ++- crates/trie/trie/src/test_utils.rs | 3 ++- crates/trie/trie/src/trie.rs | 3 ++- crates/trie/trie/src/trie_cursor/in_memory.rs | 2 +- crates/trie/trie/src/trie_cursor/mod.rs | 2 +- crates/trie/trie/src/trie_cursor/noop.rs | 2 +- crates/trie/trie/src/trie_cursor/subnode.rs | 2 +- crates/trie/trie/src/updates.rs | 2 +- crates/trie/trie/src/walker.rs | 2 +- crates/trie/trie/src/witness.rs | 3 ++- 20 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4857d0fd2bd..25ff7a66361a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8772,6 +8772,7 @@ dependencies = [ name = "reth-trie" version = "1.0.6" dependencies = [ + "alloy-primitives", "alloy-rlp", "auto_impl", "criterion", diff --git a/crates/trie/trie/Cargo.toml b/crates/trie/trie/Cargo.toml index 54e7d6e9d2ac..eef6cfe5461b 100644 --- a/crates/trie/trie/Cargo.toml +++ b/crates/trie/trie/Cargo.toml @@ -23,6 +23,7 @@ revm.workspace = true # alloy alloy-rlp.workspace = true +alloy-primitives.workspace = true # tracing tracing.workspace = true diff --git a/crates/trie/trie/benches/hash_post_state.rs b/crates/trie/trie/benches/hash_post_state.rs index 636ce4462173..49759f14a969 100644 --- a/crates/trie/trie/benches/hash_post_state.rs +++ b/crates/trie/trie/benches/hash_post_state.rs @@ -1,7 +1,7 @@ #![allow(missing_docs, unreachable_pub)] +use alloy_primitives::{keccak256, Address, B256, U256}; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use proptest::{prelude::*, strategy::ValueTree, test_runner::TestRunner}; -use reth_primitives::{keccak256, Address, B256, U256}; use reth_trie::{HashedPostState, HashedStorage}; use revm::db::{states::BundleBuilder, BundleAccount}; use std::collections::HashMap; diff --git a/crates/trie/trie/benches/trie_root.rs b/crates/trie/trie/benches/trie_root.rs index 3f7efecc3a1f..ad169936463a 100644 --- a/crates/trie/trie/benches/trie_root.rs +++ b/crates/trie/trie/benches/trie_root.rs @@ -1,8 +1,9 @@ #![allow(missing_docs, unreachable_pub)] +use alloy_primitives::B256; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use proptest::{prelude::*, strategy::ValueTree, test_runner::TestRunner}; use proptest_arbitrary_interop::arb; -use reth_primitives::{ReceiptWithBloom, B256}; +use reth_primitives::ReceiptWithBloom; use reth_trie::triehash::KeccakHasher; /// Benchmarks different implementations of the root calculation. diff --git a/crates/trie/trie/src/hashed_cursor/mod.rs b/crates/trie/trie/src/hashed_cursor/mod.rs index b4961deae377..9b539cdce7d1 100644 --- a/crates/trie/trie/src/hashed_cursor/mod.rs +++ b/crates/trie/trie/src/hashed_cursor/mod.rs @@ -1,4 +1,5 @@ -use reth_primitives::{Account, B256, U256}; +use alloy_primitives::{B256, U256}; +use reth_primitives::Account; use reth_storage_errors::db::DatabaseError; /// Implementation of hashed state cursor traits for the post state. diff --git a/crates/trie/trie/src/hashed_cursor/post_state.rs b/crates/trie/trie/src/hashed_cursor/post_state.rs index e93795533dfe..53a2cdb3bb64 100644 --- a/crates/trie/trie/src/hashed_cursor/post_state.rs +++ b/crates/trie/trie/src/hashed_cursor/post_state.rs @@ -3,7 +3,8 @@ use crate::{ forward_cursor::ForwardInMemoryCursor, HashedAccountsSorted, HashedPostStateSorted, HashedStorageSorted, }; -use reth_primitives::{Account, B256, U256}; +use alloy_primitives::{B256, U256}; +use reth_primitives::Account; use reth_storage_errors::db::DatabaseError; use std::collections::HashSet; diff --git a/crates/trie/trie/src/node_iter.rs b/crates/trie/trie/src/node_iter.rs index ef63a60d1d79..feebe36e16e9 100644 --- a/crates/trie/trie/src/node_iter.rs +++ b/crates/trie/trie/src/node_iter.rs @@ -1,5 +1,5 @@ use crate::{hashed_cursor::HashedCursor, trie_cursor::TrieCursor, walker::TrieWalker, Nibbles}; -use reth_primitives::B256; +use alloy_primitives::B256; use reth_storage_errors::db::DatabaseError; /// Represents a branch node in the trie. diff --git a/crates/trie/trie/src/prefix_set.rs b/crates/trie/trie/src/prefix_set.rs index fa14464241ea..4997228050a3 100644 --- a/crates/trie/trie/src/prefix_set.rs +++ b/crates/trie/trie/src/prefix_set.rs @@ -1,5 +1,5 @@ use crate::Nibbles; -use reth_primitives::B256; +use alloy_primitives::B256; use std::{ collections::{HashMap, HashSet}, sync::Arc, diff --git a/crates/trie/trie/src/progress.rs b/crates/trie/trie/src/progress.rs index 1594d7f6e084..25195b48adb8 100644 --- a/crates/trie/trie/src/progress.rs +++ b/crates/trie/trie/src/progress.rs @@ -1,5 +1,5 @@ use crate::{hash_builder::HashBuilder, trie_cursor::CursorSubNode, updates::TrieUpdates}; -use reth_primitives::B256; +use alloy_primitives::B256; use reth_stages_types::MerkleCheckpoint; /// The progress of the state root computation. diff --git a/crates/trie/trie/src/proof.rs b/crates/trie/trie/src/proof.rs index 5c85fd040b8b..122518974590 100644 --- a/crates/trie/trie/src/proof.rs +++ b/crates/trie/trie/src/proof.rs @@ -6,9 +6,9 @@ use crate::{ walker::TrieWalker, HashBuilder, Nibbles, }; +use alloy_primitives::{keccak256, Address, B256}; use alloy_rlp::{BufMut, Encodable}; use reth_execution_errors::trie::StateProofError; -use reth_primitives::{keccak256, Address, B256}; use reth_trie_common::{ proof::ProofRetainer, AccountProof, MultiProof, StorageMultiProof, TrieAccount, }; diff --git a/crates/trie/trie/src/state.rs b/crates/trie/trie/src/state.rs index 1677e3b4931d..d634f05f0f39 100644 --- a/crates/trie/trie/src/state.rs +++ b/crates/trie/trie/src/state.rs @@ -2,9 +2,10 @@ use crate::{ prefix_set::{PrefixSetMut, TriePrefixSetsMut}, Nibbles, }; +use alloy_primitives::{keccak256, Address, B256, U256}; use itertools::Itertools; use rayon::prelude::{IntoParallelIterator, ParallelIterator}; -use reth_primitives::{keccak256, Account, Address, B256, U256}; +use reth_primitives::Account; use revm::db::{states::CacheAccount, AccountStatus, BundleAccount}; use std::{ borrow::Cow, diff --git a/crates/trie/trie/src/test_utils.rs b/crates/trie/trie/src/test_utils.rs index e2fc1f192c32..0d0462be90f2 100644 --- a/crates/trie/trie/src/test_utils.rs +++ b/crates/trie/trie/src/test_utils.rs @@ -1,5 +1,6 @@ +use alloy_primitives::{Address, B256, U256}; use alloy_rlp::encode_fixed_size; -use reth_primitives::{Account, Address, B256, U256}; +use reth_primitives::Account; use reth_trie_common::{triehash::KeccakHasher, TrieAccount}; /// Re-export of [triehash]. diff --git a/crates/trie/trie/src/trie.rs b/crates/trie/trie/src/trie.rs index 2b5c6d0b63c7..4047028658ea 100644 --- a/crates/trie/trie/src/trie.rs +++ b/crates/trie/trie/src/trie.rs @@ -9,9 +9,10 @@ use crate::{ walker::TrieWalker, HashBuilder, Nibbles, TrieAccount, }; +use alloy_primitives::{keccak256, Address, B256}; use alloy_rlp::{BufMut, Encodable}; use reth_execution_errors::{StateRootError, StorageRootError}; -use reth_primitives::{constants::EMPTY_ROOT_HASH, keccak256, Address, B256}; +use reth_primitives::constants::EMPTY_ROOT_HASH; use tracing::trace; #[cfg(feature = "metrics")] diff --git a/crates/trie/trie/src/trie_cursor/in_memory.rs b/crates/trie/trie/src/trie_cursor/in_memory.rs index 4159606c4920..ccb797cde8d4 100644 --- a/crates/trie/trie/src/trie_cursor/in_memory.rs +++ b/crates/trie/trie/src/trie_cursor/in_memory.rs @@ -3,7 +3,7 @@ use crate::{ forward_cursor::ForwardInMemoryCursor, updates::{StorageTrieUpdatesSorted, TrieUpdatesSorted}, }; -use reth_primitives::B256; +use alloy_primitives::B256; use reth_storage_errors::db::DatabaseError; use reth_trie_common::{BranchNodeCompact, Nibbles}; use std::collections::HashSet; diff --git a/crates/trie/trie/src/trie_cursor/mod.rs b/crates/trie/trie/src/trie_cursor/mod.rs index 3e3b408ed705..c6d42642db37 100644 --- a/crates/trie/trie/src/trie_cursor/mod.rs +++ b/crates/trie/trie/src/trie_cursor/mod.rs @@ -1,5 +1,5 @@ use crate::{BranchNodeCompact, Nibbles}; -use reth_primitives::B256; +use alloy_primitives::B256; use reth_storage_errors::db::DatabaseError; /// In-memory implementations of trie cursors. diff --git a/crates/trie/trie/src/trie_cursor/noop.rs b/crates/trie/trie/src/trie_cursor/noop.rs index 94670cf7f6cd..f3239b581090 100644 --- a/crates/trie/trie/src/trie_cursor/noop.rs +++ b/crates/trie/trie/src/trie_cursor/noop.rs @@ -1,6 +1,6 @@ use super::{TrieCursor, TrieCursorFactory}; use crate::{BranchNodeCompact, Nibbles}; -use reth_primitives::B256; +use alloy_primitives::B256; use reth_storage_errors::db::DatabaseError; /// Noop trie cursor factory. diff --git a/crates/trie/trie/src/trie_cursor/subnode.rs b/crates/trie/trie/src/trie_cursor/subnode.rs index 5385f6e312cf..c2ba839ebf2e 100644 --- a/crates/trie/trie/src/trie_cursor/subnode.rs +++ b/crates/trie/trie/src/trie_cursor/subnode.rs @@ -1,5 +1,5 @@ use crate::{BranchNodeCompact, Nibbles, StoredSubNode, CHILD_INDEX_RANGE}; -use reth_primitives::B256; +use alloy_primitives::B256; /// Cursor for iterating over a subtrie. #[derive(Clone)] diff --git a/crates/trie/trie/src/updates.rs b/crates/trie/trie/src/updates.rs index 10bf036a95da..9cb42fd68c64 100644 --- a/crates/trie/trie/src/updates.rs +++ b/crates/trie/trie/src/updates.rs @@ -1,5 +1,5 @@ use crate::{walker::TrieWalker, BranchNodeCompact, HashBuilder, Nibbles}; -use reth_primitives::B256; +use alloy_primitives::B256; use std::collections::{HashMap, HashSet}; /// The aggregation of trie updates. diff --git a/crates/trie/trie/src/walker.rs b/crates/trie/trie/src/walker.rs index 76dde9f0c94b..e75a96d0f1f4 100644 --- a/crates/trie/trie/src/walker.rs +++ b/crates/trie/trie/src/walker.rs @@ -3,7 +3,7 @@ use crate::{ trie_cursor::{CursorSubNode, TrieCursor}, BranchNodeCompact, Nibbles, }; -use reth_primitives::B256; +use alloy_primitives::B256; use reth_storage_errors::db::DatabaseError; use std::collections::HashSet; diff --git a/crates/trie/trie/src/witness.rs b/crates/trie/trie/src/witness.rs index 51c85c035c8c..fe6db2754d7e 100644 --- a/crates/trie/trie/src/witness.rs +++ b/crates/trie/trie/src/witness.rs @@ -2,10 +2,11 @@ use crate::{ hashed_cursor::HashedCursorFactory, prefix_set::TriePrefixSetsMut, proof::Proof, trie_cursor::TrieCursorFactory, HashedPostState, }; +use alloy_primitives::{keccak256, Bytes, B256}; use alloy_rlp::{BufMut, Decodable, Encodable}; use itertools::Either; use reth_execution_errors::{StateProofError, TrieWitnessError}; -use reth_primitives::{constants::EMPTY_ROOT_HASH, keccak256, Bytes, B256}; +use reth_primitives::constants::EMPTY_ROOT_HASH; use reth_trie_common::{ BranchNode, HashBuilder, Nibbles, TrieAccount, TrieNode, CHILD_INDEX_RANGE, };