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

eth_getBlockByNumber doesn't follow Ethereum JSON-RPC API specification #700

Closed
e00dan opened this issue Sep 13, 2022 · 4 comments
Closed
Assignees

Comments

@e00dan
Copy link

e00dan commented Sep 13, 2022

What happened:

Request:

{
	"jsonrpc":"2.0",
	"method":"eth_getBlockByNumber",
	"params":[
		"0x0", 
		false
	],
	"id":1
}

returns block with "nonce": "0x0".

This is crashing graph-node events indexer because it expects 8 bytes of hex-encoded data.

image

What you expected to happen:

Nonce should be 8 bytes data:
"nonce": "0x0000000000000000"

According to Ethereum JSON RPC specification nonce should be 8 bytes: "nonce: DATA, 8 Bytes - hash of the generated proof-of-work. null when its pending block."

Source: https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash

Additional information:

I think Axon doesn't pad hex values length to what Ethereum spec uses. eg. Axon returns nonce: 0x0 instead of Rinkeby nonce: "nonce": "0x0000000000000000" for Genesis block.

Axon genesis block:

{
    "jsonrpc": "2.0",
    "result": {
        "hash": "0x8ba3f664e40093323344a7a97a3705fc9948a440ed9d5ba10ad49d9cb9ccbdf0",
        "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "author": "0x0000000000000000000000000000000000000000",
        "miner": "0x0000000000000000000000000000000000000000",
        "stateRoot": "0x3afda6598cfc84363c343f4cf1ab7e65fdac504e38d0b3bddeab2c57158df9fc",
        "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "number": "0x0",
        "gasUsed": "0x0",
        "gasLimit": "0x0",
        "extraData": "0x",
        "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "timestamp": "0x61b828ca",
        "difficulty": "0x0",
        "totalDifficulty": null,
        "sealFields": [],
        "baseFeePerGas": "0x539",
        "uncles": [],
        "transactions": [
            "0xb517d9e01b5bebe8bf4bae42224635bb0926aadf520557a4636cd77e8ca1d36b",
            "0xfeee53ae26a79f83037a81f17125f413a516882591da36c6306988043d26d803",
            "0x7754489ee8b55755cf2624e0e1b5b5c671b95d9581932a6404cb177f985e4e38",
            "0x5b524e9de399d0095f3d7fe4b6953e18b25a4fe073b40d9f724d9f101a808fd0"
        ],
        "size": "0x220",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "nonce": "0x0"
    },
    "id": 1
}

Rinkeby genesis block:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "difficulty": "0x2",
        "extraData": "0xd783010600846765746887676f312e372e33856c696e7578000000000000000004ff37b6cf0d06c59dc22ae2084dcd97d400d913ac93506bf6bb9aeec2d2783649c74b1b2c809ba20174b73743dc2eb2b90ebf334786cba6983a3500422f9da701",
        "gasLimit": "0x47e7c4",
        "gasUsed": "0x0",
        "hash": "0x64c7de1f16e1af1a4df968340083b68e029907337ecb24dda695e4852fae9994",
        "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "miner": "0x0000000000000000000000000000000000000000",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "nonce": "0x0000000000000000",
        "number": "0x1b4",
        "parentHash": "0xef085723d86c56bd702e078308895e5c1131e7146377d2d492f5644fb467cda6",
        "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
        "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
        "size": "0x260",
        "stateRoot": "0x9853b6c62bd454466f4843b73e2f0bdd655a4e754c259d6cc0ad4e580d788f43",
        "timestamp": "0x58ee5f58",
        "totalDifficulty": "0x342",
        "transactions": [],
        "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
        "uncles": []
    }
}
@e00dan e00dan changed the title Graph-node fails to index Axon chain eth_getBlockByNumber doesn't follow Ethereum JSON-RPC API specification Sep 13, 2022
@KaoImin
Copy link
Contributor

KaoImin commented Sep 14, 2022

Thanks for your report. Please fix this issue @ImJeremyHe thx.

@ImJeremyHe
Copy link
Contributor

ImJeremyHe commented Sep 14, 2022

@kuzirashi Hello! Please pull the newest code. If the bug is still there, would you mind offering more details?
Branch: main@47d7fb8

curl 'http://127.0.0.1:8000/' \
  -H 'Accept: */*' \
  -H 'Accept-Language: zh-CN,zh;q=0.9' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json' \
  -H 'Origin: chrome-extension://coohjcphdfgbiolnekdpbcijmhambjff' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: none' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Chromium";v="104", " Not A;Brand";v="99", "Google Chrome";v="104"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --data-raw $'{\n\u0009"jsonrpc":"2.0",\n\u0009"method":"eth_getBlockByNumber",\n\u0009"params":[\n\u0009\u0009"0x0", \n\u0009\u0009false\n\u0009],\n\u0009"id":1\n}\n' \
  --compressed

Output:

{
    "jsonrpc": "2.0",
    "result": {
        "hash": "0x03b46bcebf4b6e984342f10211fb95c805044e85de1fd2c9de6c29e8f941c929",
        "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
        "author": "0x0000000000000000000000000000000000000000",
        "miner": "0x0000000000000000000000000000000000000000",
        "stateRoot": "0xdda84758b8397c4c86d4610fb98ee3dcd09cb92738a9ed64be715819ad585260",
        "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "number": "0x0",
        "gasUsed": "0x0",
        "gasLimit": "0x0",
        "extraData": "0x",
        "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "timestamp": "0x61b828ca",
        "difficulty": "0x0",
        "totalDifficulty": null,
        "sealFields": [],
        "baseFeePerGas": "0x539",
        "uncles": [],
        "transactions": [
            "0x3bbe1ebf56b864d91ff5d7505be6df8a13a232a3c5969b30ad5fd254226c6e6b",
            "0x01240fb109c0c9ca0c095542d04140cc00d13bb66dd262ec088ba1b27424c8ac",
            "0xdf58cdda98ae3139026750bda1e3100442b59f91e26b6adac5749e3b026219ef",
            "0xfcbd67037cb8789fcb215cabed5e60a66afec59698a36d2afaa0cda626d66f07",
            "0x41bdc59db755cd3da3f41c2fdaf936e16d16130b202a8fd3c608c06b14d243ce",
            "0xca338c9e4eb563817bc363a243602b30c5a9608d94e3a04f948f60d40fc127f8",
            "0x378803d6f9517956f38e67c773956cf646625775207080b237e82334cbebcdb2"
        ],
        "size": "0x222",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "nonce": "0x0000000000000000"
    },
    "id": 1
}

This PR seems to have fixed the bug you mentioned. #647

@e00dan
Copy link
Author

e00dan commented Sep 14, 2022

@ImJeremyHe

Oh, thank you for the information!

I've used Axon CLI for the test so maybe that's why I have older code. I will check the latest version!

@e00dan
Copy link
Author

e00dan commented Sep 14, 2022

It is working. Thank you.

image

@e00dan e00dan closed this as completed Sep 14, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants