Skip to content

fix(StdCheats): exclude P256VERIFY precompile in assumeNotPrecompile - #927

Open
maurelian wants to merge 1 commit into
foundry-rs:masterfrom
maurelian:fix/assume-not-precompile-p256verify
Open

maurelian wants to merge 1 commit into
foundry-rs:masterfrom
maurelian:fix/assume-not-precompile-p256verify

Conversation

@maurelian

Copy link
Copy Markdown

assumeNotPrecompile excludes 0x01–0xff, so fuzzers can still pick 0x100, the P256VERIFY precompile added in Osaka (EIP-7951). Tests that then vm.etch that address fail with "cannot use precompile 0x…0100". We found this running tests on the Amsterdam hardfork.

This widens the excluded range to 0x100, updates the testFuzz_AssumeNotPrecompile assertion, and adds test_AssumeNotPrecompileP256Verify, which uses the existing StdCheatsMock pattern. Both tests fail without the fix.

assumeNotPrecompile only excluded 0x01-0xff, so fuzzers could pick 0x100,
the P256VERIFY precompile added in Osaka (EIP-7951).
Comment thread test/StdCheats.t.sol
assumeNotPrecompile(addr, getChain("optimism_sepolia").chainId);
assertTrue(
addr < address(1) || (addr > address(9) && addr < address(0x4200000000000000000000000000000000000000))
addr < address(1) || (addr > address(0x100) && addr < address(0x4200000000000000000000000000000000000000))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This expands the range a lot, but I think it's still reasonable to consider it "within the range of things that might become precompiles". Can change to just add 0x100 instead of expanding, if preferred.

@grandizzy grandizzy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants