Skip to content

Commit 4a606ce

Browse files
committed
style: nits
1 parent dfea9f0 commit 4a606ce

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

crates/evm/evm/src/inspectors/revert_diagnostic.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ use foundry_evm_core::{
66
};
77
use revm::{
88
bytecode::opcode::{EXTCODESIZE, REVERT},
9-
context::{Cfg, ContextTr, JournalTr},
9+
context::{ContextTr, JournalTr},
1010
inspector::JournalExt,
1111
interpreter::{
1212
interpreter::EthInterpreter, interpreter_types::Jumps, CallInputs, CallOutcome, CallScheme,
1313
InstructionResult, Interpreter, InterpreterAction, InterpreterResult,
1414
},
15-
precompile::{PrecompileSpecId, Precompiles},
16-
primitives::hardfork::SpecId,
1715
Database, Inspector,
1816
};
1917
use std::fmt;
@@ -72,12 +70,6 @@ pub struct RevertDiagnostic {
7270
}
7371

7472
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-
8173
/// Returns the effective target address whose code would be executed.
8274
/// For delegate calls, this is the `bytecode_address`. Otherwise, it's the `target_address`.
8375
fn code_target_address(&self, inputs: &mut CallInputs) -> Address {
@@ -134,13 +126,13 @@ where
134126
fn call(&mut self, ctx: &mut CTX, inputs: &mut CallInputs) -> Option<CallOutcome> {
135127
let target = self.code_target_address(inputs);
136128

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) {
138130
return None;
139131
}
140132

141133
if let Ok(state) = ctx.journal().code(target) {
142134
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()));
144136
}
145137
}
146138
None
@@ -161,10 +153,10 @@ where
161153
// REVERT (offset, size)
162154
if REVERT == interp.bytecode.opcode() {
163155
if let Ok(size) = interp.stack.peek(1) {
164-
if size == U256::ZERO {
156+
if size.is_zero() {
165157
// Check empty revert with same depth as a non-contract call
166158
if let Some((_, _, depth)) = self.non_contract_call {
167-
if ctx.journal().depth() == depth {
159+
if ctx.journal_ref().depth() == depth {
168160
self.handle_revert_diagnostic(interp);
169161
} else {
170162
self.non_contract_call = None;
@@ -174,7 +166,7 @@ where
174166

175167
// Check empty revert with same depth as a non-contract size check
176168
if let Some((_, depth)) = self.non_contract_size_check {
177-
if depth == ctx.journal().depth() {
169+
if depth == ctx.journal_ref().depth() {
178170
self.handle_revert_diagnostic(interp);
179171
} else {
180172
self.non_contract_size_check = None;
@@ -187,12 +179,14 @@ where
187179
else if EXTCODESIZE == interp.bytecode.opcode() {
188180
if let Ok(word) = interp.stack.peek(0) {
189181
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+
{
191185
return;
192186
}
193187

194188
// 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()));
196190
self.is_extcodesize_step = true;
197191
}
198192
}

0 commit comments

Comments
 (0)