foundry_evm_core/
lib.rs

1//! # foundry-evm-core
2//!
3//! Core EVM abstractions.
4
5#![cfg_attr(not(test), warn(unused_crate_dependencies))]
6#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
7
8use crate::constants::DEFAULT_CREATE2_DEPLOYER;
9use alloy_evm::eth::EthEvmContext;
10use alloy_primitives::Address;
11use auto_impl::auto_impl;
12use backend::DatabaseExt;
13use revm::{inspector::NoOpInspector, interpreter::CreateInputs, Inspector};
14use revm_inspectors::access_list::AccessListInspector;
15
16#[macro_use]
17extern crate tracing;
18
19pub mod abi {
20    pub use foundry_cheatcodes_spec::Vm;
21    pub use foundry_evm_abi::*;
22}
23
24pub mod env;
25pub use env::*;
26pub mod backend;
27pub mod buffer;
28pub mod constants;
29pub mod decode;
30pub mod either_evm;
31pub mod evm;
32pub mod fork;
33pub mod ic;
34pub mod opcodes;
35pub mod opts;
36pub mod precompiles;
37pub mod state_snapshot;
38pub mod utils;
39
40/// An extension trait that allows us to add additional hooks to Inspector for later use in
41/// handlers.
42#[auto_impl(&mut, Box)]
43pub trait InspectorExt: for<'a> Inspector<EthEvmContext<&'a mut dyn DatabaseExt>> {
44    /// Determines whether the `DEFAULT_CREATE2_DEPLOYER` should be used for a CREATE2 frame.
45    ///
46    /// If this function returns true, we'll replace CREATE2 frame with a CALL frame to CREATE2
47    /// factory.
48    fn should_use_create2_factory(
49        &mut self,
50        _context: &mut EthEvmContext<&mut dyn DatabaseExt>,
51        _inputs: &CreateInputs,
52    ) -> bool {
53        false
54    }
55
56    /// Simulates `console.log` invocation.
57    fn console_log(&mut self, msg: &str) {
58        let _ = msg;
59    }
60
61    /// Returns `true` if the current network is Odyssey.
62    fn is_odyssey(&self) -> bool {
63        false
64    }
65
66    /// Returns the CREATE2 deployer address.
67    fn create2_deployer(&self) -> Address {
68        DEFAULT_CREATE2_DEPLOYER
69    }
70}
71
72impl InspectorExt for NoOpInspector {}
73
74impl InspectorExt for AccessListInspector {}