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_getLogs returns wrong blockHash #208

Closed
gzliudan opened this issue Nov 17, 2022 · 6 comments
Closed

eth_getLogs returns wrong blockHash #208

gzliudan opened this issue Nov 17, 2022 · 6 comments

Comments

@gzliudan
Copy link
Collaborator

gzliudan commented Nov 17, 2022

Now the rpc node of xinfin blockchain returns wrong blockHash when call method eth_getLogs. Below is an example:

request:

curl -s -X POST https://arpc.apothem.network/ -H "Content-Type: application/json" -d '
{
    "id": 1610,
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [
        {
            "address": "0x53350795c11cee781a7e174479778f848d76ab2a",
            "fromBlock": "0x22b2277",
            "toBlock": "0x22b2277",
            "topics": [
                [
                    "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                    "0x6a12b3df6cba4203bd7fd06b816789f87de8c594299aed5717ae070fac781bac"
                ]
            ]
        }
    ]
}' | jq

response:

{
  "jsonrpc": "2.0",
  "id": 1610,
  "result": [
    {
      "address": "xdc53350795c11cee781a7e174479778f848d76ab2a",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
        "0x0000000000000000000000000000000000000000000000000000000000000000",
        "0x000000000000000000000000ce77393582d39048a4fc73770ab19d2b239c45dd"
      ],
      "data": "0x000000000000000000000000000000000000000000084595161401484a000000",
      "blockNumber": "0x22b2277",
      "transactionHash": "0xbebc0bab1a0f9844b86b8edf3a169bb1eef9337ac8d2684d5ae758b6521c12fe",
      "transactionIndex": "0x1",
      "blockHash": "0x194a513ea40c94fccaca470cccb24c2ff3bd6398dec9a04e3eb3a4bfef8a330e",
      "logIndex": "0x2",
      "removed": false
    }
  ]
}

The right blockHash shoud be 0xe8ec0bfc021f839fd0a69ae89689e309632af2cc434e8a096732068f0736864b according to https://explorer.apothem.network/blocks/0x22b2277#transactions. The blockHash 0x194a513ea40c94fccaca470cccb24c2ff3bd6398dec9a04e3eb3a4bfef8a330e in response is wrong.

@simone1999
Copy link

I'm running into the same issues, which makes multiple applications I want to set up for the XDC network crash. The Block hashes actually seem random and are also not the parent hashes or comparable.

@gzliudan
Copy link
Collaborator Author

gzliudan commented Feb 10, 2023

Gnosis safe and graph-node use eth_getLogs and eth_getBlockByHash method also. This bug should be fixed.

@gzliudan
Copy link
Collaborator Author

gzliudan commented Feb 13, 2023

It seems this bug disappeared from one block number. For example, The blockHash of block number 45204373 / 0x2b1c395 is 0xeff3b01cb14bd7eaaaf3972249be2b69cea6724acb0949751c29c57bd675ab47.

1677147827602

And below command returns right blockHash now.
request

curl -s -X POST https://erpc.apothem.network/  -H "Content-Type: application/json" -d '
{
    "id": 1610,
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [
        {
            "address": "0x53350795c11cee781a7e174479778f848d76ab2a",
            "fromBlock": "0x2b1c395",
            "toBlock": "0x2b1c395",
            "topics": [
                [
                    "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                    "0x6a12b3df6cba4203bd7fd06b816789f87de8c594299aed5717ae070fac781bac"
                ]
            ]
        }
    ]
}' | jq

response

{
  "jsonrpc": "2.0",
  "id": 1610,
  "result": [
    {
      "address": "0x53350795c11cee781a7e174479778f848d76ab2a",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
        "0x000000000000000000000000d4ce02705041f04135f1949bc835c1fe0885513c",
        "0x00000000000000000000000085f33e1242d87a875301312bd4ebaee8876517ba"
      ],
      "data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
      "blockNumber": "0x2b1c395",
      "transactionHash": "0x2a70ccf516712fd885dd1bf3e45cb6f0b75dd3dd7ad09c747b7798c081ccdca9",
      "transactionIndex": "0x1",
      "blockHash": "0xeff3b01cb14bd7eaaaf3972249be2b69cea6724acb0949751c29c57bd675ab47",
      "logIndex": "0x1",
      "removed": false
    }
  ]
}

1677147894023

But the older block number of this JSONRPC still returns wrong blockHash, such as 36381303.

@simone1999
Copy link

if there is any way we can support this, let us know. This issue really would be great to get fixed as it's holding a lot of our developments back. We also run a mainnet full and archive node, so if access to it helps, I can generate a URL for you to access it.

@gzliudan
Copy link
Collaborator Author

gzliudan commented Feb 13, 2023

Here is another test case. The hash of block 45631260 / 0x2b8471c is 0xd10ca14840489e88070508428fed14f96e39ad20cc524468a0d54a221b9b87e1 according to explorer.

1677147680005

Request:

curl -s -X POST https://erpc.apothem.network/ -H "Content-Type: application/json" -d '
{
    "id": 1610,
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [
        {
            "address": "0x2a5c77b016df1b3b0ae4e79a68f8adf64ee741ba",
            "fromBlock": "0x2b8471c",
            "toBlock": "0x2b8471c",
            "topics": [
                [
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
                ]
            ]
        }
    ]
}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 1610,
  "result": [
    {
      "address": "0x2a5c77b016df1b3b0ae4e79a68f8adf64ee741ba",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
        "0x000000000000000000000000738bf270934a46bd607ca8cb1222cf16faf099fc",
        "0x0000000000000000000000005a4674ab5768e08c347d78ace037b9875a488b73"
      ],
      "data": "0x0000000000000000000000000000000000000000000000004c53ecdc18a60000",
      "blockNumber": "0x2b8471c",
      "transactionHash": "0x0b1c97fabd7d7a9505e5df426ecf5f8ebbf8bae988eb64e394c177d656cb7199",
      "transactionIndex": "0x1",
      "blockHash": "0x851cb67720d6a78bef95be0148d0ef620c6daf6fd662befcccf38097f2973873",
      "logIndex": "0x1",
      "removed": false
    }
  ]
}

1677148428749

The blockHash 0x851cb67720d6a78bef95be0148d0ef620c6daf6fd662befcccf38097f2973873 in above response is wrong. This can be verified by eth_getBlockByHash:

Request:

curl -s -X POST https://erpc.apothem.network/ -H "Content-Type: application/json" -d '
{
    "id":1,
    "jsonrpc":"2.0",
    "method":"eth_getBlockByHash",
    "params":["0x851cb67720d6a78bef95be0148d0ef620c6daf6fd662befcccf38097f2973873", false]
}' | jq

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}

1677148352948

This block block 45631260 / 0x2b8471c is created at Thu Feb 23 2023 16:03:43 GMT+0800. So this bug is not fixed in all new blocks.

gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue May 29, 2023
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue May 29, 2023
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue Aug 31, 2023
gzliudan added a commit to gzliudan/XDPoSChain that referenced this issue Aug 31, 2023
@gzliudan
Copy link
Collaborator Author

Closed by #320.

liam-lai added a commit that referenced this issue Oct 12, 2023
* core: fix blockHash for eth_getLogs, eth_getFilterLogs, eth_getTransactionReceipt (#208)

* eth/filters: fix blockHash in eth_getfilterchanges (#208)

* set testnet v2 block (#330)

* set testnet v2 block

* set testnet v2 block
@gzliudan gzliudan mentioned this issue Apr 20, 2024
19 tasks
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

2 participants