diff --git a/src/node/rpc/call.rs b/src/node/rpc/call.rs index a1eaebfce..c87e7055d 100644 --- a/src/node/rpc/call.rs +++ b/src/node/rpc/call.rs @@ -1,21 +1,15 @@ use super::{HlEthApi, HlNodeCore}; use crate::evm::transaction::HlTxEnv; -use alloy_consensus::TxType; -use alloy_primitives::{TxKind, U256}; use alloy_rpc_types::TransactionRequest; -use alloy_signer::Either; -use reth::rpc::server_types::eth::{revm_utils::CallFees, EthApiError, RpcInvalidTransactionError}; -use reth_evm::{block::BlockExecutorFactory, ConfigureEvm, EvmEnv, EvmFactory, SpecFor}; +use reth::rpc::server_types::eth::EthApiError; +use reth_evm::{block::BlockExecutorFactory, ConfigureEvm, EvmFactory, TxEnvFor}; use reth_primitives::NodePrimitives; -use reth_provider::{ProviderHeader, ProviderTx}; +use reth_provider::{ProviderError, ProviderHeader, ProviderTx}; use reth_rpc_eth_api::{ helpers::{estimate::EstimateCall, Call, EthCall, LoadBlock, LoadState, SpawnBlocking}, - FromEthApiError, FromEvmError, FullEthApiTypes, IntoEthApiError, -}; -use revm::{ - context::{Block as _, TxEnv}, - Database, + FromEvmError, FullEthApiTypes, RpcConvert, RpcTypes, }; +use revm::context::TxEnv; impl EthCall for HlEthApi where @@ -44,7 +38,11 @@ where EvmFactory: EvmFactory>, >, >, - Error: FromEvmError, + RpcConvert: RpcConvert, Network = Self::NetworkTypes>, + NetworkTypes: RpcTypes>, + Error: FromEvmError + + From<::Error> + + From, > + SpawnBlocking, Self::Error: From, N: HlNodeCore, diff --git a/src/node/rpc/mod.rs b/src/node/rpc/mod.rs index 695407a9e..42ffaf1f8 100644 --- a/src/node/rpc/mod.rs +++ b/src/node/rpc/mod.rs @@ -20,7 +20,6 @@ use reth::{ }; use reth_evm::ConfigureEvm; use reth_network::NetworkInfo; -use reth_optimism_rpc::eth::EthApiNodeBackend; use reth_primitives::NodePrimitives; use reth_provider::{ BlockNumReader, BlockReader, BlockReaderIdExt, ProviderBlock, ProviderHeader, ProviderReceipt, @@ -31,11 +30,11 @@ use reth_rpc_eth_api::{ AddDevSigners, EthApiSpec, EthFees, EthSigner, EthState, LoadBlock, LoadFee, LoadState, SpawnBlocking, Trace, }, - EthApiTypes, FromEvmError, RpcNodeCore, RpcNodeCoreExt, + EthApiTypes, FromEvmError, RpcConverter, RpcNodeCore, RpcNodeCoreExt, }; use std::{fmt, sync::Arc}; -use crate::HlPrimitives; +use reth_optimism_rpc::eth::EthApiNodeBackend; mod block; mod call; @@ -57,6 +56,8 @@ pub(crate) struct HlEthApiInner { pub struct HlEthApi { /// Gateway to node's core components. pub(crate) inner: Arc>, + /// Converter for RPC types. + tx_resp_builder: RpcConverter, } impl fmt::Debug for HlEthApi { @@ -69,13 +70,14 @@ impl EthApiTypes for HlEthApi where Self: Send + Sync, N: HlNodeCore, + N::Evm: std::fmt::Debug, { type Error = EthApiError; type NetworkTypes = Ethereum; - type TransactionCompat = Self; + type RpcConvert = RpcConverter; - fn tx_resp_builder(&self) -> &Self::TransactionCompat { - self + fn tx_resp_builder(&self) -> &Self::RpcConvert { + &self.tx_resp_builder } } @@ -83,7 +85,7 @@ impl RpcNodeCore for HlEthApi where N: HlNodeCore, { - type Primitives = HlPrimitives; + type Primitives = N::Primitives; type Provider = N::Provider; type Pool = N::Pool; type Evm = ::Evm; @@ -152,6 +154,7 @@ impl SpawnBlocking for HlEthApi where Self: Send + Sync + Clone + 'static, N: HlNodeCore, + N::Evm: std::fmt::Debug, { #[inline] fn io_task_spawner(&self) -> impl TaskSpawner { @@ -189,11 +192,13 @@ where } } -impl LoadState for HlEthApi where +impl LoadState for HlEthApi +where N: HlNodeCore< Provider: StateProviderFactory + ChainSpecProvider, Pool: TransactionPool, - > + >, + N::Evm: std::fmt::Debug, { } @@ -210,7 +215,11 @@ where impl EthFees for HlEthApi where - Self: LoadFee, + Self: LoadFee< + Provider: ChainSpecProvider< + ChainSpec: EthChainSpec
>, + >, + >, N: HlNodeCore, { } @@ -268,6 +277,9 @@ where .proof_permits(ctx.config.proof_permits) .build_inner(); - Ok(HlEthApi { inner: Arc::new(HlEthApiInner { eth_api }) }) + Ok(HlEthApi { + inner: Arc::new(HlEthApiInner { eth_api }), + tx_resp_builder: Default::default(), + }) } } diff --git a/src/node/rpc/transaction.rs b/src/node/rpc/transaction.rs index 4b9ed4b84..79738d100 100644 --- a/src/node/rpc/transaction.rs +++ b/src/node/rpc/transaction.rs @@ -1,28 +1,14 @@ use super::HlNodeCore; -use crate::{ - node::{ - primitives::{tx_wrapper::convert_recovered, TransactionSigned}, - rpc::HlEthApi, - }, - HlPrimitives, -}; -use alloy_network::{Ethereum, Network}; -use alloy_primitives::{Bytes, Signature, B256}; +use crate::node::rpc::HlEthApi; +use alloy_primitives::{Bytes, B256}; use reth::{ - builder::FullNodeComponents, - primitives::{Receipt, Recovered}, - providers::ReceiptProvider, - rpc::{ - eth::helpers::types::EthRpcConverter, - server_types::eth::{utils::recover_raw_transaction, EthApiError}, - types::{TransactionInfo, TransactionRequest}, - }, + rpc::server_types::eth::utils::recover_raw_transaction, transaction_pool::{PoolTransaction, TransactionOrigin, TransactionPool}, }; use reth_provider::{BlockReader, BlockReaderIdExt, ProviderTx, TransactionsProvider}; use reth_rpc_eth_api::{ helpers::{EthSigner, EthTransactions, LoadTransaction, SpawnBlocking}, - FromEthApiError, FullEthApiTypes, RpcNodeCore, RpcNodeCoreExt, TransactionCompat, + FromEthApiError, FullEthApiTypes, RpcNodeCore, RpcNodeCoreExt, }; impl LoadTransaction for HlEthApi @@ -33,41 +19,6 @@ where { } -impl TransactionCompat for HlEthApi -where - N: FullNodeComponents>, -{ - type Primitives = HlPrimitives; - type Transaction = ::TransactionResponse; - - type Error = EthApiError; - - fn fill( - &self, - tx: Recovered, - tx_info: TransactionInfo, - ) -> Result { - let builder = EthRpcConverter::default(); - builder.fill(convert_recovered(tx), tx_info) - } - - fn build_simulate_v1_transaction( - &self, - request: TransactionRequest, - ) -> Result { - let Ok(tx) = request.build_typed_tx() else { - return Err(EthApiError::TransactionConversionError); - }; - - // Create an empty signature for the transaction. - let signature = Signature::new(Default::default(), Default::default(), false); - Ok(TransactionSigned(reth_primitives::TransactionSigned::new_unhashed( - tx.into(), - signature, - ))) - } -} - impl EthTransactions for HlEthApi where Self: LoadTransaction,