Open
Description
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
55802bad5f9068d969df4273b5c2a960332e8e42
What version of Foundryup are you on?
1.0.1
What command(s) is the bug in?
No response
Operating System
Linux
Describe the bug
// SPDX-License-Identifier: WTFPL
pragma solidity ^0.8.29;
import {Test} from "forge-std/Test.sol";
contract SimpleTest is Test {
function testBlockHashSimple() public {
vm.roll(type(uint72).max); // If you replace this with `vm.roll(type(uint64).max);` (or below) it will work properly.
uint256 blockNumber = vm.getBlockNumber() - 1;
vm.setBlockhash(blockNumber, keccak256("vyper"));
emit log_bytes32(blockhash(blockNumber));
}
}
Logs:
0x0000000000000000000000000000000000000000000000000000000000000000
Traces:
[4964] SimpleTest::testBlockHashSimple()
├─ [0] VM::roll(4722366482869645213695 [4.722e21])
│ └─ ← [Return]
├─ [0] VM::getBlockNumber() [staticcall]
│ └─ ← [Return] 4722366482869645213695 [4.722e21]
├─ [0] VM::setBlockhash(4722366482869645213694 [4.722e21], 0xcde04c9d98738375f7f1bbf067b84e35f9327a84c3d709815de017a16d090c11)
│ └─ ← [Return]
├─ emit log_bytes32(val: 0x0000000000000000000000000000000000000000000000000000000000000000)
└─ ← [Stop]
The correct output should be:
[PASS] testBlockHashSimple() (gas: 4964)
Logs:
0xcde04c9d98738375f7f1bbf067b84e35f9327a84c3d709815de017a16d090c11
Traces:
[4964] SimpleTest::testBlockHashSimple()
├─ [0] VM::roll(18446744073709551615 [1.844e19])
│ └─ ← [Return]
├─ [0] VM::getBlockNumber() [staticcall]
│ └─ ← [Return] 18446744073709551615 [1.844e19]
├─ [0] VM::setBlockhash(18446744073709551614 [1.844e19], 0xcde04c9d98738375f7f1bbf067b84e35f9327a84c3d709815de017a16d090c11)
│ └─ ← [Return]
├─ emit log_bytes32(val: 0xcde04c9d98738375f7f1bbf067b84e35f9327a84c3d709815de017a16d090c11)
└─ ← [Stop]
Metadata
Metadata
Assignees
Type
Projects
Status
In Progress