onflow / flow-evm-gateway

FlowEVM Gateway implements an Ethereum-equivalent JSON-RPC API for EVM clients to use
https://developers.flow.com/evm/about
Apache License 2.0
11 stars 9 forks source link

`eth_getLogs` returns incorrect records when filtering by block number #439

Closed kilkka closed 1 month ago

kilkka commented 1 month ago

Problem

For some of the earliest blocks on the EVM testnet (below block ~100), filtering logs by block number can result in logs from blocks outside that range getting returned.

Steps to Reproduce

For example, this request to https://testnet.evm.nodes.onflow.org for block 9:

{
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "id": "1",
    "params": [
        {
            "topics": [
                [
                    "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0"
                ]
            ],
            "fromBlock": "0x9",
            "toBlock": "0x9"
        }
    ]
}

Results in logs coming back from blocks 2519, 2532, and 2546:

{
    "jsonrpc": "2.0",
    "id": "1",
    "result": [
        {
            "address": "0xf8146b4aef631853f0eb98dbe28706d029e52c52",
            "topics": [
                "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
                "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000023f946ffbc8829bfd"
            ],
            "data": "0x",
            "blockNumber": "0x9d7",
            "transactionHash": "0x56e8d9586ed4422136ab0e79c9c537b33f09b7a3b870ca569e230a15b925c3b2",
            "transactionIndex": "0x0",
            "blockHash": "0xcad79e3019da8014f623f351f01c88d1bcb4613352d4801548c6b07992fd1393",
            "logIndex": "0x0",
            "removed": false
        },
        {
            "address": "0x4eb7be1347727d2ebc8fbf85cc82fd23c59d669a",
            "topics": [
                "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
                "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000023f946ffbc8829bfd"
            ],
            "data": "0x",
            "blockNumber": "0x9e4",
            "transactionHash": "0x23de904c89530a9225fa41733d5651f26cf587be51eed84a08bfc039beb9e3ca",
            "transactionIndex": "0x0",
            "blockHash": "0xf64d8bd7a1c0795c445fdf8829e7cdf2a572797b75daa8f208ad1a85d2b93a56",
            "logIndex": "0x0",
            "removed": false
        },
        {
            "address": "0x91adb5cba277f53a44d4cfc7a5c6b744ab4e7477",
            "topics": [
                "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
                "0x0000000000000000000000000000000000000000000000000000000000000000",
                "0x0000000000000000000000000000000000000000000000023f946ffbc8829bfd"
            ],
            "data": "0x",
            "blockNumber": "0x9f2",
            "transactionHash": "0x24488eccbd33523548b7d12835eb442dd7c4d9d01ec5ea9b0e54eba2ac965737",
            "transactionIndex": "0x0",
            "blockHash": "0x6b2844981b110526dea03bfb5e68456d03b936f2e649850f8616841b1c0a2af9",
            "logIndex": "0x0",
            "removed": false
        }
    ]
}

Will note that all four of those block numbers start with 0x9.

Similar issue when filtering for block number 10, 11, and others in the early block range on testnet.

Acceptance Criteria

Return only the logs from the specified range in the results.

Context

We are indexing data for SimpleHash, the multi-chain token API.

sideninja commented 1 month ago

We will investigate this issue asap! thank you for reporting.

m-Peter commented 1 month ago

Will note that all four of those block numbers start with 0x9.

@kilkka That hint was pure :1st_place_medal: in helping find the issue :bow:

sideninja commented 1 month ago

@kilkka the fix was made, we will update the deployment soon. Thank you for your report!