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, it 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    /// Returns the gas limit cap for the transaction.
21    ///
22    /// Cap is introduced in [`EIP-7825: Transaction Gas Limit Cap`](https://eips.ethereum.org/EIPS/eip-7825)
23    /// with initial cap of 30M gas.
24    ///
25    /// Value before EIP-7825 is `u64::MAX`.
26    fn tx_gas_limit_cap(&self) -> u64;
27
28    /// Specification id
29    fn spec(&self) -> Self::Spec;
30
31    /// Returns the maximum number of blobs allowed per transaction.
32    /// If it is None, check for max count will be skipped.
33    fn max_blobs_per_tx(&self) -> Option<u64>;
34
35    /// Returns the maximum code size for the given spec id.
36    fn max_code_size(&self) -> usize;
37
38    /// Returns the max initcode size for the given spec id.
39    fn max_initcode_size(&self) -> usize;
40
41    /// Returns whether the EIP-3607 (account clearing) is disabled.
42    fn is_eip3607_disabled(&self) -> bool;
43
44    /// Returns whether the EIP-3541 (disallowing new contracts with 0xEF prefix) is disabled.
45    fn is_eip3541_disabled(&self) -> bool;
46
47    /// Returns whether the balance check is disabled.
48    fn is_balance_check_disabled(&self) -> bool;
49
50    /// Returns whether the block gas limit check is disabled.
51    fn is_block_gas_limit_disabled(&self) -> bool;
52
53    /// Returns whether the nonce check is disabled.
54    fn is_nonce_check_disabled(&self) -> bool;
55
56    /// Returns whether the base fee check is disabled.
57    fn is_base_fee_check_disabled(&self) -> bool;
58
59    /// Returns whether the priority fee check is disabled.
60    fn is_priority_fee_check_disabled(&self) -> bool;
61
62    /// Returns whether the fee charge is disabled.
63    fn is_fee_charge_disabled(&self) -> bool;
64}
65
66/// What bytecode analysis to perform
67#[derive(Clone, Default, Debug, Eq, PartialEq, Hash)]
68#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
69pub enum AnalysisKind {
70    /// Do not perform bytecode analysis
71    Raw,
72    /// Perform bytecode analysis
73    #[default]
74    Analyse,
75}
76
77/// Transaction destination
78pub type TransactTo = TxKind;
79
80/// Create scheme
81#[derive(Clone, Copy, Default, Debug, Eq, PartialEq, Hash)]
82#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
83pub enum CreateScheme {
84    /// Legacy create scheme of `CREATE`
85    #[default]
86    Create,
87    /// Create scheme of `CREATE2`
88    Create2 {
89        /// Salt
90        salt: U256,
91    },
92    /// Custom scheme where we set up the original address
93    Custom {
94        /// Custom contract creation address.
95        address: Address,
96    },
97}