Skip to content

Commit

Permalink
storage: replace reth-primitive imports
Browse files Browse the repository at this point in the history
  • Loading branch information
estensen committed Sep 18, 2024
1 parent c09391f commit cb036ac
Show file tree
Hide file tree
Showing 49 changed files with 141 additions and 107 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/storage/db-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ reth-stages-types.workspace = true
reth-storage-errors.workspace = true
reth-trie-common.workspace = true

# ethereum
alloy-primitives = { workspace = true }

# codecs
modular-bitfield.workspace = true
parity-scale-codec = { version = "3.2.1", features = ["bytes"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/db-api/src/models/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
table::{Decode, Encode},
DatabaseError,
};
use reth_primitives::{Address, BlockNumber, StorageKey};
use alloy_primitives::{Address, BlockNumber, StorageKey};
use serde::{Deserialize, Serialize};

/// [`BlockNumber`] concatenated with [`Address`].
Expand Down
3 changes: 2 additions & 1 deletion crates/storage/db-api/src/models/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Block related models and types.
use alloy_primitives::B256;
use reth_codecs::{add_arbitrary_tests, Compact};
use reth_primitives::{Header, B256};
use reth_primitives::Header;
use serde::{Deserialize, Serialize};

/// The storage representation of a block's ommers.
Expand Down
6 changes: 5 additions & 1 deletion crates/storage/db-api/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ use crate::{
table::{Compress, Decode, Decompress, Encode},
DatabaseError,
};
use alloy_primitives::{Address, Log, B256, U256};
use reth_codecs::{add_arbitrary_tests, Compact};
use reth_primitives::{Address, B256, *};
use reth_primitives::{
Account, Bytecode, GenesisAccount, Header, Receipt, Requests, SealedHeader, StorageEntry,
TransactionSignedNoHash, TxType,
};
use reth_prune_types::{PruneCheckpoint, PruneSegment};
use reth_stages_types::StageCheckpoint;
use reth_trie_common::{StoredNibbles, StoredNibblesSubKey, *};
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/db-api/src/models/sharded_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
table::{Decode, Encode},
DatabaseError,
};
use reth_primitives::BlockNumber;
use alloy_primitives::BlockNumber;
use serde::{Deserialize, Serialize};
use std::hash::Hash;

Expand Down
2 changes: 1 addition & 1 deletion crates/storage/db-api/src/models/storage_sharded_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{
table::{Decode, Encode},
DatabaseError,
};
use alloy_primitives::{Address, BlockNumber, B256};
use derive_more::AsRef;
use reth_primitives::{Address, BlockNumber, B256};
use serde::{Deserialize, Serialize};

use super::ShardedKey;
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/db-api/src/scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
table::{Compress, Decompress},
DatabaseError,
};
use reth_primitives::*;
use alloy_primitives::U256;

