This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
JSON-RPC method eth_getLogs
returns empty array when specifying topics only
#1511
Labels
C:JSON-RPC
JSON-RPC client
System info: Ethermint current version, Ubuntu 20.04
Steps to reproduce:
eth_getLogs
method specifying the topic/sExpected behavior: Return the (last) log inside the log array
Actual behavior: Returns empty array
Additional info: For some reason, when trying to capture this behavior on a test, the response is the expected one. Locally, a test case was added in the integration tests at
tests/integration_tests/test_filters.py
to cover this case:This test passes without any issue. However, when performing the same actions manually, the method returns an empty array.
When a block range is specified along with the topics array on the
getLogs
call, the response is the expected one.Edit: Quoting the web3py docs, the method
web3.eth.get_logs()
uses other JSON-RPC methods under the hood:This seems to be the reason of the discrepancy between the test result and the manual test response.Update: The
getLogs
method under the hood works as a filter with the specified topics and a block range. If the block range is not specified, it defaults tofromBlock: "latest", toBlock: "latest"
. Then, if we callgetLogs
within the same block that the transaction happened, we will get a log in the result. However, if we make the same call one or more blocks later, the result will be an empty array. The mentioned test passes because it makes the call within the same block of the transaction.The text was updated successfully, but these errors were encountered: