@@ -6,14 +6,12 @@ use foundry_evm_core::{
6
6
} ;
7
7
use revm:: {
8
8
bytecode:: opcode:: { EXTCODESIZE , REVERT } ,
9
- context:: { Cfg , ContextTr , JournalTr } ,
9
+ context:: { ContextTr , JournalTr } ,
10
10
inspector:: JournalExt ,
11
11
interpreter:: {
12
12
interpreter:: EthInterpreter , interpreter_types:: Jumps , CallInputs , CallOutcome , CallScheme ,
13
13
InstructionResult , Interpreter , InterpreterAction , InterpreterResult ,
14
14
} ,
15
- precompile:: { PrecompileSpecId , Precompiles } ,
16
- primitives:: hardfork:: SpecId ,
17
15
Database , Inspector ,
18
16
} ;
19
17
use std:: fmt;
@@ -72,12 +70,6 @@ pub struct RevertDiagnostic {
72
70
}
73
71
74
72
impl RevertDiagnostic {
75
- /// Checks if the `target` address is a precompile for the given `spec_id`.
76
- fn is_precompile ( & self , spec_id : SpecId , target : Address ) -> bool {
77
- let precompiles = Precompiles :: new ( PrecompileSpecId :: from_spec_id ( spec_id) ) ;
78
- precompiles. contains ( & target)
79
- }
80
-
81
73
/// Returns the effective target address whose code would be executed.
82
74
/// For delegate calls, this is the `bytecode_address`. Otherwise, it's the `target_address`.
83
75
fn code_target_address ( & self , inputs : & mut CallInputs ) -> Address {
@@ -134,13 +126,13 @@ where
134
126
fn call ( & mut self , ctx : & mut CTX , inputs : & mut CallInputs ) -> Option < CallOutcome > {
135
127
let target = self . code_target_address ( inputs) ;
136
128
137
- if IGNORE . contains ( & target) || self . is_precompile ( ctx. cfg ( ) . spec ( ) . into ( ) , target) {
129
+ if IGNORE . contains ( & target) || ctx. journal_ref ( ) . precompile_addresses ( ) . contains ( & target) {
138
130
return None ;
139
131
}
140
132
141
133
if let Ok ( state) = ctx. journal ( ) . code ( target) {
142
134
if state. is_empty ( ) && !inputs. input . is_empty ( ) {
143
- self . non_contract_call = Some ( ( target, inputs. scheme , ctx. journal ( ) . depth ( ) ) ) ;
135
+ self . non_contract_call = Some ( ( target, inputs. scheme , ctx. journal_ref ( ) . depth ( ) ) ) ;
144
136
}
145
137
}
146
138
None
@@ -161,10 +153,10 @@ where
161
153
// REVERT (offset, size)
162
154
if REVERT == interp. bytecode . opcode ( ) {
163
155
if let Ok ( size) = interp. stack . peek ( 1 ) {
164
- if size == U256 :: ZERO {
156
+ if size. is_zero ( ) {
165
157
// Check empty revert with same depth as a non-contract call
166
158
if let Some ( ( _, _, depth) ) = self . non_contract_call {
167
- if ctx. journal ( ) . depth ( ) == depth {
159
+ if ctx. journal_ref ( ) . depth ( ) == depth {
168
160
self . handle_revert_diagnostic ( interp) ;
169
161
} else {
170
162
self . non_contract_call = None ;
@@ -174,7 +166,7 @@ where
174
166
175
167
// Check empty revert with same depth as a non-contract size check
176
168
if let Some ( ( _, depth) ) = self . non_contract_size_check {
177
- if depth == ctx. journal ( ) . depth ( ) {
169
+ if depth == ctx. journal_ref ( ) . depth ( ) {
178
170
self . handle_revert_diagnostic ( interp) ;
179
171
} else {
180
172
self . non_contract_size_check = None ;
@@ -187,12 +179,14 @@ where
187
179
else if EXTCODESIZE == interp. bytecode . opcode ( ) {
188
180
if let Ok ( word) = interp. stack . peek ( 0 ) {
189
181
let addr = Address :: from_word ( word. into ( ) ) ;
190
- if IGNORE . contains ( & addr) || self . is_precompile ( ctx. cfg ( ) . spec ( ) . into ( ) , addr) {
182
+ if IGNORE . contains ( & addr) ||
183
+ ctx. journal_ref ( ) . precompile_addresses ( ) . contains ( & addr)
184
+ {
191
185
return ;
192
186
}
193
187
194
188
// Optimistically cache --> validated and cleared (if necessary) at `fn step_end()`
195
- self . non_contract_size_check = Some ( ( addr, ctx. journal ( ) . depth ( ) ) ) ;
189
+ self . non_contract_size_check = Some ( ( addr, ctx. journal_ref ( ) . depth ( ) ) ) ;
196
190
self . is_extcodesize_step = true ;
197
191
}
198
192
}
0 commit comments