Skip to content

feat: alloy-evm and new revm integration#14021

Merged
klkvr merged 11 commits intomainfrom
klkvr/alloy-evm
Feb 17, 2025
Merged

feat: alloy-evm and new revm integration#14021
klkvr merged 11 commits intomainfrom
klkvr/alloy-evm

Conversation

@klkvr
Copy link
Member

@klkvr klkvr commented Jan 27, 2025

Integrates Evm trait moved to alloy-evm. Core Evm construction logic is now implemented via EvmFactory and ConfigureEvm implementations are just required to hold one.

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is pretty cool,
love that this now doesn't require any interface changes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is okay because this type is a ZST anyway

@klkvr klkvr changed the base branch from main to klkvr/generic-halt-reason January 30, 2025 18:13
Base automatically changed from klkvr/generic-halt-reason to main January 30, 2025 21:03
Cargo.toml Outdated
alloy-chains = { version = "0.1.32", default-features = false }
alloy-dyn-abi = "0.8.15"
alloy-eip2124 = { version = "0.1.0", default-features = false }
alloy-evm = { path = "../evm/crates/evm" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudl be able to use from git now

@emhane emhane added A-execution Related to the Execution and EVM A-dependencies Pull requests or issues that are about dependencies labels Feb 4, 2025
/// Helper trait to bound [`revm::Database::Error`] with common requirements.
pub trait Database: revm::Database<Error: core::error::Error + Send + Sync + 'static> {}
impl<T> Database for T where T: revm::Database<Error: core::error::Error + Send + Sync + 'static> {}
pub use alloy_evm::{Database, Evm, EvmEnv, EvmError, InvalidTxError};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if it's actually more helpful to not re-export all of these so libraries update their deps to point to alloy directly instead

&self,
db: DB,
header: &Self::Header,
) -> <Self::EvmFactory as EvmFactory<EvmEnv<Self::Spec>>>::Evm<'_, DB, ()> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be helpful to create a type alias as adapter for this and export it from crate root to improve devx with the trait, smthg like

pub type EvmTy<'a, T, DB> = <<T as ConfigureEvm>::EvmFactory<EvmEnv<T::Spec>>>::Evm<'a, DB, ()>;

use alloc::sync::Arc;
use alloy_consensus::{BlockHeader, Header};
use alloy_eips::eip7840::BlobParams;
use alloy_op_evm::OpEvmFactory;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the plan to move this to op-alloy?

ExecutionResult::Halt { reason, gas_used } => {
let error =
Some(RpcInvalidTransactionError::halt(reason, tx_env.gas_limit()).to_string());
Some(Self::Error::from_evm_halt(reason, tx_env.gas_limit()).to_string());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice application of this pattern, good eye

Comment on lines 330 to 342
ExecutionResult::Revert { .. } | ExecutionResult::Halt { .. } => {
// We know that transaction succeeded with a higher gas limit before, so any failure
// means that we need to increase it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to add some trace level logging here right away to differentiate the two in debugging? does the migration to alloy not change so much code the we can still consider the sigp audit of the reth code to apply to the code in alloy?

@klkvr klkvr force-pushed the klkvr/alloy-evm branch 6 times, most recently from 25eb1b0 to 7e97984 Compare February 12, 2025 18:03
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gg

@mattsse mattsse marked this pull request as ready for review February 17, 2025 19:02
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Co-authored-by: rakita <rakita@users.noreply.github.com>
@klkvr klkvr enabled auto-merge February 17, 2025 19:35
@klkvr klkvr changed the title [wip] feat: alloy-evm integration feat: alloy-evm integration Feb 17, 2025
@klkvr klkvr changed the title feat: alloy-evm integration feat: alloy-evm and new revm integration Feb 17, 2025
@klkvr klkvr disabled auto-merge February 17, 2025 19:39
@klkvr klkvr enabled auto-merge February 17, 2025 19:43
@klkvr klkvr added this pull request to the merge queue Feb 17, 2025
Merged via the queue into main with commit 336c3d1 Feb 17, 2025
43 checks passed
@klkvr klkvr deleted the klkvr/alloy-evm branch February 17, 2025 20:15
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 22, 2026
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Co-authored-by: rakita <rakita@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-dependencies Pull requests or issues that are about dependencies A-execution Related to the Execution and EVM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants