Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bins/revme/src/cmd/evmrunner.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use clap::Parser;
use database::BenchmarkDB;
use inspector::inspectors::TracerEip3155;
use inspector::{inspectors::TracerEip3155, InspectEvm};
use revm::{
bytecode::{Bytecode, BytecodeDecodeError},
primitives::{address, hex, Address, TxKind},
Context, Database, ExecuteEvm, InspectEvm, MainBuilder, MainContext,
Context, Database, ExecuteEvm, MainBuilder, MainContext,
};
use std::io::Error as IoError;
use std::path::PathBuf;
Expand Down
4 changes: 2 additions & 2 deletions bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{
};
use database::State;
use indicatif::{ProgressBar, ProgressDrawTarget};
use inspector::inspectors::TracerEip3155;
use inspector::{inspectors::TracerEip3155, InspectCommitEvm};
use revm::{
bytecode::Bytecode,
context::{block::BlockEnv, cfg::CfgEnv, tx::TxEnv},
Expand All @@ -16,7 +16,7 @@ use revm::{
database_interface::EmptyDB,
primitives::{keccak256, Bytes, TxKind, B256},
specification::{eip4844::TARGET_BLOB_GAS_PER_BLOCK_CANCUN, hardfork::SpecId},
Context, ExecuteCommitEvm, InspectCommitEvm, MainBuilder, MainContext,
Context, ExecuteCommitEvm, MainBuilder, MainContext,
};
use serde_json::json;
use statetest_types::{SpecName, Test, TestSuite};
Expand Down
4 changes: 0 additions & 4 deletions crates/context/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use core::ops::{Deref, DerefMut};

pub struct Evm<CTX, INSP, I, P> {
pub data: EvmData<CTX, INSP>,
pub enabled_inspection: bool,
pub instruction: I,
pub precompiles: P,
}
Expand All @@ -17,7 +16,6 @@ impl<CTX> Evm<CTX, (), (), ()> {
pub fn new(ctx: CTX) -> Self {
Evm {
data: EvmData { ctx, inspector: () },
enabled_inspection: false,
instruction: (),
precompiles: (),
}
Expand All @@ -32,7 +30,6 @@ impl<CTX: ContextSetters, INSP, I, P> Evm<CTX, INSP, I, P> {
ctx: self.data.ctx,
inspector,
},
enabled_inspection: self.enabled_inspection,
instruction: self.instruction,
precompiles: self.precompiles,
}
Expand All @@ -42,7 +39,6 @@ impl<CTX: ContextSetters, INSP, I, P> Evm<CTX, INSP, I, P> {
pub fn with_precompiles<OP>(self, precompiles: OP) -> Evm<CTX, INSP, I, OP> {
Evm {
data: self.data,
enabled_inspection: self.enabled_inspection,
instruction: self.instruction,
precompiles,
}
Expand Down
Empty file removed crates/handler/src/evm.rs
Empty file.
60 changes: 30 additions & 30 deletions crates/handler/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,33 @@ use std::{boxed::Box, rc::Rc, sync::Arc};

/// Call frame trait
pub trait Frame: Sized {
type Context;
type Evm;
type FrameInit;
type FrameResult;
type Error;

fn init_first(
context: &mut Self::Context,
evm: &mut Self::Evm,
frame_input: Self::FrameInit,
) -> Result<FrameOrResult<Self>, Self::Error>;

fn init(
&self,
context: &mut Self::Context,
evm: &mut Self::Evm,
frame_input: Self::FrameInit,
) -> Result<FrameOrResult<Self>, Self::Error>;

fn run(&mut self, context: &mut Self::Context) -> Result<FrameInitOrResult<Self>, Self::Error>;
fn run(&mut self, evm: &mut Self::Evm) -> Result<FrameInitOrResult<Self>, Self::Error>;

fn return_result(
&mut self,
context: &mut Self::Context,
evm: &mut Self::Evm,
result: Self::FrameResult,
) -> Result<(), Self::Error>;
}

pub struct EthFrame<CTX, ERROR, IW: InterpreterTypes> {
phantom: core::marker::PhantomData<(CTX, ERROR)>,
pub struct EthFrame<EVM, ERROR, IW: InterpreterTypes> {
phantom: core::marker::PhantomData<(EVM, ERROR)>,
/// Data of the frame.
data: FrameData,
/// Input data for the frame.
Expand All @@ -71,46 +71,46 @@ pub struct EthFrame<CTX, ERROR, IW: InterpreterTypes> {
pub memory: Rc<RefCell<SharedMemory>>,
}

impl<EVM, ERROR> Frame for EthFrame<EVM, ERROR, EthInterpreter<()>>
impl<EVM, ERROR> Frame for EthFrame<EVM, ERROR, EthInterpreter>
where
EVM: EvmTrait<
Precompiles: PrecompileProvider<Context = EVM::Context, Output = InterpreterResult>,
Instructions: InstructionProvider<
Context = EVM::Context,
InterpreterTypes = EthInterpreter<()>,
InterpreterTypes = EthInterpreter,
Output = InterpreterAction,
>,
>,
ERROR: From<CtxTraitDbError<EVM::Context>> + From<PrecompileErrors>,
{
type Context = EVM;
type Evm = EVM;
type FrameInit = FrameInput;
type FrameResult = FrameResult;
type Error = ERROR;

fn init_first(
context: &mut Self::Context,
evm: &mut Self::Evm,
frame_input: Self::FrameInit,
) -> Result<FrameOrResult<Self>, Self::Error> {
EthFrame::init_first(context, frame_input)
EthFrame::init_first(evm, frame_input)
}

fn init(
&self,
context: &mut Self::Context,
evm: &mut Self::Evm,
frame_input: Self::FrameInit,
) -> Result<FrameOrResult<Self>, Self::Error> {
self.init(context, frame_input)
self.init(evm, frame_input)
}

fn run(&mut self, context: &mut Self::Context) -> Result<FrameInitOrResult<Self>, Self::Error> {
fn run(&mut self, context: &mut Self::Evm) -> Result<FrameInitOrResult<Self>, Self::Error> {
let next_action = context.run_interpreter(&mut self.interpreter);
self.run_frame(context, next_action)
self.process_next_action(context, next_action)
}

fn return_result(
&mut self,
context: &mut Self::Context,
context: &mut Self::Evm,
result: Self::FrameResult,
) -> Result<(), Self::Error> {
self.return_result(context, result)
Expand Down Expand Up @@ -511,21 +511,21 @@ where
}
}

impl<CTX, ERROR> EthFrame<CTX, ERROR, EthInterpreter<()>>
impl<EVM, ERROR> EthFrame<EVM, ERROR, EthInterpreter>
where
CTX: EvmTrait<
EVM: EvmTrait<
Context: ContextTrait,
Precompiles: PrecompileProvider<Context = CTX::Context, Output = InterpreterResult>,
Precompiles: PrecompileProvider<Context = EVM::Context, Output = InterpreterResult>,
Instructions: InstructionProvider<
Context = CTX::Context,
InterpreterTypes = EthInterpreter<()>,
Context = EVM::Context,
InterpreterTypes = EthInterpreter,
Output = InterpreterAction,
>,
>,
ERROR: From<CtxTraitDbError<CTX::Context>> + From<PrecompileErrors>,
ERROR: From<CtxTraitDbError<EVM::Context>> + From<PrecompileErrors>,
{
pub fn init_first(
evm: &mut CTX,
evm: &mut EVM,
frame_input: FrameInput,
) -> Result<ItemOrResult<Self, FrameResult>, ERROR> {
let memory = Rc::new(RefCell::new(SharedMemory::new()));
Expand All @@ -541,16 +541,16 @@ where

fn init(
&self,
context: &mut CTX,
evm: &mut EVM,
frame_init: FrameInput,
) -> Result<ItemOrResult<Self, FrameResult>, ERROR> {
self.memory.borrow_mut().new_context();
Self::init_with_context(context, self.depth + 1, frame_init, self.memory.clone())
Self::init_with_context(evm, self.depth + 1, frame_init, self.memory.clone())
}

pub fn run_frame(
pub fn process_next_action(
&mut self,
evm: &mut CTX,
evm: &mut EVM,
next_action: InterpreterAction,
) -> Result<FrameInitOrResult<Self>, ERROR> {
let context = evm.ctx();
Expand Down Expand Up @@ -615,9 +615,9 @@ where
Ok(result)
}

fn return_result(&mut self, context: &mut CTX, result: FrameResult) -> Result<(), ERROR> {
fn return_result(&mut self, evm: &mut EVM, result: FrameResult) -> Result<(), ERROR> {
self.memory.borrow_mut().free_context();
core::mem::replace(context.ctx().error(), Ok(()))?;
core::mem::replace(evm.ctx().error(), Ok(()))?;

// Insert result to the top frame.
match result {
Expand Down
Loading
Loading