Skip to content

Commit

Permalink
fix: encode block as is in debug_getRawBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jul 6, 2024
1 parent 3b976bc commit 9250261
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use jsonrpsee::core::RpcResult;
use reth_chainspec::EthereumHardforks;
use reth_evm::ConfigureEvmEnv;
use reth_primitives::{
Address, Block, BlockId, BlockNumberOrTag, Bytes, TransactionSignedEcRecovered, Withdrawals,
B256, U256,
Address, Block, BlockId, BlockNumberOrTag, Bytes, TransactionSignedEcRecovered, B256, U256,
};
use reth_provider::{
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, HeaderProvider, StateProviderFactory,
Expand Down Expand Up @@ -674,17 +673,14 @@ where

/// Handler for `debug_getRawBlock`
async fn raw_block(&self, block_id: BlockId) -> RpcResult<Bytes> {
let block = self.inner.provider.block_by_id(block_id).to_rpc_result()?;

let block = self
.inner
.provider
.block_by_id(block_id)
.to_rpc_result()?
.ok_or_else(|| EthApiError::UnknownBlockNumber)?;
let mut res = Vec::new();
if let Some(mut block) = block {
// In RPC withdrawals are always present
if block.withdrawals.is_none() {
block.withdrawals = Some(Withdrawals::default());
}
block.encode(&mut res);
}

block.encode(&mut res);
Ok(res.into())
}

Expand Down

0 comments on commit 9250261

Please sign in to comment.