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 does not return anything if filtered #494

Closed
CoveMB opened this issue Sep 6, 2022 · 6 comments · Fixed by #590
Closed

eth_getLogs does not return anything if filtered #494

CoveMB opened this issue Sep 6, 2022 · 6 comments · Fixed by #590
Assignees
Labels
bug Something isn't working limechain
Milestone

Comments

@CoveMB
Copy link

CoveMB commented Sep 6, 2022

Description

No logs are returned from the call when we add any filter other than address.

This works:
await provider.getLogs({ address: address })
Any of those won't:

await provider.getLogs({
        address: address,
        fromBlock: 0,
        toBlock: "latest",
        topics: ["0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d"],
      })

or

await provider.getLogs({
        address: address,
        fromBlock: 0,
        toBlock: "latest"
      })

or

await provider.getLogs({
        address: address,
        topics: ["0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d"],
      })

More info:
Request of the one with all filters: d633b6db-a9f7-47c0-8d87-aa87f79d2ce2
[Request ID: d633b6db-a9f7-47c0-8d87-aa87f79d2ce2] [GET] contracts/0x0000000000000000000000000000000002dc46db/results/logs?timestamp=gte:1598571652.347251002&timestamp=lte:1598573131.733718001&topic0=0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d 200 633 ms

Steps to reproduce

  • deploy a contract that emit events
  • use eth_getLogs to get the logs adding a filter

Additional context

No response

Hedera network

testnet

Version

tesnet

Operating system

No response

@CoveMB CoveMB added the bug Something isn't working label Sep 6, 2022
@dimitrovmaksim
Copy link
Collaborator

dimitrovmaksim commented Sep 14, 2022

Hey, currently getLogs can't resolve block tags, this should be fixed by this PR #532.

For this case

await provider.getLogs({
        address: address,
        topics: ["0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d"],
      })

It should be working, but could you post the event signature, so I can check the topic and verify

P.S. Is this on the testnet? Those timestamps from the request look pretty old

@Nana-EC
Copy link
Collaborator

Nana-EC commented Sep 19, 2022

@BjMrq please see above comment and request for further details

@CoveMB
Copy link
Author

CoveMB commented Sep 29, 2022

Hello, thanks for looking at this, it was on testnet using local json relayer.

I just tried again on deployed json relayer for testnet.

I freshly deployed the following contract https://github.com/BjMrq/hardhat-sandbox/blob/2211ee994a2397adf522832fd700ddf5fc402056/contracts/AccessRolesBox.sol
With underlying contract https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol
ABI and event info: https://github.com/BjMrq/hardhat-sandbox/blob/2211ee994a2397adf522832fd700ddf5fc402056/artifacts/contracts/AccessRolesBox.sol/AccessRolesBox.json

Same result, when I run

await provider.getLogs({
        address: address
      })

I get the events:

{
  blockNumber: 25406467,
  blockHash: '0x9efd8366ecca242abb57e15be623cd6e372bb18cf09f541a2736d135c423b426',
  transactionIndex: 1,
  removed: false,
  address: '0x0000000000000000000000000000000002e39Dcb',
  data: '0x',
  topics: [
    '0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d',
    '0x6860fe8d21cf07b079a82a9c51c03bf562359a53cac82a0cbfd033ab91761ccd',
    '0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b',
    '0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b'
  ],
  transactionHash: '0xedbffd06130874301a6f342c98b09464f8806a25430c726566d3139475c34c7c',
  logIndex: 0
}
{
  blockNumber: 25406467,
  blockHash: '0x9efd8366ecca242abb57e15be623cd6e372bb18cf09f541a2736d135c423b426',
  transactionIndex: 1,
  removed: false,
  address: '0x0000000000000000000000000000000002e39Dcb',
  data: '0x',
  topics: [
    '0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d',
    '0x0e8cefca32b79d2efbc5f5c583ce3aca66d94228747c49d0dae86c46974e111a',
    '0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b',
    '0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b'
  ],
  transactionHash: '0xedbffd06130874301a6f342c98b09464f8806a25430c726566d3139475c34c7c',
  logIndex: 1
}
{
  blockNumber: 25406467,
  blockHash: '0x9efd8366ecca242abb57e15be623cd6e372bb18cf09f541a2736d135c423b426',
  transactionIndex: 1,
  removed: false,
  address: '0x0000000000000000000000000000000002e39Dcb',
  data: '0x',
  topics: [
    '0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d',
    '0x0000000000000000000000000000000000000000000000000000000000000000',
    '0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b',
    '0x0000000000000000000000001d358d88b9215a1d42a22f46e7766b6f7fd5142b'
  ],
  transactionHash: '0xedbffd06130874301a6f342c98b09464f8806a25430c726566d3139475c34c7c',
  logIndex: 2
}

but with:

await provider.getLogs({
        address: address,
        topics: ["0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d"],
      })

I get no result at all.

@dimitrovmaksim
Copy link
Collaborator

dimitrovmaksim commented Sep 29, 2022

Hey, thanks for the reply. I think I know what is happening here. Just to confirm, does this request return a status code 400? Also if you add "fromBlock":"0x183AC03", "toBlock":"0x183AC03" as params it will return a response?

@dimitrovmaksim
Copy link
Collaborator

dimitrovmaksim commented Oct 5, 2022

According to HIP-482, for eth_getLogs fromBlock and toBlock filters should default to latest, although currently it does not work like this (should be fixed by #590). This means that if eth_getLogs() is called without blockHash or fromBlock and toBlock filters, it will only fetch logs for the latest block. This means that filtering only by address, or address and topics, or only topics, without any block filters may still result in empty response, because it will fetch logs only from the latest block, which may not contain any results for that address or topic

@Nana-EC
Copy link
Collaborator

Nana-EC commented Oct 17, 2022

@BjMrq with #590 merged into the main branch this should be resolved.
Please note @dimitrovmaksim's comment above noting the edge case for the latest block scenario.
Feel free to comment if you believe this was not addressed

@Nana-EC Nana-EC closed this as completed Oct 17, 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
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants