From ea0a96a926b98e9d5b917c19b952236a95f527f3 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 17 Feb 2025 17:52:09 +0100 Subject: [PATCH] chore(storage-api): reduce dependence on reth-db (#14539) --- Cargo.lock | 1 - crates/storage/db-api/src/models/mod.rs | 2 +- crates/storage/storage-api/Cargo.toml | 1 - crates/storage/storage-api/src/account.rs | 2 +- crates/storage/storage-api/src/block_indices.rs | 2 +- crates/storage/storage-api/src/chain.rs | 4 ++-- crates/storage/storage-api/src/hashing.rs | 6 +++--- crates/storage/storage-api/src/history.rs | 2 +- crates/storage/storage-api/src/noop.rs | 2 +- 9 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c2b438f1e..533fab58e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9490,7 +9490,6 @@ dependencies = [ "reth-chainspec", "reth-db", "reth-db-api", - "reth-db-models", "reth-ethereum-primitives", "reth-execution-types", "reth-primitives-traits", diff --git a/crates/storage/db-api/src/models/mod.rs b/crates/storage/db-api/src/models/mod.rs index 19e3600db..7a4cbe669 100644 --- a/crates/storage/db-api/src/models/mod.rs +++ b/crates/storage/db-api/src/models/mod.rs @@ -25,7 +25,7 @@ pub use accounts::*; pub use blocks::*; pub use integer_list::IntegerList; pub use reth_db_models::{ - blocks::StaticFileBlockWithdrawals, AccountBeforeTx, ClientVersion, StoredBlockBodyIndices, + AccountBeforeTx, ClientVersion, StaticFileBlockWithdrawals, StoredBlockBodyIndices, StoredBlockWithdrawals, }; pub use sharded_key::ShardedKey; diff --git a/crates/storage/storage-api/Cargo.toml b/crates/storage/storage-api/Cargo.toml index cd3bb6763..bcba142d4 100644 --- a/crates/storage/storage-api/Cargo.toml +++ b/crates/storage/storage-api/Cargo.toml @@ -14,7 +14,6 @@ workspace = true [dependencies] # reth reth-chainspec.workspace = true -reth-db-models.workspace = true reth-db-api.workspace = true reth-execution-types.workspace = true reth-primitives-traits.workspace = true diff --git a/crates/storage/storage-api/src/account.rs b/crates/storage/storage-api/src/account.rs index b01deb359..4a23c1059 100644 --- a/crates/storage/storage-api/src/account.rs +++ b/crates/storage/storage-api/src/account.rs @@ -5,7 +5,7 @@ use alloc::{ use alloy_primitives::{Address, BlockNumber}; use auto_impl::auto_impl; use core::ops::{RangeBounds, RangeInclusive}; -use reth_db_models::AccountBeforeTx; +use reth_db_api::models::AccountBeforeTx; use reth_primitives_traits::Account; use reth_storage_errors::provider::ProviderResult; diff --git a/crates/storage/storage-api/src/block_indices.rs b/crates/storage/storage-api/src/block_indices.rs index 5a4f1e22b..bfb22ecbc 100644 --- a/crates/storage/storage-api/src/block_indices.rs +++ b/crates/storage/storage-api/src/block_indices.rs @@ -1,7 +1,7 @@ use alloc::vec::Vec; use alloy_primitives::BlockNumber; use core::ops::RangeInclusive; -use reth_db_models::StoredBlockBodyIndices; +use reth_db_api::models::StoredBlockBodyIndices; use reth_storage_errors::provider::ProviderResult; /// Client trait for fetching block body indices related data. diff --git a/crates/storage/storage-api/src/chain.rs b/crates/storage/storage-api/src/chain.rs index ffb4214c7..2d1853988 100644 --- a/crates/storage/storage-api/src/chain.rs +++ b/crates/storage/storage-api/src/chain.rs @@ -4,10 +4,10 @@ use alloy_consensus::Header; use alloy_primitives::BlockNumber; use core::marker::PhantomData; use reth_chainspec::{ChainSpecProvider, EthereumHardforks}; -use reth_db::{ +use reth_db::tables; +use reth_db_api::{ cursor::{DbCursorRO, DbCursorRW}, models::{StoredBlockOmmers, StoredBlockWithdrawals}, - tables, transaction::{DbTx, DbTxMut}, DbTxUnwindExt, }; diff --git a/crates/storage/storage-api/src/hashing.rs b/crates/storage/storage-api/src/hashing.rs index 73969cad2..f3a244506 100644 --- a/crates/storage/storage-api/src/hashing.rs +++ b/crates/storage/storage-api/src/hashing.rs @@ -2,7 +2,7 @@ use alloc::collections::{BTreeMap, BTreeSet}; use alloy_primitives::{map::HashMap, Address, BlockNumber, B256}; use auto_impl::auto_impl; use core::ops::{RangeBounds, RangeInclusive}; -use reth_db::models::{AccountBeforeTx, BlockNumberAddress}; +use reth_db_api::models::{AccountBeforeTx, BlockNumberAddress}; use reth_primitives_traits::{Account, StorageEntry}; use reth_storage_errors::provider::ProviderResult; @@ -29,7 +29,7 @@ pub trait HashingWriter: Send + Sync { range: impl RangeBounds, ) -> ProviderResult>>; - /// Inserts all accounts into [reth_db::tables::AccountsHistory] table. + /// Inserts all accounts into the `AccountsHistory` table. /// /// # Returns /// @@ -39,7 +39,7 @@ pub trait HashingWriter: Send + Sync { accounts: impl IntoIterator)>, ) -> ProviderResult>>; - /// Unwind and clear storage hashing + /// Unwind and clear storage hashing. /// /// # Returns /// diff --git a/crates/storage/storage-api/src/history.rs b/crates/storage/storage-api/src/history.rs index ec7b1a5e3..befe5b2a3 100644 --- a/crates/storage/storage-api/src/history.rs +++ b/crates/storage/storage-api/src/history.rs @@ -1,7 +1,7 @@ use alloy_primitives::{Address, BlockNumber, B256}; use auto_impl::auto_impl; use core::ops::{RangeBounds, RangeInclusive}; -use reth_db::models::{AccountBeforeTx, BlockNumberAddress}; +use reth_db_api::models::{AccountBeforeTx, BlockNumberAddress}; use reth_primitives_traits::StorageEntry; use reth_storage_errors::provider::ProviderResult; diff --git a/crates/storage/storage-api/src/noop.rs b/crates/storage/storage-api/src/noop.rs index fac4e74fa..5a2cad5e5 100644 --- a/crates/storage/storage-api/src/noop.rs +++ b/crates/storage/storage-api/src/noop.rs @@ -20,7 +20,7 @@ use core::{ ops::{RangeBounds, RangeInclusive}, }; use reth_chainspec::{ChainInfo, ChainSpecProvider, EthChainSpec, MAINNET}; -use reth_db_models::{AccountBeforeTx, StoredBlockBodyIndices}; +use reth_db_api::models::{AccountBeforeTx, StoredBlockBodyIndices}; use reth_ethereum_primitives::EthPrimitives; use reth_primitives_traits::{ Account, Bytecode, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader,