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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ alloy-primitives = { version = "0.8", default-features = false }

# revm
revm = { version = "20.0.0-alpha.1", default-features = false }
revm-optimism = { version = "1.0.0-alpha.1", default-features = false }
op-revm = { version = "1.0.0-alpha.1", default-features = false }

# misc
derive_more = { version = "1", default-features = false, features = ["full"] }
serde = { version = "1", default-features = false, features = ["derive"] }

[patch.crates-io]
revm = { git = "https://github.com/bluealloy/revm", rev = "a8a9893b" }
revm-optimism = { git = "https://github.com/bluealloy/revm", rev = "a8a9893b" }
revm = { git = "https://github.com/bluealloy/revm", rev = "cfc885f" }
op-revm = { git = "https://github.com/bluealloy/revm", rev = "cfc885f" }
4 changes: 2 additions & 2 deletions crates/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ alloy-consensus.workspace = true
alloy-primitives.workspace = true

revm.workspace = true
revm-optimism = { workspace = true, optional = true }
op-revm = { workspace = true, optional = true }

[features]
default = ["std"]
std = [
"alloy-primitives/std",
"revm/std"
]
op = ["revm-optimism"]
op = ["op-revm"]
2 changes: 1 addition & 1 deletion crates/evm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ where
}

#[cfg(feature = "op")]
impl InvalidTxError for revm_optimism::OpTransactionError {
impl InvalidTxError for op_revm::OpTransactionError {
fn is_nonce_too_low(&self) -> bool {
matches!(self, Self::Base(tx) if tx.is_nonce_too_low())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl IntoTxEnv<Self> for TxEnv {
}

#[cfg(feature = "op")]
impl<T: revm::context::Transaction> IntoTxEnv<Self> for revm_optimism::OpTransaction<T> {
impl<T: revm::context::Transaction> IntoTxEnv<Self> for op_revm::OpTransaction<T> {
fn into_tx_env(self) -> Self {
self
}
Expand Down
2 changes: 1 addition & 1 deletion crates/op-evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ workspace = true
alloy-primitives.workspace = true
alloy-evm = { workspace = true, features = ["op"] }
revm.workspace = true
revm-optimism.workspace = true
op-revm.workspace = true


[features]
Expand Down
34 changes: 23 additions & 11 deletions crates/op-evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,27 @@ use core::{
fmt::Debug,
ops::{Deref, DerefMut},
};
use op_revm::{
handler::precompiles::OpPrecompileProvider, DefaultOp, OpBuilder, OpContext, OpHaltReason,
OpSpecId, OpTransaction, OpTransactionError,
};
use revm::{
context::{setters::ContextSetters, BlockEnv, TxEnv},
context_interface::result::{EVMError, ResultAndState},
handler::instructions::EthInstructions,
handler::{instructions::EthInstructions, PrecompileProvider},
inspector::NoOpInspector,
interpreter::interpreter::EthInterpreter,
interpreter::{interpreter::EthInterpreter, InterpreterResult},
Context, ExecuteEvm, InspectEvm, Inspector,
};
use revm_optimism::{
DefaultOp, OpBuilder, OpContext, OpHaltReason, OpSpecId, OpTransaction, OpTransactionError,
};

/// OP EVM implementation.
#[allow(missing_debug_implementations)] // missing revm::OpContext Debug impl
pub struct OpEvm<DB: Database, I> {
inner: revm_optimism::OpEvm<OpContext<DB>, I, EthInstructions<EthInterpreter, OpContext<DB>>>,
pub struct OpEvm<DB: Database, I, P = OpPrecompileProvider<OpContext<DB>>> {
inner: op_revm::OpEvm<OpContext<DB>, I, EthInstructions<EthInterpreter, OpContext<DB>>, P>,
inspect: bool,
}

impl<DB: Database, I> OpEvm<DB, I> {
impl<DB: Database, I, P> OpEvm<DB, I, P> {
/// Provides a reference to the EVM context.
pub const fn ctx(&self) -> &OpContext<DB> {
&self.inner.0.data.ctx
Expand All @@ -47,7 +48,17 @@ impl<DB: Database, I> OpEvm<DB, I> {
}
}

impl<DB: Database, I> Deref for OpEvm<DB, I> {
impl<DB: Database, I, P> OpEvm<DB, I, P> {
/// Creates a new OP EVM instance.
pub const fn new(
evm: op_revm::OpEvm<OpContext<DB>, I, EthInstructions<EthInterpreter, OpContext<DB>>, P>,
inspect: bool,
) -> Self {
Self { inner: evm, inspect }
}
}

impl<DB: Database, I, P> Deref for OpEvm<DB, I, P> {
type Target = OpContext<DB>;

#[inline]
Expand All @@ -56,17 +67,18 @@ impl<DB: Database, I> Deref for OpEvm<DB, I> {
}
}

impl<DB: Database, I> DerefMut for OpEvm<DB, I> {
impl<DB: Database, I, P> DerefMut for OpEvm<DB, I, P> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
self.ctx_mut()
}
}

impl<DB, I> Evm for OpEvm<DB, I>
impl<DB, I, P> Evm for OpEvm<DB, I, P>
where
DB: Database,
I: Inspector<OpContext<DB>>,
P: PrecompileProvider<Context = OpContext<DB>, Output = InterpreterResult>,
{
type DB = DB;
type Tx = OpTransaction<TxEnv>;
Expand Down
Loading