revm_context_interface/cfg.rs
1//! Configuration for the EVM. Containing [`SpecId`].
2use auto_impl::auto_impl;
3use core::{fmt::Debug, hash::Hash};
4use primitives::{hardfork::SpecId, Address, TxKind, U256};
5
6/// Configuration for the EVM.
7#[auto_impl(&, &mut, Box, Arc)]
8pub trait Cfg {
9 /// Specification id type, it requires to be convertible to `SpecId` so it can be used
10 /// by default in mainnet.
11 type Spec: Into<SpecId> + Clone;
12
13 /// Returns the chain ID of the EVM that is compared with the transaction's chain ID.
14 fn chain_id(&self) -> u64;
15
16 /// Returns whether the transaction's chain ID check is enabled.
17 fn tx_chain_id_check(&self) -> bool;
18
19 /// Returns the gas limit cap for the transaction.
20 ///
21 /// Cap is introduced in [`EIP-7825: Transaction Gas Limit Cap`](https://eips.ethereum.org/EIPS/eip-7825)
22 /// with initial cap of 30M gas.
23 ///
24 /// Value before EIP-7825 is `u64::MAX`.
25 fn tx_gas_limit_cap(&self) -> u64;
26
27 /// Specification id
28 fn spec(&self) -> Self::Spec;
29
30 /// Returns the maximum number of blobs allowed per transaction.
31 /// If it is None, check for max count will be skipped.
32 fn max_blobs_per_tx(&self) -> Option<u64>;
33
34 /// Returns the maximum code size for the given spec id.
35 fn max_code_size(&self) -> usize;
36
37 /// Returns the max initcode size for the given spec id.
38 fn max_initcode_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 EIP-3541 (disallowing new contracts with 0xEF prefix) is disabled.
44 fn is_eip3541_disabled(&self) -> bool;
45
46 /// Returns whether the EIP-7623 (increased calldata cost) is disabled.
47 fn is_eip7623_disabled(&self) -> bool;
48
49 /// Returns whether the balance check is disabled.
50 fn is_balance_check_disabled(&self) -> bool;
51
52 /// Returns whether the block gas limit check is disabled.
53 fn is_block_gas_limit_disabled(&self) -> bool;
54
55 /// Returns whether the nonce check is disabled.
56 fn is_nonce_check_disabled(&self) -> bool;
57
58 /// Returns whether the base fee check is disabled.
59 fn is_base_fee_check_disabled(&self) -> bool;
60
61 /// Returns whether the priority fee check is disabled.
62 fn is_priority_fee_check_disabled(&self) -> bool;
63
64 /// Returns whether the fee charge is disabled.
65 fn is_fee_charge_disabled(&self) -> bool;
66
67 /// Returns the limit in bytes for the memory buffer.
68 fn memory_limit(&self) -> u64;
69}
70
71/// What bytecode analysis to perform
72#[derive(Clone, Default, Debug, Eq, PartialEq, Hash)]
73#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
74pub enum AnalysisKind {
75 /// Do not perform bytecode analysis
76 Raw,
77 /// Perform bytecode analysis
78 #[default]
79 Analyse,
80}
81
82/// Transaction destination
83pub type TransactTo = TxKind;
84
85/// Create scheme
86#[derive(Clone, Copy, Default, Debug, Eq, PartialEq, Hash)]
87#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
88pub enum CreateScheme {
89 /// Legacy create scheme of `CREATE`
90 #[default]
91 Create,
92 /// Create scheme of `CREATE2`
93 Create2 {
94 /// Salt
95 salt: U256,
96 },
97 /// Custom scheme where we set up the original address
98 Custom {
99 /// Custom contract creation address.
100 address: Address,
101 },
102}