You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import {Test} from"forge-std/Test.sol";
contractSkipTestisTest {
function testSkip() public {
uint256 value =block.timestamp;
emitlog_uint(value);
skip(1);
emitlog_uint(value);
}
}
When compiling with via_ir = true, the output is:
[PASS] testSkip() (gas: 5134)
Logs:
1
2
Solidity seems to make an assumption that block.timestamp never changes during a call, so it doesn't make sense to actually store it in a variable. It makes perfect sense to optimize away the stack storage of a constant, but it breaks test EVMs with changeable timestamps.
I'm not sure if this is solveable in Foundry, it may be a Solidity issue. OTOH it's overall a good optimization, it breaks only with Foundry's test framework architecture, why should every DeFi user in the world pay gas for that?
The text was updated successfully, but these errors were encountered:
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (3a462eb 2022-09-22T00:05:16.281308046Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
I have a trivial test:
When compiling with
via_ir = true
, the output is:Solidity seems to make an assumption that
block.timestamp
never changes during a call, so it doesn't make sense to actually store it in a variable. It makes perfect sense to optimize away the stack storage of a constant, but it breaks test EVMs with changeable timestamps.I'm not sure if this is solveable in Foundry, it may be a Solidity issue. OTOH it's overall a good optimization, it breaks only with Foundry's test framework architecture, why should every DeFi user in the world pay gas for that?
The text was updated successfully, but these errors were encountered: