Skip to content

Commit

Permalink
feat(db): move reth-storage-api::ClientVersion and StoredBlockWithdra…
Browse files Browse the repository at this point in the history
…wals to reth-db-models (#10763)
  • Loading branch information
nkysg authored Sep 9, 2024
1 parent b78e0f6 commit c258c15
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion crates/node/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ reth-cli.workspace = true
reth-cli-util.workspace = true
reth-fs-util.workspace = true
reth-db = { workspace = true, features = ["mdbx"] }
reth-db-api.workspace = true
reth-storage-errors.workspace = true
reth-provider.workspace = true
reth-network = { workspace = true, features = ["serde"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/node/core/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Version information for reth.
use reth_db_api::models::ClientVersion;
use reth_db::ClientVersion;
use reth_rpc_types::engine::ClientCode;

/// The client code for Reth
Expand Down
11 changes: 1 addition & 10 deletions crates/storage/db-api/src/models/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Block related models and types.

use reth_codecs::{add_arbitrary_tests, Compact};
use reth_primitives::{Header, Withdrawals, B256};
use reth_primitives::{Header, B256};
use serde::{Deserialize, Serialize};

/// The storage representation of a block's ommers.
Expand All @@ -15,15 +15,6 @@ pub struct StoredBlockOmmers {
pub ommers: Vec<Header>,
}

/// The storage representation of block withdrawals.
#[derive(Debug, Default, Eq, PartialEq, Clone, Serialize, Deserialize, Compact)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub struct StoredBlockWithdrawals {
/// The block withdrawals.
pub withdrawals: Withdrawals,
}

/// Hash of the block header.
pub type HeaderHash = B256;

Expand Down
6 changes: 3 additions & 3 deletions crates/storage/db-api/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ use serde::{Deserialize, Serialize};

pub mod accounts;
pub mod blocks;
pub mod client_version;
pub mod integer_list;
pub mod sharded_key;
pub mod storage_sharded_key;

pub use accounts::*;
pub use blocks::*;
pub use client_version::ClientVersion;
pub use reth_db_models::{AccountBeforeTx, StoredBlockBodyIndices};
pub use reth_db_models::{
AccountBeforeTx, ClientVersion, StoredBlockBodyIndices, StoredBlockWithdrawals,
};
pub use sharded_key::ShardedKey;

/// Macro that implements [`Encode`] and [`Decode`] for uint types.
Expand Down
11 changes: 10 additions & 1 deletion crates/storage/db-models/src/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::ops::Range;

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

/// Total number of transactions.
Expand Down Expand Up @@ -66,6 +66,15 @@ impl StoredBlockBodyIndices {
}
}

/// The storage representation of block withdrawals.
#[derive(Debug, Default, Eq, PartialEq, Clone, Serialize, Deserialize, Compact)]
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)]
pub struct StoredBlockWithdrawals {
/// The block withdrawals.
pub withdrawals: Withdrawals,
}

#[cfg(test)]
mod tests {
use crate::StoredBlockBodyIndices;
Expand Down
6 changes: 5 additions & 1 deletion crates/storage/db-models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ pub use accounts::AccountBeforeTx;

/// Blocks
pub mod blocks;
pub use blocks::StoredBlockBodyIndices;
pub use blocks::{StoredBlockBodyIndices, StoredBlockWithdrawals};

/// Client Version
pub mod client_version;
pub use client_version::ClientVersion;
2 changes: 1 addition & 1 deletion crates/storage/db/src/implementation/mdbx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
database::Database,
database_metrics::{DatabaseMetadata, DatabaseMetadataValue, DatabaseMetrics},
models::client_version::ClientVersion,
models::ClientVersion,
transaction::{DbTx, DbTxMut},
};
use reth_libmdbx::{
Expand Down
1 change: 1 addition & 0 deletions crates/storage/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub use utils::is_database_empty;
#[cfg(feature = "mdbx")]
pub use mdbx::{create_db, init_db, open_db, open_db_read_only, DatabaseEnv, DatabaseEnvKind};

pub use models::ClientVersion;
pub use reth_db_api::*;

/// Collection of database test utilities
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 @@ -23,9 +23,9 @@ use reth_db_api::{
models::{
accounts::BlockNumberAddress,
blocks::{HeaderHash, StoredBlockOmmers},
client_version::ClientVersion,
storage_sharded_key::StorageShardedKey,
AccountBeforeTx, CompactU256, ShardedKey, StoredBlockBodyIndices, StoredBlockWithdrawals,
AccountBeforeTx, ClientVersion, CompactU256, ShardedKey, StoredBlockBodyIndices,
StoredBlockWithdrawals,
},
table::{Decode, DupSort, Encode, Table},
};
Expand Down
1 change: 0 additions & 1 deletion examples/rpc-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jsonrpsee.workspace = true
reth.workspace = true
reth-chainspec.workspace = true
reth-db.workspace = true
reth-db-api.workspace = true
reth-node-ethereum.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] }
tokio = { workspace = true, features = ["full"] }
Expand Down
3 changes: 1 addition & 2 deletions examples/rpc-db/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use reth::{
utils::open_db_read_only,
};
use reth_chainspec::ChainSpecBuilder;
use reth_db::{mdbx::DatabaseArguments, DatabaseEnv};
use reth_db_api::models::ClientVersion;
use reth_db::{mdbx::DatabaseArguments, ClientVersion, DatabaseEnv};

// Bringing up the RPC
use reth::rpc::builder::{
Expand Down

0 comments on commit c258c15

Please sign in to comment.