Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions crates/node-types/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
use reth::{primitives::EthPrimitives, providers::providers::ProviderNodeTypes};
use reth_chainspec::ChainSpec;
use reth_db::mdbx;
use std::sync::Arc;

/// Convenience trait for specifying the [`ProviderNodeTypes`] implementation
/// required for Signet functionality. This is used to condense many trait
/// bounds.
pub trait Pnt:
ProviderNodeTypes<ChainSpec = ChainSpec, Primitives = EthPrimitives, DB = Arc<mdbx::DatabaseEnv>>
{
}
pub trait Pnt: ProviderNodeTypes<ChainSpec = ChainSpec, Primitives = EthPrimitives> {}

impl<T> Pnt for T where
T: ProviderNodeTypes<
ChainSpec = ChainSpec,
Primitives = EthPrimitives,
DB = Arc<mdbx::DatabaseEnv>,
>
{
}
impl<T> Pnt for T where T: ProviderNodeTypes<ChainSpec = ChainSpec, Primitives = EthPrimitives> {}

/// Convenience trait to aggregate the DB requirements
pub trait NodeTypesDbTrait:
Expand Down
10 changes: 6 additions & 4 deletions crates/rpc/src/inspect/db.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use ajj::serde_json;
use eyre::WrapErr;
use reth::providers::ProviderFactory;
use reth_db::{Database, TableViewer, table::Table};
use reth::providers::{ProviderFactory, providers::ProviderNodeTypes};
use reth_db::{Database, TableViewer, mdbx, table::Table};
use reth_db_common::{DbTool, ListFilter};
use signet_node_types::Pnt;
use std::sync::OnceLock;
use std::sync::{Arc, OnceLock};
use tracing::instrument;

/// Modeled on the `Command` struct from `reth/crates/cli/commands/src/db/list.rs`
Expand Down Expand Up @@ -95,7 +95,9 @@ impl<'a, 'b, N: Pnt> ListTableViewer<'a, 'b, N> {
}
}

impl<N: Pnt> TableViewer<()> for ListTableViewer<'_, '_, N> {
impl<N: Pnt + ProviderNodeTypes<DB = Arc<mdbx::DatabaseEnv>>> TableViewer<()>
for ListTableViewer<'_, '_, N>
{
type Error = eyre::Report;

#[instrument(skip(self), err)]
Expand Down
6 changes: 5 additions & 1 deletion crates/rpc/src/inspect/endpoints.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use std::sync::Arc;

use crate::{
RpcCtx,
inspect::db::{DbArgs, ListTableViewer},
utils::{await_jh_option_response, response_tri},
};
use ajj::{HandlerCtx, ResponsePayload};
use reth::providers::providers::ProviderNodeTypes;
use reth_db::mdbx;
use reth_node_api::FullNodeComponents;
use signet_node_types::Pnt;

Expand All @@ -15,7 +19,7 @@ pub(super) async fn db<Host, Signet>(
) -> ResponsePayload<Box<serde_json::value::RawValue>, String>
where
Host: FullNodeComponents,
Signet: Pnt,
Signet: Pnt + ProviderNodeTypes<DB = Arc<mdbx::DatabaseEnv>>,
{
let task = async move {
let table: reth_db::Tables = response_tri!(args.table(), "invalid table name");
Expand Down
6 changes: 5 additions & 1 deletion crates/rpc/src/inspect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ pub(crate) mod db;

mod endpoints;

use std::sync::Arc;

use crate::RpcCtx;
use reth::providers::providers::ProviderNodeTypes;
use reth_db::mdbx;
use reth_node_api::FullNodeComponents;
use signet_node_types::Pnt;

/// Instantiate the `inspect` API router.
pub fn inspect<Host, Signet>() -> ajj::Router<RpcCtx<Host, Signet>>
where
Host: FullNodeComponents,
Signet: Pnt,
Signet: Pnt + ProviderNodeTypes<DB = Arc<mdbx::DatabaseEnv>>,
{
ajj::Router::new().route("db", endpoints::db::<Host, Signet>)
}
6 changes: 5 additions & 1 deletion crates/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

mod config;

pub use config::{RpcServerGuard, ServeConfig};

mod ctx;
Expand All @@ -75,8 +76,11 @@ pub mod utils;
pub use ::ajj;

use ajj::Router;
use reth::providers::providers::ProviderNodeTypes;
use reth_db::mdbx::DatabaseEnv;
use reth_node_api::FullNodeComponents;
use signet_node_types::Pnt;
use std::sync::Arc;

/// Create a new router with the given host and signet types.
pub fn router<Host, Signet>() -> Router<ctx::RpcCtx<Host, Signet>>
Expand All @@ -91,7 +95,7 @@ where
pub fn hazmat_router<Host, Signet>() -> Router<ctx::RpcCtx<Host, Signet>>
where
Host: FullNodeComponents,
Signet: Pnt,
Signet: Pnt + ProviderNodeTypes<DB = Arc<DatabaseEnv>>,
{
ajj::Router::new().nest("inspect", inspect::inspect::<Host, Signet>())
}
Loading