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

Providers could do better to handle errors from the Infura and Alchemy API. #4703

Open
Cryptverse opened this issue Apr 20, 2024 · 0 comments
Assignees
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5

Comments

@Cryptverse
Copy link

Cryptverse commented Apr 20, 2024

Ethers Version

^5.6.9

Search Terms

Provider, getLogs, Alchemy, Infura

Describe the Problem

Default provider with Etherscan, Alchemy, Infura and Pocket. Querying a contract's logs over entire blockchain. Etherscan does well because it just returns 1000 so I can just start calling from blockNumber + 1 of latest event. However, Infura:

{
  "jsonrpc": "2.0",
  "id": 47,
  "error": {
    "code": -32005,
    "data": { "from": "0xBDE5F8", "limit": 10000, "to": "0x102DBCC" },
    "message": "query returned more than 10000 results. Try with this block range [0xBDE5F8, 0x102DBCC]."
  }
}

After parsing response that was emitted in 'debug' event. And, Alchemy:

{"jsonrpc":"2.0","id":43,"error":{"code":-32602,"message":"Log response size exceeded. You can make eth_getLogs requests with up to a 2K block range and no limit on the response size, or you can request any block range with a cap of 10K logs in the response. Based on your parameters and the response size limit, this block range should work: [0x0, 0xd043b8]"}}

I have tried to just add handling for this on my own in the BaseProvider object but I can't even seem to get a simple console.log() to work. Something to do with typescript compiling or whatever. Also, I think the Pocket provider request failing does not even emit a 'error' nor a 'debug' event and just causes the entire program to hang.

It is a pity that this is not handled because the Infura API would return a whole 10k events if the correct block range was used. They even give you a block range in their response error body. Just some simple parsing would extract the block range and then a retry of the getLogs call with the new range, instead of just emitting a debug event, would bring a phenomenal transformation of how these two providers integrate into this amazing library.

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

@Cryptverse Cryptverse added investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5 labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5
Projects
None yet
Development

No branches or pull requests

2 participants