mod sealed {
pub trait Sealed {}
Expand Down
3 changes: 3 additions & 0 deletions crates/storage/db-models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ workspace = true
reth-codecs.workspace = true
reth-primitives = { workspace = true, features = ["reth-codec"] }

# ethereum
alloy-primitives = { workspace = true }

# codecs
modular-bitfield.workspace = true
serde = { workspace = true, default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion crates/storage/db-models/src/accounts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use reth_codecs::{add_arbitrary_tests, Compact};
use serde::Serialize;

use reth_primitives::{Account, Address, Buf};
use alloy_primitives::Address;
use reth_primitives::{Account, Buf};

/// Account as it is saved in the database.
///
Expand Down
3 changes: 2 additions & 1 deletion crates/storage/db-models/src/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::ops::Range;

use alloy_primitives::TxNumber;
use reth_codecs::{add_arbitrary_tests, Compact};
use reth_primitives::{TxNumber, Withdrawals};
use reth_primitives::Withdrawals;
use serde::{Deserialize, Serialize};

/// Total number of transactions.
Expand Down
3 changes: 3 additions & 0 deletions crates/storage/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ reth-stages-types.workspace = true
reth-tracing.workspace = true
reth-trie-common.workspace = true

# ethereum
alloy-primitives.workspace = true

# mdbx
reth-libmdbx = { workspace = true, optional = true, features = [
"return-borrowed",
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/db/benches/utils.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use alloy_primitives::Bytes;
use reth_db::{test_utils::create_test_rw_db_with_path, DatabaseEnv};
use reth_db_api::{
database::Database,
table::{Compress, Encode, Table, TableRow},
transaction::DbTxMut,
};
use reth_fs_util as fs;
use reth_primitives::Bytes;
use std::{path::Path, sync::Arc};

/// Path where the DB is initialized for benchmarks.
Expand Down
3 changes: 2 additions & 1 deletion crates/storage/db/src/implementation/mdbx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,14 @@ mod tests {
test_utils::*,
AccountChangeSets,
};
use alloy_primitives::{Address, B256, U256};
use reth_db_api::{
cursor::{DbDupCursorRO, DbDupCursorRW, ReverseWalker, Walker},
models::{AccountBeforeTx, ShardedKey},
table::{Encode, Table},
};
use reth_libmdbx::Error;
use reth_primitives::{Account, Address, Header, StorageEntry, B256, U256};
use reth_primitives::{Account, Header, StorageEntry};
use reth_primitives_traits::IntegerList;
use reth_storage_errors::db::{DatabaseWriteError, DatabaseWriteOperation};
use std::str::FromStr;
Expand Down
3 changes: 2 additions & 1 deletion crates/storage/db/src/static_file/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use super::mask::{ColumnSelectorOne, ColumnSelectorThree, ColumnSelectorTwo};
use alloy_primitives::B256;
use derive_more::{Deref, DerefMut};
use reth_db_api::table::Decompress;
use reth_nippy_jar::{DataReader, NippyJar, NippyJarCursor};
use reth_primitives::{static_file::SegmentHeader, B256};
use reth_primitives::static_file::SegmentHeader;
use reth_storage_errors::provider::{ProviderError, ProviderResult};
use std::sync::Arc;

Expand Down
3 changes: 2 additions & 1 deletion crates/storage/db/src/static_file/masks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ use crate::{
static_file::mask::{ColumnSelectorOne, ColumnSelectorTwo, HeaderMask},
HeaderTerminalDifficulties, RawValue, Receipts, Transactions,
};
use alloy_primitives::BlockHash;
use reth_db_api::table::Table;
use reth_primitives::{BlockHash, Header};
use reth_primitives::Header;

// HEADER MASKS
add_static_file_mask!(HeaderMask, Header, 0b001);
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/db/src/tables/codecs/fuzz/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ macro_rules! impl_fuzzer_with_input {
use reth_db_api::table;

#[allow(unused_imports)]
use reth_primitives::*;


#[allow(unused_imports)]
use reth_primitives_traits::*;
Expand Down
4 changes: 2 additions & 2 deletions crates/storage/db/src/tables/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub use raw::{RawDupSort, RawKey, RawTable, RawValue, TableRawRow};
#[cfg(feature = "mdbx")]
pub(crate) mod utils;

use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash, TxNumber, B256};
use reth_db_api::{
models::{
accounts::BlockNumberAddress,
Expand All @@ -30,8 +31,7 @@ use reth_db_api::{
table::{Decode, DupSort, Encode, Table},
};
use reth_primitives::{
Account, Address, BlockHash, BlockNumber, Bytecode, Header, Receipt, Requests, StorageEntry,
TransactionSignedNoHash, TxHash, TxNumber, B256,
Account, Bytecode, Header, Receipt, Requests, StorageEntry, TransactionSignedNoHash,
};
use reth_primitives_traits::IntegerList;
use reth_prune_types::{PruneCheckpoint, PruneSegment};
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/errors/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl fmt::Display for DatabaseWriteError {
f,
"write operation {:?} failed for key \"{}\" in table {}: {}",
self.operation,
reth_primitives::hex::encode(&self.key),
alloy_primitives::hex::encode(&self.key),
self.table_name,
self.info
)
Expand Down
1 change: 1 addition & 0 deletions crates/storage/provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ reth-chain-state.workspace = true
reth-node-types.workspace = true

# ethereum
alloy-primitives.workspace = true
alloy-rpc-types-engine.workspace = true
revm.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/storage/provider/src/bundle_state/state_reverts.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use reth_primitives::{B256, U256};
use alloy_primitives::{B256, U256};
use revm::db::states::RevertToSlot;
use std::iter::Peekable;

Expand Down
11 changes: 6 additions & 5 deletions crates/storage/provider/src/providers/blockchain_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
RequestsProvider, StageCheckpointReader, StateProviderBox, StateProviderFactory, StateReader,
StaticFileProviderFactory, TransactionVariant, TransactionsProvider, WithdrawalsProvider,
};
use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash, TxNumber, B256, U256};
use alloy_rpc_types_engine::ForkchoiceState;
use reth_chain_state::{
BlockState, CanonicalInMemoryState, ForkChoiceNotifications, ForkChoiceSubscriptions,
Expand All @@ -19,10 +20,9 @@ use reth_evm::ConfigureEvmEnv;
use reth_execution_types::ExecutionOutcome;
use reth_node_types::NodeTypesWithDB;
use reth_primitives::{
Account, Address, Block, BlockHash, BlockHashOrNumber, BlockId, BlockNumHash, BlockNumber,
BlockNumberOrTag, BlockWithSenders, EthereumHardforks, Header, Receipt, SealedBlock,
SealedBlockWithSenders, SealedHeader, TransactionMeta, TransactionSigned,
TransactionSignedNoHash, TxHash, TxNumber, Withdrawal, Withdrawals, B256, U256,
Account, Block, BlockHashOrNumber, BlockId, BlockNumHash, BlockNumberOrTag, BlockWithSenders,
EthereumHardforks, Header, Receipt, SealedBlock, SealedBlockWithSenders, SealedHeader,
TransactionMeta, TransactionSigned, TransactionSignedNoHash, Withdrawal, Withdrawals,
};
use reth_prune_types::{PruneCheckpoint, PruneSegment};
use reth_stages_types::{StageCheckpoint, StageId};
Expand Down Expand Up @@ -1395,6 +1395,7 @@ mod tests {
writer::UnifiedStorageWriter,
BlockWriter, CanonChainTracker, StaticFileProviderFactory, StaticFileWriter,
};
use alloy_primitives::B256;
use itertools::Itertools;
use rand::Rng;
use reth_chain_state::{
Expand All @@ -1409,7 +1410,7 @@ mod tests {
use reth_primitives::{
BlockHashOrNumber, BlockNumHash, BlockNumberOrTag, BlockWithSenders, Receipt, SealedBlock,
SealedBlockWithSenders, StaticFileSegment, TransactionMeta, TransactionSignedNoHash,
Withdrawals, B256,
Withdrawals,
};
use reth_storage_api::{
BlockHashReader, BlockIdReader, BlockNumReader, BlockReader, BlockReaderIdExt, BlockSource,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{
AccountReader, BlockHashReader, ExecutionDataProvider, StateProvider, StateRootProvider,
};
use reth_primitives::{Account, Address, BlockNumber, Bytecode, Bytes, B256};
use alloy_primitives::{Address, BlockNumber, Bytes, B256};
use reth_primitives::{Account, Bytecode};
use reth_storage_api::{StateProofProvider, StorageRootProvider};
use reth_storage_errors::provider::ProviderResult;
use reth_trie::{
Expand Down Expand Up @@ -160,8 +161,8 @@ impl<SP: StateProvider, EDP: ExecutionDataProvider> StateProvider for BundleStat
fn storage(
&self,
account: Address,
storage_key: reth_primitives::StorageKey,
) -> ProviderResult<Option<reth_primitives::StorageValue>> {
storage_key: alloy_primitives::StorageKey,
) -> ProviderResult<Option<alloy_primitives::StorageValue>> {
let u256_storage_key = storage_key.into();
if let Some(value) = self
.block_execution_data_provider
Expand Down
4 changes: 3 additions & 1 deletion crates/storage/provider/src/providers/consistent_view.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::{BlockNumReader, DatabaseProviderFactory, HeaderProvider};
use alloy_primitives::B256;
use reth_errors::ProviderError;
use reth_primitives::{GotExpected, B256};
use reth_primitives::GotExpected;
use reth_storage_api::{BlockReader, DBProvider};
use reth_storage_errors::provider::ProviderResult;

use reth_trie::HashedPostState;
use reth_trie_db::DatabaseHashedPostState;

Expand Down
11 changes: 6 additions & 5 deletions crates/storage/provider/src/providers/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
PruneCheckpointReader, RequestsProvider, StageCheckpointReader, StateProviderBox,
StaticFileProviderFactory, TransactionVariant, TransactionsProvider, WithdrawalsProvider,
};
use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash, TxNumber, B256, U256};
use core::fmt;
use reth_chainspec::ChainInfo;
use reth_db::{init_db, mdbx::DatabaseArguments, DatabaseEnv};
Expand All @@ -15,10 +16,9 @@ use reth_errors::{RethError, RethResult};
use reth_evm::ConfigureEvmEnv;
use reth_node_types::NodeTypesWithDB;
use reth_primitives::{
Address, Block, BlockHash, BlockHashOrNumber, BlockNumber, BlockWithSenders, Header, Receipt,
SealedBlock, SealedBlockWithSenders, SealedHeader, StaticFileSegment, TransactionMeta,
TransactionSigned, TransactionSignedNoHash, TxHash, TxNumber, Withdrawal, Withdrawals, B256,
U256,
Block, BlockHashOrNumber, BlockWithSenders, Header, Receipt, SealedBlock,
SealedBlockWithSenders, SealedHeader, StaticFileSegment, TransactionMeta, TransactionSigned,
TransactionSignedNoHash, Withdrawal, Withdrawals,
};
use reth_prune_types::{PruneCheckpoint, PruneModes, PruneSegment};
use reth_stages_types::{StageCheckpoint, StageId};
Expand Down Expand Up @@ -633,6 +633,7 @@ mod tests {
test_utils::{blocks::TEST_BLOCK, create_test_provider_factory, MockNodeTypesWithDB},
BlockHashReader, BlockNumReader, BlockWriter, HeaderSyncGapProvider, TransactionsProvider,
};
use alloy_primitives::{TxNumber, B256, U256};
use assert_matches::assert_matches;
use rand::Rng;
use reth_chainspec::ChainSpecBuilder;
Expand All @@ -641,7 +642,7 @@ mod tests {
tables,
test_utils::{create_test_static_files_dir, ERROR_TEMPDIR},
};
use reth_primitives::{StaticFileSegment, TxNumber, B256, U256};
use reth_primitives::StaticFileSegment;
use reth_prune_types::{PruneMode, PruneModes};
use reth_storage_errors::provider::ProviderError;
use reth_testing_utils::generators::{self, random_block, random_header, BlockParams};
Expand Down
10 changes: 5 additions & 5 deletions crates/storage/provider/src/providers/database/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::{
StatsReader, StorageReader, StorageTrieWriter, TransactionVariant, TransactionsProvider,
TransactionsProviderExt, TrieWriter, WithdrawalsProvider,
};
use alloy_primitives::{keccak256, Address, BlockHash, BlockNumber, TxHash, TxNumber, B256, U256};
use itertools::{izip, Itertools};
use rayon::slice::ParallelSliceMut;
use reth_chainspec::{ChainInfo, ChainSpec, EthereumHardforks};
Expand All @@ -37,11 +38,10 @@ use reth_evm::ConfigureEvmEnv;
use reth_execution_types::{Chain, ExecutionOutcome};
use reth_network_p2p::headers::downloader::SyncTarget;
use reth_primitives::{
keccak256, Account, Address, Block, BlockHash, BlockHashOrNumber, BlockNumber,
BlockWithSenders, Bytecode, GotExpected, Header, Receipt, Requests, SealedBlock,
SealedBlockWithSenders, SealedHeader, StaticFileSegment, StorageEntry, TransactionMeta,
TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxHash, TxNumber,
Withdrawal, Withdrawals, B256, U256,
Account, Block, BlockHashOrNumber, BlockWithSenders, Bytecode, GotExpected, Header, Receipt,
Requests, SealedBlock, SealedBlockWithSenders, SealedHeader, StaticFileSegment, StorageEntry,
TransactionMeta, TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash,
Withdrawal, Withdrawals,
};
use reth_prune_types::{PruneCheckpoint, PruneModes, PruneSegment};
use reth_stages_types::{StageCheckpoint, StageId};
Expand Down
Loading

0 comments on commit cb036ac

Please sign in to comment.