mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: remove reth-revm optimism (#8141)
This commit is contained in:
@ -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"]
|
||||
|
||||
@ -22,4 +22,3 @@ pub mod test_utils;
|
||||
|
||||
// Convenience re-exports.
|
||||
pub use revm::{self, *};
|
||||
pub use revm_inspectors::*;
|
||||
|
||||
@ -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<DB>,
|
||||
{
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user