Consensys / ethql

A GraphQL interface to Ethereum :fire:
Apache License 2.0
622 stars 85 forks source link

Transaction Logs Query of blocksRange not working? #118

Closed zocodia closed 5 years ago

zocodia commented 5 years ago

Hi, I don't know if this is the best place to ask this but I can't find any subreddit or similar. I can't seem to get my logs filter to work over a range of blocks. Is this just something to do with a limitation of Infura GraphQL example or a bug?

{
  blocksRange(numberRange: [4409881, 4409881,]) {
    transactions(filter: { withLogs: true }) {
      logs(filter: {
        topics: [
          "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
          null,
          "0x000000000000000000000000fbb1b73c4f0bda4f67dca266ce6ef42f520fbb98"
        ]
      }) {
        topics
      }
    }
  }
}

Im trying to find the best way to fetch all ERC20 transfer events for a specific address within a range of blocks.

raulk commented 5 years ago

There's a syntax error in the snippet you pasted, @zocodia. A query like this works for me:

{
  blocksRange(numberRange: [4409881, 4409881]) {
    transactions(filter: {withLogs: true}) {
      logs(filter: {topics: ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", null, "0x000000000000000000000000fbb1b73c4f0bda4f67dca266ce6ef42f520fbb98"]}) {
        topics
        account {
          address
        }
      }
    }
  }
}
zocodia commented 5 years ago

Still doesnt work for me. I just keep getting all logs like if the filter is not applied. I'm using the example site in the readme.

kshinn commented 5 years ago

@zocodia I can reproduce your issue. You provide the topics filter, but are getting all logs back in that case. It looks like the topics filter is not getting respected in the query. I will create a PR that addresses this issue.

zocodia commented 5 years ago

Exactly, thats precisely whats happening. Thanks

kshinn commented 5 years ago

@zocodia Are you running this locally or are your going through the Infura gateway? If you are running it locally, can you verify that the proposed solution #121 fixes the issue? Locally testing, it seems like this addresses the issue, but it would be good to get an additional set of eyes on it.

zocodia commented 5 years ago

@kshinn Yeah locally works now, thank you very much! Is there any way to get past the 10 blocks range maximum?

kshinn commented 5 years ago

@zocodia Because we are still aggregating over JSON-RPC, that limit is placed there as a safe guard against spamming the node. You can define an environment variable ETHQL_QUERY_MAX_SIZE when starting the server where you can set the max range. Just take care to monitor what you are querying so that you don't end up spamming the node or getting rate limited.