@@ -8,6 +8,7 @@ mod call;
8
8
mod pending_block;
9
9
10
10
pub use receipt:: { OpReceiptBuilder , OpReceiptFieldsBuilder } ;
11
+ use reth_node_api:: NodePrimitives ;
11
12
use reth_optimism_primitives:: OpPrimitives ;
12
13
13
14
use std:: { fmt, sync:: Arc } ;
@@ -21,7 +22,8 @@ use reth_network_api::NetworkInfo;
21
22
use reth_node_builder:: EthApiBuilderCtx ;
22
23
use reth_provider:: {
23
24
BlockNumReader , BlockReader , BlockReaderIdExt , CanonStateSubscriptions , ChainSpecProvider ,
24
- EvmEnvProvider , StageCheckpointReader , StateProviderFactory ,
25
+ EvmEnvProvider , NodePrimitivesProvider , ProviderBlock , ProviderReceipt , StageCheckpointReader ,
26
+ StateProviderFactory ,
25
27
} ;
26
28
use reth_rpc:: eth:: { core:: EthApiInner , DevSigner } ;
27
29
use reth_rpc_eth_api:: {
@@ -48,6 +50,10 @@ pub type EthApiNodeBackend<N> = EthApiInner<
48
50
<N as RpcNodeCore >:: Evm ,
49
51
> ;
50
52
53
+ /// A helper trait with requirements for [`RpcNodeCore`] to be used in [`OpEthApi`].
54
+ pub trait OpNodeCore : RpcNodeCore < Provider : BlockReader > { }
55
+ impl < T > OpNodeCore for T where T : RpcNodeCore < Provider : BlockReader > { }
56
+
51
57
/// OP-Reth `Eth` API implementation.
52
58
///
53
59
/// This type provides the functionality for handling `eth_` related requests.
@@ -59,14 +65,14 @@ pub type EthApiNodeBackend<N> = EthApiInner<
59
65
/// This type implements the [`FullEthApi`](reth_rpc_eth_api::helpers::FullEthApi) by implemented
60
66
/// all the `Eth` helper traits and prerequisite traits.
61
67
#[ derive( Clone ) ]
62
- pub struct OpEthApi < N : RpcNodeCore > {
68
+ pub struct OpEthApi < N : OpNodeCore > {
63
69
/// Gateway to node's core components.
64
70
inner : Arc < OpEthApiInner < N > > ,
65
71
}
66
72
67
73
impl < N > OpEthApi < N >
68
74
where
69
- N : RpcNodeCore <
75
+ N : OpNodeCore <
70
76
Provider : BlockReaderIdExt
71
77
+ ChainSpecProvider
72
78
+ CanonStateSubscriptions < Primitives = OpPrimitives >
83
89
impl < N > EthApiTypes for OpEthApi < N >
84
90
where
85
91
Self : Send + Sync ,
86
- N : RpcNodeCore ,
92
+ N : OpNodeCore ,
87
93
{
88
94
type Error = OpEthApiError ;
89
95
type NetworkTypes = Optimism ;
96
102
97
103
impl < N > RpcNodeCore for OpEthApi < N >
98
104
where
99
- N : RpcNodeCore ,
105
+ N : OpNodeCore ,
100
106
{
101
107
type Provider = N :: Provider ;
102
108
type Pool = N :: Pool ;
@@ -132,17 +138,17 @@ where
132
138
133
139
impl < N > RpcNodeCoreExt for OpEthApi < N >
134
140
where
135
- N : RpcNodeCore ,
141
+ N : OpNodeCore ,
136
142
{
137
143
#[ inline]
138
- fn cache ( & self ) -> & EthStateCache {
144
+ fn cache ( & self ) -> & EthStateCache < ProviderBlock < N :: Provider > , ProviderReceipt < N :: Provider > > {
139
145
self . inner . eth_api . cache ( )
140
146
}
141
147
}
142
148
143
149
impl < N > EthApiSpec for OpEthApi < N >
144
150
where
145
- N : RpcNodeCore <
151
+ N : OpNodeCore <
146
152
Provider : ChainSpecProvider < ChainSpec : EthereumHardforks >
147
153
+ BlockNumReader
148
154
+ StageCheckpointReader ,
@@ -163,7 +169,7 @@ where
163
169
impl < N > SpawnBlocking for OpEthApi < N >
164
170
where
165
171
Self : Send + Sync + Clone + ' static ,
166
- N : RpcNodeCore ,
172
+ N : OpNodeCore ,
167
173
{
168
174
#[ inline]
169
175
fn io_task_spawner ( & self ) -> impl TaskSpawner {
@@ -184,7 +190,7 @@ where
184
190
impl < N > LoadFee for OpEthApi < N >
185
191
where
186
192
Self : LoadBlock < Provider = N :: Provider > ,
187
- N : RpcNodeCore <
193
+ N : OpNodeCore <
188
194
Provider : BlockReaderIdExt
189
195
+ EvmEnvProvider
190
196
+ ChainSpecProvider < ChainSpec : EthChainSpec + EthereumHardforks >
@@ -203,7 +209,7 @@ where
203
209
}
204
210
205
211
impl < N > LoadState for OpEthApi < N > where
206
- N : RpcNodeCore <
212
+ N : OpNodeCore <
207
213
Provider : StateProviderFactory + ChainSpecProvider < ChainSpec : EthereumHardforks > ,
208
214
Pool : TransactionPool ,
209
215
>
@@ -213,7 +219,7 @@ impl<N> LoadState for OpEthApi<N> where
213
219
impl < N > EthState for OpEthApi < N >
214
220
where
215
221
Self : LoadState + SpawnBlocking ,
216
- N : RpcNodeCore ,
222
+ N : OpNodeCore ,
217
223
{
218
224
#[ inline]
219
225
fn max_proof_window ( & self ) -> u64 {
@@ -224,35 +230,35 @@ where
224
230
impl < N > EthFees for OpEthApi < N >
225
231
where
226
232
Self : LoadFee ,
227
- N : RpcNodeCore ,
233
+ N : OpNodeCore ,
228
234
{
229
235
}
230
236
231
237
impl < N > Trace for OpEthApi < N >
232
238
where
233
239
Self : RpcNodeCore < Provider : BlockReader > + LoadState < Evm : ConfigureEvm < Header = Header > > ,
234
- N : RpcNodeCore ,
240
+ N : OpNodeCore ,
235
241
{
236
242
}
237
243
238
244
impl < N > AddDevSigners for OpEthApi < N >
239
245
where
240
- N : RpcNodeCore ,
246
+ N : OpNodeCore ,
241
247
{
242
248
fn with_dev_accounts ( & self ) {
243
249
* self . inner . eth_api . signers ( ) . write ( ) = DevSigner :: random_signers ( 20 )
244
250
}
245
251
}
246
252
247
- impl < N : RpcNodeCore > fmt:: Debug for OpEthApi < N > {
253
+ impl < N : OpNodeCore > fmt:: Debug for OpEthApi < N > {
248
254
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
249
255
f. debug_struct ( "OpEthApi" ) . finish_non_exhaustive ( )
250
256
}
251
257
}
252
258
253
259
/// Container type `OpEthApi`
254
260
#[ allow( missing_debug_implementations) ]
255
- struct OpEthApiInner < N : RpcNodeCore > {
261
+ struct OpEthApiInner < N : OpNodeCore > {
256
262
/// Gateway to node's core components.
257
263
eth_api : EthApiNodeBackend < N > ,
258
264
/// Sequencer client, configured to forward submitted transactions to sequencer of given OP
@@ -285,10 +291,12 @@ impl OpEthApiBuilder {
285
291
/// Builds an instance of [`OpEthApi`]
286
292
pub fn build < N > ( self , ctx : & EthApiBuilderCtx < N > ) -> OpEthApi < N >
287
293
where
288
- N : RpcNodeCore <
289
- Provider : BlockReaderIdExt
290
- + ChainSpecProvider
291
- + CanonStateSubscriptions < Primitives = OpPrimitives >
294
+ N : OpNodeCore <
295
+ Provider : BlockReaderIdExt <
296
+ Block = <<N :: Provider as NodePrimitivesProvider >:: Primitives as NodePrimitives >:: Block ,
297
+ Receipt = <<N :: Provider as NodePrimitivesProvider >:: Primitives as NodePrimitives >:: Receipt ,
298
+ > + ChainSpecProvider
299
+ + CanonStateSubscriptions
292
300
+ Clone
293
301
+ ' static ,
294
302
> ,
0 commit comments