Skip to content

Gas discrepancies between debug_traceCallMany and debug_traceTransaction #6373

@ArielTM

Description

@ArielTM

System information

Erigon version: ./erigon --version
erigon version 2.30.0-stable-35f493c5

OS & Version: Windows/Linux/OSX
Linux - Ubuntu 22.04.1 LTS aarch64

Commit hash :
commit 35f493c (HEAD, tag: v2.30.0, origin/stable)

Expected behaviour

Running debug_traceTransaction on an Ethereum Mainnet hash and debug_traceCallMany with the exact same parameters as the original Tx should produce the same structLogs, specifically the same gas consumption.

Actual behaviour

Some SSTORE opcodes have different gas consumption

Steps to reproduce the behaviour

Following 0x3db346e92e27ba7e887fab489420717f4736ddf39da50a1c6296e66b4d5552a2
(I'm using web3py)

Running with debug_traceCallMany

res = w3.provider.make_request(
    "debug_traceCallMany",
    [
        [
            {
                "transactions": [
                    {
                        "from": "0x2a69eea945305057a8f2904be9ace3b199e0f72d",
                        "to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                        "gas": hex(97584),
                        "gasPrice": hex(146000000000),
                        "data": data,
                    }
                ],
            }
        ],
        {"blockNumber": hex(13682451), "transactionIndex": 18},
        {},
    ],
)

Running also with debug_traceTransaction

res2 = w3.provider.make_request(
    "debug_traceTransaction",
    ["0x3db346e92e27ba7e887fab489420717f4736ddf39da50a1c6296e66b4d5552a2"],
)

Checking the SSTORE in position 434 at PC 15633

We can see the following:

res['result'][0][0]['structLogs'][434]['gasCost'] = 100  # debug_traceCallMany
res2['result']['structLogs'][434]['gasCost'] = 2900  # debug_traceTransaction

For some reason, the two calculation fall in different flows of SSTORE gas cost calculation:
https://github.com/wolflo/evm-opcodes/blob/main/gas.md#a7-sstore

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions