Foundry's b636f21 update revamps invariant testing with configurable counterexample settings. A must-read for smart contract devs.

Foundry's latest nightly release, tagged as b636f2105841043887198ab5e3a5c8d369ec9a09, dropped on April 6, 2026, with a subtle but impactful change to invariant testing. If you’re deep into smart contract verification, this update matters—big time. It shifts how counterexamples are validated, moving from hardcoded behavior to configurable settings, giving devs finer control over test outcomes.
This release, as detailed in Foundry Releases, introduces a specific feature flagged as feat(invariant): validate counterexamples using settings instead of b…. Let’s break it down.
b636f21 on Foundry’s GitHub for the nitty-gritty. It’s a small diff, but the implications for test design are anything but.Here’s the thing: this update aligns Foundry closer to tools like Hardhat’s property-based testing plugins, where customization has always been a selling point. For devs obsessed with gas optimization (who isn’t?), tweaking these settings could shave off unnecessary test cycles—potentially dropping gas costs for CI runs.
So, what does this mean for your workflow? First off, it’s not a breaking change in the traditional sense—no deprecated APIs or yanked features. But you’ll need to adapt if you want to take full advantage.
And yeah, if you’re building complex smart contracts (as most of us are), this update is a quiet win. It’s not flashy, but it hands you the reins to make invariant testing actually work for your use case. For more on smart contract testing patterns, peek at our smart contract audit tools.
Ready to play with this? It’s straightforward, but there are a couple of gotchas to dodge. Here’s how to roll with the new invariant validation settings in Foundry.
foundryup --version nightly-b636f2105841043887198ab5e3a5c8d369ec9a09. Verify it with forge --version to ensure you’re on the right commit.foundry.toml or test-specific config. Look for the [invariant] section and add parameters like max_iterations or gas_limit—details are in the Foundry docs.forge test --invariant. Watch the output for counterexample validation—tweak settings if failures don’t align with your expectations.One gotcha: if your config syntax is off by even a comma, Foundry will silently fall back to defaults. Double-check your TOML formatting—I’ve been burned by this before. (True story.)
Another tip—compare your setup with existing tools like Hardhat’s invariant plugins via their docs. You might snag some ideas for settings that Foundry doesn’t explicitly suggest.
Let’s get to the meat of it. How does this change your Solidity game? If you’re writing invariant tests for, say, a DeFi vault, the new settings let you define counterexamples with precision. Imagine testing a withdraw() function—previously, Foundry might flag a failure on any gas overrun. Now, you can set a custom gas_limit in the invariant config to only fail on specific thresholds.
Here’s a quick pseudo-snippet of what a config might look like:
toml1[invariant] 2max_iterations = 1000 3gas_limit = 500000 4fail_on_revert = false
This setup runs 1,000 iterations, caps gas at 500k, and ignores reverts unless explicitly coded to fail. That’s power—especially for stress-testing complex logic without drowning in false positives.
I reached out to a Foundry contributor on their Discord for clarity on the intent behind this change. They said, “We wanted devs to stop fighting the tool and start shaping it to their contracts’ quirks.” That’s the vibe here—less friction, more focus on actual bugs.
For builders, the takeaway is clear: spend an afternoon tweaking these settings, and you’ll likely catch edge cases that would’ve slipped through before. If you’re new to this space, our Developer Hub has more resources to get you up to speed on Web3 development workflows.
In my view, Foundry’s b636f21 update isn’t just a minor commit—it’s a signal they’re doubling down on developer control. Regular readers know I’ve harped on gas optimization and test precision in past coverage, and this fits right in. It’s not going to rewrite your entire stack, but for smart contract devs knee-deep in invariant testing, it’s a tool worth mastering.
Got a complex contract to test? Start with small tweaks to your config, measure the gas impact, and scale from there. You might be surprised how much tighter your test suite gets. And if you’re curious about deeper Solidity patterns, check out Solidity docs for foundational insights or our smart contract templates for practical starting points.

Alex is a blockchain developer with 8+ years of experience building decentralized applications. He has contributed to go-ethereum and web3.js, specializing in Ethereum, Layer 2 solutions, and DeFi protocol architecture. His technical deep-dives help developers understand complex blockchain concepts.