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

getLogs can't use topics filter without timestamp range #576

Closed
dimitrovmaksim opened this issue Sep 29, 2022 · 0 comments · Fixed by #590
Closed

getLogs can't use topics filter without timestamp range #576

dimitrovmaksim opened this issue Sep 29, 2022 · 0 comments · Fixed by #590
Assignees
Labels
bug Something isn't working limechain P1
Milestone

Comments

@dimitrovmaksim
Copy link
Collaborator

dimitrovmaksim commented Sep 29, 2022

Description

Looking through this Issue #494, when trying to filter eth_getLogs by topics, the relay returns an empty response. This happens due to the mirror-node requesting a timestamp range when filtering by topics:

https://testnet.mirrornode.hedera.com/api/v1/contracts/0x0000000000000000000000000000000002e39Dcb/results/logs?limit=2&order=asc&topic0=0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d'
{
  "_status": {
    "messages": [
      {
        "message": "Cannot search topics without a valid timestamp range: No timestamp range or eq operator provided"
      }
    ]
  }
}

Unfortunately without from/to blocks or a block hash we don't have timestamps filter, and we don't have a way to get a valid timestamp in the relay.

I will have to take a look how other JSON-RPC providers handle this and suggest solutions.

Steps to reproduce

Run the relay against the test net
Set the following variables in .env:

MIRROR_NODE_URL='https://testnet.mirrornode.hedera.com/'
HEDERA_NETWORK={"34.133.197.230:50211":"0.0.3"}

Execute against the relay:

curl http://localhost:7546 -X POST -H "Content-Type: application/json" --data '{"method":"eth_getLogs","params":[{"address":"0x0000000000000000000000000000000002e39Dcb", "topics":["0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d"]}],"id":1,"jsonrpc":"2.0"}' 

which should return an empty response:

{"result":[],"jsonrpc":"2.0","id":1}% 

and the mirror node request will fail with status code 400:

[Request ID: 6c997ed8-7ea7-44fa-857b-94057e39e9e4] [GET] contracts/0x0000000000000000000000000000000002e39Dcb/results/logs?topic0=0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d 400 status

But if fromBlock and toBlock are added to the request:

curl http://localhost:7546 -X POST -H "Content-Type: application/json" --data '{"method":"eth_getLogs","params":[{"address":"0x0000000000000000000000000000000002e39Dcb", "topics":["0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d"], "fromBlock":"0x183AC03", "toBlock":"0x183AC03"}],"id":1,"jsonrpc":"2.0"}'

It returns the logs:

{"result":[{"address":"0x0000000000000000000000000000000002e39dcb","blockHash":"0x9efd8366ecca242abb57e15be623cd6e372bb18cf09f541a2736d135c423b426","blockNumber":"0x183ac03","data":"0x","logIndex":"0x0","removed":false,"topics":["0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d","0x6860fe8d21cf07b079a82a9c51c03bf562359a53cac82a0cbfd033ab91761ccd","0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b","0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b"],"transactionHash":"0xedbffd06130874301a6f342c98b09464f8806a25430c726566d3139475c34c7c","transactionIndex":"0x1"},{"address":"0x0000000000000000000000000000000002e39dcb","blockHash":"0x9efd8366ecca242abb57e15be623cd6e372bb18cf09f541a2736d135c423b426","blockNumber":"0x183ac03","data":"0x","logIndex":"0x1","removed":false,"topics":["0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d","0x0e8cefca32b79d2efbc5f5c583ce3aca66d94228747c49d0dae86c46974e111a","0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b","0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b"],"transactionHash":"0xedbffd06130874301a6f342c98b09464f8806a25430c726566d3139475c34c7c","transactionIndex":"0x1"},{"address":"0x0000000000000000000000000000000002e39dcb","blockHash":"0x9efd8366ecca242abb57e15be623cd6e372bb18cf09f541a2736d135c423b426","blockNumber":"0x183ac03","data":"0x","logIndex":"0x2","removed":false,"topics":["0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b","0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b"],"transactionHash":"0xedbffd06130874301a6f342c98b09464f8806a25430c726566d3139475c34c7c","transactionIndex":"0x1"}],"jsonrpc":"2.0","id":1}% 

Additional context

No response

Hedera network

All

Version

All

Operating system

No response

@dimitrovmaksim dimitrovmaksim added the bug Something isn't working label Sep 29, 2022
@dimitrovmaksim dimitrovmaksim self-assigned this Sep 29, 2022
@Nana-EC Nana-EC moved this to In Progress in Smart Contract Sprint Board Oct 5, 2022
@Nana-EC Nana-EC added this to the 0.10 milestone Oct 5, 2022
Repository owner moved this from In Progress to Done in Smart Contract Sprint Board Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working limechain P1
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants