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
72 changes: 36 additions & 36 deletions Cargo.lock

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

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ foundry-linking = { path = "crates/linking" }
# solc & compilation utilities
foundry-block-explorers = { version = "0.20.0", default-features = false }
foundry-compilers = { version = "0.18.2", default-features = false }
foundry-fork-db = "0.17"
foundry-fork-db = "0.18"
solang-parser = { version = "=0.3.9", package = "foundry-solang-parser" }
solar-ast = { version = "=0.1.5", default-features = false }
solar-parse = { version = "=0.1.5", default-features = false }
Expand Down Expand Up @@ -257,18 +257,18 @@ alloy-rlp = "0.3"
alloy-trie = "0.9"

## op-alloy
op-alloy-consensus = "0.18.13"
op-alloy-rpc-types = "0.18.13"
op-alloy-consensus = "0.19.0"
op-alloy-rpc-types = "0.19.0"
op-alloy-flz = "0.13.1"

## revm
revm = { version = "28.0.0", default-features = false }
revm-inspectors = { version = "0.28.0", features = ["serde"] }
op-revm = { version = "9.0.1", default-features = false }
revm = { version = "29.0.0", default-features = false }
revm-inspectors = { version = "0.29.0", features = ["serde"] }
op-revm = { version = "10.0.0", default-features = false }

## alloy-evm
alloy-evm = "0.18.3"
alloy-op-evm = "0.18.3"
alloy-evm = "0.19.0"
alloy-op-evm = "0.19.0"

## cli
anstream = "0.6"
Expand Down Expand Up @@ -399,18 +399,18 @@ idna_adapter = "=1.1.0"
# alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "7fab7ee" }

## alloy-evm
# alloy-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "7762adc" }
# alloy-op-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "7762adc" }
# alloy-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "3c6cebb" }
# alloy-op-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "3c6cebb" }

## revm
# revm = { git = "https://github.com/bluealloy/revm.git", rev = "d9cda3a" }
# op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "d9cda3a" }
# revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors.git", rev = "956bc98" }
# revm-inspectors = { git = "https://github.com/zerosnacks/revm-inspectors.git", rev = "74e215d" }

## foundry
# foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers.git", rev = "e09cb89" }
# foundry-compilers = { git = "https://github.com/foundry-rs/compilers.git", rev = "e4a9b04" }
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "50683eb" }
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "eee6563" }

## solar
# solar-ast = { git = "https://github.com/paradigmxyz/solar.git", branch = "main" }
Expand Down
19 changes: 11 additions & 8 deletions crates/anvil/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ use alloy_evm::{

use foundry_evm_core::either_evm::EitherEvm;
use op_revm::OpContext;
use revm::{Inspector, precompile::PrecompileWithAddress};
use revm::{Inspector, precompile::Precompile};
use std::fmt::Debug;

/// Object-safe trait that enables injecting extra precompiles when using
/// `anvil` as a library.
pub trait PrecompileFactory: Send + Sync + Unpin + Debug {
/// Returns a set of precompiles to extend the EVM with.
fn precompiles(&self) -> Vec<(PrecompileWithAddress, u64)>;
fn precompiles(&self) -> Vec<(Precompile, u64)>;
}

/// Inject precompiles into the EVM dynamically.
pub fn inject_precompiles<DB, I>(
evm: &mut EitherEvm<DB, I, PrecompilesMap>,
precompiles: Vec<(PrecompileWithAddress, u64)>,
precompiles: Vec<(Precompile, u64)>,
) where
DB: Database,
I: Inspector<EthEvmContext<DB>> + Inspector<OpContext<DB>>,
{
for (PrecompileWithAddress(addr, func), gas) in precompiles {
for (precompile, gas) in precompiles {
let addr = *precompile.address();
let func = *precompile.precompile();
evm.precompiles_mut().apply_precompile(&addr, move |_| {
Some(DynPrecompile::from(move |input: PrecompileInput<'_>| func(input.data, gas)))
});
Expand All @@ -33,7 +35,7 @@ pub fn inject_precompiles<DB, I>(

#[cfg(test)]
mod tests {
use std::convert::Infallible;
use std::{borrow::Cow, convert::Infallible};

use alloy_evm::{EthEvm, Evm, EvmEnv, eth::EthEvmContext, precompiles::PrecompilesMap};
use alloy_op_evm::OpEvm;
Expand All @@ -49,7 +51,7 @@ mod tests {
inspector::NoOpInspector,
interpreter::interpreter::EthInterpreter,
precompile::{
PrecompileOutput, PrecompileResult, PrecompileSpecId, PrecompileWithAddress,
Precompile, PrecompileId, PrecompileOutput, PrecompileResult, PrecompileSpecId,
Precompiles,
},
primitives::hardfork::SpecId,
Expand All @@ -71,9 +73,10 @@ mod tests {
struct CustomPrecompileFactory;

impl PrecompileFactory for CustomPrecompileFactory {
fn precompiles(&self) -> Vec<(PrecompileWithAddress, u64)> {
fn precompiles(&self) -> Vec<(Precompile, u64)> {
vec![(
PrecompileWithAddress::from((
Precompile::from((
PrecompileId::Custom(Cow::Borrowed("custom_echo")),
PRECOMPILE_ADDR,
custom_echo_precompile as fn(&[u8], u64) -> PrecompileResult,
)),
Expand Down
6 changes: 1 addition & 5 deletions crates/evm/core/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,6 @@ impl DatabaseExt for Backend {
// selected. This ensures that there are no gaps in depth which would
// otherwise cause issues with the tracer
fork.journaled_state.depth = active_journaled_state.depth;
// Set proper journal of state changes into the fork.
fork.journaled_state.journal = active_journaled_state.journal.clone();

// another edge case where a fork is created and selected during setup with not
// necessarily the same caller as for the test, however we must always
Expand Down Expand Up @@ -1198,10 +1196,8 @@ impl DatabaseExt for Backend {

let active = self.inner.get_fork_mut(active_idx);
active.journaled_state = self.fork_init_journaled_state.clone();

active.journaled_state.depth = journaled_state.depth;
// Set proper journal of state changes into the fork.
active.journaled_state.journal = journaled_state.journal.clone();

for addr in persistent_addrs {
merge_journaled_state_data(addr, journaled_state, &mut active.journaled_state);
}
Expand Down
Loading