Fast node returns wrong state siliently
System information
Geth version: geth_linux version 1.3.9-5e74ea65-20240220
OS & Version: Linux
Command line:
--syncmode full --datadir /work/data --cache 8000 --rpc.allow-unprotected-txs
--history.transactions 0
--ws --ws.addr 0.0.0.0 --ws.api net,web3,eth --ws.port 8556 --ws.origins *
--http --http.addr 0.0.0.0
--http.api net,web3,eth
--http.port 8555
--http.vhosts *
--db.engine=pebble
--verbosity 4
--tries-verify-mode=none
Expected behaviour
Return missing trie root or some other error.
Actual behaviour
Return 0
Steps to reproduce the behaviour
curl -H 'Content-Type: application/json' -X POST --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0x00020F14443e103A0B72F1f2DFDaac07DDAa6Df5", "0x0", "0x237f199"], "id": 1}' http://127.0.0.1:8555
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000002704c6f721947"}
After 0x237f199 falls 128 blocks behind, executing the same command.
curl -H 'Content-Type: application/json' -X POST --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0x00020F14443e103A0B72F1f2DFDaac07DDAa6Df5", "0x0", "0x237f199"], "id": 1}' http://127.0.0.1:8555
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000000"}
The state silently changes. I would expect something like missing trie node
noted, thank you for your feedback, we will fix it.
The reason why 0x00...00 is returned is that the snap layer specified has expired (i.e. after 128 blocks), so the program will read from an empty trie since it's a fast node. Attempting to retrieve a value from an empty trie will return 0x00...00 by default instead of an error.
So the state doesn't change, it's just that the specified snap layer is missing.
The reason why
0x00...00is returned is that the snap layer specified has expired (i.e. after 128 blocks), so the program will read from an empty trie since it's a fast node. Attempting to retrieve a value from an empty trie will return0x00...00by default instead of an error.So the state doesn't change, it's just that the specified snap layer is missing.
Is it ok to return error for accessing missed layer? instead of return 0x00...00
I think it's possible to add a check at the API layer, rather than modifying the database layer. Let me quickly prepare a draft PR.