feat(anvil): add [anvil] section to foundry.toml#13653
Open
koko1123 wants to merge 1 commit intofoundry-rs:masterfrom
Open
feat(anvil): add [anvil] section to foundry.toml#13653koko1123 wants to merge 1 commit intofoundry-rs:masterfrom
koko1123 wants to merge 1 commit intofoundry-rs:masterfrom
Conversation
Dustin4444
approved these changes
Mar 7, 2026
093978c to
5c5d9f7
Compare
Add support for configuring Anvil via foundry.toml, enabling teams to version-control their Anvil settings alongside their project config. This implements a new `[anvil]` section in foundry.toml that supports: - All persistent Anvil settings (port, accounts, gas_limit, fork_url, etc.) - Profile-based overrides via `[profile.ci.anvil]` - Environment variable overrides via `FOUNDRY_ANVIL_*` - CLI flags always take precedence over config file values Implementation follows the established pattern used by `[fmt]`, `[doc]`, and `[fuzz]` sections. Closes foundry-rs#4226 Ref foundry-rs#10779
5c5d9f7 to
8f25bb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for configuring Anvil via
foundry.toml, matching the existing pattern used by[fmt],[doc],[fuzz], and other standalone sections. This closes a long-standing feature request to make Anvil project-aware.AnvilConfigstruct incrates/config/src/anvil.rswith 40+ fields covering all persistent Anvil settings (network, accounts, gas, fork, tracing, etc.)STANDALONE_SECTIONS, giving us[anvil],[profile.ci.anvil], andFOUNDRY_ANVIL_*env var support for freeNodeArgsto load config and merge with CLI args (CLI always wins)TtoOption<T>(port,accounts,balance,slots_in_an_epoch,host,order) so config file defaults can apply when CLI flags aren't explicitly passedMotivation
We're building a perpetual swap protocol at Strobe Labs that relies heavily on Anvil for testing (Prague EVM,
gas_limit = u64::MAX,no_storage_caching, custom fork configs). Today, these settings live as CLI flags in our CI scripts, duplicating what's already partially expressed infoundry.toml. Having an[anvil]section lets us colocate all Foundry configuration in one file and leverage profiles for CI vs local development.Example
Design decisions
default_valuewere changed toOption<T>so we can distinguish "user passed a flag" from "clap used its default"--load-state,--dump-state,--state,--config-out,--silent,--timestamp,--number) are intentionally excluded from the config struct since they don't make sense as persistent project configuration@blocksuffix in fork URLs (e.g.,http://localhost:8545@1400000) is preserved during merge, not droppedCloses #4226
Ref #10779
Test plan
cargo build -p foundry-configcompilescargo build -p anvilcompilesfoundry.tomlwith[anvil]section, runanvil, verify settings applyFOUNDRY_ANVIL_PORT=1234 anvilworks[profile.ci.anvil]withFOUNDRY_PROFILE=ciworks