aleth icon indicating copy to clipboard operation
aleth copied to clipboard

Hexadecimal block number in RPC methods

Open gumb0 opened this issue 5 years ago • 1 comments

  1. When retesteth requests accounts for block 0x1 (it does when its verbosity >= 5 and some test fails), confusing error is returned:
TRACE 11-11 19:39:22 aleth rpc    {"jsonrpc":"2.0","method":"debug_accountRange","params":["0x1", 1, "", 20],"id":8}
DEBUG 11-11 19:39:22 aleth overlaydb Closing state DB
DEBUG 11-11 19:39:22 aleth overlaydb Closing state DB
TRACE 11-11 19:39:22 aleth rpc    {"error":{"code":0,"data":null,"message":"Transaction index 1 out of range (0) for block 0x1"},"id":8,"jsonrpc":"2.0"}

It silently fails when converting 0x1 to block number with stoul here and returns 0: https://github.com/ethereum/aleth/blob/86aa9a3998ee700693fe16fcce37c527af3fb5f7/libweb3jsonrpc/Debug.cpp#L40

We should check what geth does and either parse it right, or return an error.

(I've checked only geth's eth_getBlockByNumber - it rejects hexadecimal of 1 digit, and debug_storageRangeAt - it seems to accept only block hash, not number)

eth_getBlockByNumber converts 0x1 to some random block number (1216253)

> eth.getBlock("0x1")
{
  author: "0x0000000000000000000000000000000000000000",
  boundary: "0x00000000000e4abdeb970e9496647ffc11155b9bc95c1af799b109d0e6b1ce30",
  difficulty: 19694637249279,
  extraData: "",
  gasLimit: 4707788,
  gasUsed: 0,
  hash: "0xad5a05a780e6a8f325362163970d3cbf7f5d9ea4e9dcc2f04fdc2b82ecb053b6",
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  miner: "0x0000000000000000000000000000000000000000",
  mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
  nonce: "0x0000000000000000",
  number: 1216253,
  parentHash: "0xa765f5b858d625059a27ba215a0cf21a80aa22869253a433034c2a391fa2b9c7",
  receiptsRoot: "0x0000000000000000000000000000000000000000000000000000000000000000",
  seedHash: "0x03b8bc47a10d1baa4dd4a339885fdc60d72cf40e32dddf3c0bb9d6da54ebe597",
  sha3Uncles: "0x0000000000000000000000000000000000000000000000000000000000000000",
  size: 0,
  stateRoot: "0x46398bbc2c3dc4ec70d1a2ca81e25c13a68c7fe9f49e66ff2473be59c6ff3ce1",
  timestamp: 1573497450,
  totalDifficulty: 1.15792089237316195423570985008687907853269984665640564039457584007913129639935e+77,
  transactions: [],
  transactionsRoot: "0x0000000000000000000000000000000000000000000000000000000000000000",
  uncles: []
}

gumb0 avatar Nov 11 '19 18:11 gumb0

@winsvega reports that 1 works in geth

Request: {"jsonrpc":"2.0","method":"debug_accountRange","params":["0x1", 1, "0", 100],"id":167}
Reply: {"jsonrpc":"2.0","id":167,"result":{"addressMap":{"0x1468288056310c82aa4c01a7e12a10f8111a0560e72b700555479031b86c357d":"0x0000000000000000000000000000000000000001","0x3772f07c10e1682f17b777a5645c4acaa3a3d9059df8c799dd0911e795a2aabb":"0xc305c901078781c232a2a521c2af7980f8385ee9","0x421df1fa259221d02aa4956eb0d35ace318ca24c0a33a64c1af96cf67cf245b6":"0x0000000000000000000000000000000000000005","0x471703c5eda8644a64cec152c58f5aacec93d72fb0bfa705f0473f9043a8357c":"0x0000000000000000000000000000000000000008","0x5b70e80538acdabd6137353b0f9d8d149f4dba91e8be2e7946e409bfdbe685b9":"0x0000000000000000000000000000000000000003","0x5c1ec1e3d18baf1f2b3cffa3877fd84acf3817659b07bac788725eb0714c2054":"0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1","0x689802d6ed1a28b049e9d4fe5334c5902fd9bc00c42821c82f82ee2da10be908":"0x0000000000000000000000000000000000000006","0x8c3ab0970b73895b8c9959bae685c3a19f45eb5ad89d42b52a340ec4ac204d19":"0x0000000000000000000000000000000000000007","0xa876da518a393dbd067dc72abfa08d475ed6447fca96d92ec3f9e7eba503ca61":"0x0000000000000000000000000000000000000004","0xc914adb94bfc1f1a197995efb70b8f67931012bd27f0562f4855444e240bc012":"0x3535353535353535353535353535353535353535","0xd52688a8f926c816ca1e079067caba944f158e764817b83fc43594370ca9cf62":"0x0000000000000000000000000000000000000002"},"nextKey":"0x0000000000000000000000000000000000000000000000000000000000000000"}}

gumb0 avatar Nov 11 '19 19:11 gumb0