Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas meter shows huge number when using vm.pauseGasMetering() along with delete X #4370

Closed
2 tasks
Tudmotu opened this issue Feb 16, 2023 · 0 comments · Fixed by #8743
Closed
2 tasks

Gas meter shows huge number when using vm.pauseGasMetering() along with delete X #4370

Tudmotu opened this issue Feb 16, 2023 · 0 comments · Fixed by #8743
Labels
A-cheatcodes Area: cheatcodes C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug
Milestone

Comments

@Tudmotu
Copy link
Contributor

Tudmotu commented Feb 16, 2023

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (25fcfef 2023-02-11T00:08:44.860915008Z)

What command(s) is the bug in?

forge test

Operating System

Linux

Describe the bug

Not sure exactly what is happening, but it seems like an integer overflow of some sort.

In one of my tests I am using vm.pauseGasMetering()/vm.resumeGasMetering() while also removing data from the storage.

Here is the simplest reproduction I could find:

pragma solidity ^0.8.18;

import 'forge-std/Test.sol';

contract NegativeGasTest is Test {
    uint a;

    function test_negativeGas () public {
        vm.pauseGasMetering();
        a = 100;
        vm.resumeGasMetering();

        delete a;
    }
}

The output of forge test looks like this:

[⠒] Compiling...
[⠔] Compiling 1 files with 0.8.18
[⠒] Solc 0.8.18 finished in 311.19ms
Compiler run successful

Running 1 test for test/negative-gas/Test.sol:NegativeGasTest
[PASS] test_negativeGas() (gas: 18446744073709549969)
Test result: ok. 1 passed; 0 failed; finished in 166.78µs

If there are any pointers to where the issue might be, I wouldn't mind trying to fix this myself and send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants