@@ -2,7 +2,7 @@ use auto_impl::auto_impl;
2
2
use core:: fmt:: Debug ;
3
3
use core:: hash:: Hash ;
4
4
use primitives:: { TxKind , U256 } ;
5
- use specification:: { constants :: MAX_CODE_SIZE , hardfork:: SpecId } ;
5
+ use specification:: hardfork:: SpecId ;
6
6
7
7
#[ auto_impl( & , & mut , Box , Arc ) ]
8
8
pub trait Cfg {
@@ -39,153 +39,6 @@ pub enum AnalysisKind {
39
39
Analyse ,
40
40
}
41
41
42
- /// EVM configuration.
43
- #[ cfg_attr( feature = "serde" , derive( serde:: Serialize , serde:: Deserialize ) ) ]
44
- #[ derive( Clone , Debug , Eq , PartialEq ) ]
45
- #[ non_exhaustive]
46
- pub struct CfgEnv < SPEC : Into < SpecId > = SpecId > {
47
- /// Chain ID of the EVM, it will be compared to the transaction's Chain ID.
48
- /// Chain ID is introduced EIP-155
49
- pub chain_id : u64 ,
50
- /// Specification for EVM represent the hardfork.
51
- pub spec : SPEC ,
52
- /// If some it will effects EIP-170: Contract code size limit. Useful to increase this because of tests.
53
- /// By default it is 0x6000 (~25kb).
54
- pub limit_contract_code_size : Option < usize > ,
55
- /// Skips the nonce validation against the account's nonce.
56
- pub disable_nonce_check : bool ,
57
- /// A hard memory limit in bytes beyond which [crate::result::OutOfGasError::Memory] cannot be resized.
58
- ///
59
- /// In cases where the gas limit may be extraordinarily high, it is recommended to set this to
60
- /// a sane value to prevent memory allocation panics. Defaults to `2^32 - 1` bytes per
61
- /// EIP-1985.
62
- #[ cfg( feature = "memory_limit" ) ]
63
- pub memory_limit : u64 ,
64
- /// Skip balance checks if true. Adds transaction cost to balance to ensure execution doesn't fail.
65
- #[ cfg( feature = "optional_balance_check" ) ]
66
- pub disable_balance_check : bool ,
67
- /// There are use cases where it's allowed to provide a gas limit that's higher than a block's gas limit. To that
68
- /// end, you can disable the block gas limit validation.
69
- /// By default, it is set to `false`.
70
- #[ cfg( feature = "optional_block_gas_limit" ) ]
71
- pub disable_block_gas_limit : bool ,
72
- /// EIP-3607 rejects transactions from senders with deployed code. In development, it can be desirable to simulate
73
- /// calls from contracts, which this setting allows.
74
- /// By default, it is set to `false`.
75
- #[ cfg( feature = "optional_eip3607" ) ]
76
- pub disable_eip3607 : bool ,
77
- /// Disables all gas refunds. This is useful when using chains that have gas refunds disabled e.g. Avalanche.
78
- /// Reasoning behind removing gas refunds can be found in EIP-3298.
79
- /// By default, it is set to `false`.
80
- #[ cfg( feature = "optional_gas_refund" ) ]
81
- pub disable_gas_refund : bool ,
82
- /// Disables base fee checks for EIP-1559 transactions.
83
- /// This is useful for testing method calls with zero gas price.
84
- /// By default, it is set to `false`.
85
- #[ cfg( feature = "optional_no_base_fee" ) ]
86
- pub disable_base_fee : bool ,
87
- }
88
-
89
- impl CfgEnv {
90
- pub fn with_chain_id ( mut self , chain_id : u64 ) -> Self {
91
- self . chain_id = chain_id;
92
- self
93
- }
94
- }
95
-
96
- impl < SPEC : Into < SpecId > + Copy > Cfg for CfgEnv < SPEC > {
97
- type Spec = SPEC ;
98
-
99
- fn chain_id ( & self ) -> u64 {
100
- self . chain_id
101
- }
102
-
103
- fn spec ( & self ) -> Self :: Spec {
104
- self . spec
105
- }
106
-
107
- fn max_code_size ( & self ) -> usize {
108
- self . limit_contract_code_size . unwrap_or ( MAX_CODE_SIZE )
109
- }
110
-
111
- fn is_eip3607_disabled ( & self ) -> bool {
112
- cfg_if:: cfg_if! {
113
- if #[ cfg( feature = "optional_eip3607" ) ] {
114
- self . disable_eip3607
115
- } else {
116
- false
117
- }
118
- }
119
- }
120
-
121
- fn is_balance_check_disabled ( & self ) -> bool {
122
- cfg_if:: cfg_if! {
123
- if #[ cfg( feature = "optional_balance_check" ) ] {
124
- self . disable_balance_check
125
- } else {
126
- false
127
- }
128
- }
129
- }
130
-
131
- fn is_gas_refund_disabled ( & self ) -> bool {
132
- cfg_if:: cfg_if! {
133
- if #[ cfg( feature = "optional_gas_refund" ) ] {
134
- self . disable_gas_refund
135
- } else {
136
- false
137
- }
138
- }
139
- }
140
-
141
- fn is_block_gas_limit_disabled ( & self ) -> bool {
142
- cfg_if:: cfg_if! {
143
- if #[ cfg( feature = "optional_block_gas_limit" ) ] {
144
- self . disable_block_gas_limit
145
- } else {
146
- false
147
- }
148
- }
149
- }
150
-
151
- fn is_nonce_check_disabled ( & self ) -> bool {
152
- self . disable_nonce_check
153
- }
154
-
155
- fn is_base_fee_check_disabled ( & self ) -> bool {
156
- cfg_if:: cfg_if! {
157
- if #[ cfg( feature = "optional_no_base_fee" ) ] {
158
- self . disable_base_fee
159
- } else {
160
- false
161
- }
162
- }
163
- }
164
- }
165
-
166
- impl Default for CfgEnv {
167
- fn default ( ) -> Self {
168
- Self {
169
- chain_id : 1 ,
170
- limit_contract_code_size : None ,
171
- spec : SpecId :: PRAGUE ,
172
- disable_nonce_check : false ,
173
- #[ cfg( feature = "memory_limit" ) ]
174
- memory_limit : ( 1 << 32 ) - 1 ,
175
- #[ cfg( feature = "optional_balance_check" ) ]
176
- disable_balance_check : false ,
177
- #[ cfg( feature = "optional_block_gas_limit" ) ]
178
- disable_block_gas_limit : false ,
179
- #[ cfg( feature = "optional_eip3607" ) ]
180
- disable_eip3607 : false ,
181
- #[ cfg( feature = "optional_gas_refund" ) ]
182
- disable_gas_refund : false ,
183
- #[ cfg( feature = "optional_no_base_fee" ) ]
184
- disable_base_fee : false ,
185
- }
186
- }
187
- }
188
-
189
42
/// Transaction destination
190
43
pub type TransactTo = TxKind ;
191
44
0 commit comments