Skip to content

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.

JournalInit has been repaced by JournalInner that should offer what we need

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@jenpaff jenpaff moved this to In Progress in Foundry Mar 17, 2025
@jenpaff jenpaff modified the milestone: v1.1.0 Mar 17, 2025
@grandizzy grandizzy added this to the v1.1.0 milestone Mar 18, 2025
@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
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.

@zerosnacks
Copy link
Member

Closing in favor of #10183

@zerosnacks zerosnacks closed this Apr 1, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Foundry Apr 1, 2025
@zerosnacks zerosnacks moved this from Done to Todo in Foundry Apr 1, 2025
@jenpaff jenpaff removed this from the v1.1.0 milestone Apr 15, 2025
@jenpaff jenpaff moved this from Todo to Completed in Foundry Apr 15, 2025
@zerosnacks zerosnacks deleted the klkvr/new-revm branch May 19, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

4 participants