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 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
63/// What bytecode analysis to perform
64#[derive(Clone, Default, Debug, Eq, PartialEq, Hash)]
65#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
66pub enum AnalysisKind {
67 /// Do not perform bytecode analysis
68 Raw,
69 /// Perform bytecode analysis
70 #[default]
71 Analyse,
72}
73
74/// Transaction destination
75pub type TransactTo = TxKind;
76
77/// Create scheme
78#[derive(Clone, Copy, Default, Debug, Eq, PartialEq, Hash)]
79#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
80pub enum CreateScheme {
81 /// Legacy create scheme of `CREATE`
82 #[default]
83 Create,
84 /// Create scheme of `CREATE2`
85 Create2 {
86 /// Salt
87 salt: U256,
88 },
89 /// Custom scheme where we set up the original address
90 Custom {
91 /// Custom contract creation address.
92 address: Address,
93 },
94}