mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add Receipt AT to ReceiptProvider (#12890)
This commit is contained in:
@ -29,7 +29,7 @@ pub struct EthHandlers<Provider, Pool, Network, Events, EthApi: EthApiTypes> {
|
||||
impl<Provider, Pool, Network, Events, EthApi> EthHandlers<Provider, Pool, Network, Events, EthApi>
|
||||
where
|
||||
Provider: StateProviderFactory
|
||||
+ BlockReader<Block = reth_primitives::Block>
|
||||
+ BlockReader<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>
|
||||
+ EvmEnvProvider
|
||||
+ Clone
|
||||
+ Unpin
|
||||
|
||||
@ -37,8 +37,11 @@
|
||||
//! block_executor: BlockExecutor,
|
||||
//! consensus: Consensus,
|
||||
//! ) where
|
||||
//! Provider: FullRpcProvider<Transaction = TransactionSigned, Block = reth_primitives::Block>
|
||||
//! + AccountReader
|
||||
//! Provider: FullRpcProvider<
|
||||
//! Transaction = TransactionSigned,
|
||||
//! Block = reth_primitives::Block,
|
||||
//! Receipt = reth_primitives::Receipt,
|
||||
//! > + AccountReader
|
||||
//! + ChangeSetReader,
|
||||
//! Pool: TransactionPool + Unpin + 'static,
|
||||
//! Network: NetworkInfo + Peers + Clone + 'static,
|
||||
@ -114,8 +117,11 @@
|
||||
//! block_executor: BlockExecutor,
|
||||
//! consensus: Consensus,
|
||||
//! ) where
|
||||
//! Provider: FullRpcProvider<Transaction = TransactionSigned, Block = reth_primitives::Block>
|
||||
//! + AccountReader
|
||||
//! Provider: FullRpcProvider<
|
||||
//! Transaction = TransactionSigned,
|
||||
//! Block = reth_primitives::Block,
|
||||
//! Receipt = reth_primitives::Receipt,
|
||||
//! > + AccountReader
|
||||
//! + ChangeSetReader,
|
||||
//! Pool: TransactionPool + Unpin + 'static,
|
||||
//! Network: NetworkInfo + Peers + Clone + 'static,
|
||||
@ -195,7 +201,7 @@ use reth_network_api::{noop::NoopNetwork, NetworkInfo, Peers};
|
||||
use reth_primitives::EthPrimitives;
|
||||
use reth_provider::{
|
||||
AccountReader, BlockReader, CanonStateSubscriptions, ChainSpecProvider, ChangeSetReader,
|
||||
EvmEnvProvider, FullRpcProvider, StateProviderFactory,
|
||||
EvmEnvProvider, FullRpcProvider, ReceiptProvider, StateProviderFactory,
|
||||
};
|
||||
use reth_rpc::{
|
||||
AdminApi, DebugApi, EngineEthApi, EthBundle, NetApi, OtterscanApi, RPCApi, RethApi, TraceApi,
|
||||
@ -263,7 +269,9 @@ pub async fn launch<Provider, Pool, Network, Tasks, Events, EvmConfig, EthApi, B
|
||||
consensus: Arc<dyn Consensus>,
|
||||
) -> Result<RpcServerHandle, RpcError>
|
||||
where
|
||||
Provider: FullRpcProvider<Block = reth_primitives::Block> + AccountReader + ChangeSetReader,
|
||||
Provider: FullRpcProvider<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>
|
||||
+ AccountReader
|
||||
+ ChangeSetReader,
|
||||
Pool: TransactionPool + 'static,
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
Tasks: TaskSpawner + Clone + 'static,
|
||||
@ -646,7 +654,10 @@ where
|
||||
EngineT: EngineTypes,
|
||||
EngineApi: EngineApiServer<EngineT>,
|
||||
EthApi: FullEthApiServer,
|
||||
Provider: BlockReader<Block = <EthApi::Provider as BlockReader>::Block>,
|
||||
Provider: BlockReader<
|
||||
Block = <EthApi::Provider as BlockReader>::Block,
|
||||
Receipt = <EthApi::Provider as ReceiptProvider>::Receipt,
|
||||
>,
|
||||
{
|
||||
let Self {
|
||||
provider,
|
||||
@ -722,7 +733,7 @@ where
|
||||
) -> RpcRegistryInner<Provider, Pool, Network, Tasks, Events, EthApi, BlockExecutor, Consensus>
|
||||
where
|
||||
EthApi: EthApiTypes + 'static,
|
||||
Provider: BlockReader<Block = reth_primitives::Block>,
|
||||
Provider: BlockReader<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>,
|
||||
{
|
||||
let Self {
|
||||
provider,
|
||||
@ -757,7 +768,10 @@ where
|
||||
) -> TransportRpcModules<()>
|
||||
where
|
||||
EthApi: FullEthApiServer,
|
||||
Provider: BlockReader<Block = <EthApi::Provider as BlockReader>::Block>,
|
||||
Provider: BlockReader<
|
||||
Block = <EthApi::Provider as BlockReader>::Block,
|
||||
Receipt = <EthApi::Provider as ReceiptProvider>::Receipt,
|
||||
>,
|
||||
{
|
||||
let mut modules = TransportRpcModules::default();
|
||||
|
||||
@ -916,7 +930,7 @@ impl<Provider, Pool, Network, Tasks, Events, EthApi, BlockExecutor, Consensus>
|
||||
RpcRegistryInner<Provider, Pool, Network, Tasks, Events, EthApi, BlockExecutor, Consensus>
|
||||
where
|
||||
Provider: StateProviderFactory
|
||||
+ BlockReader<Block = reth_primitives::Block>
|
||||
+ BlockReader<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>
|
||||
+ EvmEnvProvider
|
||||
+ Clone
|
||||
+ Unpin
|
||||
@ -1125,7 +1139,10 @@ where
|
||||
pub fn register_debug(&mut self) -> &mut Self
|
||||
where
|
||||
EthApi: EthApiSpec + EthTransactions + TraceExt,
|
||||
Provider: BlockReader<Block = <EthApi::Provider as BlockReader>::Block>,
|
||||
Provider: BlockReader<
|
||||
Block = <EthApi::Provider as BlockReader>::Block,
|
||||
Receipt = reth_primitives::Receipt,
|
||||
>,
|
||||
{
|
||||
let debug_api = self.debug_api();
|
||||
self.modules.insert(RethRpcModule::Debug, debug_api.into_rpc().into());
|
||||
@ -1279,8 +1296,10 @@ where
|
||||
impl<Provider, Pool, Network, Tasks, Events, EthApi, BlockExecutor, Consensus>
|
||||
RpcRegistryInner<Provider, Pool, Network, Tasks, Events, EthApi, BlockExecutor, Consensus>
|
||||
where
|
||||
Provider: FullRpcProvider<Block = <EthApi::Provider as BlockReader>::Block>
|
||||
+ AccountReader
|
||||
Provider: FullRpcProvider<
|
||||
Block = <EthApi::Provider as BlockReader>::Block,
|
||||
Receipt = <EthApi::Provider as ReceiptProvider>::Receipt,
|
||||
> + AccountReader
|
||||
+ ChangeSetReader,
|
||||
Pool: TransactionPool + 'static,
|
||||
Network: NetworkInfo + Peers + Clone + 'static,
|
||||
|
||||
@ -7,8 +7,10 @@ use alloy_eips::BlockId;
|
||||
use alloy_rpc_types_eth::{Block, Header, Index};
|
||||
use futures::Future;
|
||||
use reth_node_api::BlockBody;
|
||||
use reth_primitives::{Receipt, SealedBlockFor, SealedBlockWithSenders};
|
||||
use reth_provider::{BlockIdReader, BlockReader, BlockReaderIdExt, HeaderProvider};
|
||||
use reth_primitives::{SealedBlockFor, SealedBlockWithSenders};
|
||||
use reth_provider::{
|
||||
BlockIdReader, BlockReader, BlockReaderIdExt, HeaderProvider, ProviderReceipt,
|
||||
};
|
||||
use reth_rpc_types_compat::block::from_block;
|
||||
|
||||
use crate::{
|
||||
@ -24,7 +26,7 @@ pub type BlockReceiptsResult<N, E> = Result<Option<Vec<RpcReceipt<N>>>, E>;
|
||||
pub type BlockAndReceiptsResult<Eth> = Result<
|
||||
Option<(
|
||||
SealedBlockFor<<<Eth as RpcNodeCore>::Provider as BlockReader>::Block>,
|
||||
Arc<Vec<Receipt>>,
|
||||
Arc<Vec<ProviderReceipt<<Eth as RpcNodeCore>::Provider>>>,
|
||||
)>,
|
||||
<Eth as EthApiTypes>::Error,
|
||||
>;
|
||||
|
||||
@ -22,7 +22,7 @@ use reth_primitives::{
|
||||
};
|
||||
use reth_provider::{
|
||||
BlockReader, BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ProviderError,
|
||||
ReceiptProvider, StateProviderFactory,
|
||||
ProviderReceipt, ReceiptProvider, StateProviderFactory,
|
||||
};
|
||||
use reth_revm::{
|
||||
database::StateProviderDatabase,
|
||||
@ -45,8 +45,10 @@ use tracing::debug;
|
||||
pub trait LoadPendingBlock:
|
||||
EthApiTypes
|
||||
+ RpcNodeCore<
|
||||
Provider: BlockReaderIdExt<Block = reth_primitives::Block>
|
||||
+ EvmEnvProvider
|
||||
Provider: BlockReaderIdExt<
|
||||
Block = reth_primitives::Block,
|
||||
Receipt = reth_primitives::Receipt,
|
||||
> + EvmEnvProvider
|
||||
+ ChainSpecProvider<ChainSpec: EthChainSpec + EthereumHardforks>
|
||||
+ StateProviderFactory,
|
||||
Pool: TransactionPool,
|
||||
@ -119,7 +121,10 @@ pub trait LoadPendingBlock:
|
||||
&self,
|
||||
) -> impl Future<
|
||||
Output = Result<
|
||||
Option<(SealedBlockWithSenders<<Self::Provider as BlockReader>::Block>, Vec<Receipt>)>,
|
||||
Option<(
|
||||
SealedBlockWithSenders<<Self::Provider as BlockReader>::Block>,
|
||||
Vec<ProviderReceipt<Self::Provider>>,
|
||||
)>,
|
||||
Self::Error,
|
||||
>,
|
||||
> + Send
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
//! loads receipt data w.r.t. network.
|
||||
|
||||
use futures::Future;
|
||||
use reth_primitives::{Receipt, TransactionMeta};
|
||||
use reth_provider::TransactionsProvider;
|
||||
use reth_primitives::TransactionMeta;
|
||||
use reth_provider::{ProviderReceipt, ProviderTx, ReceiptProvider, TransactionsProvider};
|
||||
|
||||
use crate::{EthApiTypes, RpcNodeCoreExt, RpcReceipt};
|
||||
|
||||
@ -11,13 +11,13 @@ use crate::{EthApiTypes, RpcNodeCoreExt, RpcReceipt};
|
||||
///
|
||||
/// Behaviour shared by several `eth_` RPC methods, not exclusive to `eth_` receipts RPC methods.
|
||||
pub trait LoadReceipt:
|
||||
EthApiTypes + RpcNodeCoreExt<Provider: TransactionsProvider> + Send + Sync
|
||||
EthApiTypes + RpcNodeCoreExt<Provider: TransactionsProvider + ReceiptProvider> + Send + Sync
|
||||
{
|
||||
/// Helper method for `eth_getBlockReceipts` and `eth_getTransactionReceipt`.
|
||||
fn build_transaction_receipt(
|
||||
&self,
|
||||
tx: <Self::Provider as TransactionsProvider>::Transaction,
|
||||
tx: ProviderTx<Self::Provider>,
|
||||
meta: TransactionMeta,
|
||||
receipt: Receipt,
|
||||
receipt: ProviderReceipt<Self::Provider>,
|
||||
) -> impl Future<Output = Result<RpcReceipt<Self::NetworkTypes>, Self::Error>> + Send;
|
||||
}
|
||||
|
||||
@ -8,9 +8,10 @@ use alloy_network::TransactionBuilder;
|
||||
use alloy_primitives::{Address, Bytes, TxHash, B256};
|
||||
use alloy_rpc_types_eth::{transaction::TransactionRequest, BlockNumberOrTag, TransactionInfo};
|
||||
use futures::Future;
|
||||
use reth_primitives::{Receipt, SealedBlockWithSenders, TransactionMeta, TransactionSigned};
|
||||
use reth_primitives::{SealedBlockWithSenders, TransactionMeta, TransactionSigned};
|
||||
use reth_provider::{
|
||||
BlockNumReader, BlockReaderIdExt, ProviderTx, ReceiptProvider, TransactionsProvider,
|
||||
BlockNumReader, BlockReaderIdExt, ProviderReceipt, ProviderTx, ReceiptProvider,
|
||||
TransactionsProvider,
|
||||
};
|
||||
use reth_rpc_eth_types::{
|
||||
utils::{binary_search, recover_raw_transaction},
|
||||
@ -159,7 +160,7 @@ pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
|
||||
hash: TxHash,
|
||||
) -> impl Future<
|
||||
Output = Result<
|
||||
Option<(ProviderTx<Self::Provider>, TransactionMeta, Receipt)>,
|
||||
Option<(ProviderTx<Self::Provider>, TransactionMeta, ProviderReceipt<Self::Provider>)>,
|
||||
Self::Error,
|
||||
>,
|
||||
> + Send
|
||||
|
||||
@ -8,7 +8,7 @@ use std::{
|
||||
use alloy_network::Network;
|
||||
use alloy_rpc_types_eth::Block;
|
||||
use reth_primitives::TransactionSigned;
|
||||
use reth_provider::TransactionsProvider;
|
||||
use reth_provider::{ReceiptProvider, TransactionsProvider};
|
||||
use reth_rpc_types_compat::TransactionCompat;
|
||||
|
||||
use crate::{AsEthApiError, FromEthApiError, FromEvmError, RpcNodeCore};
|
||||
@ -47,8 +47,10 @@ pub type RpcError<T> = <T as EthApiTypes>::Error;
|
||||
/// Helper trait holds necessary trait bounds on [`EthApiTypes`] to implement `eth` API.
|
||||
pub trait FullEthApiTypes
|
||||
where
|
||||
Self: RpcNodeCore<Provider: TransactionsProvider<Transaction = TransactionSigned>>
|
||||
+ EthApiTypes<
|
||||
Self: RpcNodeCore<
|
||||
Provider: TransactionsProvider<Transaction = TransactionSigned>
|
||||
+ ReceiptProvider<Receipt = reth_primitives::Receipt>,
|
||||
> + EthApiTypes<
|
||||
TransactionCompat: TransactionCompat<
|
||||
<Self::Provider as TransactionsProvider>::Transaction,
|
||||
Transaction = RpcTransaction<Self::NetworkTypes>,
|
||||
@ -59,8 +61,10 @@ where
|
||||
}
|
||||
|
||||
impl<T> FullEthApiTypes for T where
|
||||
T: RpcNodeCore<Provider: TransactionsProvider<Transaction = TransactionSigned>>
|
||||
+ EthApiTypes<
|
||||
T: RpcNodeCore<
|
||||
Provider: TransactionsProvider<Transaction = TransactionSigned>
|
||||
+ ReceiptProvider<Receipt = reth_primitives::Receipt>,
|
||||
> + EthApiTypes<
|
||||
TransactionCompat: TransactionCompat<
|
||||
<Self::Provider as TransactionsProvider>::Transaction,
|
||||
Transaction = RpcTransaction<T::NetworkTypes>,
|
||||
|
||||
6
crates/rpc/rpc-eth-types/src/cache/mod.rs
vendored
6
crates/rpc/rpc-eth-types/src/cache/mod.rs
vendored
@ -106,7 +106,7 @@ impl EthStateCache {
|
||||
) -> Self
|
||||
where
|
||||
Provider: StateProviderFactory
|
||||
+ BlockReader<Block = reth_primitives::Block>
|
||||
+ BlockReader<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>
|
||||
+ EvmEnvProvider
|
||||
+ Clone
|
||||
+ Unpin
|
||||
@ -128,7 +128,7 @@ impl EthStateCache {
|
||||
) -> Self
|
||||
where
|
||||
Provider: StateProviderFactory
|
||||
+ BlockReader<Block = reth_primitives::Block>
|
||||
+ BlockReader<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>
|
||||
+ EvmEnvProvider
|
||||
+ Clone
|
||||
+ Unpin
|
||||
@ -348,7 +348,7 @@ where
|
||||
impl<Provider, Tasks, EvmConfig> Future for EthStateCacheService<Provider, Tasks, EvmConfig>
|
||||
where
|
||||
Provider: StateProviderFactory
|
||||
+ BlockReader<Block = reth_primitives::Block>
|
||||
+ BlockReader<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>
|
||||
+ EvmEnvProvider
|
||||
+ Clone
|
||||
+ Unpin
|
||||
|
||||
@ -794,7 +794,7 @@ where
|
||||
#[async_trait]
|
||||
impl<Provider, Eth, BlockExecutor> DebugApiServer for DebugApi<Provider, Eth, BlockExecutor>
|
||||
where
|
||||
Provider: BlockReaderIdExt<Block: Encodable>
|
||||
Provider: BlockReaderIdExt<Block: Encodable, Receipt = reth_primitives::Receipt>
|
||||
+ HeaderProvider
|
||||
+ ChainSpecProvider<ChainSpec: EthereumHardforks>
|
||||
+ StateProviderFactory
|
||||
|
||||
@ -438,7 +438,7 @@ mod tests {
|
||||
use crate::EthApi;
|
||||
|
||||
fn build_test_eth_api<
|
||||
P: BlockReaderIdExt<Block = reth_primitives::Block>
|
||||
P: BlockReaderIdExt<Block = reth_primitives::Block, Receipt = reth_primitives::Receipt>
|
||||
+ BlockReader
|
||||
+ ChainSpecProvider<ChainSpec = ChainSpec>
|
||||
+ EvmEnvProvider
|
||||
|
||||
@ -18,8 +18,10 @@ impl<Provider, Pool, Network, EvmConfig> LoadPendingBlock
|
||||
where
|
||||
Self: SpawnBlocking
|
||||
+ RpcNodeCore<
|
||||
Provider: BlockReaderIdExt<Block = reth_primitives::Block>
|
||||
+ EvmEnvProvider
|
||||
Provider: BlockReaderIdExt<
|
||||
Block = reth_primitives::Block,
|
||||
Receipt = reth_primitives::Receipt,
|
||||
> + EvmEnvProvider
|
||||
+ ChainSpecProvider<ChainSpec: EthChainSpec + EthereumHardforks>
|
||||
+ StateProviderFactory,
|
||||
Pool: TransactionPool,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Builds an RPC receipt response w.r.t. data layout of network.
|
||||
|
||||
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
|
||||
use reth_provider::TransactionsProvider;
|
||||
use reth_provider::{ReceiptProvider, TransactionsProvider};
|
||||
use reth_rpc_eth_api::{helpers::LoadReceipt, FromEthApiError, RpcNodeCoreExt, RpcReceipt};
|
||||
use reth_rpc_eth_types::{EthApiError, EthReceiptBuilder};
|
||||
|
||||
@ -9,7 +9,10 @@ use crate::EthApi;
|
||||
|
||||
impl<Provider, Pool, Network, EvmConfig> LoadReceipt for EthApi<Provider, Pool, Network, EvmConfig>
|
||||
where
|
||||
Self: RpcNodeCoreExt<Provider: TransactionsProvider<Transaction = TransactionSigned>>,
|
||||
Self: RpcNodeCoreExt<
|
||||
Provider: TransactionsProvider<Transaction = TransactionSigned>
|
||||
+ ReceiptProvider<Receipt = reth_primitives::Receipt>,
|
||||
>,
|
||||
{
|
||||
async fn build_transaction_receipt(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user