Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Generalize InterpreterTypes
  • Loading branch information
rakita committed Jan 16, 2025
commit 83473bd9f79b4540a342adf1a5a6ef43b98765c6
2 changes: 1 addition & 1 deletion crates/handler/src/eth_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub trait EthHandler {
+ From<InvalidTransaction>
+ From<<Self::Frame as Frame>::Error>;
type Precompiles: PrecompileProvider<Context = Self::Context, Error = Self::Error>;
type Instructions: InstructionProvider<WIRE = EthInterpreter, Host = Self::Context>;
type Instructions: InstructionProvider<Host = Self::Context>;
// TODO `FrameResult` should be a generic trait.
// TODO `FrameInit` should be a generic.
type Frame: Frame<
Expand Down
44 changes: 28 additions & 16 deletions crates/inspector/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,29 +204,45 @@ impl<CTX, ERROR, FRAME, HANDLER, PRECOMPILES, INSTRUCTIONS>
}
}

impl<CTX, ERROR, FRAME, HANDLER, PRECOMPILES, INSTRUCTIONS> EthHandlerNew
pub trait FrameInterpreterGetter {
type IT: InterpreterTypes;

fn interpreter(&mut self) -> &mut Interpreter<Self::IT>;
}

impl<CTX, ERROR, IW: InterpreterTypes, PRECOMPILES, INSTRUCTIONS> FrameInterpreterGetter
for EthFrame<CTX, ERROR, IW, PRECOMPILES, INSTRUCTIONS>
{
type IT = IW;

fn interpreter(&mut self) -> &mut Interpreter<Self::IT> {
&mut self.interpreter
}
}

impl<CTX, ERROR, FRAME, HANDLER, INTR, PRECOMPILES, INSTRUCTIONS> EthHandlerNew
for InspectorHandlerImpl<CTX, ERROR, FRAME, HANDLER, PRECOMPILES, INSTRUCTIONS>
where
CTX: EthContext + InspectorCtx<IT = EthInterpreter> + JournalExtGetter,
CTX: EthContext + InspectorCtx<IT = INTR> + JournalExtGetter,
INTR: InterpreterTypes,
ERROR: EthError<CTX, FRAME>,
// TODO `FrameResult` should be a generic trait.
// TODO `FrameInit` should be a generic.
FRAME: Frame<
Context = CTX,
Error = ERROR,
FrameResult = FrameResult,
FrameInit = FrameInput,
FrameContext = FrameContext<PRECOMPILES, InspectorInstructionProvider<EthInterpreter, CTX>>,
>,
Context = CTX,
Error = ERROR,
FrameResult = FrameResult,
FrameInit = FrameInput,
FrameContext = FrameContext<PRECOMPILES, InspectorInstructionProvider<INTR, CTX>>,
> + FrameInterpreterGetter<IT = INTR>,
PRECOMPILES: PrecompileProvider<Context = CTX, Error = ERROR>,
HANDLER: EthHandlerNew<Context = CTX, Error = ERROR, Frame = FRAME, Precompiles = PRECOMPILES>,
{
type Context = CTX;
type Error = ERROR;
type Frame = FRAME;
type Precompiles = PRECOMPILES;
// TODO use a generic trait for inspector instruction.
type Instructions = InspectorInstructionProvider<EthInterpreter, CTX>;
type Instructions = InspectorInstructionProvider<INTR, CTX>;

fn frame_context(
&mut self,
Expand Down Expand Up @@ -262,9 +278,7 @@ where
context.frame_end(res);
}
Ok(FrameOrResultGen::Frame(frame)) => {
// TODO(rakita)
//context.initialize_interp(&mut frame.interpreter);
todo!()
context.initialize_interp(frame.interpreter());
}
_ => (),
}
Expand Down Expand Up @@ -295,9 +309,7 @@ where
context.frame_end(res);
}
Ok(FrameOrResultGen::Frame(frame)) => {
// TODO(rakita)
// context.initialize_interp(&mut frame.interpreter);
todo!()
context.initialize_interp(frame.interpreter());
}
_ => (),
}
Expand Down
4 changes: 2 additions & 2 deletions crates/revm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(not(feature = "std"))]
extern crate alloc as std;
//#[cfg(not(feature = "std"))]
//extern crate alloc as std;

// reexport dependencies
pub use bytecode;
Expand Down