Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
396a7c9
bump revm, pending alloy-evm https://github.com/alloy-rs/evm/pull/100…
zerosnacks Jun 10, 2025
9e77339
bump alloy-evm, foundry-fork-db
zerosnacks Jun 10, 2025
90ba8c2
merge in master
zerosnacks Jun 18, 2025
3aef4e3
bump deps
zerosnacks Jun 24, 2025
73be042
bump deps
zerosnacks Jun 24, 2025
433a246
apply alloy-evm fix
zerosnacks Jun 24, 2025
f5de86f
start porting types
zerosnacks Jun 24, 2025
8d86917
unpin revm-inspectors
zerosnacks Jun 24, 2025
62db3d0
fix issues
zerosnacks Jun 24, 2025
b672ee2
continue preperation
zerosnacks Jun 25, 2025
d5d94b1
.control field was removed
zerosnacks Jun 25, 2025
fe5fb7b
frame_return_result now needs to happen in bigger run_exec_loop block
zerosnacks Jun 25, 2025
321d0d1
update handler and inspector per latest changes removing previous met…
zerosnacks Jun 26, 2025
0ada9ae
add new frame loop
zerosnacks Jun 26, 2025
57f613f
pass in frame
zerosnacks Jun 26, 2025
1968888
fix transact_raw
zerosnacks Jun 26, 2025
16bea82
continue fixes
zerosnacks Jun 26, 2025
f2908db
apply will_exit, on continue should skip as it is none, on exit (any …
zerosnacks Jun 26, 2025
144a7c3
continue clean up, some attention points in regards to InstructionRes…
zerosnacks Jun 26, 2025
afcd928
continue porting
zerosnacks Jun 27, 2025
7dc99f2
continue porting
zerosnacks Jun 27, 2025
b1b85be
temporarily use hardcoded BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE
zerosnacks Jun 27, 2025
a41fe7d
fix merge conflict
zerosnacks Jun 27, 2025
c46046b
remove clamping now that revm supports U256 internally for number and…
zerosnacks Jun 27, 2025
b6a3f8f
fix clippy
zerosnacks Jun 27, 2025
ae3a80d
fix doctest
zerosnacks Jun 27, 2025
6b2c6b1
Merge branch 'master' into zerosnacks/bump-revm-26.0.0
zerosnacks Jun 30, 2025
ebb02c6
bump alloy version
zerosnacks Jun 30, 2025
bb858b9
make assertion on `bytecode`
zerosnacks Jun 30, 2025
9a28cd4
revert bytecode(), fix to come in upcoming release
zerosnacks Jun 30, 2025
986d3e9
bump revm 27
zerosnacks Jul 1, 2025
87970de
fix debug
zerosnacks Jul 1, 2025
5b454c1
revert Cargo.toml change
zerosnacks Jul 1, 2025
f967026
clean up
zerosnacks Jul 1, 2025
e770ed7
merge in master
zerosnacks Jul 2, 2025
442c3bf
fix(`config`): block_timestamp and block_number mismatch in Config an…
yash-atreya Jul 2, 2025
53cf49b
fix clippy
zerosnacks Jul 2, 2025
6db3d97
fix(`anvil/test`): change delegatecall.value in test_call_ots_trace_t…
yash-atreya Jul 3, 2025
d0be407
bump revm: 27.0.2
yash-atreya Jul 4, 2025
2e90f0f
fix merge conflicts
zerosnacks Jul 4, 2025
fde9ecf
apply clippy fixes
zerosnacks Jul 4, 2025
f6ecfcf
fix fmt
zerosnacks Jul 4, 2025
85ef15c
fix config defaults
zerosnacks Jul 4, 2025
eb37b41
fix config change of block_number, block_timestamp require hex format…
zerosnacks Jul 4, 2025
6be1e62
fix(`evm`): create2 in InspectorHandler and trace decoder for None st…
yash-atreya Jul 4, 2025
fad3a33
fix(`forge/test`): update test fixture: can_run_test_with_json_output…
yash-atreya Jul 4, 2025
164ca4b
fix(`forge/test`): repro 6501 - account for success being false due t…
yash-atreya Jul 4, 2025
a00234b
fix(`evm/inspectors`): prevent panic in should_revert_on_address_opco…
yash-atreya Jul 7, 2025
924516f
fix merge conflict
zerosnacks Jul 7, 2025
0349b00
fix(`evm`): enable tx_chain_id_check (#10943)
yash-atreya Jul 7, 2025
ec6b480
use dynamic blob_base_fee_update_fraction selection based on hardfork…
zerosnacks Jul 7, 2025
2753b85
Merge branch 'zerosnacks/bump-revm-26.0.0' of github.com:foundry-rs/f…
zerosnacks Jul 7, 2025
e84dca3
fix merge conflicts
zerosnacks Jul 7, 2025
4461e0d
bump alloy-chains version w/ foundry-fork-db
zerosnacks Jul 7, 2025
b74f48a
fix: fork errors getting overriden by RevertDiagnostic inspector (#10…
yash-atreya Jul 8, 2025
9e8e05b
patch revm to include fix for `call_end` not being called
yash-atreya Jul 9, 2025
bce2a09
fix: can_run_test_with_json_output_verbose
yash-atreya Jul 9, 2025
154005f
Merge branch 'master' into zerosnacks/bump-revm-26.0.0
yash-atreya Jul 9, 2025
fcc183c
Revert "fix: fork errors getting overriden by RevertDiagnostic inspec…
yash-atreya Jul 9, 2025
e68006c
fix(`cast`): disable balance check for impersonated txs. (#10972)
yash-atreya Jul 9, 2025
0780536
Revert "fix(`anvil/test`): change delegatecall.value in test_call_ots…
yash-atreya Jul 9, 2025
ebe1b5d
fix(`evm`): remove Handler impl for `FoundryHandler` (#10975)
yash-atreya Jul 10, 2025
173d01e
bump foundry-fork-db 0.16, fix tests
zerosnacks Jul 10, 2025
054cce5
bump alloy
zerosnacks Jul 10, 2025
b6a8ec8
unify blob_base_fee_update_fraction in helper, clarify exception
zerosnacks Jul 10, 2025
bf2131e
move helpers to evm-core for blob_base_fee_update_fraction
zerosnacks Jul 10, 2025
7d59dfe
Update mod.rs
zerosnacks Jul 11, 2025
b8bebca
Merge branch 'master' into zerosnacks/bump-revm-26.0.0
zerosnacks Jul 14, 2025
7488b22
unpatch revm, update to 27.0.3
zerosnacks Jul 14, 2025
1f54eb0
fix fmt
zerosnacks Jul 14, 2025
37f4cb7
revert to solar 1.4, waiting for upgrade PR
zerosnacks Jul 14, 2025
f2e6572
bump alloy-evm / alloy-op-evm
zerosnacks Jul 14, 2025
d1ccd6e
forcibly downgrade solar-config, solar-macros due to breaking change …
zerosnacks Jul 14, 2025
2dc1116
Merge branch 'master' into zerosnacks/bump-revm-26.0.0
zerosnacks Jul 15, 2025
42ac804
feat(`revm bump`): add serialization method that serializes as `u64` …
zerosnacks Jul 15, 2025
d69b2ef
fix merge conflicts
zerosnacks Jul 15, 2025
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
172 changes: 122 additions & 50 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ foundry-linking = { path = "crates/linking" }
# solc & compilation utilities
foundry-block-explorers = { version = "0.19.1", default-features = false }
foundry-compilers = { version = "0.17.4", default-features = false }
foundry-fork-db = "0.15"
foundry-fork-db = "0.16"
solang-parser = { version = "=0.3.9", package = "foundry-solang-parser" }
solar-ast = { version = "=0.1.4", default-features = false }
solar-parse = { version = "=0.1.4", default-features = false }
Expand Down Expand Up @@ -263,13 +263,13 @@ op-alloy-rpc-types = "0.17.2"
op-alloy-flz = "0.13.1"

## revm
revm = { version = "24.0.1", default-features = false }
revm-inspectors = { version = "0.23.0", features = ["serde"] }
op-revm = { version = "5.0.1", default-features = false }
revm = { version = "27.0.3", default-features = false }
revm-inspectors = { version = "0.26.5", features = ["serde"] }
op-revm = { version = "8.0.3", default-features = false }

## alloy-evm
alloy-evm = "0.10.0"
alloy-op-evm = "0.10.0"
alloy-evm = "0.14.0"
alloy-op-evm = "0.14.0"

## cli
anstream = "0.6"
Expand Down Expand Up @@ -401,18 +401,18 @@ zip-extract = "=0.2.1"
# 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 = "dce752f" }
# alloy-op-evm = { git = "https://github.com/alloy-rs/evm.git", rev = "dce752f" }
# 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" }

## revm
# revm = { git = "https://github.com/bluealloy/revm.git", rev = "b5808253" }
# op-revm = { git = "https://github.com/bluealloy/revm.git", rev = "b5808253" }
# revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors.git", rev = "a625c04" }
# revm-inspectors = { git = "https://github.com/paradigmxyz/revm-inspectors.git", rev = "956bc98" }

## 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 = "811a61a" }
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "4ed9afb" }

## solar
# solar-ast = { git = "https://github.com/paradigmxyz/solar.git", branch = "main" }
Expand Down
46 changes: 31 additions & 15 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::{
hardfork::{ChainHardfork, ethereum_hardfork_from_block_tag, spec_id_from_ethereum_hardfork},
mem::{self, in_memory_db::MemDb},
};
use alloy_chains::Chain;
use alloy_consensus::BlockHeader;
use alloy_genesis::Genesis;
use alloy_network::{AnyNetwork, TransactionResponse};
Expand All @@ -38,7 +39,7 @@ use foundry_config::Config;
use foundry_evm::{
backend::{BlockchainDb, BlockchainDbMeta, SharedBackend},
constants::DEFAULT_CREATE2_DEPLOYER,
utils::apply_chain_and_block_specific_env_changes,
utils::{apply_chain_and_block_specific_env_changes, get_blob_base_fee_update_fraction},
};
use foundry_evm_core::AsEnvMut;
use itertools::Itertools;
Expand Down Expand Up @@ -513,14 +514,18 @@ impl NodeConfig {
}

pub fn get_blob_excess_gas_and_price(&self) -> BlobExcessGasAndPrice {
if let Some(blob_excess_gas_and_price) = &self.blob_excess_gas_and_price {
*blob_excess_gas_and_price
} else if let Some(excess_blob_gas) = self.genesis.as_ref().and_then(|g| g.excess_blob_gas)
{
BlobExcessGasAndPrice::new(excess_blob_gas, false)
if let Some(value) = self.blob_excess_gas_and_price {
value
} else {
// If no excess blob gas is configured, default to 0
BlobExcessGasAndPrice::new(0, false)
let excess_blob_gas =
self.genesis.as_ref().and_then(|g| g.excess_blob_gas).unwrap_or(0);
BlobExcessGasAndPrice::new(
excess_blob_gas,
get_blob_base_fee_update_fraction(
self.chain_id.unwrap_or(Chain::mainnet().id()),
self.get_genesis_timestamp(),
),
)
}
}

Expand Down Expand Up @@ -1079,12 +1084,12 @@ impl NodeConfig {
if self.chain_id.is_none() {
env.evm_env.cfg_env.chain_id = genesis.config.chain_id;
}
env.evm_env.block_env.timestamp = genesis.timestamp;
env.evm_env.block_env.timestamp = U256::from(genesis.timestamp);
if let Some(base_fee) = genesis.base_fee_per_gas {
env.evm_env.block_env.basefee = base_fee.try_into()?;
}
if let Some(number) = genesis.number {
env.evm_env.block_env.number = number;
env.evm_env.block_env.number = U256::from(number);
}
env.evm_env.block_env.beneficiary = genesis.coinbase;
}
Expand Down Expand Up @@ -1237,8 +1242,8 @@ latest block number: {latest_block}"
self.gas_limit = Some(gas_limit);

env.evm_env.block_env = BlockEnv {
number: fork_block_number,
timestamp: block.header.timestamp,
number: U256::from(fork_block_number),
timestamp: U256::from(block.header.timestamp),
difficulty: block.header.difficulty,
// ensures prevrandao is set
prevrandao: Some(block.header.mix_hash.unwrap_or_default()),
Expand Down Expand Up @@ -1268,13 +1273,24 @@ latest block number: {latest_block}"
if let (Some(blob_excess_gas), Some(blob_gas_used)) =
(block.header.excess_blob_gas, block.header.blob_gas_used)
{
env.evm_env.block_env.blob_excess_gas_and_price =
Some(BlobExcessGasAndPrice::new(blob_excess_gas, false));
let blob_base_fee_update_fraction = get_blob_base_fee_update_fraction(
fork_chain_id
.unwrap_or_else(|| U256::from(Chain::mainnet().id()))
.saturating_to(),
block.header.timestamp,
);

env.evm_env.block_env.blob_excess_gas_and_price = Some(BlobExcessGasAndPrice::new(
blob_excess_gas,
blob_base_fee_update_fraction,
));

let next_block_blob_excess_gas =
fees.get_next_block_blob_excess_gas(blob_excess_gas, blob_gas_used);

fees.set_blob_excess_gas_and_price(BlobExcessGasAndPrice::new(
next_block_blob_excess_gas,
false,
blob_base_fee_update_fraction,
));
}
}
Expand Down
25 changes: 8 additions & 17 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use super::{
backend::{
db::MaybeFullDatabase,
mem::{BlockRequest, State, state},
},
backend::mem::{BlockRequest, DatabaseRef, State, state},
sign::build_typed_transaction,
};
use crate::{
Expand Down Expand Up @@ -83,7 +80,7 @@ use anvil_core::{
};
use anvil_rpc::{error::RpcError, response::ResponseResult};
use foundry_common::provider::ProviderBuilder;
use foundry_evm::{backend::DatabaseError, decode::RevertDecoder};
use foundry_evm::decode::RevertDecoder;
use futures::{
StreamExt,
channel::{mpsc::Receiver, oneshot},
Expand All @@ -93,7 +90,7 @@ use revm::{
bytecode::Bytecode,
context::BlockEnv,
context_interface::{block::BlobExcessGasAndPrice, result::Output},
database::{CacheDB, DatabaseRef},
database::CacheDB,
interpreter::{InstructionResult, return_ok, return_revert},
primitives::eip7702::PER_EMPTY_ACCOUNT_COST,
};
Expand Down Expand Up @@ -2213,7 +2210,7 @@ impl EthApi {

Ok(NodeInfo {
current_block_number: self.backend.best_number(),
current_block_timestamp: env.evm_env.block_env.timestamp,
current_block_timestamp: env.evm_env.block_env.timestamp.saturating_to(),
current_block_hash: self.backend.best_hash(),
hard_fork: hard_fork.to_string(),
transaction_order: match *tx_order {
Expand Down Expand Up @@ -2955,7 +2952,7 @@ impl EthApi {
if let Some(block_overrides) = overrides.block {
state::apply_block_overrides(*block_overrides, &mut cache_db, &mut block);
}
this.do_estimate_gas_with_state(request, cache_db.as_dyn(), block)
this.do_estimate_gas_with_state(request, &cache_db as &dyn DatabaseRef, block)
})
.await?
})
Expand All @@ -2968,7 +2965,7 @@ impl EthApi {
fn do_estimate_gas_with_state(
&self,
mut request: WithOtherFields<TransactionRequest>,
state: &dyn DatabaseRef<Error = DatabaseError>,
state: &dyn DatabaseRef,
block_env: BlockEnv,
) -> Result<u128> {
// If the request is a simple native token transfer we can optimize
Expand Down Expand Up @@ -3490,7 +3487,7 @@ impl TryFrom<Result<(InstructionResult, Option<Output>, u128, State)>> for GasEs
}
Err(err) => Err(err),
Ok((exit, output, gas, _)) => match exit {
return_ok!() | InstructionResult::CallOrCreate => Ok(Self::Success(gas)),
return_ok!() => Ok(Self::Success(gas)),

// Revert opcodes:
InstructionResult::Revert => Ok(Self::Revert(output.map(|o| o.into_data()))),
Expand Down Expand Up @@ -3525,13 +3522,7 @@ impl TryFrom<Result<(InstructionResult, Option<Output>, u128, State)>> for GasEs
| InstructionResult::CreateContractSizeLimit
| InstructionResult::CreateContractStartingWithEF
| InstructionResult::CreateInitCodeSizeLimit
| InstructionResult::FatalExternalError
| InstructionResult::ReturnContractInNotInitEOF
| InstructionResult::EOFOpcodeDisabledInLegacy
| InstructionResult::SubRoutineStackOverflow
| InstructionResult::EofAuxDataOverflow
| InstructionResult::EofAuxDataTooSmall
| InstructionResult::InvalidEXTCALLTarget => Ok(Self::EvmError(exit)),
| InstructionResult::FatalExternalError => Ok(Self::EvmError(exit)),
},
}
}
Expand Down
11 changes: 8 additions & 3 deletions crates/anvil/src/eth/backend/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ use serde::{
Deserialize, Deserializer, Serialize,
de::{MapAccess, Visitor},
};
use std::{collections::BTreeMap, fmt, path::Path};
use std::{
collections::BTreeMap,
fmt::{self, Debug},
path::Path,
};

/// Helper trait get access to the full state data of the database
pub trait MaybeFullDatabase: DatabaseRef<Error = DatabaseError> {
pub trait MaybeFullDatabase: DatabaseRef<Error = DatabaseError> + Debug {
/// Returns a reference to the database as a `dyn DatabaseRef`.
// TODO: Required until trait upcasting is stabilized: <https://github.com/rust-lang/rust/issues/65991>
fn as_dyn(&self) -> &dyn DatabaseRef<Error = DatabaseError>;
Expand Down Expand Up @@ -242,7 +246,7 @@ impl<T: DatabaseRef<Error = DatabaseError> + Send + Sync + Clone + fmt::Debug> D
}
}

impl<T: DatabaseRef<Error = DatabaseError>> MaybeFullDatabase for CacheDB<T> {
impl<T: DatabaseRef<Error = DatabaseError> + Debug> MaybeFullDatabase for CacheDB<T> {
fn as_dyn(&self) -> &dyn DatabaseRef<Error = DatabaseError> {
self
}
Expand Down Expand Up @@ -321,6 +325,7 @@ impl<T: DatabaseRef<Error = DatabaseError>> MaybeForkedDatabase for CacheDB<T> {
}

/// Represents a state at certain point
#[derive(Debug)]
pub struct StateDb(pub(crate) Box<dyn MaybeFullDatabase + Send + Sync>);

impl StateDb {
Expand Down
17 changes: 10 additions & 7 deletions crates/anvil/src/eth/backend/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ use revm::{
database::WrapDatabaseRef,
handler::{EthPrecompiles, instructions::EthInstructions},
interpreter::InstructionResult,
precompile::{PrecompileSpecId, Precompiles, secp256r1::P256VERIFY},
precompile::{
PrecompileSpecId, Precompiles,
secp256r1::{P256VERIFY, P256VERIFY_BASE_GAS_FEE},
},
primitives::hardfork::SpecId,
};
use std::sync::Arc;
use std::{fmt::Debug, sync::Arc};

/// Represents an executed transaction (transacted on the DB)
#[derive(Debug)]
Expand Down Expand Up @@ -229,10 +232,10 @@ impl<DB: Db + ?Sized, V: TransactionValidator> TransactionExecutor<'_, DB, V> {
receipts_root,
logs_bloom: bloom,
difficulty,
number: block_number,
number: block_number.saturating_to(),
gas_limit,
gas_used: cumulative_gas_used,
timestamp,
timestamp: timestamp.saturating_to(),
extra_data: Default::default(),
mix_hash: mix_hash.unwrap_or_default(),
nonce: Default::default(),
Expand Down Expand Up @@ -329,7 +332,7 @@ impl<DB: Db + ?Sized, V: TransactionValidator> Iterator for &mut TransactionExec
let mut evm = new_evm_with_inspector(&mut *self.db, &env, &mut inspector);

if self.odyssey {
inject_precompiles(&mut evm, vec![P256VERIFY]);
inject_precompiles(&mut evm, vec![(P256VERIFY, P256VERIFY_BASE_GAS_FEE)]);
}

if let Some(factory) = &self.precompile_factory {
Expand Down Expand Up @@ -428,7 +431,7 @@ pub fn new_evm_with_inspector<DB, I>(
inspector: I,
) -> EitherEvm<DB, I, PrecompilesMap>
where
DB: Database<Error = DatabaseError>,
DB: Database<Error = DatabaseError> + Debug,
I: Inspector<EthEvmContext<DB>> + Inspector<OpContext<DB>>,
{
if env.is_optimism {
Expand Down Expand Up @@ -500,7 +503,7 @@ pub fn new_evm_with_inspector_ref<'db, DB, I>(
inspector: &'db mut I,
) -> EitherEvm<WrapDatabaseRef<&'db DB>, &'db mut I, PrecompilesMap>
where
DB: DatabaseRef<Error = DatabaseError> + 'db + ?Sized,
DB: DatabaseRef<Error = DatabaseError> + Debug + 'db + ?Sized,
I: Inspector<EthEvmContext<WrapDatabaseRef<&'db DB>>>
+ Inspector<OpContext<WrapDatabaseRef<&'db DB>>>,
WrapDatabaseRef<&'db DB>: Database<Error = DatabaseError>,
Expand Down
Loading
Loading