Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/StdCheats.sol
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ abstract contract StdCheatsSafe {
// address), but the same rationale for excluding them applies so we include those too.

// These are reserved by Ethereum and may be on all EVM-compatible chains.
vm.assume(addr < address(0x1) || addr > address(0xff));
// 0x100 is P256VERIFY (EIP-7951).
vm.assume(addr < address(0x1) || addr > address(0x100));

// forgefmt: disable-start
if (chainId == 10 || chainId == 420 || chainId == 11155420) {
Expand Down
14 changes: 13 additions & 1 deletion test/StdCheats.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,19 @@ contract StdCheatsTest is Test {
function testFuzz_AssumeNotPrecompile(address addr) external {
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.

|| addr > address(0x4200000000000000000000000000000000000800)
);
}

function test_AssumeNotPrecompileP256Verify() external {
StdCheatsMock stdCheatsMock = new StdCheatsMock();

// P256VERIFY (EIP-7951)
vm.expectRevert();
stdCheatsMock.exposedAssumeNotPrecompile(address(0x100));
}

function testFuzz_AssumeNotForgeAddress(address addr) external pure {
assumeNotForgeAddress(addr);
assertTrue(
Expand Down Expand Up @@ -508,6 +516,10 @@ contract StdCheatsMock is StdCheats {
function exposedAssumeNotBlacklisted(address token, address addr) external view {
return assumeNotBlacklisted(token, addr);
}

function exposedAssumeNotPrecompile(address addr) external pure {
assumeNotPrecompile(addr);
}
}

contract StdCheatsForkTest is Test {
Expand Down
Loading