From 051fb65fc46013dff64e46ca410445d63ea5620a Mon Sep 17 00:00:00 2001 From: "A.L." Date: Thu, 5 Dec 2024 02:15:24 +0800 Subject: [PATCH] fix: use `vm.getBlockTimestamp` for `skip` and `rewind` (#634) Given that during `via-ir` compilations, the `block.timestamp` variable might be distorted due to optimizations, the more correct way to obtain the block timestamp. See [this discussion](https://github.com/foundry-rs/foundry/issues/1373#issuecomment-2485290776) --- src/StdCheats.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/StdCheats.sol b/src/StdCheats.sol index 95850d11..051ef71b 100644 --- a/src/StdCheats.sol +++ b/src/StdCheats.sol @@ -645,11 +645,11 @@ abstract contract StdCheats is StdCheatsSafe { // Skip forward or rewind time by the specified number of seconds function skip(uint256 time) internal virtual { - vm.warp(block.timestamp + time); + vm.warp(vm.getBlockTimestamp() + time); } function rewind(uint256 time) internal virtual { - vm.warp(block.timestamp - time); + vm.warp(vm.getBlockTimestamp() - time); } // Setup a prank from an address that has some ether