chore(db): move mod tables to db-api (#14540)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
DaniPopes
2025-02-17 21:53:39 +01:00
committed by GitHub
parent 336c3d1fac
commit 482f4557eb
106 changed files with 269 additions and 274 deletions

View File

@ -15,9 +15,7 @@ workspace = true
# reth
reth-primitives-traits.workspace = true
reth-execution-errors.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-storage-errors.workspace = true
reth-trie.workspace = true
revm.workspace = true

View File

@ -2,7 +2,7 @@ use crate::{
DatabaseHashedCursorFactory, DatabaseProof, DatabaseStateRoot, DatabaseStorageRoot,
DatabaseTrieCursorFactory, DatabaseTrieWitness,
};
use reth_db::transaction::DbTx;
use reth_db_api::transaction::DbTx;
use reth_trie::{
proof::Proof, witness::TrieWitness, KeccakKeyHasher, KeyHasher, StateRoot, StorageRoot,
};

View File

@ -1,8 +1,9 @@
use alloy_primitives::{B256, U256};
use reth_db::tables;
use reth_db_api::{
cursor::{DbCursorRO, DbDupCursorRO},
tables,
transaction::DbTx,
DatabaseError,
};
use reth_primitives_traits::Account;
use reth_trie::hashed_cursor::{HashedCursor, HashedCursorFactory, HashedStorageCursor};
@ -29,14 +30,14 @@ impl<TX: DbTx> HashedCursorFactory for DatabaseHashedCursorFactory<'_, TX> {
type StorageCursor =
DatabaseHashedStorageCursor<<TX as DbTx>::DupCursor<tables::HashedStorages>>;
fn hashed_account_cursor(&self) -> Result<Self::AccountCursor, reth_db::DatabaseError> {
fn hashed_account_cursor(&self) -> Result<Self::AccountCursor, DatabaseError> {
Ok(DatabaseHashedAccountCursor(self.0.cursor_read::<tables::HashedAccounts>()?))
}
fn hashed_storage_cursor(
&self,
hashed_address: B256,
) -> Result<Self::StorageCursor, reth_db::DatabaseError> {
) -> Result<Self::StorageCursor, DatabaseError> {
Ok(DatabaseHashedStorageCursor::new(
self.0.cursor_dup_read::<tables::HashedStorages>()?,
hashed_address,
@ -62,11 +63,11 @@ where
{
type Value = Account;
fn seek(&mut self, key: B256) -> Result<Option<(B256, Self::Value)>, reth_db::DatabaseError> {
fn seek(&mut self, key: B256) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
self.0.seek(key)
}
fn next(&mut self) -> Result<Option<(B256, Self::Value)>, reth_db::DatabaseError> {
fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
self.0.next()
}
}
@ -95,14 +96,11 @@ where
{
type Value = U256;
fn seek(
&mut self,
subkey: B256,
) -> Result<Option<(B256, Self::Value)>, reth_db::DatabaseError> {
fn seek(&mut self, subkey: B256) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
Ok(self.cursor.seek_by_key_subkey(self.hashed_address, subkey)?.map(|e| (e.key, e.value)))
}
fn next(&mut self) -> Result<Option<(B256, Self::Value)>, reth_db::DatabaseError> {
fn next(&mut self) -> Result<Option<(B256, Self::Value)>, DatabaseError> {
Ok(self.cursor.next_dup_val()?.map(|e| (e.key, e.value)))
}
}
@ -111,7 +109,7 @@ impl<C> HashedStorageCursor for DatabaseHashedStorageCursor<C>
where
C: DbCursorRO<tables::HashedStorages> + DbDupCursorRO<tables::HashedStorages>,
{
fn is_storage_empty(&mut self) -> Result<bool, reth_db::DatabaseError> {
fn is_storage_empty(&mut self) -> Result<bool, DatabaseError> {
Ok(self.cursor.seek_exact(self.hashed_address)?.is_none())
}
}

View File

@ -4,10 +4,10 @@ use alloy_primitives::{
};
use core::{marker::PhantomData, ops::RangeInclusive};
use derive_more::Deref;
use reth_db::tables;
use reth_db_api::{
cursor::DbCursorRO,
models::{AccountBeforeTx, BlockNumberAddress},
tables,
transaction::DbTx,
DatabaseError,
};

View File

@ -3,14 +3,14 @@ use alloy_primitives::{
map::{AddressMap, B256Map},
Address, BlockNumber, B256, U256,
};
use reth_db::tables;
use reth_db_api::{
cursor::DbCursorRO,
models::{AccountBeforeTx, BlockNumberAddress},
tables,
transaction::DbTx,
DatabaseError,
};
use reth_execution_errors::StateRootError;
use reth_storage_errors::db::DatabaseError;
use reth_trie::{
hashed_cursor::HashedPostStateCursorFactory, trie_cursor::InMemoryTrieCursorFactory,
updates::TrieUpdates, HashedPostState, HashedStorage, KeccakKeyHasher, KeyHasher, StateRoot,

View File

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

View File

@ -1,13 +1,10 @@
use alloy_primitives::B256;
use reth_db::{
cursor::{DbCursorRW, DbDupCursorRW},
tables,
};
use reth_db_api::{
cursor::{DbCursorRO, DbDupCursorRO},
cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO, DbDupCursorRW},
tables,
transaction::DbTx,
DatabaseError,
};
use reth_storage_errors::db::DatabaseError;
use reth_trie::{
trie_cursor::{TrieCursor, TrieCursorFactory},
updates::StorageTrieUpdates,

View File

@ -1,8 +1,7 @@
#![allow(missing_docs)]
use alloy_primitives::B256;
use reth_db::tables;
use reth_db_api::{cursor::DbCursorRW, transaction::DbTxMut};
use reth_db_api::{cursor::DbCursorRW, tables, transaction::DbTxMut};
use reth_provider::test_utils::create_test_provider_factory;
use reth_trie::{
prefix_set::PrefixSetMut, trie_cursor::TrieCursor, walker::TrieWalker, BranchNodeCompact,

View File

@ -14,7 +14,7 @@ workspace = true
[dependencies]
# reth
reth-primitives.workspace = true
reth-db.workspace = true
reth-storage-errors.workspace = true
reth-trie.workspace = true
reth-trie-common.workspace = true
reth-trie-db.workspace = true
@ -57,7 +57,6 @@ metrics = ["reth-metrics", "dep:metrics", "reth-trie/metrics"]
test-utils = [
"reth-trie/test-utils",
"reth-trie-common/test-utils",
"reth-db/test-utils",
"reth-primitives/test-utils",
"reth-provider/test-utils",
"reth-trie-db/test-utils",

View File

@ -5,12 +5,12 @@ use alloy_primitives::{
};
use alloy_rlp::{BufMut, Encodable};
use itertools::Itertools;
use reth_db::DatabaseError;
use reth_execution_errors::StorageRootError;
use reth_provider::{
providers::ConsistentDbView, BlockReader, DBProvider, DatabaseProviderFactory, ProviderError,
StateCommitmentProvider,
};
use reth_storage_errors::db::DatabaseError;
use reth_trie::{
hashed_cursor::{HashedCursorFactory, HashedPostStateCursorFactory},
node_iter::{TrieElement, TrieNodeIter},

View File

@ -4,12 +4,12 @@ use crate::{stats::ParallelTrieTracker, storage_root_targets::StorageRootTargets
use alloy_primitives::B256;
use alloy_rlp::{BufMut, Encodable};
use itertools::Itertools;
use reth_db::DatabaseError;
use reth_execution_errors::StorageRootError;
use reth_provider::{
providers::ConsistentDbView, BlockReader, DBProvider, DatabaseProviderFactory, ProviderError,
StateCommitmentProvider,
};
use reth_storage_errors::db::DatabaseError;
use reth_trie::{
hashed_cursor::{HashedCursorFactory, HashedPostStateCursorFactory},
node_iter::{TrieElement, TrieNodeIter},
@ -166,7 +166,7 @@ where
let (storage_root, _, updates) = match storage_roots.remove(&hashed_address) {
Some(rx) => rx.recv().map_err(|_| {
ParallelStateRootError::StorageRoot(StorageRootError::Database(
reth_db::DatabaseError::Other(format!(
DatabaseError::Other(format!(
"channel closed for {hashed_address}"
)),
))