From 00f9acb94eeac76c4d204bb37011007797daa6ea Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 7 May 2024 18:55:46 +0200 Subject: [PATCH] chore: remove reth-revm optimism (#8141) --- Cargo.lock | 4 +- bin/reth/Cargo.toml | 1 - crates/blockchain-tree/Cargo.toml | 2 +- crates/consensus/beacon/Cargo.toml | 1 - crates/optimism/evm/Cargo.toml | 1 - crates/optimism/node/Cargo.toml | 1 - crates/payload/optimism/Cargo.toml | 1 - crates/revm/Cargo.toml | 12 +-- crates/revm/src/lib.rs | 1 - crates/revm/src/test_utils.rs | 98 +--------------------- crates/rpc/rpc/Cargo.toml | 4 +- crates/rpc/rpc/src/eth/api/call.rs | 3 +- crates/rpc/rpc/src/eth/api/transactions.rs | 6 +- crates/rpc/rpc/src/eth/error.rs | 2 +- crates/rpc/rpc/src/trace.rs | 10 +-- 15 files changed, 18 insertions(+), 129 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ee45d88a..76ab2dccc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5387,7 +5387,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 2.0.60", @@ -7653,13 +7653,11 @@ name = "reth-revm" version = "0.2.0-beta.6" dependencies = [ "reth-consensus-common", - "reth-evm", "reth-interfaces", "reth-primitives", "reth-provider", "reth-trie", "revm", - "revm-inspectors", "tracing", ] diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 3f5d78834..37b26686f 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -133,7 +133,6 @@ min-trace-logs = ["tracing/release_max_level_trace"] optimism = [ "reth-primitives/optimism", - "reth-revm/optimism", "reth-interfaces/optimism", "reth-rpc/optimism", "reth-provider/optimism", diff --git a/crates/blockchain-tree/Cargo.toml b/crates/blockchain-tree/Cargo.toml index 912f593dc..70ce9a290 100644 --- a/crates/blockchain-tree/Cargo.toml +++ b/crates/blockchain-tree/Cargo.toml @@ -50,4 +50,4 @@ assert_matches.workspace = true [features] test-utils = [] -optimism = ["reth-primitives/optimism", "reth-interfaces/optimism", "reth-provider/optimism", "reth-revm/optimism"] +optimism = ["reth-primitives/optimism", "reth-interfaces/optimism", "reth-provider/optimism"] diff --git a/crates/consensus/beacon/Cargo.toml b/crates/consensus/beacon/Cargo.toml index 8fb9d3ec3..7b106b2d3 100644 --- a/crates/consensus/beacon/Cargo.toml +++ b/crates/consensus/beacon/Cargo.toml @@ -71,6 +71,5 @@ optimism = [ "reth-provider/optimism", "reth-blockchain-tree/optimism", "reth-beacon-consensus-core/optimism", - "reth-revm/optimism", "reth-rpc/optimism" ] diff --git a/crates/optimism/evm/Cargo.toml b/crates/optimism/evm/Cargo.toml index 4e5fd2f19..a1c3a168b 100644 --- a/crates/optimism/evm/Cargo.toml +++ b/crates/optimism/evm/Cargo.toml @@ -33,7 +33,6 @@ reth-revm = { workspace = true, features = ["test-utils"] } optimism = [ "reth-primitives/optimism", "reth-provider/optimism", - "reth-revm/optimism", "reth-interfaces/optimism", "revm-primitives/optimism", ] diff --git a/crates/optimism/node/Cargo.toml b/crates/optimism/node/Cargo.toml index be8791c78..9432ce9ed 100644 --- a/crates/optimism/node/Cargo.toml +++ b/crates/optimism/node/Cargo.toml @@ -64,7 +64,6 @@ optimism = [ "reth-provider/optimism", "reth-rpc-types-compat/optimism", "reth-rpc/optimism", - "reth-revm/optimism", "reth-evm-optimism/optimism", "reth-optimism-payload-builder/optimism", "reth-beacon-consensus/optimism", diff --git a/crates/payload/optimism/Cargo.toml b/crates/payload/optimism/Cargo.toml index c58d0ecb5..567c02833 100644 --- a/crates/payload/optimism/Cargo.toml +++ b/crates/payload/optimism/Cargo.toml @@ -37,7 +37,6 @@ sha2.workspace = true [features] optimism = [ "reth-primitives/optimism", - "reth-revm/optimism", "reth-provider/optimism", "reth-rpc-types-compat/optimism", "reth-evm-optimism/optimism", diff --git a/crates/revm/Cargo.toml b/crates/revm/Cargo.toml index ca52c7c90..2b621ed76 100644 --- a/crates/revm/Cargo.toml +++ b/crates/revm/Cargo.toml @@ -17,26 +17,16 @@ reth-primitives.workspace = true reth-interfaces.workspace = true reth-provider.workspace = true reth-consensus-common.workspace = true -reth-evm = { workspace = true, optional = true } reth-trie = { workspace = true, optional = true } # revm revm.workspace = true -revm-inspectors.workspace = true # common tracing.workspace = true [dev-dependencies] -reth-evm.workspace = true reth-trie.workspace = true [features] -test-utils = ["dep:reth-trie", "dep:reth-evm"] -optimism = [ - "revm/optimism", - "reth-primitives/optimism", - "reth-provider/optimism", - "reth-interfaces/optimism", -] -js-tracer = ["revm-inspectors/js-tracer"] +test-utils = ["dep:reth-trie"] diff --git a/crates/revm/src/lib.rs b/crates/revm/src/lib.rs index 7f950afb0..8e5419567 100644 --- a/crates/revm/src/lib.rs +++ b/crates/revm/src/lib.rs @@ -22,4 +22,3 @@ pub mod test_utils; // Convenience re-exports. pub use revm::{self, *}; -pub use revm_inspectors::*; diff --git a/crates/revm/src/test_utils.rs b/crates/revm/src/test_utils.rs index 48e6e7c4d..8c4d1894c 100644 --- a/crates/revm/src/test_utils.rs +++ b/crates/revm/src/test_utils.rs @@ -1,31 +1,13 @@ -use reth_evm::{ConfigureEvm, ConfigureEvmEnv}; use reth_interfaces::provider::ProviderResult; use reth_primitives::{ - keccak256, revm::config::revm_spec, trie::AccountProof, Account, Address, BlockNumber, - Bytecode, Bytes, ChainSpec, Head, Header, StorageKey, TransactionSigned, B256, U256, + keccak256, trie::AccountProof, Account, Address, BlockNumber, Bytecode, Bytes, StorageKey, + B256, U256, }; - -#[cfg(not(feature = "optimism"))] -use reth_primitives::revm::env::fill_tx_env; use reth_provider::{AccountReader, BlockHashReader, StateProvider, StateRootProvider}; use reth_trie::updates::TrieUpdates; -use revm::{ - db::BundleState, - primitives::{AnalysisKind, CfgEnvWithHandlerCfg, TxEnv}, -}; +use revm::db::BundleState; use std::collections::HashMap; -#[cfg(feature = "optimism")] -use { - reth_primitives::revm::env::fill_op_tx_env, - revm::{inspector_handle_register, GetInspector}, -}; - -use revm::{ - primitives::{HandlerCfg, SpecId}, - Database, Evm, EvmBuilder, -}; - /// Mock state for testing #[derive(Debug, Default, Clone, Eq, PartialEq)] pub struct StateProviderTest { @@ -107,77 +89,3 @@ impl StateProvider for StateProviderTest { unimplemented!("proof generation is not supported") } } - -/// Test EVM configuration. -#[derive(Debug, Default, Clone, Copy)] -#[non_exhaustive] -pub struct TestEvmConfig; - -impl ConfigureEvmEnv for TestEvmConfig { - #[allow(unused_variables)] - fn fill_tx_env(tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) { - #[cfg(not(feature = "optimism"))] - fill_tx_env(tx_env, transaction, sender); - - #[cfg(feature = "optimism")] - { - let mut buf = Vec::with_capacity(transaction.length_without_header()); - transaction.encode_enveloped(&mut buf); - fill_op_tx_env(tx_env, transaction, sender, buf.into()); - } - } - - fn fill_cfg_env( - cfg_env: &mut CfgEnvWithHandlerCfg, - chain_spec: &ChainSpec, - header: &Header, - total_difficulty: U256, - ) { - let spec_id = revm_spec( - chain_spec, - Head { - number: header.number, - timestamp: header.timestamp, - difficulty: header.difficulty, - total_difficulty, - hash: Default::default(), - }, - ); - - cfg_env.chain_id = chain_spec.chain().id(); - cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Analyse; - - cfg_env.handler_cfg.spec_id = spec_id; - #[cfg(feature = "optimism")] - { - cfg_env.handler_cfg.is_optimism = chain_spec.is_optimism(); - } - } -} - -impl ConfigureEvm for TestEvmConfig { - type DefaultExternalContext<'a> = (); - - fn evm<'a, DB: Database + 'a>(&self, db: DB) -> Evm<'a, (), DB> { - #[cfg(feature = "optimism")] - let handler_cfg = HandlerCfg { spec_id: SpecId::LATEST, is_optimism: true }; - #[cfg(not(feature = "optimism"))] - let handler_cfg = HandlerCfg { spec_id: SpecId::LATEST }; - EvmBuilder::default().with_db(db).with_handler_cfg(handler_cfg).build() - } - - #[cfg(feature = "optimism")] - fn evm_with_inspector<'a, DB, I>(&self, db: DB, inspector: I) -> Evm<'a, I, DB> - where - DB: Database + 'a, - I: GetInspector, - { - let handler_cfg = HandlerCfg { spec_id: SpecId::LATEST, is_optimism: true }; - EvmBuilder::default() - .with_db(db) - .with_external_context(inspector) - .with_handler_cfg(handler_cfg) - .append_handler_register(inspector_handle_register) - .build() - } -} diff --git a/crates/rpc/rpc/Cargo.toml b/crates/rpc/rpc/Cargo.toml index 513c7da13..224866be6 100644 --- a/crates/rpc/rpc/Cargo.toml +++ b/crates/rpc/rpc/Cargo.toml @@ -21,11 +21,11 @@ reth-provider = { workspace = true, features = ["test-utils"] } reth-transaction-pool = { workspace = true, features = ["test-utils"] } reth-network-api.workspace = true reth-rpc-engine-api.workspace = true -reth-revm = { workspace = true, features = ["js-tracer"] } +reth-revm.workspace = true reth-tasks = { workspace = true, features = ["rayon"] } reth-consensus-common.workspace = true reth-rpc-types-compat.workspace = true -revm-inspectors.workspace = true +revm-inspectors = { workspace = true, features = ["js-tracer"] } reth-evm.workspace = true reth-network-types.workspace = true diff --git a/crates/rpc/rpc/src/eth/api/call.rs b/crates/rpc/rpc/src/eth/api/call.rs index 8ef2af2f5..acd5c30e8 100644 --- a/crates/rpc/rpc/src/eth/api/call.rs +++ b/crates/rpc/rpc/src/eth/api/call.rs @@ -18,7 +18,7 @@ use reth_primitives::{revm::env::tx_env_with_recovered, BlockId, Bytes, TxKind, use reth_provider::{ BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProvider, StateProviderFactory, }; -use reth_revm::{access_list::AccessListInspector, database::StateProviderDatabase}; +use reth_revm::database::StateProviderDatabase; use reth_rpc_types::{ state::StateOverride, AccessListWithGasUsed, Bundle, EthCallResponse, StateContext, TransactionRequest, @@ -31,6 +31,7 @@ use revm::{ }, DatabaseCommit, }; +use revm_inspectors::access_list::AccessListInspector; use tracing::trace; // Gas per transaction not creating a contract. diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index 75470e1fe..721cef3db 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -24,10 +24,7 @@ use reth_primitives::{ use reth_provider::{ BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProviderBox, StateProviderFactory, }; -use reth_revm::{ - database::StateProviderDatabase, - tracing::{TracingInspector, TracingInspectorConfig}, -}; +use reth_revm::database::StateProviderDatabase; use reth_rpc_types::{ transaction::{ EIP1559TransactionRequest, EIP2930TransactionRequest, EIP4844TransactionRequest, @@ -47,6 +44,7 @@ use revm::{ }, GetInspector, Inspector, }; +use revm_inspectors::tracing::{TracingInspector, TracingInspectorConfig}; use std::future::Future; use crate::eth::revm_utils::FillableTransaction; diff --git a/crates/rpc/rpc/src/eth/error.rs b/crates/rpc/rpc/src/eth/error.rs index 203b5bbd7..305536aab 100644 --- a/crates/rpc/rpc/src/eth/error.rs +++ b/crates/rpc/rpc/src/eth/error.rs @@ -5,7 +5,6 @@ use alloy_sol_types::decode_revert_reason; use jsonrpsee::types::{error::CALL_EXECUTION_FAILED_CODE, ErrorObject}; use reth_interfaces::RethError; use reth_primitives::{revm_primitives::InvalidHeader, Address, Bytes, U256}; -use reth_revm::tracing::{js::JsInspectorError, MuxError}; use reth_rpc_types::{ error::EthRpcErrorCode, request::TransactionInputError, BlockError, ToRpcError, }; @@ -14,6 +13,7 @@ use reth_transaction_pool::error::{ PoolTransactionError, }; use revm::primitives::{EVMError, ExecutionResult, HaltReason, OutOfGasError}; +use revm_inspectors::tracing::{js::JsInspectorError, MuxError}; use std::time::Duration; /// Result alias diff --git a/crates/rpc/rpc/src/trace.rs b/crates/rpc/rpc/src/trace.rs index 5ee089a91..710440914 100644 --- a/crates/rpc/rpc/src/trace.rs +++ b/crates/rpc/rpc/src/trace.rs @@ -11,10 +11,7 @@ use reth_primitives::{ revm::env::tx_env_with_recovered, BlockId, BlockNumberOrTag, Bytes, SealedHeader, B256, U256, }; use reth_provider::{BlockReader, ChainSpecProvider, EvmEnvProvider, StateProviderFactory}; -use reth_revm::{ - database::StateProviderDatabase, - tracing::{parity::populate_state_diff, TracingInspector, TracingInspectorConfig}, -}; +use reth_revm::database::StateProviderDatabase; use reth_rpc_api::TraceApiServer; use reth_rpc_types::{ state::StateOverride, @@ -31,7 +28,10 @@ use revm::{ db::{CacheDB, DatabaseCommit}, primitives::EnvWithHandlerCfg, }; -use revm_inspectors::opcode::OpcodeGasInspector; +use revm_inspectors::{ + opcode::OpcodeGasInspector, + tracing::{parity::populate_state_diff, TracingInspector, TracingInspectorConfig}, +}; use std::{collections::HashSet, sync::Arc}; use tokio::sync::{AcquireError, OwnedSemaphorePermit};