From 8a00d2d25cb81bd0137d0fcab57133b78d95657b Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 4 Dec 2024 04:13:47 +0400 Subject: [PATCH] chore: relax rpc bounds (#13100) --- .../rpc-eth-api/src/helpers/transaction.rs | 31 +++++++++++++------ crates/rpc/rpc-eth-api/src/types.rs | 7 ++--- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/crates/rpc/rpc-eth-api/src/helpers/transaction.rs b/crates/rpc/rpc-eth-api/src/helpers/transaction.rs index 9d77e01193..3b4ecb9de2 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/transaction.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/transaction.rs @@ -8,7 +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::{SealedBlockWithSenders, TransactionMeta, TransactionSigned}; +use reth_primitives::{ + transaction::SignedTransactionIntoRecoveredExt, SealedBlockWithSenders, TransactionMeta, + TransactionSigned, +}; use reth_provider::{ BlockNumReader, BlockReaderIdExt, ProviderReceipt, ProviderTx, ReceiptProvider, TransactionsProvider, @@ -120,10 +123,13 @@ pub trait EthTransactions: LoadTransaction { } /// Returns the _historical_ transaction and the block it was mined in + #[expect(clippy::type_complexity)] fn historical_transaction_by_hash_at( &self, hash: B256, - ) -> impl Future, Self::Error>> + Send { + ) -> impl Future< + Output = Result>, B256)>, Self::Error>, + > + Send { async move { match self.transaction_by_hash_at(hash).await? { None => Ok(None), @@ -475,11 +481,7 @@ pub trait EthTransactions: LoadTransaction { /// /// Behaviour shared by several `eth_` RPC methods, not exclusive to `eth_` transactions RPC /// methods. -pub trait LoadTransaction: - SpawnBlocking - + FullEthApiTypes - + RpcNodeCoreExt -{ +pub trait LoadTransaction: SpawnBlocking + FullEthApiTypes + RpcNodeCoreExt { /// Returns the transaction by hash. /// /// Checks the pool and state. @@ -539,11 +541,16 @@ pub trait LoadTransaction: /// Returns the transaction by including its corresponding [`BlockId`]. /// /// Note: this supports pending transactions + #[expect(clippy::type_complexity)] fn transaction_by_hash_at( &self, transaction_hash: B256, - ) -> impl Future, Self::Error>> + Send - { + ) -> impl Future< + Output = Result< + Option<(TransactionSource>, BlockId)>, + Self::Error, + >, + > + Send { async move { Ok(self.transaction_by_hash(transaction_hash).await?.map(|tx| match tx { tx @ TransactionSource::Pool(_) => (tx, BlockId::pending()), @@ -555,11 +562,15 @@ pub trait LoadTransaction: } /// Fetches the transaction and the transaction's block + #[expect(clippy::type_complexity)] fn transaction_and_block( &self, hash: B256, ) -> impl Future< - Output = Result)>, Self::Error>, + Output = Result< + Option<(TransactionSource>, Arc)>, + Self::Error, + >, > + Send { async move { let (transaction, at) = match self.transaction_by_hash_at(hash).await? { diff --git a/crates/rpc/rpc-eth-api/src/types.rs b/crates/rpc/rpc-eth-api/src/types.rs index 62af1432b1..c97ea5735e 100644 --- a/crates/rpc/rpc-eth-api/src/types.rs +++ b/crates/rpc/rpc-eth-api/src/types.rs @@ -7,7 +7,6 @@ use std::{ use alloy_network::Network; use alloy_rpc_types_eth::Block; -use reth_primitives::TransactionSigned; use reth_provider::{ProviderTx, ReceiptProvider, TransactionsProvider}; use reth_rpc_types_compat::TransactionCompat; use reth_transaction_pool::{PoolTransaction, TransactionPool}; @@ -49,8 +48,7 @@ pub type RpcError = ::Error; pub trait FullEthApiTypes where Self: RpcNodeCore< - Provider: TransactionsProvider - + ReceiptProvider, + Provider: TransactionsProvider + ReceiptProvider, Pool: TransactionPool< Transaction: PoolTransaction>, >, @@ -66,8 +64,7 @@ where impl FullEthApiTypes for T where T: RpcNodeCore< - Provider: TransactionsProvider - + ReceiptProvider, + Provider: TransactionsProvider + ReceiptProvider, Pool: TransactionPool< Transaction: PoolTransaction>, >,