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

Incorrect balance stateDiff for trace_call #7200

Closed
qk-santi opened this issue Mar 28, 2023 · 6 comments · Fixed by #11813
Closed

Incorrect balance stateDiff for trace_call #7200

qk-santi opened this issue Mar 28, 2023 · 6 comments · Fixed by #11813
Assignees

Comments

@qk-santi
Copy link

System information

Erigon version: erigon/2.40.1

OS & Version: Linux

Chain/Network: ethereum mainnet

Expected behaviour

curl http://ERIGON_IP -X POST \
--header 'Content-Type: application/json' \
--data '{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "trace_call",
    "params": [
        {
            "data": "0x095ea7b3000000000000000000000000444444444444444444444444444444444444444400000000000000000000000000000000000000000000000000000002540be400",
            "from": "0x22810f72f09475db64c9d2ece70af42c46daa382",
            "to": "0x6b175474e89094c44da98b954eedeac495271d0f",
            "value": "0x0"
        },
        [
            "stateDiff",
            "trace"
        ],
        "latest"
    ]
}

Eth balance to be static, so this line in stateDiff

            "balance": "=",

Output from Nethermind:

{
  "jsonrpc": "2.0",
  "result": {
    "output": "0x0000000000000000000000000000000000000000000000000000000000000001",
    "stateDiff": {
      "0x22810f72f09475db64c9d2ece70af42c46daa382": {
        "balance": "=",
        "code": "=",
        "nonce": {
          "*": {
            "from": "0x45",
            "to": "0x46"
          }
        },
        "storage": {}
      },
      "0x6b175474e89094c44da98b954eedeac495271d0f": {
        "balance": "=",
        "code": "=",
        "nonce": "=",
        "storage": {
          "0xdc081208ef88f431946b370c4326b00ab68cdb0a56d5a9cdab330ab591b0f4fb": {
            "*": {
              "from": "0x0000000000000000000000000000000000000000000000000000000000000000",
              "to": "0x00000000000000000000000000000000000000000000000000000002540be400"
            }
          }
        }
      }
    },
    "trace": [
      {
        "action": {
          "callType": "call",
          "from": "0x22810f72f09475db64c9d2ece70af42c46daa382",
          "gas": "0x23c2f198",
          "input": "0x095ea7b3000000000000000000000000444444444444444444444444444444444444444400000000000000000000000000000000000000000000000000000002540be400",
          "to": "0x6b175474e89094c44da98b954eedeac495271d0f",
          "value": "0x0"
        },
        "result": {
          "gasUsed": "0x5fc2",
          "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
        },
        "subtraces": 0,
        "traceAddress": [],
        "type": "call"
      }
    ],
    "vmTrace": null
  },
  "id": 1
}

Actual behaviour

It indicates an Eth balance change on the wallet, which shouldn't exist:

            "balance": {
                "*": {
                    "from": "0xdb41af42d950ca",
                    "to": "0x12294729269af74f8"

Complete Erigon response:

{
    "output": "0x0000000000000000000000000000000000000000000000000000000000000001",
    "stateDiff": {
        "0x22810f72f09475db64c9d2ece70af42c46daa382": {
            "balance": {
                "*": {
                    "from": "0xdb41af42d950ca",
                    "to": "0x12294729269af74f8"
                }
            },
            "code": "=",
            "nonce": {
                "*": {
                    "from": "0x45",
                    "to": "0x46"
                }
            },
            "storage": {}
        },
        "0x6b175474e89094c44da98b954eedeac495271d0f": {
            "balance": "=",
            "code": "=",
            "nonce": "=",
            "storage": {
                "0xdc081208ef88f431946b370c4326b00ab68cdb0a56d5a9cdab330ab591b0f4fb": {
                    "*": {
                        "from": "0x0000000000000000000000000000000000000000000000000000000000000000",
                        "to": "0x00000000000000000000000000000000000000000000000000000002540be400"
                    }
                }
            }
        }
    },
    "trace": [
        {
            "action": {
                "callType": "call",
                "from": "0x22810f72f09475db64c9d2ece70af42c46daa382",
                "gas": "0x8000000041905699",
                "input": "0x095ea7b3000000000000000000000000444444444444444444444444444444444444444400000000000000000000000000000000000000000000000000000002540be400",
                "to": "0x6b175474e89094c44da98b954eedeac495271d0f",
                "value": "0x0"
            },
            "result": {
                "gasUsed": "0x5fc2",
                "output": "0x0000000000000000000000000000000000000000000000000000000000000001"
            },
            "subtraces": 0,
            "traceAddress": [],
            "type": "call"
        }
    ],
    "vmTrace": null
}

Steps to reproduce the behaviour

As you can see, the wallet Eth balance from the calling wallet 0x22810... went from 0xdb41af42d950ca to 0x12294729269af74f8 (from 0.061 to 20.94 ETH)

The decoded transaction data is just an approve method, so we wouldn't expect any balance change when using trace_call.

{
  "method": "approve",
  "types": [
    "address",
    "uint256"
  ],
  "inputs": [
    "4444444444444444444444444444444444444444",
    {
      "type": "BigNumber",
      "hex": "0x02540be400"
    }
  ],
  "names": [
    "usr",
    "wad"
  ]
}
@github-actions
Copy link

github-actions bot commented May 8, 2023

This issue is stale because it has been open for 40 days with no activity. Remove stale label or comment, or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label May 8, 2023
@qk-santi
Copy link
Author

qk-santi commented May 8, 2023

Keeping this open

@github-actions github-actions bot removed the Stale label May 9, 2023
@github-actions
Copy link

This issue is stale because it has been open for 40 days with no activity. Remove stale label or comment, or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jun 18, 2023
@qk-santi
Copy link
Author

Keeping this open

@github-actions github-actions bot removed the Stale label Jun 19, 2023
@github-actions
Copy link

github-actions bot commented Aug 5, 2023

This issue is stale because it has been open for 40 days with no activity. Remove stale label or comment, or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Aug 5, 2023
@qk-santi
Copy link
Author

qk-santi commented Aug 5, 2023

Keeping this open

@github-actions github-actions bot removed the Stale label Aug 29, 2023
@yperbasis yperbasis self-assigned this Jun 25, 2024
@VBulikov VBulikov assigned somnathb1 and unassigned yperbasis Aug 30, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants