Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bump revm #10051

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft

feat: bump revm #10051

wants to merge 27 commits into from

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Mar 10, 2025

Motivation

Bumps revm to bluealloy/revm@9e39df5

Depends on foundry-rs/foundry-fork-db#44, paradigmxyz/revm-inspectors#246

Solution

Clone [email protected]:alloy-rs/evm.git into the parent of the project root

At this point this PR only partially migrates foundry-evm-core crate. The most impactful change is that Evm type is not longer present. Instead block. cfg and tx envs are stored along with transactions on a larget Context type which also holds db and journal and thus not very nice to pass around.

This PR addresses this by re-introducing Env type internally, and the mutable borrowing of Env is solved via a helper EnvMut:

/// Helper container type for [`EvmEnv`] and [`TxEnv`].
#[derive(Clone, Debug, Default)]
pub struct Env {
pub evm_env: EvmEnv,
pub tx: TxEnv,
}
/// Helper struct with mutable references to the block and cfg environments.
pub struct EnvMut<'a> {
pub block: &'a mut BlockEnv,
pub cfg: &'a mut CfgEnv,
pub tx: &'a mut TxEnv,
}
impl EnvMut<'_> {
/// Returns a copy of the environment.
pub fn to_owned(&self) -> Env {
Env {
evm_env: EvmEnv { cfg_env: self.cfg.to_owned(), block_env: self.block.to_owned() },
tx: self.tx.to_owned(),
}
}
}
pub trait AsEnvMut {
fn as_env_mut(&mut self) -> EnvMut<'_>;
}

The idea here is to avoid migrating entire codebase to completely new environment types and refactor this later if we see a nicer approach.

Another big blocker is changed JournaledState structure which we don't have decision on yet. I've partially updated code to use JournalInit but this approach is likely not sound for some cases.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@zerosnacks
Copy link
Member

Created a tracking ticket here to identify dependencies / track blockers / questions: #10116

@zerosnacks zerosnacks modified the milestones: v1.1.0, v1.2.0 Mar 19, 2025
@zerosnacks zerosnacks modified the milestones: v1.2.0, v1.1.0 Mar 20, 2025
match err {
EVMError::Database(err) => err.into(),
EVMError::Custom(err) => Self::msg(err),
EVMError::Header(err) => Self::msg(err.to_string()),
EVMError::Precompile(err) => Self::msg(err),
Copy link
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants