Inconsistent `totalDifficulty` value from `eth_getBlockByNumber` method
NikitosnikN opened this issue · comments
System information
Erigon version: erigon version 1.1.12-dev-376131b1
OS & Version: Linux
Erigon Command (with flags/config):
erigon --chain=bsc --datadir=/home/erigon/persistence/data --http.addr=0.0.0.0 --rpc.accessList=/home/erigon/acl-config/acl.json --rpc.batch.limit=1000 --http.api=eth,erigon,web3,net,debug,txpool,trace --http.vhosts=* --http.corsdomain=null --http --ws --db.pagesize=4096 --ethash.dagdir=/home/erigon/persistence/dag --maxpeers=100 --private.api.addr=0.0.0.0:9090 --private.api.ratelimit=31872 --rpc.returndata.limit=150000 --metrics --metrics.addr=0.0.0.0 --healthcheck --port=30303 --snap.stop --snapshots=false --torrent.download.rate=512mb --torrent.download.slots=5 --sentry.drop-useless-peers --db.size.limit=8TB --no-downloader --downloader.disable.ipv4 --downloader.disable.ipv6
Concensus Layer: nimbus
Chain/Network: bsc-mainnet
Description
on multiple eth_getBlockByNumber
requests to the same block erigon client is returning inconsistent totalDifficulty
value
Expected behaviour
return consistent totalDifficulty
field value to the same block
origin erigon, bsc geth and original geth are working as expected
Actual behaviour
value is different on several requests to node
Steps to reproduce the behaviour
python script (also can be reproduced with any http client including curl)
script:
def main(url):
import requests
latest = requests.post(url, json={
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["latest", False],
"id": 1,
}).json()["result"]
by_number = requests.post(url, json={
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": [latest["number"], False],
"id": 1,
}).json()["result"]
by_number_2 = requests.post(url, json={
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": [latest["number"], False],
"id": 1,
}).json()["result"]
by_number_3 = requests.post(url, json={
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": [latest["number"], False],
"id": 1,
}).json()["result"]
print("latest: ", latest["number"], latest["totalDifficulty"])
print("by_number: ", by_number["number"], by_number["totalDifficulty"])
print("by_number_2: ", by_number_2["number"], by_number_2["totalDifficulty"])
print("by_number_3: ", by_number_3["number"], by_number_3["totalDifficulty"])
example result:
latest: 0x21bd42f 0xa48b1
by_number: 0x21bd42f 0x975b1
by_number_2: 0x21bd42f 0xe3407
by_number_3: 0x21bd42f 0x975b1
Reproduced, will follow
Use the latest commit, run integration stage_headers --reset. And than restart.
Reopen if still have some problem
we have the same issue: example request
{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x21e18f5",true],"id":1}
response:
"totalDifficulty": "0xec855"
should be
"totalDifficulty": "0x434fc36"
Use the latest commit in devel branch and then integration stage_headers --reset
now it is truncating blocks, we were pointing to the wrong directory where the database is not, but an error did not appear, it would be ideal to add an error if the DB is not found when running "integration stage_headers --reset"