paradigmxyz / reth

Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust
https://reth.rs/
Apache License 2.0
3.94k stars 1.17k forks source link

JSON-RPC: eth_getBalance Inconsistency #10682

Open ZzPoLariszZ opened 2 months ago

ZzPoLariszZ commented 2 months ago

Describe the bug

The balance of the given address requested from Reth is different from QuickNode and Infura

Steps to reproduce

curl http://localhost:8545 \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"method":"eth_getBalance","params":["0x0000000000000000000000000000000000000000", "0x1306D3B"],"id":1,"jsonrpc":"2.0"}'

From Reth

The result is 0x2d50d3b2d7840cb6d76 (13374842859180050312566)

From QuickNode and Infura

The result is 0x2d47a18b5b27a27e0ac (13364240691015941873836)

Node logs

No response

Platform(s)

Linux (x86)

What version/commit are you on?

reth Version: 1.0.6

What database version are you on?

Current database version: 2 Local database version: 2

Which chain / network are you on?

mainnet

What type of node are you running?

Archive (default)

What prune config do you use, if any?

No response

If you've built Reth from source, provide the full command you used

No response

Code of Conduct

ZzPoLariszZ commented 2 months ago

The inconsistency starts from Block 19879895

Reth balance at 19879894: 13361851371947497370023 Geth balance at 19879894: 13361851371947497370023

Reth balance at 19879895: 13371549989026870435183 Geth balance at 19879895: 13361851371947497370024

The related transaction 0x82f5cc4aaf9c6d006c2535be5d95ff387dbd65749763cfbe8d52f595e0fbe666

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open for 21 days with no activity.

jsvisa commented 2 weeks ago

reproduced on reth v1.1.0, try to find the causes

jsvisa commented 2 weeks ago

After some digging, in my node, the first discrepancy of the 0x0000000000000000000000000000000000000000's balance occured in block 17455888, diffs as below:

blknum,reth,erigon
...
17455886,11734187543945161994027,11734187543945161994027
17455887,11734187543945161994027,11734187543945161994027
17455888,13397775667035432152370,11734199307305109737224
17455889,13397775667035432152370,11734199307305109737224
...

Then I used prestateTracer to find which tx leads to this discrepancy, but the results of reth and erigon are the same, RPC as below:

{
  "jsonrpc": "2.0",
  "method": "debug_traceBlockByNumber",
  "id": 67,
  "params": [
    "0x10a5b10",
    {
      "tracer": "prestateTracer",
      "tracerConfig": {"diffMode": true}
    }
  ]
}

So seems the pre and the calculated post state are correct, but the post state persisted into disk maybe corrupted?

alexlee85 commented 3 days ago

same problem here, any progress?