feat(db): move reth-storage-api::ClientVersion and StoredBlockWithdrawals to reth-db-models (#10763)

This commit is contained in:
nk_ysg
2024-09-09 21:53:45 +08:00
committed by GitHub
parent b78e0f6069
commit c258c1547e
13 changed files with 25 additions and 25 deletions

2
Cargo.lock generated
View File

@ -2927,7 +2927,6 @@ dependencies = [
"reth",
"reth-chainspec",
"reth-db",
"reth-db-api",
"reth-node-ethereum",
"reth-provider",
"tokio",
@ -7684,7 +7683,6 @@ dependencies = [
"reth-config",
"reth-consensus-common",
"reth-db",
"reth-db-api",
"reth-discv4",
"reth-discv5",
"reth-fs-util",

View File

@ -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"] }

View File

@ -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

View File

@ -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.
@ -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;

View File

@ -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.

View File

@ -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.
@ -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;

View File

@ -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;

View File

@ -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::{

View File

@ -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

View File

@ -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},
};

View File

@ -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"] }

View File

@ -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::{