chore: phase out ethers rpc block types (#1463)

This commit is contained in:
Matthias Seitz
2023-02-20 16:02:33 +01:00
committed by GitHub
parent 2a9472e9c3
commit 50203a8f2a
22 changed files with 119 additions and 95 deletions

View File

@ -7,7 +7,7 @@ use reth_eth_wire::{
GetReceipts, NodeData, Receipts,
};
use reth_interfaces::p2p::error::RequestResult;
use reth_primitives::{rpc, BlockHashOrNumber, Header, HeadersDirection, PeerId, U256};
use reth_primitives::{BlockHashOrNumber, Header, HeadersDirection, PeerId, U256};
use reth_provider::{BlockProvider, HeaderProvider};
use std::{
borrow::Borrow,
@ -160,9 +160,7 @@ where
let mut total_bytes = APPROX_BODY_SIZE;
for hash in request.0 {
if let Some(block) =
self.client.block(rpc::BlockId::Hash(rpc::H256(hash.0))).unwrap_or_default()
{
if let Some(block) = self.client.block_by_hash(hash).unwrap_or_default() {
let body = BlockBody {
transactions: block.body,
ommers: block.ommers,

View File

@ -1,4 +1,5 @@
use crate::{Header, SealedHeader, TransactionSigned, Withdrawal, H256};
use ethers_core::types::BlockNumber;
use reth_codecs::derive_arbitrary;
use reth_rlp::{Decodable, DecodeError, Encodable, RlpDecodable, RlpEncodable};
use serde::{
@ -361,9 +362,22 @@ impl BlockNumberOrTag {
}
}
impl<T: Into<u64>> From<T> for BlockNumberOrTag {
fn from(num: T) -> Self {
BlockNumberOrTag::Number(num.into())
impl From<u64> for BlockNumberOrTag {
fn from(num: u64) -> Self {
BlockNumberOrTag::Number(num)
}
}
impl From<ethers_core::types::BlockNumber> for BlockNumberOrTag {
fn from(value: BlockNumber) -> Self {
match value {
BlockNumber::Latest => BlockNumberOrTag::Latest,
BlockNumber::Finalized => BlockNumberOrTag::Finalized,
BlockNumber::Safe => BlockNumberOrTag::Safe,
BlockNumber::Earliest => BlockNumberOrTag::Earliest,
BlockNumber::Pending => BlockNumberOrTag::Pending,
BlockNumber::Number(num) => BlockNumberOrTag::Number(num.as_u64()),
}
}
}
@ -439,11 +453,31 @@ pub struct BlockHash {
/// Whether the block must be a canonical block
pub require_canonical: Option<bool>,
}
impl BlockHash {
pub fn from_hash(block_hash: H256, require_canonical: Option<bool>) -> Self {
BlockHash { block_hash, require_canonical }
}
}
impl From<H256> for BlockHash {
fn from(value: H256) -> Self {
Self::from_hash(value, None)
}
}
impl From<BlockHash> for H256 {
fn from(value: BlockHash) -> Self {
value.block_hash
}
}
impl AsRef<H256> for BlockHash {
fn as_ref(&self) -> &H256 {
&self.block_hash
}
}
#[cfg(test)]
mod test {
use super::{BlockId, BlockNumberOrTag::*, *};

View File

@ -1,4 +1,4 @@
use crate::{rpc::BlockNumber as RpcBlockNumber, BlockNumber, H256};
use crate::{BlockNumber, BlockNumberOrTag, H256};
/// Current status of the blockchain's head.
#[derive(Default, Debug, Eq, PartialEq)]
@ -15,14 +15,14 @@ pub struct ChainInfo {
impl ChainInfo {
/// Attempts to convert a [BlockNumber](crate::rpc::BlockNumber) enum to a numeric value
pub fn convert_block_number(&self, number: RpcBlockNumber) -> Option<u64> {
pub fn convert_block_number(&self, number: BlockNumberOrTag) -> Option<u64> {
match number {
RpcBlockNumber::Finalized => self.last_finalized,
RpcBlockNumber::Safe => self.safe_finalized,
RpcBlockNumber::Earliest => Some(0),
RpcBlockNumber::Number(num) => Some(num.as_u64()),
RpcBlockNumber::Pending => None,
RpcBlockNumber::Latest => Some(self.best_number),
BlockNumberOrTag::Finalized => self.last_finalized,
BlockNumberOrTag::Safe => self.safe_finalized,
BlockNumberOrTag::Earliest => Some(0),
BlockNumberOrTag::Number(num) => Some(num),
BlockNumberOrTag::Pending => None,
BlockNumberOrTag::Latest => Some(self.best_number),
}
}
}

View File

@ -1,5 +1,5 @@
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
use reth_primitives::{rpc::BlockId, Bytes, H256};
use reth_primitives::{BlockId, Bytes, H256};
use reth_rpc_types::RichBlock;
/// Debug rpc interface.

View File

@ -1,7 +1,7 @@
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
use reth_primitives::{
rpc::{transaction::eip2930::AccessListWithGasUsed, BlockId, BlockNumber},
Address, Bytes, H256, H64, U256, U64,
rpc::transaction::eip2930::AccessListWithGasUsed, Address, BlockId, BlockNumberOrTag, Bytes,
H256, H64, U256, U64,
};
use reth_rpc_types::{
CallRequest, EIP1186AccountProofResponse, FeeHistory, Index, RichBlock, SyncStatus,
@ -43,7 +43,11 @@ pub trait EthApi {
/// Returns information about a block by number.
#[method(name = "eth_getBlockByNumber")]
async fn block_by_number(&self, number: BlockNumber, full: bool) -> Result<Option<RichBlock>>;
async fn block_by_number(
&self,
number: BlockNumberOrTag,
full: bool,
) -> Result<Option<RichBlock>>;
/// Returns the number of transactions in a block from a block matching the given block hash.
#[method(name = "eth_getBlockTransactionCountByHash")]
@ -51,7 +55,10 @@ pub trait EthApi {
/// Returns the number of transactions in a block matching the given block number.
#[method(name = "eth_getBlockTransactionCountByNumber")]
async fn block_transaction_count_by_number(&self, number: BlockNumber) -> Result<Option<U256>>;
async fn block_transaction_count_by_number(
&self,
number: BlockNumberOrTag,
) -> Result<Option<U256>>;
/// Returns the number of uncles in a block from a block matching the given block hash.
#[method(name = "eth_getUncleCountByBlockHash")]
@ -59,7 +66,7 @@ pub trait EthApi {
/// Returns the number of uncles in a block with given block number.
#[method(name = "eth_getUncleCountByBlockNumber")]
async fn block_uncles_count_by_number(&self, number: BlockNumber) -> Result<U256>;
async fn block_uncles_count_by_number(&self, number: BlockNumberOrTag) -> Result<U256>;
/// Returns an uncle block of the given block and index.
#[method(name = "eth_getUncleByBlockHashAndIndex")]
@ -73,7 +80,7 @@ pub trait EthApi {
#[method(name = "eth_getUncleByBlockNumberAndIndex")]
async fn uncle_by_block_number_and_index(
&self,
number: BlockNumber,
number: BlockNumberOrTag,
index: Index,
) -> Result<Option<RichBlock>>;
@ -93,7 +100,7 @@ pub trait EthApi {
#[method(name = "eth_getTransactionByBlockNumberAndIndex")]
async fn transaction_by_block_number_and_index(
&self,
number: BlockNumber,
number: BlockNumberOrTag,
index: Index,
) -> Result<Option<Transaction>>;

View File

@ -1,5 +1,5 @@
use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc};
use reth_primitives::{rpc::BlockId, Bytes, H256};
use reth_primitives::{BlockId, Bytes, H256};
use reth_rpc_types::{
trace::{filter::TraceFilter, parity::*},
CallRequest, Index,

View File

@ -9,9 +9,7 @@ use jsonrpsee::{
types::error::{CallError, ErrorCode},
};
use reth_primitives::{
hex_literal::hex,
rpc::{BlockId, BlockNumber},
Address, Bytes, NodeRecord, H256, H64, U256,
hex_literal::hex, Address, BlockId, BlockNumberOrTag, Bytes, NodeRecord, H256, H64, U256,
};
use reth_rpc_api::{
clients::{AdminApiClient, EthApiClient},
@ -52,7 +50,7 @@ where
let address = Address::default();
let index = Index::default();
let hash = H256::default();
let block_number = BlockNumber::default();
let block_number = BlockNumberOrTag::default();
let call_request = CallRequest::default();
let transaction_request = TransactionRequest::default();
let bytes = Bytes::default();
@ -159,7 +157,7 @@ async fn test_basic_debug_calls<C>(client: &C)
where
C: ClientT + SubscriptionClientT + Sync,
{
let block_id = BlockId::Number(BlockNumber::default());
let block_id = BlockId::Number(BlockNumberOrTag::default());
assert!(is_unimplemented(DebugApiClient::raw_header(client, block_id).await.err().unwrap()));
assert!(is_unimplemented(DebugApiClient::raw_block(client, block_id).await.err().unwrap()));
@ -183,7 +181,7 @@ async fn test_basic_trace_calls<C>(client: &C)
where
C: ClientT + SubscriptionClientT + Sync,
{
let block_id = BlockId::Number(BlockNumber::default());
let block_id = BlockId::Number(BlockNumberOrTag::default());
let trace_filter = TraceFilter {
from_block: None,
to_block: None,

View File

@ -7,7 +7,6 @@ use reth_executor::{
use reth_interfaces::consensus::ForkchoiceState;
use reth_primitives::{
proofs::{self, EMPTY_LIST_HASH},
rpc::{BlockId, H256 as EthersH256},
ChainSpec, Hardfork, Header, SealedBlock, TransactionSigned, H64, U256,
};
use reth_provider::{BlockProvider, HeaderProvider, StateProvider};
@ -158,7 +157,7 @@ impl<Client: HeaderProvider + BlockProvider + StateProvider> EngineApi<Client> {
return Ok(PayloadStatus::new(PayloadStatusEnum::Valid, block_hash))
}
let Some(parent) = self.client.block(BlockId::Hash(EthersH256(parent_hash.0)))? else {
let Some(parent) = self.client.block_by_hash(parent_hash)? else {
// TODO: cache block for storing later
return Ok(PayloadStatus::from_status(PayloadStatusEnum::Syncing))
};

View File

@ -1,7 +1,7 @@
use crate::{result::internal_rpc_err, EthApiSpec};
use async_trait::async_trait;
use jsonrpsee::core::RpcResult as Result;
use reth_primitives::{rpc::BlockId, Bytes, H256};
use reth_primitives::{BlockId, Bytes, H256};
use reth_rpc_api::DebugApiServer;
use reth_rpc_types::RichBlock;

View File

@ -4,7 +4,7 @@ use crate::{
eth::error::{EthApiError, EthResult},
EthApi,
};
use reth_primitives::{rpc::BlockId, H256};
use reth_primitives::{BlockId, H256};
use reth_provider::{BlockProvider, StateProviderFactory};
use reth_rpc_types::{Block, RichBlock};

View File

@ -8,8 +8,7 @@ use async_trait::async_trait;
use reth_interfaces::Result;
use reth_network_api::NetworkInfo;
use reth_primitives::{
rpc::{BlockId, BlockNumber},
Address, ChainInfo, TransactionSigned, H256, U64,
Address, BlockId, BlockNumberOrTag, ChainInfo, TransactionSigned, H256, U64,
};
use reth_provider::{BlockProvider, StateProviderFactory};
use std::num::NonZeroUsize;
@ -97,7 +96,7 @@ impl<Client, Pool, Network> EthApi<Client, Pool, Network>
where
Client: BlockProvider + StateProviderFactory + 'static,
{
fn convert_block_number(&self, num: BlockNumber) -> Result<Option<u64>> {
fn convert_block_number(&self, num: BlockNumberOrTag) -> Result<Option<u64>> {
self.client().convert_block_number(num)
}
@ -119,17 +118,17 @@ where
block_id: BlockId,
) -> Result<Option<<Client as StateProviderFactory>::HistorySP<'_>>> {
match block_id {
BlockId::Hash(hash) => self.state_at_hash(H256(hash.0)).map(Some),
BlockId::Hash(hash) => self.state_at_hash(hash.into()).map(Some),
BlockId::Number(num) => self.state_at_block_number(num),
}
}
/// Returns the state at the given [BlockNumber] enum
/// Returns the state at the given [BlockNumberOrTag] enum
///
/// Returns `None` if no state available.
pub(crate) fn state_at_block_number(
&self,
num: BlockNumber,
num: BlockNumberOrTag,
) -> Result<Option<<Client as StateProviderFactory>::HistorySP<'_>>> {
if let Some(number) = self.convert_block_number(num)? {
self.state_at_number(number).map(Some)
@ -158,7 +157,7 @@ where
pub(crate) fn latest_state(
&self,
) -> Result<Option<<Client as StateProviderFactory>::HistorySP<'_>>> {
self.state_at_block_number(BlockNumber::Latest)
self.state_at_block_number(BlockNumberOrTag::Latest)
}
}

View File

@ -1,14 +1,15 @@
//! Implementation of the [`jsonrpsee`] generated [`reth_rpc_api::EthApiServer`] trait
//! Handles RPC requests for the `eth_` namespace.
use super::EthApiSpec;
use crate::{
eth::{api::EthApi, error::EthApiError},
result::{internal_rpc_err, ToRpcResult},
};
use jsonrpsee::core::RpcResult as Result;
use reth_primitives::{
rpc::{transaction::eip2930::AccessListWithGasUsed, BlockId, BlockNumber},
Address, Bytes, Header, H256, H64, U256, U64,
rpc::transaction::eip2930::AccessListWithGasUsed, Address, BlockId, BlockNumberOrTag, Bytes,
Header, H256, H64, U256, U64,
};
use reth_provider::{BlockProvider, HeaderProvider, StateProviderFactory};
use reth_rpc_api::EthApiServer;
@ -20,8 +21,6 @@ use reth_transaction_pool::TransactionPool;
use serde_json::Value;
use std::collections::BTreeMap;
use super::EthApiSpec;
#[async_trait::async_trait]
impl<Client, Pool, Network> EthApiServer for EthApi<Client, Pool, Network>
where
@ -62,7 +61,7 @@ where
async fn block_by_number(
&self,
_number: BlockNumber,
_number: BlockNumberOrTag,
_full: bool,
) -> Result<Option<RichBlock>> {
Err(internal_rpc_err("unimplemented"))
@ -74,7 +73,7 @@ where
async fn block_transaction_count_by_number(
&self,
_number: BlockNumber,
_number: BlockNumberOrTag,
) -> Result<Option<U256>> {
Err(internal_rpc_err("unimplemented"))
}
@ -83,7 +82,7 @@ where
Err(internal_rpc_err("unimplemented"))
}
async fn block_uncles_count_by_number(&self, _number: BlockNumber) -> Result<U256> {
async fn block_uncles_count_by_number(&self, _number: BlockNumberOrTag) -> Result<U256> {
Err(internal_rpc_err("unimplemented"))
}
@ -97,7 +96,7 @@ where
async fn uncle_by_block_number_and_index(
&self,
_number: BlockNumber,
_number: BlockNumberOrTag,
_index: Index,
) -> Result<Option<RichBlock>> {
Err(internal_rpc_err("unimplemented"))
@ -120,7 +119,7 @@ where
async fn transaction_by_block_number_and_index(
&self,
_number: BlockNumber,
_number: BlockNumberOrTag,
_index: Index,
) -> Result<Option<reth_rpc_types::Transaction>> {
Err(internal_rpc_err("unimplemented"))
@ -212,8 +211,7 @@ where
// Sorted map that's populated in two rounds:
// 1. Cache entries until first non-cached block
// 2. Database query from the first non-cached block
let mut fee_history_cache_items =
BTreeMap::<reth_primitives::BlockNumber, FeeHistoryCacheItem>::new();
let mut fee_history_cache_items = BTreeMap::new();
let mut first_non_cached_block = None;
let mut last_non_cached_block = None;
@ -347,7 +345,7 @@ mod tests {
};
use rand::random;
use reth_network_api::test_utils::NoopNetwork;
use reth_primitives::{rpc::BlockNumber, Block, Header, H256, U256};
use reth_primitives::{Block, BlockNumberOrTag, Header, H256, U256};
use reth_provider::test_utils::{MockEthProvider, NoopProvider};
use reth_rpc_api::EthApiServer;
use reth_transaction_pool::test_utils::testing_pool;
@ -358,7 +356,7 @@ mod tests {
async fn test_fee_history() {
let eth_api = EthApi::new(NoopProvider::default(), testing_pool(), NoopNetwork::default());
let response = eth_api.fee_history(1.into(), BlockNumber::Latest.into(), None).await;
let response = eth_api.fee_history(1.into(), BlockNumberOrTag::Latest.into(), None).await;
assert!(matches!(response, RpcResult::Err(RpcError::Call(CallError::Custom(_)))));
let Err(RpcError::Call(CallError::Custom(error_object))) = response else { unreachable!() };
assert_eq!(error_object.code(), INVALID_PARAMS_CODE);

View File

@ -4,7 +4,7 @@ use crate::{
eth::error::{EthApiError, EthResult},
EthApi,
};
use reth_primitives::{rpc::BlockId, Address, Bytes, H256, U256};
use reth_primitives::{Address, BlockId, Bytes, H256, U256};
use reth_provider::{BlockProvider, StateProvider, StateProviderFactory};
impl<Client, Pool, Network> EthApi<Client, Pool, Network>

View File

@ -108,14 +108,14 @@ where
FilterBlockOption::Range { from_block, to_block } => {
// from block is maximum of block from last poll or `from_block` of filter
if let Some(filter_from_block) =
from_block.and_then(|num| info.convert_block_number(num))
from_block.and_then(|num| info.convert_block_number(num.into()))
{
from_block_number = start_block.max(filter_from_block)
}
// to block is max the best number
if let Some(filter_to_block) =
to_block.and_then(|num| info.convert_block_number(num))
to_block.and_then(|num| info.convert_block_number(num.into()))
{
to_block_number = filter_to_block;
if to_block_number > best_number {
@ -220,7 +220,7 @@ where
// while block_number <= to_block {
// let _block = self
// .client
// .block_by_number(BlockNumber::Number(block_number.into()))
// .block_by_number(BlockNumberOrTag::Number(block_number.into()))
// .to_rpc_result()?
// .ok_or(EthApiError::UnknownBlockNumber)?;
//

View File

@ -1,7 +1,7 @@
use crate::result::internal_rpc_err;
use async_trait::async_trait;
use jsonrpsee::core::RpcResult as Result;
use reth_primitives::{rpc::BlockId, Bytes, H256};
use reth_primitives::{BlockId, Bytes, H256};
use reth_rpc_api::TraceApiServer;
use reth_rpc_types::{
trace::{filter::TraceFilter, parity::*},

View File

@ -10,7 +10,7 @@ use reth_db::{
};
use reth_interfaces::Result;
use reth_primitives::{
rpc::BlockId, Block, BlockHash, BlockNumber, ChainInfo, ChainSpec, Hardfork, Header,
Block, BlockHash, BlockId, BlockNumber, ChainInfo, ChainSpec, Hardfork, Header,
TransactionSigned, TxHash, TxNumber, Withdrawal, H256, U256,
};
use std::{ops::RangeBounds, sync::Arc};

View File

@ -5,10 +5,8 @@ use crate::{
use parking_lot::Mutex;
use reth_interfaces::Result;
use reth_primitives::{
keccak256,
rpc::{BlockId, BlockNumber},
Account, Address, Block, BlockHash, Bytes, ChainInfo, Header, StorageKey, StorageValue,
TransactionSigned, TxHash, H256, U256,
keccak256, Account, Address, Block, BlockHash, BlockId, BlockNumberOrTag, Bytes, ChainInfo,
Header, StorageKey, StorageValue, TransactionSigned, TxHash, H256, U256,
};
use std::{collections::HashMap, ops::RangeBounds, sync::Arc};
@ -191,9 +189,9 @@ impl BlockProvider for MockEthProvider {
fn block(&self, id: BlockId) -> Result<Option<Block>> {
let lock = self.blocks.lock();
match id {
BlockId::Hash(hash) => Ok(lock.get(&H256(hash.0)).cloned()),
BlockId::Number(BlockNumber::Number(num)) => {
Ok(lock.values().find(|b| b.number == num.as_u64()).cloned())
BlockId::Hash(hash) => Ok(lock.get(hash.as_ref()).cloned()),
BlockId::Number(BlockNumberOrTag::Number(num)) => {
Ok(lock.values().find(|b| b.number == num).cloned())
}
_ => {
unreachable!("unused in network tests")

View File

@ -4,8 +4,8 @@ use crate::{
};
use reth_interfaces::Result;
use reth_primitives::{
rpc::BlockId, Account, Address, Block, BlockHash, BlockNumber, Bytes, ChainInfo, Header,
StorageKey, StorageValue, TransactionSigned, TxHash, TxNumber, H256, U256,
Account, Address, Block, BlockHash, BlockId, BlockNumber, Bytes, ChainInfo, Header, StorageKey,
StorageValue, TransactionSigned, TxHash, TxNumber, H256, U256,
};
use std::ops::RangeBounds;

View File

@ -1,9 +1,6 @@
use crate::{BlockIdProvider, HeaderProvider, TransactionsProvider};
use reth_interfaces::Result;
use reth_primitives::{
rpc::{BlockId, BlockNumber},
Block, H256,
};
use reth_primitives::{Block, BlockId, BlockNumberOrTag, H256};
/// Api trait for fetching `Block` related data.
#[auto_impl::auto_impl(&, Arc)]
@ -15,17 +12,16 @@ pub trait BlockProvider:
/// Returns the block. Returns `None` if block is not found.
fn block_by_hash(&self, hash: H256) -> Result<Option<Block>> {
// TODO: replace with ruint
self.block(BlockId::Hash(reth_primitives::rpc::H256::from(hash.0)))
self.block(hash.into())
}
/// Returns the block. Returns `None` if block is not found.
fn block_by_number_or_tag(&self, num: BlockNumber) -> Result<Option<Block>> {
self.block(BlockId::Number(num))
fn block_by_number_or_tag(&self, num: BlockNumberOrTag) -> Result<Option<Block>> {
self.block(num.into())
}
/// Returns the block. Returns `None` if block is not found.
fn block_by_number(&self, num: u64) -> Result<Option<Block>> {
self.block(BlockId::Number(BlockNumber::Number(num.into())))
self.block(num.into())
}
}

View File

@ -1,9 +1,6 @@
use super::BlockHashProvider;
use reth_interfaces::Result;
use reth_primitives::{
rpc::{BlockId, BlockNumber},
ChainInfo, H256, U256,
};
use reth_primitives::{BlockId, BlockNumberOrTag, ChainInfo, H256, U256};
/// Client trait for transforming [BlockId].
#[auto_impl::auto_impl(&, Arc)]
@ -11,18 +8,18 @@ pub trait BlockIdProvider: BlockHashProvider + Send + Sync {
/// Returns the current info for the chain.
fn chain_info(&self) -> Result<ChainInfo>;
/// Converts the `BlockNumber` variants.
/// Converts the `BlockNumberOrTag` variants.
fn convert_block_number(
&self,
num: BlockNumber,
num: BlockNumberOrTag,
) -> Result<Option<reth_primitives::BlockNumber>> {
let num = match num {
BlockNumber::Latest => self.chain_info()?.best_number,
BlockNumber::Earliest => 0,
BlockNumber::Pending => return Ok(None),
BlockNumber::Number(num) => num.as_u64(),
BlockNumber::Finalized => return Ok(self.chain_info()?.last_finalized),
BlockNumber::Safe => return Ok(self.chain_info()?.safe_finalized),
BlockNumberOrTag::Latest => self.chain_info()?.best_number,
BlockNumberOrTag::Earliest => 0,
BlockNumberOrTag::Pending => return Ok(None),
BlockNumberOrTag::Number(num) => num,
BlockNumberOrTag::Finalized => return Ok(self.chain_info()?.last_finalized),
BlockNumberOrTag::Safe => return Ok(self.chain_info()?.safe_finalized),
};
Ok(Some(num))
}
@ -30,9 +27,9 @@ pub trait BlockIdProvider: BlockHashProvider + Send + Sync {
/// Get the hash of the block by matching the given id.
fn block_hash_for_id(&self, block_id: BlockId) -> Result<Option<H256>> {
match block_id {
BlockId::Hash(hash) => Ok(Some(H256(hash.0))),
BlockId::Hash(hash) => Ok(Some(hash.into())),
BlockId::Number(num) => {
if matches!(num, BlockNumber::Latest) {
if matches!(num, BlockNumberOrTag::Latest) {
return Ok(Some(self.chain_info()?.best_hash))
}
self.convert_block_number(num)?
@ -49,7 +46,7 @@ pub trait BlockIdProvider: BlockHashProvider + Send + Sync {
block_id: BlockId,
) -> Result<Option<reth_primitives::BlockNumber>> {
match block_id {
BlockId::Hash(hash) => self.block_number(H256(hash.0)),
BlockId::Hash(hash) => self.block_number(hash.into()),
BlockId::Number(num) => self.convert_block_number(num),
}
}

View File

@ -1,6 +1,6 @@
use crate::BlockIdProvider;
use reth_interfaces::Result;
use reth_primitives::{rpc::BlockId, BlockNumber, TransactionSigned, TxHash, TxNumber};
use reth_primitives::{BlockId, BlockNumber, TransactionSigned, TxHash, TxNumber};
use std::ops::RangeBounds;
/// Client trait for fetching [TransactionSigned] related data.

View File

@ -1,5 +1,5 @@
use reth_interfaces::Result;
use reth_primitives::{rpc::BlockId, Withdrawal};
use reth_primitives::{BlockId, Withdrawal};
/// Client trait for fetching [Withdrawal] related data.
pub trait WithdrawalsProvider: Send + Sync {