kardiachain/go-kardia

Buggy behaviours of event logs RPC APIs

trinhdn97 opened this issue · 1 comments

Current behaviours

  • blockhash field of event logs is always empty 0x0000000000000000000000000000000000000000.
curl --location --request POST 'https://kai-internal-1.kardiachain.io/' \
--header 'Content-Type: application/json' \
--header 'Cookie: __cfduid=d0de3543a6b9c69cec083b6758e1677f31617347746' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getLogs",
    "params": [
        {
            "fromBlock": 1583362,
            "toBlock": 1583475
        }
    ],
    "id": 1
}'

will results like below, the blockHeight is correct but the blockHash fields are always empty.

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        {
            "address": "0x4dae614b2ea2faeedde7830a2e7fceddae9f9161",
            "topics": [
                "0xb0d234274aef7a61aa5a2eb44c23881ebf46a068cccbd413c978bcbd555fe17f"
            ],
            "data": "0x0000000000000000000000002dbf5da7f4e3cc72fb3f9cf4413543796c5f3206000000000000000000000000000000000000000000000878678326eac9000000",
            "blockHeight": 1583362,
            "transactionHash": "0x17c8686caea71e8b89b4b443c4b008b29c9e878ac5b48ebec3cd5dfb06d0290d",
            "transactionIndex": 0,
            "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "logIndex": 1,
            "removed": false
        },
        {
            "address": "0xf512b1e8acc96baf05b470182f1814bfb14df563",
            "topics": [
                "0x15490ebb4bc37fd11febf8b4a71b7bed47ac2d66d82fbdd5c83da3f202726eed"
            ],
            "data": "0x0000000000000000000000007640b8f0ee079873d8a54cd7e5d95c8dd43073b80000000000000000000000000000000000000000000000000000000000000000",
            "blockHeight": 1583451,
            "transactionHash": "0xba5928d357647e5e983f09a64b89e93827a9d9ebc1d0a6fd89d6193f97b703c6",
            "transactionIndex": 0,
            "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "logIndex": 1,
            "removed": false
        },
        {
            "address": "0xeff34b63f55200a9d635b8abbbfcc719b4977864",
            "topics": [
                "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                "0x0000000000000000000000004102a799b5b87db21f7707e2cc2789330254397f",
                "0x000000000000000000000000bf42a75a362df31b62bb99257f9a66163eb6b962"
            ],
            "data": "0x0000000000000000000000000000000000000000000000000000000001312d01",
            "blockHeight": 1583475,
            "transactionHash": "0x2e37b77519a29769db600fe32dd69f9d476287dea570638d2c1e4d3410a3fd30",
            "transactionIndex": 0,
            "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
            "logIndex": 1,
            "removed": false
        }
    ]
}
  • kai_getLogs API is crashed with error block info is missing when we try to retrieve logs of old blocks, which didn't include a logsBloom in block info after being applied to state.
curl --location --request POST 'https://kai-internal-1.kardiachain.io/' \
--header 'Content-Type: application/json' \
--header 'Cookie: __cfduid=d0de3543a6b9c69cec083b6758e1677f31617347746' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "kai_getLogs",
    "params": [
        {
            "fromBlock": 1,
            "toBlock": 2
        }
    ],
    "id": 1
}'

which will response error instead of an empty events list

{
    "jsonrpc": "2.0",
    "id": 1,
    "error": {
        "code": -32000,
        "message": "block info is missing"
    }
}

Expected behaviours

We should include the correct blockHash of the block which these events are emitted in. We also should skip old blocks which don't have a block logsBloom to avoid crashing the whole logs query.

Fixed in #143