op-geth icon indicating copy to clipboard operation
op-geth copied to clipboard

eth_getBlockByNumber vs eth_getBlockByHash responses discrepancies

Open yaanakbr opened this issue 1 year ago • 2 comments

We are running a curl request for eth_getBlockByNumber vs eth_getBlockByHash responses, For block 46772657, there is one transaction in the block. However, eth_getBlockByHash returns a chainId field in the transaction while eth_getBlockByNum does not return chainId field in the transaction.

Do you know why there is a difference for this block?

RPC backend version: Geth/v0.1.0-unstable-0a77db9c/linux-amd64/go1.20.1

curl request eth_getBlockByNumber:

curl -s https://<QUIKNODE-ENDPOINT>/XXX -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBlockByNumber", "params": ["0x2c9b1b1", true] }'

response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "difficulty": "0x2",
    "extraData": "0xd98301090a846765746889676f312e31352e3133856c696e7578000000000000cebb9731665fbaa5bad7259f336e0e3bc3f4235bd023d41269ef1d692272ab932efd94784330c27ffeece1cb02bdd868baae3acc1684e120ce1c1545df7ad9b601",
    "gasLimit": "0xe4e1c0",
    "gasUsed": "0x5208",
    "hash": "0xf58a82de42a8b12dd5bb9e0aee47ba9512832309e629027b81b5f23dcb4b3e71",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "miner": "0x0000000000000000000000000000000000000000",
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce": "0x0000000000000000",
    "number": "0x2c9b1b1",
    "parentHash": "0x454badb331c9cb14ae6897530011081492a3e58c47a364a6f62ce416dcf64a8c",
    "receiptsRoot": "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": "0x2d0",
    "stateRoot": "0x5307c8b991a8cf03eabfb96f1e0b8a05b0dc423734f759a39a4f9716de2bbaa0",
    "timestamp": "0x6391d861",
    "totalDifficulty": "0x5936363",
    "transactions": [
      {
        "blockHash": "0xf58a82de42a8b12dd5bb9e0aee47ba9512832309e629027b81b5f23dcb4b3e71",
        "blockNumber": "0x2c9b1b1",
        "from": "0xb20c8dca769b63314d1965cebedb87e2a3a70715",
        "gas": "0x5208",
        "gasPrice": "0x10c8e0",
        "hash": "0x8fb278a0ecaeaa660fd88c794dc51a1940cf9832ca543332e59ef3691d7680b7",
        "input": "0x",
        "nonce": "0xb",
        "to": "0x6abf790d3b4a80ebfce25dccbfa07f6f8e5cab1a",
        "transactionIndex": "0x0",
        "value": "0x3c6568f12e8000",
        "v": "0x38",
        "r": "0xf4f4795c43f3699e2b2fe3fe629f11d274ed4252c6052015b9bc10182b3ab6c6",
        "s": "0x68c5a331660b592d50ddd670a8df8953f75b8b71adb1dfe4febc47771f2a4e18",
        "queueOrigin": "sequencer",
        "l1TxOrigin": null,
        "l1BlockNumber": "0xf646a0",
        "l1Timestamp": "0x6391d861",
        "index": "0x2c9b1b0",
        "queueIndex": null,
        "rawTransaction": "0xf8690b8310c8e0825208946abf790d3b4a80ebfce25dccbfa07f6f8e5cab1a873c6568f12e80008038a0f4f4795c43f3699e2b2fe3fe629f11d274ed4252c6052015b9bc10182b3ab6c6a068c5a331660b592d50ddd670a8df8953f75b8b71adb1dfe4febc47771f2a4e18"
      }
    ],
    "transactionsRoot": "0x8917ef36a9e241c2cfc48d5fa49afef55c9638c70a73295c263d6f9283931a9a",
    "uncles": []
  }
}

curl request eth_getBlockByHash:

curl -s https://<QUIKNODE-ENDPOINT>/XXX -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 1, "method": "eth_getBlockByHash", "params": ["0xf58a82de42a8b12dd5bb9e0aee47ba9512832309e629027b81b5f23dcb4b3e71", true] }' 

response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "difficulty": "0x2",
    "extraData": "0xd98301090a846765746889676f312e31352e3133856c696e7578000000000000cebb9731665fbaa5bad7259f336e0e3bc3f4235bd023d41269ef1d692272ab932efd94784330c27ffeece1cb02bdd868baae3acc1684e120ce1c1545df7ad9b601",
    "gasLimit": "0xe4e1c0",
    "gasUsed": "0x5208",
    "hash": "0xf58a82de42a8b12dd5bb9e0aee47ba9512832309e629027b81b5f23dcb4b3e71",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "miner": "0x0000000000000000000000000000000000000000",
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce": "0x0000000000000000",
    "number": "0x2c9b1b1",
    "parentHash": "0x454badb331c9cb14ae6897530011081492a3e58c47a364a6f62ce416dcf64a8c",
    "receiptsRoot": "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": "0x2d0",
    "stateRoot": "0x5307c8b991a8cf03eabfb96f1e0b8a05b0dc423734f759a39a4f9716de2bbaa0",
    "timestamp": "0x6391d861",
    "totalDifficulty": "0x5936363",
    "transactions": [
      {
        "blockHash": "0xf58a82de42a8b12dd5bb9e0aee47ba9512832309e629027b81b5f23dcb4b3e71",
        "blockNumber": "0x2c9b1b1",
        "from": "0xb20c8dca769b63314d1965cebedb87e2a3a70715",
        "gas": "0x5208",
        "gasPrice": "0x10c8e0",
        "hash": "0x8fb278a0ecaeaa660fd88c794dc51a1940cf9832ca543332e59ef3691d7680b7",
        "input": "0x",
        "nonce": "0xb",
        "to": "0x6abf790d3b4a80ebfce25dccbfa07f6f8e5cab1a",
        "transactionIndex": "0x0",
        "value": "0x3c6568f12e8000",
        "type": "0x0",
        "chainId": "0xa",
        "v": "0x38",
        "r": "0xf4f4795c43f3699e2b2fe3fe629f11d274ed4252c6052015b9bc10182b3ab6c6",
        "s": "0x68c5a331660b592d50ddd670a8df8953f75b8b71adb1dfe4febc47771f2a4e18"
      }
    ],
    "transactionsRoot": "0x8917ef36a9e241c2cfc48d5fa49afef55c9638c70a73295c263d6f9283931a9a",
    "uncles": []
  }
}

Thanks for the help in advance! :)

yaanakbr avatar Jul 25 '23 17:07 yaanakbr

I did start this conversation here:

https://github.com/ethereum-optimism/optimism/issues/6107#issuecomment-1603313548

But from what I read correctly, I was told to bring it up w/ geth so I am bringing this issue here :)

yaanakbr avatar Jul 25 '23 17:07 yaanakbr

chainId is missing in the response object, this is most likely due to client implementation differing from the execution spec. The latest release of geth, v1.13.12 has fixes to make the RPC conformant to the execution specification, probably fixed now.

sambacha avatar Feb 13 '24 20:02 sambacha