Skip to content

Commit

Permalink
rename and wip Inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
rakita committed Nov 21, 2024
1 parent b6015e9 commit 45b2dc5
Show file tree
Hide file tree
Showing 25 changed files with 518 additions and 524 deletions.
18 changes: 9 additions & 9 deletions crates/handler/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use interpreter::{
interpreter_wiring::{LoopControl, ReturnData, RuntimeFlag},
return_ok, return_revert, CallInputs, CallOutcome, CallValue, CreateInputs, CreateOutcome,
CreateScheme, EOFCreateInputs, EOFCreateKind, FrameInput, Gas, Host, InputsImpl,
InstructionResult, InterpreterAction, InterpreterResult, InterpreterWire, NewInterpreter,
InstructionResult, Interpreter, InterpreterAction, InterpreterResult, InterpreterTypes,
SharedMemory,
};
use precompile::PrecompileErrors;
Expand Down Expand Up @@ -55,21 +55,21 @@ EthFrame<CTX,IW,PR<CTX>,IP<IW,CTX> {
EXEC -> FRAME makes sense
FRAME needs to have
NewInterpreter<WIRE>
Interpreter<WIRE>
InnerContext<PRECOMPILES,INSTRUCTIONS, MEMORY>
*/

pub struct EthFrame<CTX, ERROR, IW: InterpreterWire, PRECOMPILE, INSTRUCTIONS> {
pub struct EthFrame<CTX, ERROR, IW: InterpreterTypes, PRECOMPILE, INSTRUCTIONS> {
_phantom: core::marker::PhantomData<fn() -> (CTX, ERROR)>,
data: FrameData,
// TODO include this
depth: usize,
/// Journal checkpoint.
pub checkpoint: JournalCheckpoint,
/// Interpreter.
pub interpreter: NewInterpreter<IW>,
pub interpreter: Interpreter<IW>,
/// Precompiles provider.
pub precompiles: PRECOMPILE,
/// Instruction provider.
Expand All @@ -81,11 +81,11 @@ pub struct EthFrame<CTX, ERROR, IW: InterpreterWire, PRECOMPILE, INSTRUCTIONS> {
impl<CTX, IW, ERROR, PRECOMP, INST> EthFrame<CTX, ERROR, IW, PRECOMP, INST>
where
CTX: JournalStateGetter,
IW: InterpreterWire,
IW: InterpreterTypes,
{
pub fn new(
data: FrameData,
interpreter: NewInterpreter<IW>,
interpreter: Interpreter<IW>,
checkpoint: JournalCheckpoint,
precompiles: PRECOMP,
instructions: INST,
Expand Down Expand Up @@ -231,7 +231,7 @@ where
FrameData::Call(CallFrame {
return_memory_range: inputs.return_memory_offset.clone(),
}),
NewInterpreter::new(
Interpreter::new(
memory.clone(),
bytecode,
interpreter_input,
Expand Down Expand Up @@ -342,7 +342,7 @@ where

Ok(FrameOrResultGen::Frame(Self::new(
FrameData::Create(CreateFrame { created_address }),
NewInterpreter::new(
Interpreter::new(
memory.clone(),
bytecode,
interpreter_input,
Expand Down Expand Up @@ -463,7 +463,7 @@ where

Ok(FrameOrResultGen::Frame(Self::new(
FrameData::Create(CreateFrame { created_address }),
NewInterpreter::new(
Interpreter::new(
memory.clone(),
Bytecode::Eof(Arc::new(initcode)),
interpreter_input,
Expand Down
23 changes: 9 additions & 14 deletions crates/inspector/src/eip3155.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@ use revm::{
CallInputs, CallOutcome, CreateInputs, CreateOutcome, Interpreter, InterpreterResult,
},
primitives::{hex, HashMap, B256, U256},
context_interface::Transaction,
EvmContext, EvmWiring,
};
use serde::Serialize;
use std::io::Write;

/// [EIP-3155](https://eips.ethereum.org/EIPS/eip-3155) tracer [Inspector].
#[derive_where(Debug)]
pub struct TracerEip3155 {
#[derive_where(Debug; CTX, INTR)]
pub struct TracerEip3155<CTX, INTR> {
#[derive_where(skip)]
output: Box<dyn Write>,
gas_inspector: GasInspector,
gas_inspector: GasInspector<CTX, INTR>,

/// Print summary of the execution.
print_summary: bool,
Expand Down Expand Up @@ -99,7 +97,7 @@ struct Summary {
fork: Option<String>,
}

impl TracerEip3155 {
impl<CTX, INTR> TracerEip3155<CTX, INTR> {
/// Sets the writer to use for the output.
pub fn set_writer(&mut self, writer: Box<dyn Write>) {
self.output = writer;
Expand Down Expand Up @@ -128,9 +126,7 @@ impl TracerEip3155 {
*mem_size = 0;
*skip = false;
}
}

impl TracerEip3155 {
pub fn new(output: Box<dyn Write>) -> Self {
Self {
output,
Expand Down Expand Up @@ -166,11 +162,7 @@ impl TracerEip3155 {
self.output.flush()
}

fn print_summary<EvmWiringT: EvmWiring>(
&mut self,
result: &InterpreterResult,
context: &mut EvmContext<EvmWiringT>,
) {
fn print_summary(&mut self, result: &InterpreterResult, context: &mut CTX) {
if self.print_summary {
let spec_name: &str = context.spec_id().into();
let value = Summary {
Expand All @@ -189,7 +181,10 @@ impl TracerEip3155 {
}
}

impl<EvmWiringT: EvmWiring> Inspector<EvmWiringT> for TracerEip3155 {
impl<CTX, INTR> Inspector for TracerEip3155<CTX, INTR> {
type Context = CTX;
type InterpreterTypes = INTR;

fn initialize_interp(
&mut self,
interp: &mut Interpreter,
Expand Down
Loading

0 comments on commit 45b2dc5

Please sign in to comment.