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 opts;
35pub mod precompiles;
36pub mod state_snapshot;
37pub mod utils;
38
39/// An extension trait that allows us to add additional hooks to Inspector for later use in
40/// handlers.
41#[auto_impl(&mut, Box)]
42pub trait InspectorExt: for<'a> Inspector<EthEvmContext<&'a mut dyn DatabaseExt>> {
43    /// Determines whether the `DEFAULT_CREATE2_DEPLOYER` should be used for a CREATE2 frame.
44    ///
45    /// If this function returns true, we'll replace CREATE2 frame with a CALL frame to CREATE2
46    /// factory.
47    fn should_use_create2_factory(
48        &mut self,
49        _context: &mut EthEvmContext<&mut dyn DatabaseExt>,
50        _inputs: &CreateInputs,
51    ) -> bool {
52        false
53    }
54
55    /// Simulates `console.log` invocation.
56    fn console_log(&mut self, msg: &str) {
57        let _ = msg;
58    }
59
60    /// Returns `true` if the current network is Odyssey.
61    fn is_odyssey(&self) -> bool {
62        false
63    }
64
65    /// Returns the CREATE2 deployer address.
66    fn create2_deployer(&self) -> Address {
67        DEFAULT_CREATE2_DEPLOYER
68    }
69}
70
71impl InspectorExt for NoOpInspector {}
72
73impl InspectorExt for AccessListInspector {}