fix: encode block as is in debug_getRawBlock (#9353)

This commit is contained in:
Matthias Seitz
2024-07-06 21:43:29 +02:00
committed by GitHub
parent 7579f91d0a
commit abf3aff194
2 changed files with 9 additions and 13 deletions

View File

@@ -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()));

View File

@@ -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,
@@ -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())
}