feat: abstract over Evm::Error (#14085)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Arsenii Kulikov
2025-01-30 17:02:20 +04:00
committed by GitHub
parent 6b13409812
commit 98a021ee7d
40 changed files with 298 additions and 247 deletions

View File

@ -6,7 +6,7 @@ use reth_optimism_evm::OpBlockExecutionError;
use reth_rpc_eth_api::AsEthApiError;
use reth_rpc_eth_types::EthApiError;
use reth_rpc_server_types::result::{internal_rpc_err, rpc_err};
use revm::primitives::{InvalidTransaction, OptimismInvalidTransaction};
use revm::primitives::{EVMError, InvalidTransaction, OptimismInvalidTransaction};
/// Optimism specific errors, that extend [`EthApiError`].
#[derive(Debug, thiserror::Error)]
@ -119,3 +119,12 @@ impl From<BlockError> for OpEthApiError {
Self::Eth(error.into())
}
}
impl<DB> From<EVMError<DB>> for OpEthApiError
where
EthApiError: From<EVMError<DB>>,
{
fn from(error: EVMError<DB>) -> Self {
Self::Eth(error.into())
}
}

View File

@ -40,8 +40,7 @@ where
let excess_blob_gas = block.excess_blob_gas();
let timestamp = block.timestamp();
let mut l1_block_info =
reth_optimism_evm::extract_l1_info(block.body()).map_err(OpEthApiError::from)?;
let mut l1_block_info = reth_optimism_evm::extract_l1_info(block.body())?;
return block
.body()

View File

@ -6,7 +6,7 @@ use reth_evm::ConfigureEvm;
use reth_provider::ProviderHeader;
use reth_rpc_eth_api::{
helpers::{estimate::EstimateCall, Call, EthCall, LoadBlock, LoadState, SpawnBlocking},
FromEthApiError, FullEthApiTypes, IntoEthApiError,
FromEthApiError, FromEvmError, FullEthApiTypes, IntoEthApiError,
};
use reth_rpc_eth_types::{revm_utils::CallFees, RpcInvalidTransactionError};
use revm::primitives::{BlockEnv, OptimismFields, TxEnv};
@ -28,8 +28,10 @@ where
impl<N> Call for OpEthApi<N>
where
Self: LoadState<Evm: ConfigureEvm<Header = ProviderHeader<Self::Provider>, TxEnv = TxEnv>>
+ SpawnBlocking,
Self: LoadState<
Evm: ConfigureEvm<Header = ProviderHeader<Self::Provider>, TxEnv = TxEnv>,
Error: FromEvmError<Self::Evm>,
> + SpawnBlocking,
Self::Error: From<OpEthApiError>,
N: OpNodeCore,
{

View File

@ -30,7 +30,7 @@ use reth_rpc_eth_api::{
AddDevSigners, EthApiSpec, EthFees, EthSigner, EthState, LoadBlock, LoadFee, LoadState,
SpawnBlocking, Trace,
},
EthApiTypes, RpcNodeCore, RpcNodeCoreExt,
EthApiTypes, FromEvmError, RpcNodeCore, RpcNodeCoreExt,
};
use reth_rpc_eth_types::{EthStateCache, FeeHistoryCache, GasPriceOracle};
use reth_tasks::{
@ -252,6 +252,7 @@ where
Header = ProviderHeader<Self::Provider>,
Transaction = ProviderTx<Self::Provider>,
>,
Error: FromEvmError<Self::Evm>,
>,
N: OpNodeCore,
{

View File

@ -21,7 +21,7 @@ use reth_provider::{
};
use reth_rpc_eth_api::{
helpers::{LoadPendingBlock, SpawnBlocking},
EthApiTypes, FromEthApiError, RpcNodeCore,
EthApiTypes, FromEthApiError, FromEvmError, RpcNodeCore,
};
use reth_rpc_eth_types::{EthApiError, PendingBlock};
use reth_transaction_pool::{PoolTransaction, TransactionPool};
@ -34,6 +34,7 @@ where
NetworkTypes: Network<
HeaderResponse = alloy_rpc_types_eth::Header<ProviderHeader<Self::Provider>>,
>,
Error: FromEvmError<Self::Evm>,
>,
N: RpcNodeCore<
Provider: BlockReaderIdExt<