foundry_evm_core/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! # foundry-evm-core
//!
//! Core EVM abstractions.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

use auto_impl::auto_impl;
use backend::DatabaseExt;
use revm::{inspectors::NoOpInspector, interpreter::CreateInputs, EvmContext, Inspector};
use revm_inspectors::access_list::AccessListInspector;

#[macro_use]
extern crate tracing;

pub mod abi {
    pub use foundry_cheatcodes_spec::Vm;
    pub use foundry_evm_abi::*;
}

mod ic;

pub mod backend;
pub mod buffer;
pub mod constants;
pub mod decode;
pub mod fork;
pub mod opcodes;
pub mod opts;
pub mod precompiles;
pub mod state_snapshot;
pub mod utils;

/// An extension trait that allows us to add additional hooks to Inspector for later use in
/// handlers.
#[auto_impl(&mut, Box)]
pub trait InspectorExt: for<'a> Inspector<&'a mut dyn DatabaseExt> {
    /// Determines whether the `DEFAULT_CREATE2_DEPLOYER` should be used for a CREATE2 frame.
    ///
    /// If this function returns true, we'll replace CREATE2 frame with a CALL frame to CREATE2
    /// factory.
    fn should_use_create2_factory(
        &mut self,
        _context: &mut EvmContext<&mut dyn DatabaseExt>,
        _inputs: &mut CreateInputs,
    ) -> bool {
        false
    }

    /// Simulates `console.log` invocation.
    fn console_log(&mut self, _input: String) {}

    /// Returns `true` if the current network is Alphanet.
    fn is_alphanet(&self) -> bool {
        false
    }
}

impl InspectorExt for NoOpInspector {}

impl InspectorExt for AccessListInspector {}