Skip to content

Commit 534f6df

Browse files
committed
clean up
1 parent 53922ac commit 534f6df

File tree

11 files changed

+23
-29
lines changed

11 files changed

+23
-29
lines changed

Diff for: Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: crates/evm/core/src/backend/cow.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ use foundry_fork_db::DatabaseError;
1616
use revm::{
1717
bytecode::Bytecode,
1818
context::{result::ResultAndState, JournalInit},
19-
context_interface::result::ResultAndState,
2019
database::DatabaseRef,
2120
primitives::{hardfork::SpecId, EnvWithHandlerCfg, HashMap as Map},
22-
state::{Account, AccountInfo, Bytecode},
21+
state::{Account, AccountInfo},
2322
Database, DatabaseCommit, ExecuteEvm, JournaledState,
2423
};
2524
use std::{borrow::Cow, collections::BTreeMap};
@@ -91,7 +90,7 @@ impl<'a> CowBackend<'a> {
9190
/// Returns a mutable instance of the Backend.
9291
///
9392
/// If this is the first time this is called, the backed is cloned and initialized.
94-
fn backend_mut(&mut self, env: EnvMut<'_>) -> &mut Backend {
93+
fn backend_mut(&mut self, mut env: EnvMut<'_>) -> &mut Backend {
9594
let env = env.as_env_mut().to_owned();
9695
if !self.is_initialized {
9796
let backend = self.backend.to_mut();
@@ -167,7 +166,7 @@ impl DatabaseExt for CowBackend<'_> {
167166
&mut self,
168167
id: Option<LocalForkId>,
169168
block_number: u64,
170-
env: EnvMut<'_>,
169+
mut env: EnvMut<'_>,
171170
journaled_state: &mut JournaledState<'_>,
172171
) -> eyre::Result<()> {
173172
self.backend_mut(env.as_env_mut()).roll_fork(id, block_number, env, journaled_state)

Diff for: crates/evm/core/src/backend/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use alloy_primitives::Address;
22
pub use foundry_fork_db::{DatabaseError, DatabaseResult};
3-
use revm::{context::result::EVMError, context_interface::result::EVMError};
3+
use revm::context::result::EVMError;
44
use std::{convert::Infallible, fmt::Display};
55

66
pub type BackendResult<T> = Result<T, BackendError>;

Diff for: crates/evm/core/src/backend/mod.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ use revm::{
2020
database::{CacheDB, DatabaseRef},
2121
inspector::NoOpInspector,
2222
precompile::{PrecompileSpecId, Precompiles},
23-
primitives::{
24-
hardfork::SpecId, EnvWithHandlerCfg, EvmState, EvmStorageSlot, HashMap as Map, Log,
25-
KECCAK_EMPTY,
26-
},
27-
state::{Account, AccountInfo},
23+
primitives::{hardfork::SpecId, EnvWithHandlerCfg, HashMap as Map, Log, KECCAK_EMPTY},
24+
state::{Account, AccountInfo, EvmState, EvmStorageSlot},
2825
Database, DatabaseCommit, JournaledState,
2926
};
3027
use std::{
@@ -1054,8 +1051,8 @@ impl DatabaseExt for Backend {
10541051
if let Some(active_fork_id) = self.active_fork_id() {
10551052
self.forks.update_block(
10561053
self.ensure_fork_id(active_fork_id).cloned()?,
1057-
env.evm_env.block_env.number,
1058-
env.evm_env.block_env.timestamp,
1054+
env.block.number,
1055+
env.block.timestamp,
10591056
)?;
10601057
}
10611058

Diff for: crates/evm/core/src/backend/snapshot.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use alloy_primitives::{map::AddressHashMap, B256, U256};
33
use revm::{primitives::HashMap, state::AccountInfo, JournaledState};
44
use serde::{Deserialize, Serialize};
55

6-
use crate::Env;
7-
86
/// A minimal abstraction of a state at a certain point in time
97
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
108
pub struct StateSnapshot {

Diff for: crates/evm/core/src/fork/multi.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
//! The design is similar to the single `SharedBackend`, `BackendHandler` but supports multiple
44
//! concurrently active pairs at once.
55
6-
use crate::Env;
7-
86
use super::CreateFork;
97
use crate::Env;
108
use alloy_consensus::BlockHeader;

Diff for: crates/evm/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ pub mod opts;
3737
pub mod precompiles;
3838
pub mod state_snapshot;
3939
pub mod utils;
40-
pub use env::*;
4140
use utils::FoundryEvmCtx;
4241

4342
/// An extension trait that allows us to add additional hooks to Inspector for later use in

Diff for: crates/evm/core/src/utils.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
pub use crate::ic::*;
22
use crate::{
33
backend::DatabaseExt, constants::DEFAULT_CREATE2_DEPLOYER_CODEHASH, precompiles::ODYSSEY_P256,
4-
AsEnvMut, Env, InspectorExt,
4+
AsEnvMut, Env, EnvMut, InspectorExt,
55
};
66
use alloy_consensus::BlockHeader;
7-
use alloy_evm::{eth::EthEvmContext, EvmEnv};
7+
use alloy_evm::eth::EthEvmContext;
88
use alloy_json_abi::{Function, JsonAbi};
99
use alloy_network::{AnyTxEnvelope, TransactionResponse};
1010
use alloy_primitives::{Address, Bytes, Selector, TxKind, B256, U256};
@@ -20,7 +20,6 @@ use revm::{
2020
return_ok, CallInputs, CallOutcome, CallScheme, CallValue, CreateInputs, CreateOutcome,
2121
Gas, InstructionResult, InterpreterResult,
2222
},
23-
precompile::secp256r1::P256VERIFY,
2423
primitives::{hardfork::SpecId, HandlerCfg, KECCAK_EMPTY},
2524
};
2625
use std::{cell::RefCell, rc::Rc, sync::Arc};

Diff for: crates/verify/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ foundry-config.workspace = true
1818
foundry-cli.workspace = true
1919
foundry-common.workspace = true
2020
foundry-evm.workspace = true
21+
foundry-evm-core.workspace = true
2122
serde_json.workspace = true
2223
alloy-json-abi.workspace = true
2324
alloy-primitives.workspace = true

Diff for: crates/verify/src/bytecode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl VerifyBytecodeArgs {
243243
)
244244
.await?;
245245

246-
env.evm_env.block_env.number = 0_u64; // Genesis block
246+
env.block.number = 0_u64; // Genesis block
247247
let genesis_block = provider.get_block(gen_blk_num.into()).full().await?;
248248

249249
// Setup genesis tx and env.
@@ -445,7 +445,7 @@ impl VerifyBytecodeArgs {
445445
evm_opts,
446446
)
447447
.await?;
448-
env.evm_env.block_env.number = simulation_block;
448+
env.block.number = simulation_block;
449449
let block = provider.get_block(simulation_block.into()).full().await?;
450450

451451
// Workaround for the NonceTooHigh issue as we're not simulating prior txs of the same

Diff for: crates/verify/src/utils.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use foundry_evm::{
1616
constants::DEFAULT_CREATE2_DEPLOYER, executors::TracingExecutor, opts::EvmOpts,
1717
traces::TraceMode,
1818
};
19+
use foundry_evm_core::AsEnvMut;
1920
use reqwest::Url;
2021
use revm::primitives::{
2122
bytecode::Bytecode,
@@ -350,13 +351,14 @@ pub async fn get_tracing_executor(
350351
Ok((env, executor))
351352
}
352353

353-
pub fn configure_env_block(env: &mut Env, block: &AnyRpcBlock) {
354-
env.evm_env.block_env.timestamp = block.header.timestamp;
355-
env.evm_env.block_env.beneficiary = block.header.beneficiary;
356-
env.evm_env.block_env.difficulty = block.header.difficulty;
357-
env.evm_env.block_env.prevrandao = block.header.mix_hash;
358-
env.evm_env.block_env.basefee = block.header.base_fee_per_gas.unwrap_or_default();
359-
env.evm_env.block_env.gas_limit = block.header.gas_limit;
354+
pub fn configure_env_block(mut env: impl AsEnvMut, block: &AnyRpcBlock) {
355+
let env = env.as_env_mut();
356+
env.block.timestamp = block.header.timestamp;
357+
env.block.beneficiary = block.header.beneficiary;
358+
env.block.difficulty = block.header.difficulty;
359+
env.block.prevrandao = block.header.mix_hash;
360+
env.block.basefee = block.header.base_fee_per_gas.unwrap_or_default();
361+
env.block.gas_limit = block.header.gas_limit;
360362
}
361363

362364
pub fn deploy_contract(

0 commit comments

Comments
 (0)