Skip to content

Commit b663800

Browse files
rakitamattsse
andauthored
feat: integrate Inspector frame_start/frame_end hooks (#414)
## WIP - Do not merge Integrates `frame_start` and `frame_end` hooks from bluealloy/revm#3518. --------- Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
1 parent 81fc3bb commit b663800

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

src/tracing/debug.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ use revm::{
1414
result::{HaltReasonTr, ResultAndState},
1515
Block, ContextTr, Transaction,
1616
},
17+
handler::FrameResult,
1718
inspector::JournalExt,
18-
interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter},
19+
interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, FrameInput, Interpreter},
1920
primitives::{Address, Log, U256},
2021
DatabaseRef, Inspector,
2122
};
@@ -347,6 +348,23 @@ where
347348
fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) {
348349
delegate!(self => inspector.selfdestruct(contract, target, value))
349350
}
351+
352+
fn frame_start(
353+
&mut self,
354+
context: &mut CTX,
355+
frame_input: &mut FrameInput,
356+
) -> Option<FrameResult> {
357+
delegate!(self => inspector.frame_start(context, frame_input))
358+
}
359+
360+
fn frame_end(
361+
&mut self,
362+
context: &mut CTX,
363+
frame_input: &FrameInput,
364+
frame_result: &mut FrameResult,
365+
) {
366+
delegate!(self => inspector.frame_end(context, frame_input, frame_result))
367+
}
350368
}
351369

352370
/// Error type for [DebugInspector]

src/tracing/mux.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use revm::{
1212
result::{HaltReasonTr, ResultAndState},
1313
ContextTr,
1414
},
15+
handler::FrameResult,
1516
inspector::JournalExt,
16-
interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter},
17+
interpreter::{CallInputs, CallOutcome, CreateInputs, CreateOutcome, FrameInput, Interpreter},
1718
DatabaseRef, Inspector,
1819
};
1920
use thiserror::Error;
@@ -276,6 +277,36 @@ where
276277
<TracingInspector as Inspector<CTX>>::selfdestruct(inspector, contract, target, value);
277278
}
278279
}
280+
281+
#[inline]
282+
fn frame_start(
283+
&mut self,
284+
context: &mut CTX,
285+
frame_input: &mut FrameInput,
286+
) -> Option<FrameResult> {
287+
if let Some(ref mut inspector) = self.four_byte {
288+
let _ = inspector.frame_start(context, frame_input);
289+
}
290+
if let Some(ref mut inspector) = self.tracing {
291+
return inspector.frame_start(context, frame_input);
292+
}
293+
None
294+
}
295+
296+
#[inline]
297+
fn frame_end(
298+
&mut self,
299+
context: &mut CTX,
300+
frame_input: &FrameInput,
301+
frame_result: &mut FrameResult,
302+
) {
303+
if let Some(ref mut inspector) = self.four_byte {
304+
inspector.frame_end(context, frame_input, frame_result);
305+
}
306+
if let Some(ref mut inspector) = self.tracing {
307+
inspector.frame_end(context, frame_input, frame_result);
308+
}
309+
}
279310
}
280311

281312
/// Error type for [MuxInspector]

0 commit comments

Comments
 (0)