11use crate :: {
2+ Pnt ,
23 eth:: EthError ,
34 interest:: { ActiveFilter , FilterManager , FilterOutput , SubscriptionManager } ,
45 receipts:: build_signet_receipt,
56 util:: BlockRangeInclusiveIter ,
6- Pnt ,
77} ;
88use alloy:: {
99 consensus:: { BlockHeader , Header , Signed , Transaction , TxEnvelope } ,
@@ -16,21 +16,21 @@ use reth::{
1616 core:: primitives:: SignerRecoverable ,
1717 primitives:: { Block , EthPrimitives , Receipt , Recovered , RecoveredBlock , TransactionSigned } ,
1818 providers:: {
19- providers:: { BlockchainProvider , ProviderNodeTypes } ,
2019 BlockHashReader , BlockIdReader , BlockNumReader , CanonStateSubscriptions , HeaderProvider ,
2120 ProviderBlock , ProviderError , ProviderReceipt , ReceiptProvider , StateProviderFactory ,
2221 TransactionsProvider ,
22+ providers:: { BlockchainProvider , ProviderNodeTypes } ,
2323 } ,
2424 revm:: { database:: StateProviderDatabase , primitives:: hardfork:: SpecId } ,
2525 rpc:: {
2626 eth:: { filter:: EthFilterError , helpers:: types:: EthRpcConverter } ,
2727 server_types:: eth:: {
28+ EthApiError , EthConfig , EthStateCache , FeeHistoryCache , FeeHistoryEntry ,
29+ GasPriceOracle ,
2830 fee_history:: {
2931 calculate_reward_percentiles_for_block, fee_history_cache_new_blocks_task,
3032 } ,
31- logs_utils:: { self , append_matching_block_logs, ProviderOrBlock } ,
32- EthApiError , EthConfig , EthStateCache , FeeHistoryCache , FeeHistoryEntry ,
33- GasPriceOracle ,
33+ logs_utils:: { self , ProviderOrBlock , append_matching_block_logs} ,
3434 } ,
3535 types:: { FilterBlockOption , FilteredParams } ,
3636 } ,
@@ -41,12 +41,12 @@ use reth_node_api::{BlockBody, FullNodeComponents};
4141use reth_rpc_eth_api:: { RpcBlock , RpcConvert , RpcReceipt , RpcTransaction } ;
4242use signet_evm:: EvmNeedsTx ;
4343use signet_tx_cache:: client:: TxCache ;
44- use signet_types:: { constants:: SignetSystemConstants , MagicSig } ;
44+ use signet_types:: { MagicSig , constants:: SignetSystemConstants } ;
4545use std:: { marker:: PhantomData , sync:: Arc } ;
46- use tracing:: { instrument , trace , Level } ;
46+ use tracing:: { Level , instrument , trace } ;
4747use trevm:: {
48- revm:: { context:: CfgEnv , database:: StateBuilder } ,
4948 Cfg ,
49+ revm:: { context:: CfgEnv , database:: StateBuilder } ,
5050} ;
5151
5252/// Type alias for EVMs using a [`StateProviderBox`] as the `DB` type for
@@ -312,6 +312,20 @@ where
312312 Ok ( builder. build ( ) )
313313 }
314314
315+ /// Get the [`Header`] for a given block.
316+ pub async fn raw_header (
317+ & self ,
318+ t : impl Into < BlockId > ,
319+ ) -> Result < Option < ( B256 , Header ) > , EthApiError > {
320+ let Some ( hash) = self . provider . block_hash_for_id ( t. into ( ) ) ? else {
321+ return Ok ( None ) ;
322+ } ;
323+
324+ let header = self . cache . get_header ( hash) . await . map_err ( EthApiError :: from) ?;
325+
326+ Ok ( Some ( ( hash, header) ) )
327+ }
328+
315329 /// Get the block for a given block, returning the block hash and
316330 /// the block itself.
317331 pub async fn raw_block (
@@ -513,20 +527,18 @@ where
513527 build_signet_receipt ( tx, meta, receipt, all_receipts. to_vec ( ) ) . map ( Some )
514528 }
515529
516- /// Create the [`Block `] object for a specific [`BlockId`].
530+ /// Create the [`Header `] object for a specific [`BlockId`].
517531 pub async fn block_cfg ( & self , mut block_id : BlockId ) -> Result < Header , EthApiError > {
518532 // If the block is pending, we'll load the latest and
519533 let pending = block_id. is_pending ( ) ;
520534 if pending {
521535 block_id = BlockId :: latest ( ) ;
522536 }
523537
524- let Some ( ( _, block ) ) = self . raw_block ( block_id) . await ? else {
538+ let Some ( ( _, mut header ) ) = self . raw_header ( block_id) . await ? else {
525539 return Err ( EthApiError :: HeaderNotFound ( block_id) ) ;
526540 } ;
527541
528- let mut header = block. clone_header ( ) ;
529-
530542 // Modify the header for pending blocks, to simulate the next block.
531543 if pending {
532544 header. parent_hash = header. hash_slow ( ) ;
0 commit comments