trie: replace reth_primitives with alloy_primitives (#10931)

Signed-off-by: Abhishekkochar <abhishekkochar2@gmail.com>
This commit is contained in:
Abhishek kochar
2024-09-16 19:48:04 +08:00
committed by GitHub
parent 0fa8e83e16
commit 5468921b90
19 changed files with 31 additions and 18 deletions

2
Cargo.lock generated
View File

@ -8890,6 +8890,7 @@ dependencies = [
name = "reth-trie-db"
version = "1.0.6"
dependencies = [
"alloy-primitives",
"alloy-rlp",
"auto_impl",
"derive_more",
@ -8924,6 +8925,7 @@ dependencies = [
name = "reth-trie-parallel"
version = "1.0.6"
dependencies = [
"alloy-primitives",
"alloy-rlp",
"criterion",
"derive_more",

View File

@ -26,6 +26,7 @@ revm.workspace = true
# alloy
alloy-rlp.workspace = true
alloy-primitives.workspace = true
# tracing
tracing.workspace = true

View File

@ -1,9 +1,10 @@
use alloy_primitives::{B256, U256};
use reth_db::tables;
use reth_db_api::{
cursor::{DbCursorRO, DbDupCursorRO},
transaction::DbTx,
};
use reth_primitives::{Account, B256, U256};
use reth_primitives::Account;
use reth_trie::hashed_cursor::{HashedCursor, HashedCursorFactory, HashedStorageCursor};
/// A struct wrapping database transaction that implements [`HashedCursorFactory`].

View File

@ -1,3 +1,4 @@
use alloy_primitives::{keccak256, BlockNumber, B256};
use derive_more::Deref;
use reth_db::tables;
use reth_db_api::{
@ -6,7 +7,7 @@ use reth_db_api::{
transaction::DbTx,
DatabaseError,
};
use reth_primitives::{keccak256, BlockNumber, StorageEntry, B256};
use reth_primitives::StorageEntry;
use reth_trie::prefix_set::{PrefixSetMut, TriePrefixSets};
use reth_trie_common::Nibbles;
use std::{

View File

@ -1,7 +1,7 @@
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
use alloy_primitives::{Address, B256};
use reth_db_api::transaction::DbTx;
use reth_execution_errors::StateProofError;
use reth_primitives::{Address, B256};
use reth_trie::{
hashed_cursor::HashedPostStateCursorFactory, proof::Proof,
trie_cursor::InMemoryTrieCursorFactory, MultiProof, TrieInput,

View File

@ -1,4 +1,5 @@
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory, PrefixSetLoader};
use alloy_primitives::{keccak256, Address, BlockNumber, B256, U256};
use reth_db::tables;
use reth_db_api::{
cursor::DbCursorRO,
@ -6,7 +7,7 @@ use reth_db_api::{
transaction::DbTx,
};
use reth_execution_errors::StateRootError;
use reth_primitives::{keccak256, Account, Address, BlockNumber, B256, U256};
use reth_primitives::Account;
use reth_storage_errors::db::DatabaseError;
use reth_trie::{
hashed_cursor::HashedPostStateCursorFactory, trie_cursor::InMemoryTrieCursorFactory,

View File

@ -1,10 +1,10 @@
use std::collections::hash_map;
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
use alloy_primitives::{keccak256, Address, BlockNumber, B256};
use reth_db::{cursor::DbCursorRO, models::BlockNumberAddress, tables, DatabaseError};
use reth_db_api::transaction::DbTx;
use reth_execution_errors::StorageRootError;
use reth_primitives::{keccak256, Address, BlockNumber, B256};
use reth_trie::{
hashed_cursor::HashedPostStateCursorFactory, HashedPostState, HashedStorage, StorageRoot,
};

View File

@ -1,3 +1,4 @@
use alloy_primitives::B256;
use reth_db::{
cursor::{DbCursorRW, DbDupCursorRW},
tables,
@ -6,7 +7,6 @@ use reth_db_api::{
cursor::{DbCursorRO, DbDupCursorRO},
transaction::DbTx,
};
use reth_primitives::B256;
use reth_storage_errors::db::DatabaseError;
use reth_trie::{
trie_cursor::{TrieCursor, TrieCursorFactory},

View File

@ -1,7 +1,7 @@
use crate::{DatabaseHashedCursorFactory, DatabaseTrieCursorFactory};
use alloy_primitives::{Bytes, B256};
use reth_db_api::transaction::DbTx;
use reth_execution_errors::TrieWitnessError;
use reth_primitives::{Bytes, B256};
use reth_trie::{
hashed_cursor::HashedPostStateCursorFactory, trie_cursor::InMemoryTrieCursorFactory,
witness::TrieWitness, HashedPostState, TrieInput,

View File

@ -1,10 +1,11 @@
use alloy_primitives::{B256, U256};
use proptest::prelude::*;
use reth_db::{
cursor::{DbCursorRO, DbCursorRW, DbDupCursorRW},
tables,
transaction::DbTxMut,
};
use reth_primitives::{Account, StorageEntry, B256, U256};
use reth_primitives::{Account, StorageEntry};
use reth_provider::test_utils::create_test_provider_factory;
use reth_trie::{
test_utils::{state_root_prehashed, storage_root_prehashed},

View File

@ -1,8 +1,9 @@
use alloy_primitives::{B256, U256};
use proptest::prelude::*;
use proptest_arbitrary_interop::arb;
use reth_db::{tables, test_utils::create_test_rw_db};
use reth_db_api::{database::Database, transaction::DbTxMut};
use reth_primitives::{Account, StorageEntry, B256, U256};
use reth_primitives::{Account, StorageEntry};
use reth_trie::{
hashed_cursor::{
HashedCursor, HashedCursorFactory, HashedPostStateCursorFactory, HashedStorageCursor,

View File

@ -1,5 +1,6 @@
use alloy_primitives::{keccak256, Address, Bytes, B256, U256};
use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET};
use reth_primitives::{constants::EMPTY_ROOT_HASH, keccak256, Account, Address, Bytes, B256, U256};
use reth_primitives::{constants::EMPTY_ROOT_HASH, Account};
use reth_provider::test_utils::{create_test_provider_factory, insert_genesis};
use reth_trie::{proof::Proof, Nibbles};
use reth_trie_common::{AccountProof, StorageProof};

View File

@ -1,3 +1,4 @@
use alloy_primitives::{keccak256, Address, B256, U256};
use proptest::{prelude::ProptestConfig, proptest};
use proptest_arbitrary_interop::arb;
use reth_db::{tables, test_utils::TempDatabase, DatabaseEnv};
@ -5,7 +6,7 @@ use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO},
transaction::DbTxMut,
};
use reth_primitives::{hex_literal::hex, Account, StorageEntry, U256};
use reth_primitives::{constants::EMPTY_ROOT_HASH, hex_literal::hex, Account, StorageEntry};
use reth_provider::{
test_utils::create_test_provider_factory, DatabaseProviderRW, StorageTrieWriter, TrieWriter,
};
@ -25,7 +26,6 @@ use std::{
use alloy_rlp::Encodable;
use reth_db_api::transaction::DbTx;
use reth_primitives::{constants::EMPTY_ROOT_HASH, keccak256, Address, B256};
use reth_trie::{
prefix_set::TriePrefixSets, updates::StorageTrieUpdates, HashBuilder,
IntermediateStateRootState, Nibbles, StateRootProgress, TrieAccount,

View File

@ -1,6 +1,6 @@
use alloy_primitives::B256;
use reth_db::tables;
use reth_db_api::{cursor::DbCursorRW, transaction::DbTxMut};
use reth_primitives::B256;
use reth_provider::test_utils::create_test_provider_factory;
use reth_trie::{
prefix_set::PrefixSetMut, trie_cursor::TrieCursor, walker::TrieWalker, StorageTrieEntry,

View File

@ -23,6 +23,7 @@ reth-provider.workspace = true
# alloy
alloy-rlp.workspace = true
alloy-primitives.workspace = true
# tracing
tracing.workspace = true

View File

@ -1,9 +1,10 @@
#![allow(missing_docs, unreachable_pub)]
use alloy_primitives::{B256, U256};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use proptest::{prelude::*, strategy::ValueTree, test_runner::TestRunner};
use proptest_arbitrary_interop::arb;
use rayon::ThreadPoolBuilder;
use reth_primitives::{Account, B256, U256};
use reth_primitives::Account;
use reth_provider::{
providers::ConsistentDbView, test_utils::create_test_provider_factory, StateChangeWriter,
TrieWriter,

View File

@ -1,10 +1,10 @@
#[cfg(feature = "metrics")]
use crate::metrics::ParallelStateRootMetrics;
use crate::{stats::ParallelTrieTracker, storage_root_targets::StorageRootTargets};
use alloy_primitives::B256;
use alloy_rlp::{BufMut, Encodable};
use itertools::Itertools;
use reth_execution_errors::StorageRootError;
use reth_primitives::B256;
use reth_provider::{
providers::ConsistentDbView, BlockReader, DBProvider, DatabaseProviderFactory, ProviderError,
};
@ -240,9 +240,10 @@ pub enum AsyncStateRootError {
#[cfg(test)]
mod tests {
use super::*;
use alloy_primitives::{keccak256, Address, U256};
use rand::Rng;
use rayon::ThreadPoolBuilder;
use reth_primitives::{keccak256, Account, Address, StorageEntry, U256};
use reth_primitives::{Account, StorageEntry};
use reth_provider::{test_utils::create_test_provider_factory, HashingWriter};
use reth_trie::{test_utils, HashedPostState, HashedStorage};

View File

@ -226,8 +226,9 @@ impl From<ParallelStateRootError> for ProviderError {
#[cfg(test)]
mod tests {
use super::*;
use alloy_primitives::{keccak256, Address, U256};
use rand::Rng;
use reth_primitives::{keccak256, Account, Address, StorageEntry, U256};
use reth_primitives::{Account, StorageEntry};
use reth_provider::{test_utils::create_test_provider_factory, HashingWriter};
use reth_trie::{test_utils, HashedPostState, HashedStorage};

View File

@ -1,5 +1,5 @@
use alloy_primitives::B256;
use derive_more::{Deref, DerefMut};
use reth_primitives::B256;
use reth_trie::prefix_set::PrefixSet;
use std::collections::HashMap;