Skip to content

Commit

Permalink
chore: split db abstraction into new crate (paradigmxyz#8594)
Browse files Browse the repository at this point in the history
  • Loading branch information
onbjerg authored Jun 4, 2024
1 parent a809574 commit 51a28f2
Show file tree
Hide file tree
Showing 183 changed files with 824 additions and 754 deletions.
57 changes: 47 additions & 10 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ members = [
"crates/storage/codecs/",
"crates/storage/codecs/derive/",
"crates/storage/db/",
"crates/storage/db-api/",
"crates/storage/db-common",
"crates/storage/errors/",
"crates/storage/libmdbx-rs/",
Expand Down Expand Up @@ -240,6 +241,7 @@ reth-config = { path = "crates/config" }
reth-consensus = { path = "crates/consensus/consensus" }
reth-consensus-common = { path = "crates/consensus/common" }
reth-db = { path = "crates/storage/db" }
reth-db-api = { path = "crates/storage/db-api" }
reth-db-common = { path = "crates/storage/db-common" }
reth-discv4 = { path = "crates/net/discv4" }
reth-discv5 = { path = "crates/net/discv5" }
Expand Down
1 change: 1 addition & 0 deletions bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ reth-config.workspace = true
reth-primitives = { workspace = true, features = ["arbitrary", "clap"] }
reth-fs-util.workspace = true
reth-db = { workspace = true, features = ["mdbx"] }
reth-db-api.workspace = true
reth-exex.workspace = true
reth-provider = { workspace = true }
reth-evm.workspace = true
Expand Down
6 changes: 2 additions & 4 deletions bin/reth/src/commands/db/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ use crate::{
};
use ahash::RandomState;
use clap::Parser;
use reth_db::{
cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx, DatabaseEnv, RawKey,
RawTable, RawValue, TableViewer, Tables,
};
use reth_db::{DatabaseEnv, RawKey, RawTable, RawValue, TableViewer, Tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx};
use std::{
hash::{BuildHasher, Hasher},
sync::Arc,
Expand Down
5 changes: 2 additions & 3 deletions bin/reth/src/commands/db/clear.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use clap::{Parser, Subcommand};
use reth_db::{
use reth_db::{static_file::iter_static_files, TableViewer, Tables};
use reth_db_api::{
database::Database,
static_file::iter_static_files,
table::Table,
transaction::{DbTx, DbTxMut},
TableViewer, Tables,
};
use reth_primitives::{static_file::find_fixed_range, StaticFileSegment};
use reth_provider::{ProviderFactory, StaticFileProviderFactory};
Expand Down
8 changes: 3 additions & 5 deletions bin/reth/src/commands/db/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ use crate::{
utils::DbTool,
};
use clap::Parser;
use reth_db::{
cursor::DbCursorRO, database::Database, open_db_read_only, table::Table, tables_to_generic,
transaction::DbTx, DatabaseEnv, Tables,
};
use reth_db::{open_db_read_only, tables_to_generic, DatabaseEnv, Tables};
use reth_db_api::{cursor::DbCursorRO, database::Database, table::Table, transaction::DbTx};
use std::{
collections::HashMap,
fmt::Debug,
Expand Down Expand Up @@ -95,7 +93,7 @@ where
T::Key: Hash,
T::Value: PartialEq,
{
let table = T::TABLE;
let table = T::NAME;

info!("Analyzing table {table}...");
let result = find_diffs_advanced::<T>(&primary_tx, &secondary_tx)?;
Expand Down
12 changes: 6 additions & 6 deletions bin/reth/src/commands/db/get.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::utils::DbTool;
use clap::Parser;
use reth_db::{
database::Database,
static_file::{ColumnSelectorOne, ColumnSelectorTwo, HeaderMask, ReceiptMask, TransactionMask},
table::{Decompress, DupSort, Table},
tables, RawKey, RawTable, Receipts, TableViewer, Transactions,
};
use reth_db_api::{
database::Database,
table::{Decompress, DupSort, Table},
};
use reth_primitives::{BlockHash, Header, StaticFileSegment};
use reth_provider::StaticFileProviderFactory;
use tracing::error;
Expand Down Expand Up @@ -200,10 +202,8 @@ pub(crate) fn maybe_json_value_parser(value: &str) -> Result<String, eyre::Error
mod tests {
use super::*;
use clap::{Args, Parser};
use reth_db::{
models::{storage_sharded_key::StorageShardedKey, ShardedKey},
AccountsHistory, HashedAccounts, Headers, StageCheckpoints, StoragesHistory,
};
use reth_db::{AccountsHistory, HashedAccounts, Headers, StageCheckpoints, StoragesHistory};
use reth_db_api::models::{storage_sharded_key::StorageShardedKey, ShardedKey};
use reth_primitives::{Address, B256};
use std::str::FromStr;

Expand Down
3 changes: 2 additions & 1 deletion bin/reth/src/commands/db/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use super::tui::DbListTUI;
use crate::utils::{DbTool, ListFilter};
use clap::Parser;
use eyre::WrapErr;
use reth_db::{database::Database, table::Table, DatabaseEnv, RawValue, TableViewer, Tables};
use reth_db::{DatabaseEnv, RawValue, TableViewer, Tables};
use reth_db_api::{database::Database, table::Table};
use reth_primitives::hex;
use std::{cell::RefCell, sync::Arc};
use tracing::error;
Expand Down
5 changes: 2 additions & 3 deletions bin/reth/src/commands/db/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use comfy_table::{Cell, Row, Table as ComfyTable};
use eyre::WrapErr;
use human_bytes::human_bytes;
use itertools::Itertools;
use reth_db::{
database::Database, mdbx, static_file::iter_static_files, DatabaseEnv, TableViewer, Tables,
};
use reth_db::{mdbx, static_file::iter_static_files, DatabaseEnv, TableViewer, Tables};
use reth_db_api::database::Database;
use reth_fs_util as fs;
use reth_node_core::dirs::{ChainPath, DataDirPath};
use reth_primitives::static_file::{find_fixed_range, SegmentRangeInclusive};
Expand Down
6 changes: 2 additions & 4 deletions bin/reth/src/commands/db/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ use ratatui::{
widgets::{Block, Borders, List, ListItem, ListState, Paragraph, Wrap},
Frame, Terminal,
};
use reth_db::{
table::{Table, TableRow},
RawValue,
};
use reth_db::RawValue;
use reth_db_api::table::{Table, TableRow};
use std::{
io,
time::{Duration, Instant},
Expand Down
3 changes: 2 additions & 1 deletion bin/reth/src/commands/debug_cmd/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_runner::CliContext;
use reth_config::Config;
use reth_consensus::Consensus;
use reth_db::{database::Database, DatabaseEnv};
use reth_db::DatabaseEnv;
use reth_db_api::database::Database;
use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
headers::reverse_headers::ReverseHeadersDownloaderBuilder,
Expand Down
3 changes: 2 additions & 1 deletion bin/reth/src/commands/debug_cmd/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use reth_beacon_consensus::EthBeaconConsensus;
use reth_cli_runner::CliContext;
use reth_config::Config;
use reth_consensus::Consensus;
use reth_db::{cursor::DbCursorRO, tables, transaction::DbTx, DatabaseEnv};
use reth_db::{tables, DatabaseEnv};
use reth_db_api::{cursor::DbCursorRO, transaction::DbTx};
use reth_evm::execute::{BatchBlockExecutionOutput, BatchExecutor, BlockExecutorProvider};
use reth_network::NetworkHandle;
use reth_network_api::NetworkInfo;
Expand Down
3 changes: 2 additions & 1 deletion bin/reth/src/commands/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use futures::{Stream, StreamExt};
use reth_beacon_consensus::EthBeaconConsensus;
use reth_config::Config;
use reth_consensus::Consensus;
use reth_db::{database::Database, tables, transaction::DbTx};
use reth_db::tables;
use reth_db_api::{database::Database, transaction::DbTx};
use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
file_client::{ChunkedFileReader, FileClient, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE},
Expand Down
3 changes: 2 additions & 1 deletion bin/reth/src/commands/import_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use crate::{
};
use clap::Parser;
use reth_consensus::noop::NoopConsensus;
use reth_db::{tables, transaction::DbTx};
use reth_db::tables;
use reth_db_api::transaction::DbTx;
use reth_downloaders::file_client::{
ChunkedFileReader, FileClient, DEFAULT_BYTE_LEN_CHUNK_CHAIN_FILE,
};
Expand Down
Loading

0 comments on commit 51a28f2

Please sign in to comment.