diff --git a/Cargo.toml b/Cargo.toml index a70bbaf3..d78f9e29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.8.2" +version = "0.8.3" edition = "2021" rust-version = "1.81" authors = ["init4"] diff --git a/crates/rpc/src/ctx.rs b/crates/rpc/src/ctx.rs index 7ce57ea5..51ed6413 100644 --- a/crates/rpc/src/ctx.rs +++ b/crates/rpc/src/ctx.rs @@ -312,6 +312,20 @@ where Ok(builder.build()) } + /// Get the [`Header`] for a given block. + pub async fn raw_header( + &self, + t: impl Into, + ) -> Result, EthApiError> { + let Some(hash) = self.provider.block_hash_for_id(t.into())? else { + return Ok(None); + }; + + let header = self.cache.get_header(hash).await.map_err(EthApiError::from)?; + + Ok(Some((hash, header))) + } + /// Get the block for a given block, returning the block hash and /// the block itself. pub async fn raw_block( @@ -513,7 +527,7 @@ where build_signet_receipt(tx, meta, receipt, all_receipts.to_vec()).map(Some) } - /// Create the [`Block`] object for a specific [`BlockId`]. + /// Create the [`Header`] object for a specific [`BlockId`]. pub async fn block_cfg(&self, mut block_id: BlockId) -> Result { // If the block is pending, we'll load the latest and let pending = block_id.is_pending(); @@ -521,12 +535,10 @@ where block_id = BlockId::latest(); } - let Some((_, block)) = self.raw_block(block_id).await? else { + let Some((_, mut header)) = self.raw_header(block_id).await? else { return Err(EthApiError::HeaderNotFound(block_id)); }; - let mut header = block.clone_header(); - // Modify the header for pending blocks, to simulate the next block. if pending { header.parent_hash = header.hash_slow();