mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: Use traits from reth 1.5.0
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
use revm::{
|
||||
context::{ContextSetters, Evm as EvmCtx},
|
||||
context::{ContextSetters, Evm, FrameStack},
|
||||
context_interface::ContextTr,
|
||||
handler::{
|
||||
evm::{ContextDbError, FrameInitResult},
|
||||
instructions::{EthInstructions, InstructionProvider},
|
||||
EthPrecompiles, EvmTr, PrecompileProvider,
|
||||
EthFrame, EthPrecompiles, EvmTr, FrameInitOrResult, FrameTr, PrecompileProvider,
|
||||
},
|
||||
inspector::{InspectorEvmTr, JournalExt},
|
||||
interpreter::{interpreter::EthInterpreter, Interpreter, InterpreterAction, InterpreterTypes},
|
||||
interpreter::{interpreter::EthInterpreter, InterpreterResult},
|
||||
Inspector,
|
||||
};
|
||||
|
||||
@ -14,19 +15,23 @@ pub mod builder;
|
||||
pub mod ctx;
|
||||
mod exec;
|
||||
|
||||
pub struct HlEvmInner<CTX, INSP, I = EthInstructions<EthInterpreter, CTX>, P = EthPrecompiles>(
|
||||
pub EvmCtx<CTX, INSP, I, P>,
|
||||
);
|
||||
pub struct HlEvmInner<
|
||||
CTX: ContextTr,
|
||||
INSP,
|
||||
I = EthInstructions<EthInterpreter, CTX>,
|
||||
P = EthPrecompiles,
|
||||
>(pub Evm<CTX, INSP, I, P, EthFrame<EthInterpreter>>);
|
||||
|
||||
impl<CTX: ContextTr, INSP>
|
||||
HlEvmInner<CTX, INSP, EthInstructions<EthInterpreter, CTX>, EthPrecompiles>
|
||||
{
|
||||
pub fn new(ctx: CTX, inspector: INSP) -> Self {
|
||||
Self(EvmCtx {
|
||||
Self(Evm {
|
||||
ctx,
|
||||
inspector,
|
||||
instruction: EthInstructions::new_mainnet(),
|
||||
precompiles: EthPrecompiles::default(),
|
||||
frame_stack: FrameStack::new(),
|
||||
})
|
||||
}
|
||||
|
||||
@ -42,12 +47,9 @@ impl<CTX: ContextTr, INSP>
|
||||
impl<CTX, INSP, I, P> InspectorEvmTr for HlEvmInner<CTX, INSP, I, P>
|
||||
where
|
||||
CTX: ContextTr<Journal: JournalExt> + ContextSetters,
|
||||
I: InstructionProvider<
|
||||
Context = CTX,
|
||||
InterpreterTypes: InterpreterTypes<Output = InterpreterAction>,
|
||||
>,
|
||||
I: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>,
|
||||
INSP: Inspector<CTX, I::InterpreterTypes>,
|
||||
P: PrecompileProvider<CTX>,
|
||||
P: PrecompileProvider<CTX, Output = InterpreterResult>,
|
||||
{
|
||||
type Inspector = INSP;
|
||||
|
||||
@ -59,41 +61,29 @@ where
|
||||
(&mut self.0.ctx, &mut self.0.inspector)
|
||||
}
|
||||
|
||||
fn run_inspect_interpreter(
|
||||
fn ctx_inspector_frame(
|
||||
&mut self,
|
||||
interpreter: &mut Interpreter<
|
||||
<Self::Instructions as InstructionProvider>::InterpreterTypes,
|
||||
>,
|
||||
) -> <<Self::Instructions as InstructionProvider>::InterpreterTypes as InterpreterTypes>::Output
|
||||
{
|
||||
self.0.run_inspect_interpreter(interpreter)
|
||||
) -> (&mut Self::Context, &mut Self::Inspector, &mut Self::Frame) {
|
||||
(&mut self.0.ctx, &mut self.0.inspector, self.0.frame_stack.get())
|
||||
}
|
||||
|
||||
fn ctx_inspector_frame_instructions(
|
||||
&mut self,
|
||||
) -> (&mut Self::Context, &mut Self::Inspector, &mut Self::Frame, &mut Self::Instructions) {
|
||||
(&mut self.0.ctx, &mut self.0.inspector, self.0.frame_stack.get(), &mut self.0.instruction)
|
||||
}
|
||||
}
|
||||
|
||||
impl<CTX, INSP, I, P> EvmTr for HlEvmInner<CTX, INSP, I, P>
|
||||
where
|
||||
CTX: ContextTr,
|
||||
I: InstructionProvider<
|
||||
Context = CTX,
|
||||
InterpreterTypes: InterpreterTypes<Output = InterpreterAction>,
|
||||
>,
|
||||
P: PrecompileProvider<CTX>,
|
||||
I: InstructionProvider<Context = CTX, InterpreterTypes = EthInterpreter>,
|
||||
P: PrecompileProvider<CTX, Output = InterpreterResult>,
|
||||
{
|
||||
type Context = CTX;
|
||||
type Instructions = I;
|
||||
type Precompiles = P;
|
||||
|
||||
fn run_interpreter(
|
||||
&mut self,
|
||||
interpreter: &mut Interpreter<
|
||||
<Self::Instructions as InstructionProvider>::InterpreterTypes,
|
||||
>,
|
||||
) -> <<Self::Instructions as InstructionProvider>::InterpreterTypes as InterpreterTypes>::Output
|
||||
{
|
||||
let context = &mut self.0.ctx;
|
||||
let instructions = &mut self.0.instruction;
|
||||
interpreter.run_plain(instructions.instruction_table(), context)
|
||||
}
|
||||
type Frame = EthFrame<EthInterpreter>;
|
||||
|
||||
fn ctx(&mut self) -> &mut Self::Context {
|
||||
&mut self.0.ctx
|
||||
@ -110,6 +100,30 @@ where
|
||||
fn ctx_precompiles(&mut self) -> (&mut Self::Context, &mut Self::Precompiles) {
|
||||
(&mut self.0.ctx, &mut self.0.precompiles)
|
||||
}
|
||||
|
||||
fn frame_stack(&mut self) -> &mut FrameStack<Self::Frame> {
|
||||
&mut self.0.frame_stack
|
||||
}
|
||||
|
||||
fn frame_init(
|
||||
&mut self,
|
||||
frame_input: <Self::Frame as FrameTr>::FrameInit,
|
||||
) -> Result<FrameInitResult<'_, Self::Frame>, ContextDbError<Self::Context>> {
|
||||
self.0.frame_init(frame_input)
|
||||
}
|
||||
|
||||
fn frame_run(
|
||||
&mut self,
|
||||
) -> Result<FrameInitOrResult<Self::Frame>, ContextDbError<Self::Context>> {
|
||||
self.0.frame_run()
|
||||
}
|
||||
|
||||
fn frame_return_result(
|
||||
&mut self,
|
||||
result: <Self::Frame as FrameTr>::FrameResult,
|
||||
) -> Result<Option<<Self::Frame as FrameTr>::FrameResult>, ContextDbError<Self::Context>> {
|
||||
self.0.frame_return_result(result)
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user