Remove trait method Call::evm_config (#12095)

This commit is contained in:
Emilia Hane
2024-10-27 00:20:08 +08:00
committed by GitHub
parent b257408060
commit 1bdf429af5
7 changed files with 24 additions and 40 deletions

View File

@@ -9,7 +9,7 @@ use reth_primitives::{
};
use reth_rpc_eth_api::{
helpers::{Call, EthCall, LoadState, SpawnBlocking},
FromEthApiError, IntoEthApiError,
FromEthApiError, IntoEthApiError, RpcNodeCore,
};
use reth_rpc_eth_types::{revm_utils::CallFees, RpcInvalidTransactionError};
@@ -24,9 +24,9 @@ where
impl<N> Call for OpEthApi<N>
where
Self: LoadState + SpawnBlocking,
N: RpcNodeCore,
Self: LoadState<Evm: ConfigureEvm<Header = Header>> + SpawnBlocking,
Self::Error: From<OpEthApiError>,
N: FullNodeComponents,
{
#[inline]
fn call_gas_limit(&self) -> u64 {
@@ -38,11 +38,6 @@ where
self.inner.max_simulate_blocks()
}
#[inline]
fn evm_config(&self) -> &impl ConfigureEvm<Header = Header> {
self.inner.evm_config()
}
fn create_txn_env(
&self,
block_env: &BlockEnv,

View File

@@ -3,6 +3,7 @@
use crate::{
AsEthApiError, FromEthApiError, FromEvmError, FullEthApiTypes, IntoEthApiError, RpcBlock,
RpcNodeCore,
};
use alloy_eips::{eip1559::calc_next_block_base_fee, eip2930::AccessListResult};
use alloy_primitives::{Address, Bytes, TxKind, B256, U256};
@@ -300,7 +301,7 @@ pub trait EthCall: Call + LoadPendingBlock {
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg.clone(),
block_env.clone(),
Call::evm_config(&this).tx_env(tx, *signer),
RpcNodeCore::evm_config(&this).tx_env(tx, *signer),
);
let (res, _) = this.transact(&mut db, env)?;
db.commit(res.state);
@@ -452,7 +453,7 @@ pub trait EthCall: Call + LoadPendingBlock {
}
/// Executes code on state.
pub trait Call: LoadState + SpawnBlocking {
pub trait Call: LoadState<Evm: ConfigureEvm<Header = Header>> + SpawnBlocking {
/// Returns default gas limit to use for `eth_call` and tracing RPC methods.
///
/// Data access in default trait method implementations.
@@ -461,11 +462,6 @@ pub trait Call: LoadState + SpawnBlocking {
/// Returns the maximum number of blocks accepted for `eth_simulateV1`.
fn max_simulate_blocks(&self) -> u64;
/// Returns a handle for reading evm config.
///
/// Data access in default (L1) trait method implementations.
fn evm_config(&self) -> &impl ConfigureEvm<Header = Header>;
/// Executes the closure with the state that corresponds to the given [`BlockId`].
fn with_state_at_block<F, R>(&self, at: BlockId, f: F) -> Result<R, Self::Error>
where
@@ -486,7 +482,7 @@ pub trait Call: LoadState + SpawnBlocking {
DB: Database,
EthApiError: From<DB::Error>,
{
let mut evm = Call::evm_config(self).evm_with_env(db, env);
let mut evm = self.evm_config().evm_with_env(db, env);
let res = evm.transact().map_err(Self::Error::from_evm_err)?;
let (_, env) = evm.into_db_and_env_with_handler_cfg();
Ok((res, env))
@@ -504,7 +500,7 @@ pub trait Call: LoadState + SpawnBlocking {
DB: Database,
EthApiError: From<DB::Error>,
{
let mut evm = Call::evm_config(self).evm_with_env_and_inspector(db, env, inspector);
let mut evm = self.evm_config().evm_with_env_and_inspector(db, env, inspector);
let res = evm.transact().map_err(Self::Error::from_evm_err)?;
let (_, env) = evm.into_db_and_env_with_handler_cfg();
Ok((res, env))
@@ -636,7 +632,7 @@ pub trait Call: LoadState + SpawnBlocking {
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg,
block_env,
Call::evm_config(&this).tx_env(tx.as_signed(), tx.signer()),
RpcNodeCore::evm_config(&this).tx_env(tx.as_signed(), tx.signer()),
);
let (res, _) = this.transact(&mut db, env)?;
@@ -669,7 +665,7 @@ pub trait Call: LoadState + SpawnBlocking {
{
let env = EnvWithHandlerCfg::new_with_cfg_env(cfg, block_env, Default::default());
let mut evm = Call::evm_config(self).evm_with_env(db, env);
let mut evm = self.evm_config().evm_with_env(db, env);
let mut index = 0;
for (sender, tx) in transactions {
if tx.hash() == target_tx_hash {
@@ -677,7 +673,7 @@ pub trait Call: LoadState + SpawnBlocking {
break
}
Call::evm_config(self).fill_tx_env(evm.tx_mut(), tx, *sender);
self.evm_config().fill_tx_env(evm.tx_mut(), tx, *sender);
evm.transact_commit().map_err(Self::Error::from_evm_err)?;
index += 1;
}

View File

@@ -229,7 +229,7 @@ pub trait Trace: LoadState {
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg,
block_env,
Call::evm_config(&this).tx_env(tx.as_signed(), tx.signer()),
RpcNodeCore::evm_config(&this).tx_env(tx.as_signed(), tx.signer()),
);
let (res, _) =
this.inspect(StateCacheDbRefMutWrapper(&mut db), env, &mut inspector)?;

View File

@@ -27,7 +27,7 @@ use reth_provider::{
use reth_revm::database::StateProviderDatabase;
use reth_rpc_api::DebugApiServer;
use reth_rpc_eth_api::{
helpers::{Call, EthApiSpec, EthTransactions, TraceExt},
helpers::{EthApiSpec, EthTransactions, TraceExt},
EthApiTypes, FromEthApiError, RpcNodeCore,
};
use reth_rpc_eth_types::{EthApiError, StateCacheDb};
@@ -120,7 +120,8 @@ where
env: Env::boxed(
cfg.cfg_env.clone(),
block_env.clone(),
Call::evm_config(this.eth_api()).tx_env(tx.as_signed(), tx.signer()),
RpcNodeCore::evm_config(this.eth_api())
.tx_env(tx.as_signed(), tx.signer()),
),
handler_cfg: cfg.handler_cfg,
};
@@ -263,7 +264,7 @@ where
// apply relevant system calls
let mut system_caller = SystemCaller::new(
Call::evm_config(this.eth_api()).clone(),
RpcNodeCore::evm_config(this.eth_api()).clone(),
RpcNodeCore::provider(this.eth_api()).chain_spec(),
);
@@ -293,7 +294,7 @@ where
env: Env::boxed(
cfg.cfg_env.clone(),
block_env,
Call::evm_config(this.eth_api()).tx_env(tx.as_signed(), tx.signer()),
RpcNodeCore::evm_config(this.eth_api()).tx_env(tx.as_signed(), tx.signer()),
),
handler_cfg: cfg.handler_cfg,
};
@@ -562,7 +563,7 @@ where
env: Env::boxed(
cfg.cfg_env.clone(),
block_env.clone(),
Call::evm_config(this.eth_api()).tx_env(tx, *signer),
RpcNodeCore::evm_config(this.eth_api()).tx_env(tx, *signer),
),
handler_cfg: cfg.handler_cfg,
};

View File

@@ -12,7 +12,7 @@ use reth_primitives::{
PooledTransactionsElement,
};
use reth_revm::database::StateProviderDatabase;
use reth_rpc_eth_api::{FromEthApiError, FromEvmError};
use reth_rpc_eth_api::{FromEthApiError, FromEvmError, RpcNodeCore};
use reth_tasks::pool::BlockingTaskGuard;
use revm::{
db::CacheDB,
@@ -166,7 +166,7 @@ where
let mut total_gas_fess = U256::ZERO;
let mut hasher = Keccak256::new();
let mut evm = Call::evm_config(&eth_api).evm_with_env(db, env);
let mut evm = RpcNodeCore::evm_config(&eth_api).evm_with_env(db, env);
let mut results = Vec::with_capacity(transactions.len());
let mut transactions = transactions.into_iter().peekable();
@@ -187,7 +187,7 @@ where
.effective_tip_per_gas(basefee)
.ok_or_else(|| RpcInvalidTransactionError::FeeCapTooLow)
.map_err(Eth::Error::from_eth_err)?;
Call::evm_config(&eth_api).fill_tx_env(evm.tx_mut(), &tx, signer);
RpcNodeCore::evm_config(&eth_api).fill_tx_env(evm.tx_mut(), &tx, signer);
let ResultAndState { result, state } =
evm.transact().map_err(Eth::Error::from_evm_err)?;

View File

@@ -13,7 +13,7 @@ impl<Provider, Pool, Network, EvmConfig> EthCall for EthApi<Provider, Pool, Netw
impl<Provider, Pool, Network, EvmConfig> Call for EthApi<Provider, Pool, Network, EvmConfig>
where
Self: LoadState + SpawnBlocking,
Self: LoadState<Evm: ConfigureEvm<Header = Header>> + SpawnBlocking,
EvmConfig: ConfigureEvm<Header = Header>,
{
#[inline]
@@ -25,9 +25,4 @@ where
fn max_simulate_blocks(&self) -> u64 {
self.inner.max_simulate_blocks()
}
#[inline]
fn evm_config(&self) -> &impl ConfigureEvm<Header = Header> {
self.inner.evm_config()
}
}

View File

@@ -21,10 +21,7 @@ use reth_primitives::{BlockId, Header};
use reth_provider::{BlockReader, ChainSpecProvider, EvmEnvProvider, StateProviderFactory};
use reth_revm::database::StateProviderDatabase;
use reth_rpc_api::TraceApiServer;
use reth_rpc_eth_api::{
helpers::{Call, TraceExt},
FromEthApiError,
};
use reth_rpc_eth_api::{helpers::TraceExt, FromEthApiError, RpcNodeCore};
use reth_rpc_eth_types::{error::EthApiError, utils::recover_raw_transaction};
use reth_tasks::pool::BlockingTaskGuard;
use revm::{
@@ -124,7 +121,7 @@ where
let env = EnvWithHandlerCfg::new_with_cfg_env(
cfg,
block,
Call::evm_config(self.eth_api()).tx_env(tx.as_signed(), tx.signer()),
RpcNodeCore::evm_config(self.eth_api()).tx_env(tx.as_signed(), tx.signer()),
);
let config = TracingInspectorConfig::from_parity_config(&trace_types);