Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rpc): remove redundant Trace::evm_config #12102

Merged
merged 6 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions crates/optimism/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,9 @@ where

impl<N> Trace for OpEthApi<N>
where
Self: LoadState,
N: FullNodeComponents,
Self: LoadState<Evm: ConfigureEvm<Header = Header>>,
N: RpcNodeCore,
{
#[inline]
fn evm_config(&self) -> &impl ConfigureEvm<Header = Header> {
self.inner.evm_config()
}
}

impl<N> AddDevSigners for OpEthApi<N>
Expand Down
15 changes: 5 additions & 10 deletions crates/rpc/rpc-eth-api/src/helpers/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ use revm_primitives::{EnvWithHandlerCfg, EvmState, ExecutionResult, ResultAndSta
use super::{Call, LoadBlock, LoadPendingBlock, LoadState, LoadTransaction};

/// Executes CPU heavy tasks.
pub trait Trace: LoadState {
/// Returns a handle for reading evm config.
///
/// Data access in default (L1) trait method implementations.
fn evm_config(&self) -> &impl ConfigureEvm<Header = Header>;

pub trait Trace: LoadState<Evm: ConfigureEvm<Header = Header>> {
/// Executes the [`EnvWithHandlerCfg`] against the given [Database] without committing state
/// changes.
fn inspect<DB, I>(
Expand Down Expand Up @@ -60,7 +55,7 @@ pub trait Trace: LoadState {

I: GetInspector<DB>,
{
let mut evm = Trace::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 (db, env) = evm.into_db_and_env_with_handler_cfg();
Ok((res, env, db))
Expand Down Expand Up @@ -201,7 +196,7 @@ pub trait Trace: LoadState {

// apply relevant system calls
let mut system_caller = SystemCaller::new(
Trace::evm_config(&this).clone(),
this.evm_config().clone(),
RpcNodeCore::provider(&this).chain_spec(),
);
system_caller
Expand Down Expand Up @@ -344,7 +339,7 @@ pub trait Trace: LoadState {

// apply relevant system calls
let mut system_caller = SystemCaller::new(
Trace::evm_config(&this).clone(),
this.evm_config().clone(),
RpcNodeCore::provider(&this).chain_spec(),
);
system_caller
Expand Down Expand Up @@ -379,7 +374,7 @@ pub trait Trace: LoadState {
block_number: Some(block_number),
base_fee: Some(base_fee),
};
let tx_env = Trace::evm_config(&this).tx_env(tx, *signer);
let tx_env = this.evm_config().tx_env(tx, *signer);
(tx_info, tx_env)
})
.peekable();
Expand Down
10 changes: 2 additions & 8 deletions crates/rpc/rpc/src/eth/helpers/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ use reth_rpc_eth_api::helpers::{LoadState, Trace};

use crate::EthApi;

impl<Provider, Pool, Network, EvmConfig> Trace for EthApi<Provider, Pool, Network, EvmConfig>
where
Self: LoadState,
EvmConfig: ConfigureEvm<Header = Header>,
impl<Provider, Pool, Network, EvmConfig> Trace for EthApi<Provider, Pool, Network, EvmConfig> where
Self: LoadState<Evm: ConfigureEvm<Header = Header>>
{
#[inline]
fn evm_config(&self) -> &impl ConfigureEvm<Header = Header> {
self.inner.evm_config()
}
}
Loading