mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: rm unused databasemetadata trait (#14003)
This commit is contained in:
@ -2,10 +2,7 @@
|
|||||||
|
|
||||||
use alloy_rpc_types_engine::JwtSecret;
|
use alloy_rpc_types_engine::JwtSecret;
|
||||||
use reth_consensus::{ConsensusError, FullConsensus};
|
use reth_consensus::{ConsensusError, FullConsensus};
|
||||||
use reth_db_api::{
|
use reth_db_api::{database_metrics::DatabaseMetrics, Database};
|
||||||
database_metrics::{DatabaseMetadata, DatabaseMetrics},
|
|
||||||
Database,
|
|
||||||
};
|
|
||||||
use reth_engine_primitives::BeaconConsensusEngineHandle;
|
use reth_engine_primitives::BeaconConsensusEngineHandle;
|
||||||
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
|
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvmFor};
|
||||||
use reth_network_api::FullNetwork;
|
use reth_network_api::FullNetwork;
|
||||||
@ -25,7 +22,7 @@ pub trait FullNodeTypes: Send + Sync + Unpin + 'static {
|
|||||||
/// Node's types with the database.
|
/// Node's types with the database.
|
||||||
type Types: NodeTypesWithEngine;
|
type Types: NodeTypesWithEngine;
|
||||||
/// Underlying database type used by the node to store and retrieve data.
|
/// Underlying database type used by the node to store and retrieve data.
|
||||||
type DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static;
|
type DB: Database + DatabaseMetrics + Clone + Unpin + 'static;
|
||||||
/// The provider type used to interact with the node.
|
/// The provider type used to interact with the node.
|
||||||
type Provider: FullProvider<NodeTypesWithDBAdapter<Self::Types, Self::DB>>;
|
type Provider: FullProvider<NodeTypesWithDBAdapter<Self::Types, Self::DB>>;
|
||||||
}
|
}
|
||||||
@ -37,7 +34,7 @@ pub struct FullNodeTypesAdapter<Types, DB, Provider>(PhantomData<(Types, DB, Pro
|
|||||||
impl<Types, DB, Provider> FullNodeTypes for FullNodeTypesAdapter<Types, DB, Provider>
|
impl<Types, DB, Provider> FullNodeTypes for FullNodeTypesAdapter<Types, DB, Provider>
|
||||||
where
|
where
|
||||||
Types: NodeTypesWithEngine,
|
Types: NodeTypesWithEngine,
|
||||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
|
||||||
Provider: FullProvider<NodeTypesWithDBAdapter<Types, DB>>,
|
Provider: FullProvider<NodeTypesWithDBAdapter<Types, DB>>,
|
||||||
{
|
{
|
||||||
type Types = Types;
|
type Types = Types;
|
||||||
|
|||||||
@ -13,10 +13,7 @@ use alloy_eips::eip4844::env_settings::EnvKzgSettings;
|
|||||||
use futures::Future;
|
use futures::Future;
|
||||||
use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks};
|
use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks};
|
||||||
use reth_cli_util::get_secret_key;
|
use reth_cli_util::get_secret_key;
|
||||||
use reth_db_api::{
|
use reth_db_api::{database::Database, database_metrics::DatabaseMetrics};
|
||||||
database::Database,
|
|
||||||
database_metrics::{DatabaseMetadata, DatabaseMetrics},
|
|
||||||
};
|
|
||||||
use reth_engine_tree::tree::TreeConfig;
|
use reth_engine_tree::tree::TreeConfig;
|
||||||
use reth_exex::ExExContext;
|
use reth_exex::ExExContext;
|
||||||
use reth_network::{
|
use reth_network::{
|
||||||
@ -236,7 +233,7 @@ impl<DB, ChainSpec: EthChainSpec> NodeBuilder<DB, ChainSpec> {
|
|||||||
|
|
||||||
impl<DB, ChainSpec> NodeBuilder<DB, ChainSpec>
|
impl<DB, ChainSpec> NodeBuilder<DB, ChainSpec>
|
||||||
where
|
where
|
||||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
|
||||||
ChainSpec: EthChainSpec + EthereumHardforks,
|
ChainSpec: EthChainSpec + EthereumHardforks,
|
||||||
{
|
{
|
||||||
/// Configures the types of the node.
|
/// Configures the types of the node.
|
||||||
@ -297,7 +294,7 @@ impl<DB, ChainSpec> WithLaunchContext<NodeBuilder<DB, ChainSpec>> {
|
|||||||
|
|
||||||
impl<DB, ChainSpec> WithLaunchContext<NodeBuilder<DB, ChainSpec>>
|
impl<DB, ChainSpec> WithLaunchContext<NodeBuilder<DB, ChainSpec>>
|
||||||
where
|
where
|
||||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
|
||||||
ChainSpec: EthChainSpec + EthereumHardforks,
|
ChainSpec: EthChainSpec + EthereumHardforks,
|
||||||
{
|
{
|
||||||
/// Configures the types of the node.
|
/// Configures the types of the node.
|
||||||
@ -548,7 +545,7 @@ where
|
|||||||
|
|
||||||
impl<T, DB, CB, AO> WithLaunchContext<NodeBuilderWithComponents<RethFullAdapter<DB, T>, CB, AO>>
|
impl<T, DB, CB, AO> WithLaunchContext<NodeBuilderWithComponents<RethFullAdapter<DB, T>, CB, AO>>
|
||||||
where
|
where
|
||||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
|
||||||
T: NodeTypesWithEngine + NodeTypesForProvider,
|
T: NodeTypesWithEngine + NodeTypesForProvider,
|
||||||
CB: NodeComponentsBuilder<RethFullAdapter<DB, T>>,
|
CB: NodeComponentsBuilder<RethFullAdapter<DB, T>>,
|
||||||
AO: RethRpcAddOns<NodeAdapter<RethFullAdapter<DB, T>, CB::Components>>,
|
AO: RethRpcAddOns<NodeAdapter<RethFullAdapter<DB, T>, CB::Components>>,
|
||||||
|
|||||||
@ -13,10 +13,7 @@ use rayon::ThreadPoolBuilder;
|
|||||||
use reth_chainspec::{Chain, EthChainSpec, EthereumHardforks};
|
use reth_chainspec::{Chain, EthChainSpec, EthereumHardforks};
|
||||||
use reth_config::{config::EtlConfig, PruneConfig};
|
use reth_config::{config::EtlConfig, PruneConfig};
|
||||||
use reth_consensus::noop::NoopConsensus;
|
use reth_consensus::noop::NoopConsensus;
|
||||||
use reth_db_api::{
|
use reth_db_api::{database::Database, database_metrics::DatabaseMetrics};
|
||||||
database::Database,
|
|
||||||
database_metrics::{DatabaseMetadata, DatabaseMetrics},
|
|
||||||
};
|
|
||||||
use reth_db_common::init::{init_genesis, InitStorageError};
|
use reth_db_common::init::{init_genesis, InitStorageError};
|
||||||
use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHeaderDownloader};
|
use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHeaderDownloader};
|
||||||
use reth_engine_local::MiningMode;
|
use reth_engine_local::MiningMode;
|
||||||
@ -572,7 +569,7 @@ impl<N, DB>
|
|||||||
>
|
>
|
||||||
where
|
where
|
||||||
N: NodeTypes,
|
N: NodeTypes,
|
||||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
|
||||||
{
|
{
|
||||||
/// Returns the configured `ProviderFactory`.
|
/// Returns the configured `ProviderFactory`.
|
||||||
const fn provider_factory(&self) -> &ProviderFactory<NodeTypesWithDBAdapter<N, DB>> {
|
const fn provider_factory(&self) -> &ProviderFactory<NodeTypesWithDBAdapter<N, DB>> {
|
||||||
|
|||||||
@ -4,10 +4,7 @@ use alloy_consensus::BlockHeader;
|
|||||||
use futures::{future::Either, stream, stream_select, StreamExt};
|
use futures::{future::Either, stream, stream_select, StreamExt};
|
||||||
use reth_chainspec::EthChainSpec;
|
use reth_chainspec::EthChainSpec;
|
||||||
use reth_consensus_debug_client::{DebugConsensusClient, EtherscanBlockProvider};
|
use reth_consensus_debug_client::{DebugConsensusClient, EtherscanBlockProvider};
|
||||||
use reth_db_api::{
|
use reth_db_api::{database_metrics::DatabaseMetrics, Database};
|
||||||
database_metrics::{DatabaseMetadata, DatabaseMetrics},
|
|
||||||
Database,
|
|
||||||
};
|
|
||||||
use reth_engine_local::{LocalEngineService, LocalPayloadAttributesBuilder};
|
use reth_engine_local::{LocalEngineService, LocalPayloadAttributesBuilder};
|
||||||
use reth_engine_service::service::{ChainEvent, EngineService};
|
use reth_engine_service::service::{ChainEvent, EngineService};
|
||||||
use reth_engine_tree::{
|
use reth_engine_tree::{
|
||||||
@ -71,7 +68,7 @@ impl EngineNodeLauncher {
|
|||||||
impl<Types, DB, T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeLauncher
|
impl<Types, DB, T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeLauncher
|
||||||
where
|
where
|
||||||
Types: NodeTypesForProvider + NodeTypesWithEngine,
|
Types: NodeTypesForProvider + NodeTypesWithEngine,
|
||||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
|
||||||
T: FullNodeTypes<
|
T: FullNodeTypes<
|
||||||
Types = Types,
|
Types = Types,
|
||||||
DB = DB,
|
DB = DB,
|
||||||
|
|||||||
@ -15,10 +15,7 @@ pub use reth_primitives_traits::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use reth_chainspec::EthChainSpec;
|
use reth_chainspec::EthChainSpec;
|
||||||
use reth_db_api::{
|
use reth_db_api::{database_metrics::DatabaseMetrics, Database};
|
||||||
database_metrics::{DatabaseMetadata, DatabaseMetrics},
|
|
||||||
Database,
|
|
||||||
};
|
|
||||||
use reth_engine_primitives::EngineTypes;
|
use reth_engine_primitives::EngineTypes;
|
||||||
use reth_payload_primitives::BuiltPayload;
|
use reth_payload_primitives::BuiltPayload;
|
||||||
use reth_trie_db::StateCommitment;
|
use reth_trie_db::StateCommitment;
|
||||||
@ -51,7 +48,7 @@ pub trait NodeTypesWithEngine: NodeTypes {
|
|||||||
/// Its types are configured by node internally and are not intended to be user configurable.
|
/// Its types are configured by node internally and are not intended to be user configurable.
|
||||||
pub trait NodeTypesWithDB: NodeTypes {
|
pub trait NodeTypesWithDB: NodeTypes {
|
||||||
/// Underlying database type used by the node to store and retrieve data.
|
/// Underlying database type used by the node to store and retrieve data.
|
||||||
type DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static;
|
type DB: Database + DatabaseMetrics + Clone + Unpin + 'static;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An adapter type combining [`NodeTypes`] and db into [`NodeTypesWithDB`].
|
/// An adapter type combining [`NodeTypes`] and db into [`NodeTypesWithDB`].
|
||||||
@ -102,7 +99,7 @@ where
|
|||||||
impl<Types, DB> NodeTypesWithDB for NodeTypesWithDBAdapter<Types, DB>
|
impl<Types, DB> NodeTypesWithDB for NodeTypesWithDBAdapter<Types, DB>
|
||||||
where
|
where
|
||||||
Types: NodeTypes,
|
Types: NodeTypes,
|
||||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
DB: Database + DatabaseMetrics + Clone + Unpin + 'static,
|
||||||
{
|
{
|
||||||
type DB = DB;
|
type DB = DB;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,35 +40,3 @@ impl<DB: DatabaseMetrics> DatabaseMetrics for Arc<DB> {
|
|||||||
<DB as DatabaseMetrics>::report_metrics(self)
|
<DB as DatabaseMetrics>::report_metrics(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The type used to store metadata about the database.
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
pub struct DatabaseMetadataValue {
|
|
||||||
/// The freelist size
|
|
||||||
freelist_size: Option<usize>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DatabaseMetadataValue {
|
|
||||||
/// Creates a new [`DatabaseMetadataValue`] with the given freelist size.
|
|
||||||
pub const fn new(freelist_size: Option<usize>) -> Self {
|
|
||||||
Self { freelist_size }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the freelist size, if available.
|
|
||||||
pub const fn freelist_size(&self) -> Option<usize> {
|
|
||||||
self.freelist_size
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Includes a method to return a [`DatabaseMetadataValue`] type, which can be used to dynamically
|
|
||||||
/// retrieve information about the database.
|
|
||||||
pub trait DatabaseMetadata {
|
|
||||||
/// Returns a metadata type, [`DatabaseMetadataValue`] for the database.
|
|
||||||
fn metadata(&self) -> DatabaseMetadataValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<DB: DatabaseMetadata> DatabaseMetadata for Arc<DB> {
|
|
||||||
fn metadata(&self) -> DatabaseMetadataValue {
|
|
||||||
<DB as DatabaseMetadata>::metadata(self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use metrics::{gauge, Label};
|
|||||||
use reth_db_api::{
|
use reth_db_api::{
|
||||||
cursor::{DbCursorRO, DbCursorRW},
|
cursor::{DbCursorRO, DbCursorRW},
|
||||||
database::Database,
|
database::Database,
|
||||||
database_metrics::{DatabaseMetadata, DatabaseMetadataValue, DatabaseMetrics},
|
database_metrics::DatabaseMetrics,
|
||||||
models::ClientVersion,
|
models::ClientVersion,
|
||||||
transaction::{DbTx, DbTxMut},
|
transaction::{DbTx, DbTxMut},
|
||||||
};
|
};
|
||||||
@ -276,12 +276,6 @@ impl DatabaseMetrics for DatabaseEnv {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DatabaseMetadata for DatabaseEnv {
|
|
||||||
fn metadata(&self) -> DatabaseMetadataValue {
|
|
||||||
DatabaseMetadataValue::new(self.freelist().ok())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DatabaseEnv {
|
impl DatabaseEnv {
|
||||||
/// Opens the database at the specified path with the given `EnvKind`.
|
/// Opens the database at the specified path with the given `EnvKind`.
|
||||||
///
|
///
|
||||||
|
|||||||
@ -46,9 +46,7 @@ pub mod test_utils {
|
|||||||
use crate::mdbx::DatabaseArguments;
|
use crate::mdbx::DatabaseArguments;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use reth_db_api::{
|
use reth_db_api::{
|
||||||
database::Database,
|
database::Database, database_metrics::DatabaseMetrics, models::ClientVersion,
|
||||||
database_metrics::{DatabaseMetadata, DatabaseMetadataValue, DatabaseMetrics},
|
|
||||||
models::ClientVersion,
|
|
||||||
};
|
};
|
||||||
use reth_fs_util;
|
use reth_fs_util;
|
||||||
use reth_libmdbx::MaxReadTransactionDuration;
|
use reth_libmdbx::MaxReadTransactionDuration;
|
||||||
@ -155,12 +153,6 @@ pub mod test_utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<DB: DatabaseMetadata> DatabaseMetadata for TempDatabase<DB> {
|
|
||||||
fn metadata(&self) -> DatabaseMetadataValue {
|
|
||||||
self.db().metadata()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create `static_files` path for testing
|
/// Create `static_files` path for testing
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn create_test_static_files_dir() -> (TempDir, PathBuf) {
|
pub fn create_test_static_files_dir() -> (TempDir, PathBuf) {
|
||||||
|
|||||||
Reference in New Issue
Block a user