foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.12k stars 1.68k forks source link

bug(debugger): layout displays the wrong SSTORE and JUMP opcode cost #6433

Open alex0207s opened 9 months ago

alex0207s commented 9 months ago

Component

Forge

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

What version of Foundry are you on?

forge 0.2.0 (55dd5de 2023-11-24T00:21:15.586516000Z)

What command(s) is the bug in?

forge debug

Operating System

macOS (Apple Silicon)

Describe the bug

Repro example

Paste the contract setNumber.sol in src folder

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

contract SetNumber {
    uint256 num = 1;

    function setNumber(uint256 _num) external payable {
        num = _num;
    }
}

Run:

forge debug src/setNumber.sol --sig "setNumber(uint256)" 0

In the debugger layout, the SSTORE and JUMP opcode are 3969 and 6 gas, respectively.

screenshot

Issues Identified:

Additional Info

Further Question

Is there a way to include intrinsic gas when calculating the refund gas or even include it in the gas report?

zerosnacks commented 2 months ago

Able to reproduce with given setup, values have remained the same since the report