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 /// 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 blob target and max count for the given spec id.
32 /// If it is None, check for max count will be skipped.
33 ///
34 /// EIP-7840: Add blob schedule to execution client configuration files
35 fn blob_max_count(&self) -> Option<u64>;
36
37 /// Returns the maximum code size for the given spec id.
38 fn max_code_size(&self) -> usize;
39
40 /// Returns whether the EIP-3607 (account clearing) is disabled.
41 fn is_eip3607_disabled(&self) -> bool;
42
43 /// Returns whether the balance check is disabled.
44 fn is_balance_check_disabled(&self) -> bool;
45
46 /// Returns whether the block gas limit check is disabled.
47 fn is_block_gas_limit_disabled(&self) -> bool;
48
49 /// Returns whether the nonce check is disabled.
50 fn is_nonce_check_disabled(&self) -> bool;
51
52 /// Returns whether the base fee check is disabled.
53 fn is_base_fee_check_disabled(&self) -> bool;
54}
55
56/// What bytecode analysis to perform
57#[derive(Clone, Default, Debug, Eq, PartialEq, Hash)]
58#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
59pub enum AnalysisKind {
60 /// Do not perform bytecode analysis
61 Raw,
62 /// Perform bytecode analysis
63 #[default]
64 Analyse,
65}
66
67/// Transaction destination
68pub type TransactTo = TxKind;
69
70/// Create scheme
71#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
72#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
73pub enum CreateScheme {
74 /// Legacy create scheme of `CREATE`
75 Create,
76 /// Create scheme of `CREATE2`
77 Create2 {
78 /// Salt
79 salt: U256,
80 },
81 /// Custom scheme where we set up the original address
82 Custom {
83 /// Custom contract creation address.
84 address: Address,
85 },
86}