Skip to content

Commit 8a74a59

Browse files
authored
refactor: strip ctx from hazmat and remove factory from rpc ctx (#22)
1 parent 84f6430 commit 8a74a59

File tree

5 files changed

+22
-43
lines changed

5 files changed

+22
-43
lines changed

crates/rpc/src/ctx/full.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{RuRevmState, SignetCtx};
22
use alloy::{consensus::Header, eips::BlockId};
33
use reth::{
4-
providers::{ProviderFactory, ProviderResult, providers::BlockchainProvider},
4+
providers::{ProviderResult, providers::BlockchainProvider},
55
rpc::server_types::eth::{EthApiError, EthConfig},
66
rpc::types::BlockNumberOrTag,
77
tasks::{TaskExecutor, TaskSpawner},
@@ -102,7 +102,6 @@ where
102102
pub fn new<Tasks>(
103103
host: Host,
104104
constants: SignetSystemConstants,
105-
factory: ProviderFactory<Signet>,
106105
provider: BlockchainProvider<Signet>,
107106
eth_config: EthConfig,
108107
tx_cache: Option<TxCache>,
@@ -111,7 +110,7 @@ where
111110
where
112111
Tasks: TaskSpawner + Clone + 'static,
113112
{
114-
RpcCtxInner::new(host, constants, factory, provider, eth_config, tx_cache, spawner)
113+
RpcCtxInner::new(host, constants, provider, eth_config, tx_cache, spawner)
115114
.map(|inner| Self { inner: Arc::new(inner) })
116115
}
117116
}
@@ -177,7 +176,6 @@ where
177176
pub fn new<Tasks>(
178177
host: Host,
179178
constants: SignetSystemConstants,
180-
factory: ProviderFactory<Signet>,
181179
provider: BlockchainProvider<Signet>,
182180
eth_config: EthConfig,
183181
tx_cache: Option<TxCache>,
@@ -186,14 +184,12 @@ where
186184
where
187185
Tasks: TaskSpawner + Clone + 'static,
188186
{
189-
SignetCtx::new(constants, factory, provider, eth_config, tx_cache, spawner).map(|signet| {
190-
Self {
191-
host,
192-
signet,
193-
shared: SharedContext {
194-
tracing_semaphores: Semaphore::new(eth_config.max_tracing_requests).into(),
195-
},
196-
}
187+
SignetCtx::new(constants, provider, eth_config, tx_cache, spawner).map(|signet| Self {
188+
host,
189+
signet,
190+
shared: SharedContext {
191+
tracing_semaphores: Semaphore::new(eth_config.max_tracing_requests).into(),
192+
},
197193
})
198194
}
199195

crates/rpc/src/ctx/signet.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use reth::{
1919
primitives::{Block, Receipt, Recovered, RecoveredBlock, TransactionSigned},
2020
providers::{
2121
BlockHashReader, BlockIdReader, BlockNumReader, CanonStateSubscriptions, HeaderProvider,
22-
ProviderBlock, ProviderError, ProviderFactory, ProviderReceipt, ProviderResult,
23-
ReceiptProvider, StateProviderFactory, TransactionsProvider, providers::BlockchainProvider,
22+
ProviderBlock, ProviderError, ProviderReceipt, ProviderResult, ReceiptProvider,
23+
StateProviderFactory, TransactionsProvider, providers::BlockchainProvider,
2424
},
2525
revm::{database::StateProviderDatabase, primitives::hardfork::SpecId},
2626
rpc::{
@@ -65,7 +65,6 @@ where
6565
eth_config: EthConfig,
6666

6767
// State stuff
68-
factory: ProviderFactory<Inner>,
6968
provider: BlockchainProvider<Inner>,
7069
cache: EthStateCache<
7170
ProviderBlock<BlockchainProvider<Inner>>,
@@ -106,7 +105,6 @@ where
106105
/// [`CanonChainTracker`]: reth::providers::CanonChainTracker
107106
pub fn new<Tasks>(
108107
constants: SignetSystemConstants,
109-
factory: ProviderFactory<Inner>,
110108
provider: BlockchainProvider<Inner>,
111109
eth_config: EthConfig,
112110
tx_cache: Option<TxCache>,
@@ -138,7 +136,6 @@ where
138136

139137
Ok(Self {
140138
constants,
141-
factory,
142139
provider,
143140
eth_config,
144141
cache,
@@ -156,11 +153,6 @@ where
156153
&self.constants
157154
}
158155

159-
/// Access the signet [`ProviderFactory`].
160-
pub const fn factory(&self) -> &ProviderFactory<Inner> {
161-
&self.factory
162-
}
163-
164156
/// Access the signet DB
165157
pub const fn provider(&self) -> &BlockchainProvider<Inner> {
166158
&self.provider

crates/rpc/src/inspect/endpoints.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1-
use std::sync::Arc;
2-
31
use crate::{
4-
RpcCtx,
52
inspect::db::{DbArgs, ListTableViewer},
63
utils::{await_handler, response_tri},
74
};
85
use ajj::{HandlerCtx, ResponsePayload};
9-
use reth::providers::providers::ProviderNodeTypes;
6+
use reth::providers::{ProviderFactory, providers::ProviderNodeTypes};
107
use reth_db::mdbx;
11-
use reth_node_api::FullNodeComponents;
128
use signet_node_types::Pnt;
9+
use std::sync::Arc;
1310

1411
/// Handler for the `db` endpoint in the `inspect` module.
15-
pub(super) async fn db<Host, Signet>(
12+
pub(super) async fn db<Signet>(
1613
hctx: HandlerCtx,
1714
args: DbArgs,
18-
ctx: RpcCtx<Host, Signet>,
15+
ctx: ProviderFactory<Signet>,
1916
) -> ResponsePayload<Box<serde_json::value::RawValue>, String>
2017
where
21-
Host: FullNodeComponents,
2218
Signet: Pnt + ProviderNodeTypes<DB = Arc<mdbx::DatabaseEnv>>,
2319
{
2420
let task = async move {
2521
let table: reth_db::Tables = response_tri!(args.table(), "invalid table name");
2622

27-
let viewer = ListTableViewer::new(ctx.signet().factory(), &args);
23+
let viewer = ListTableViewer::new(&ctx, &args);
2824

2925
response_tri!(table.view(&viewer), "Failed to view table");
3026

crates/rpc/src/inspect/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ pub(crate) mod db;
22

33
mod endpoints;
44

5-
use std::sync::Arc;
6-
7-
use crate::RpcCtx;
8-
use reth::providers::providers::ProviderNodeTypes;
5+
use reth::providers::{ProviderFactory, providers::ProviderNodeTypes};
96
use reth_db::mdbx;
10-
use reth_node_api::FullNodeComponents;
117
use signet_node_types::Pnt;
8+
use std::sync::Arc;
129

1310
/// Instantiate the `inspect` API router.
14-
pub fn inspect<Host, Signet>() -> ajj::Router<RpcCtx<Host, Signet>>
11+
pub fn inspect<Signet>() -> ajj::Router<ProviderFactory<Signet>>
1512
where
16-
Host: FullNodeComponents,
1713
Signet: Pnt + ProviderNodeTypes<DB = Arc<mdbx::DatabaseEnv>>,
1814
{
19-
ajj::Router::new().route("db", endpoints::db::<Host, Signet>)
15+
ajj::Router::new().route("db", endpoints::db::<Signet>)
2016
}

crates/rpc/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub mod utils;
7979
pub use ::ajj;
8080

8181
use ajj::Router;
82-
use reth::providers::providers::ProviderNodeTypes;
82+
use reth::providers::{ProviderFactory, providers::ProviderNodeTypes};
8383
use reth_db::mdbx::DatabaseEnv;
8484
use reth_node_api::FullNodeComponents;
8585
use signet_node_types::Pnt;
@@ -98,10 +98,9 @@ where
9898
}
9999

100100
/// Create a new hazmat router that exposes the `inspect` API.
101-
pub fn hazmat_router<Host, Signet>() -> Router<ctx::RpcCtx<Host, Signet>>
101+
pub fn hazmat_router<Signet>() -> Router<ProviderFactory<Signet>>
102102
where
103-
Host: FullNodeComponents,
104103
Signet: Pnt + ProviderNodeTypes<DB = Arc<DatabaseEnv>>,
105104
{
106-
ajj::Router::new().nest("inspect", inspect::inspect::<Host, Signet>())
105+
ajj::Router::new().nest("inspect", inspect::inspect::<Signet>())
107106
}

0 commit comments

Comments
 (0)