revm_context_interface/
cfg.rs

1//! Configuration for the EVM. Containing [`SpecId`].
2use auto_impl::auto_impl;
3use core::fmt::Debug;
4use core::hash::Hash;
5use primitives::{hardfork::SpecId, Address, TxKind, U256};
6
7/// Configuration for the EVM.
8#[auto_impl(&, &mut, Box, Arc)]
9pub trait Cfg {
10    /// Specification id type, in requires to be convertible to `SpecId` so it can be used
11    /// by default in mainnet.
12    type Spec: Into<SpecId> + Clone;
13
14    /// Returns the chain ID of the EVM that is compared with the transaction's chain ID.
15    fn chain_id(&self) -> u64;
16
17    /// Returns whether the transaction's chain ID check is enabled.
18    fn tx_chain_id_check(&self) -> bool;
19
20    /// Specification id
21    fn spec(&self) -> Self::Spec;
22
23    /// Returns the blob target and max count for the given spec id.
24    /// If it is None, check for max count will be skipped.
25    ///
26    /// EIP-7840: Add blob schedule to execution client configuration files
27    fn blob_max_count(&self) -> Option<u64>;
28
29    /// Returns the maximum code size for the given spec id.
30    fn max_code_size(&self) -> usize;
31
32    /// Returns whether the EIP-3607 (account clearing) is disabled.
33    fn is_eip3607_disabled(&self) -> bool;
34
35    /// Returns whether the balance check is disabled.
36    fn is_balance_check_disabled(&self) -> bool;
37
38    /// Returns whether the block gas limit check is disabled.
39    fn is_block_gas_limit_disabled(&self) -> bool;
40
41    /// Returns whether the nonce check is disabled.
42    fn is_nonce_check_disabled(&self) -> bool;
43
44    /// Returns whether the base fee check is disabled.
45    fn is_base_fee_check_disabled(&self) -> bool;
46}
47
48/// What bytecode analysis to perform
49#[derive(Clone, Default, Debug, Eq, PartialEq, Hash)]
50#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
51pub enum AnalysisKind {
52    /// Do not perform bytecode analysis
53    Raw,
54    /// Perform bytecode analysis
55    #[default]
56    Analyse,
57}
58
59/// Transaction destination
60pub type TransactTo = TxKind;
61
62/// Create scheme
63#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
64#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
65pub enum CreateScheme {
66    /// Legacy create scheme of `CREATE`
67    Create,
68    /// Create scheme of `CREATE2`
69    Create2 {
70        /// Salt
71        salt: U256,
72    },
73    /// Custom scheme where we set up the original address
74    Custom {
75        /// Custom contract creation address.
76        address: Address,
77    },
78}