Skip to content
Closed
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: 3 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ runs = 256
[invariant]
depth = 15
runs = 10

[lint]
lint_on_build = false
8 changes: 4 additions & 4 deletions src/utils/BlockHashLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ library BlockHashLib {
/// consistent with the EVM's native `BLOCKHASH` behavior.
function blockHash(uint256 blockNumber) internal view returns (bytes32 result) {
unchecked {
// If `blockNumber + 256` overflows:
// - Typical chain height (`block.number > 255`) -> `staticcall` -> 0.
// - Very early chain (`block.number <= 255`) -> `blockhash` -> 0.
if (block.number <= blockNumber + 256) return blockhash(blockNumber);
// If `blockNumber + 257` overflows:
// - Typical chain height (`block.number > 256`) -> `staticcall` -> 0.
// - Very early chain (`block.number <= 256`) -> `blockhash` -> 0.
if (block.number < blockNumber + 257) return blockhash(blockNumber);
}
/// @solidity memory-safe-assembly
assembly {
Expand Down