11use crate :: {
2- Pnt ,
32 eth:: EthError ,
43 interest:: { ActiveFilter , FilterManager , FilterOutput , SubscriptionManager } ,
54 receipts:: build_signet_receipt,
6- util :: BlockRangeInclusiveIter ,
5+ utils :: BlockRangeInclusiveIter ,
76} ;
87use alloy:: {
98 consensus:: { BlockHeader , Header , Signed , Transaction , TxEnvelope } ,
@@ -14,12 +13,11 @@ use alloy::{
1413} ;
1514use reth:: {
1615 core:: primitives:: SignerRecoverable ,
17- primitives:: { Block , EthPrimitives , Receipt , Recovered , RecoveredBlock , TransactionSigned } ,
16+ primitives:: { Block , Receipt , Recovered , RecoveredBlock , TransactionSigned } ,
1817 providers:: {
1918 BlockHashReader , BlockIdReader , BlockNumReader , CanonStateSubscriptions , HeaderProvider ,
20- ProviderBlock , ProviderError , ProviderReceipt , ReceiptProvider , StateProviderFactory ,
21- TransactionsProvider ,
22- providers:: { BlockchainProvider , ProviderNodeTypes } ,
19+ ProviderBlock , ProviderError , ProviderFactory , ProviderReceipt , ProviderResult ,
20+ ReceiptProvider , StateProviderFactory , TransactionsProvider , providers:: BlockchainProvider ,
2321 } ,
2422 revm:: { database:: StateProviderDatabase , primitives:: hardfork:: SpecId } ,
2523 rpc:: {
@@ -40,6 +38,7 @@ use reth_chainspec::{BaseFeeParams, ChainSpec, ChainSpecProvider};
4038use reth_node_api:: { BlockBody , FullNodeComponents } ;
4139use reth_rpc_eth_api:: { RpcBlock , RpcConvert , RpcReceipt , RpcTransaction } ;
4240use signet_evm:: EvmNeedsTx ;
41+ use signet_node_types:: Pnt ;
4342use signet_tx_cache:: client:: TxCache ;
4443use signet_types:: { MagicSig , constants:: SignetSystemConstants } ;
4544use std:: { marker:: PhantomData , sync:: Arc } ;
@@ -80,17 +79,16 @@ where
8079 pub fn new < Tasks > (
8180 host : Host ,
8281 constants : SignetSystemConstants ,
83- provider : BlockchainProvider < Signet > ,
82+ factory : ProviderFactory < Signet > ,
8483 eth_config : EthConfig ,
8584 tx_cache : Option < TxCache > ,
8685 spawner : Tasks ,
87- ) -> Self
86+ ) -> ProviderResult < Self >
8887 where
8988 Tasks : TaskSpawner + Clone + ' static ,
9089 {
91- let inner = RpcCtxInner :: new ( host, constants, provider, eth_config, tx_cache, spawner) ;
92-
93- Self { inner : Arc :: new ( inner) }
90+ RpcCtxInner :: new ( host, constants, factory, eth_config, tx_cache, spawner)
91+ . map ( |inner| Self { inner : Arc :: new ( inner) } )
9492 }
9593}
9694
@@ -136,16 +134,16 @@ where
136134 pub fn new < Tasks > (
137135 host : Host ,
138136 constants : SignetSystemConstants ,
139- provider : BlockchainProvider < Signet > ,
137+ factory : ProviderFactory < Signet > ,
140138 eth_config : EthConfig ,
141139 tx_cache : Option < TxCache > ,
142140 spawner : Tasks ,
143- ) -> Self
141+ ) -> ProviderResult < Self >
144142 where
145143 Tasks : TaskSpawner + Clone + ' static ,
146144 {
147- let signet = SignetCtx :: new ( constants, provider , eth_config, tx_cache, spawner) ;
148- Self { host, signet }
145+ SignetCtx :: new ( constants, factory , eth_config, tx_cache, spawner)
146+ . map ( |signet| Self { host, signet } )
149147 }
150148
151149 pub const fn host ( & self ) -> & Host {
@@ -194,6 +192,7 @@ where
194192 eth_config : EthConfig ,
195193
196194 // State stuff
195+ factory : ProviderFactory < Inner > ,
197196 provider : BlockchainProvider < Inner > ,
198197 cache : EthStateCache <
199198 ProviderBlock < BlockchainProvider < Inner > > ,
@@ -217,20 +216,22 @@ where
217216
218217impl < Inner > SignetCtx < Inner >
219218where
220- Inner : ProviderNodeTypes < ChainSpec = ChainSpec , Primitives = EthPrimitives > ,
219+ Inner : Pnt ,
221220{
222221 /// Instantiate a new `SignetCtx`, spawning necessary tasks to keep the
223222 /// relevant caches up to date.
224223 pub fn new < Tasks > (
225224 constants : SignetSystemConstants ,
226- provider : BlockchainProvider < Inner > ,
225+ factory : ProviderFactory < Inner > ,
227226 eth_config : EthConfig ,
228227 tx_cache : Option < TxCache > ,
229228 spawner : Tasks ,
230- ) -> Self
229+ ) -> ProviderResult < Self >
231230 where
232231 Tasks : TaskSpawner + Clone + ' static ,
233232 {
233+ let provider = BlockchainProvider :: new ( factory. clone ( ) ) ?;
234+
234235 let cache = EthStateCache :: spawn_with ( provider. clone ( ) , eth_config. cache , spawner. clone ( ) ) ;
235236 let gas_oracle =
236237 GasPriceOracle :: new ( provider. clone ( ) , eth_config. gas_oracle , cache. clone ( ) ) ;
@@ -249,8 +250,9 @@ where
249250
250251 let subs = SubscriptionManager :: new ( provider. clone ( ) , eth_config. stale_filter_ttl ) ;
251252
252- Self {
253+ Ok ( Self {
253254 constants,
255+ factory,
254256 provider,
255257 eth_config,
256258 cache,
@@ -260,14 +262,19 @@ where
260262 filters,
261263 subs,
262264 _pd : PhantomData ,
263- }
265+ } )
264266 }
265267
266268 /// Access the signet constants
267269 pub const fn constants ( & self ) -> & SignetSystemConstants {
268270 & self . constants
269271 }
270272
273+ /// Access the signet [`ProviderFactory`].
274+ pub const fn factory ( & self ) -> & ProviderFactory < Inner > {
275+ & self . factory
276+ }
277+
271278 /// Access the signet DB
272279 pub const fn provider ( & self ) -> & BlockchainProvider < Inner > {
273280 & self . provider
0 commit comments