Skip to content

Commit

Permalink
fix: encode block as is in debug_getRawBlock (#9353)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jul 6, 2024
1 parent 7579f91 commit abf3aff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion crates/rpc/rpc-builder/tests/it/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ where
let block_id = BlockId::Number(BlockNumberOrTag::default());

DebugApiClient::raw_header(client, block_id).await.unwrap();
DebugApiClient::raw_block(client, block_id).await.unwrap();
DebugApiClient::raw_block(client, block_id).await.unwrap_err();
DebugApiClient::raw_transaction(client, B256::default()).await.unwrap();
DebugApiClient::raw_receipts(client, block_id).await.unwrap();
assert!(is_unimplemented(DebugApiClient::bad_blocks(client).await.err().unwrap()));
Expand Down
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 abf3aff

Please sign in to comment.