Skip to content

refactor(anvil): remove Env wrapper entirely#13947

Merged
mattsse merged 1 commit intofoundry-rs:masterfrom
mablr:refactor/anvil-remove-env-completely
Mar 26, 2026
Merged

refactor(anvil): remove Env wrapper entirely#13947
mattsse merged 1 commit intofoundry-rs:masterfrom
mablr:refactor/anvil-remove-env-completely

Conversation

@mablr
Copy link
Contributor

@mablr mablr commented Mar 26, 2026

Motivation

#13941 #13942 #13945 Follow-up - final stage: remove Env wrapper entirely

  • Backend.env: Arc<RwLock<Env>> -> evm_env: Arc<RwLock<EvmEnv>> + networks: NetworkConfigs
  • fn env() -> &Arc<RwLock<Env>> renamed to evm_env() -> &Arc<RwLock<EvmEnv>>
  • with_genesis() takes Arc<RwLock<EvmEnv>> + NetworkConfigs instead of Arc<RwLock<Env>>
  • config.rs: Env::new() replaced with plain EvmEnv construction; networks passed separately to with_genesis(); setup_fork_db / setup_fork_db_config now take &mut EvmEnv directly
  • env.networks.* replaced with self.networks.*
  • Local Env clones in do_mine_block, with_pending_block, replay_tx_with_inspector, reset_fork, reset_block_number replaced with EvmEnv-only clones
  • env.rs deleted

… `NetworkConfigs`

`Env` was a thin wrapper over (`EvmEnv`, `NetworkConfigs`)

- `Backend.env`: `Arc<RwLock<Env>>` -> `evm_env: Arc<RwLock<EvmEnv>>` + `networks: NetworkConfigs`
- fn `env() -> &Arc<RwLock<Env>>`  renamed to  `evm_env() -> &Arc<RwLock<EvmEnv>>`
- `with_genesis()` takes `Arc<RwLock<EvmEnv>>` + `NetworkConfigs` instead of `Arc<RwLock<Env>>`
- config.rs: `Env::new()` replaced with plain `EvmEnv` construction; networks
  passed separately to with_genesis(); `setup_fork_db` / `setup_fork_db_config`
  now take &mut EvmEnv directly
- `env.networks.*` replaced with `self.networks.*`
- Local `Env` clones in do_mine_block, with_pending_block, replay_tx_with_inspector,
  reset_fork, reset_block_number replaced with `EvmEnv`-only clones
- env.rs deleted
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lfg

@mattsse mattsse merged commit 59824ce into foundry-rs:master Mar 26, 2026
16 checks passed
@github-project-automation github-project-automation bot moved this to Done in Foundry Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants