Motivation
When I first entered this space >4 years ago, the first thing i built was an indexer for the aave protocol. Now 4years later, looking at this app not much has improved and I would probably do it the same way again.
Indexing events should be easy, but it is not.
Perhaps i might be able to do a few calls less, or I might be able to use alchemy* on L2s, but the core pain of eth_getLogs
persists.
- there is no cursor
- there is no handling of reorgs
- constant block-range limits on increasingly faster chains are pain
Running an archive node myself, might be possible, but it’s a huge barrier of entry for “getting started”.
While the bigger providers, started to offer custom built solutions for the problem (pipelines by alchemy, and streams by quicknode), these solutions require a vendor lock in, so there should be a feasible node level alternative imo.
Spec
My knowledge on the topic is at best, limited. Therefore I will not suggest any specific spec.
That said, I assume a new method would need to be introduced to not break existing eth_getLogs
usage.
My naive assumptions is that:
fromBlock
should also accept a blockHash. This way*getLogs
could returnremoved: true
events, if thefromBlock
was reorged.- if the search range exceeds some sort of limit on the archive node, the node should just return (not error) and the return should contain the last visited blockHash, so on the next query one can continue from there.
Perhaps it could make sense to have a more complex cursor including e.g. a txIndex
. I assume with ever growing blocks one might end up in a situation where one block might exceed the node limits (iirc. there was some issue with infura in the past).
Prior work
There seem to be two related prs that i could find:
- Proposal: Paginated Filter Queries ethereum/go-ethereum#17487 i think the first time this issue was raised, but eventually the topic has gotten stale
- JSONRPC responses with cursor/paging · Issue #617 · ethereum/execution-apis · GitHub a somewhat newer thread on the topic, with what i think are bot responses
- predictable block ranges when using eth_getLog · Issue #10606 · paradigmxyz/reth · GitHub slightly unrelated, but seems like ppl have pushed to get at least alchemy level feature parity accross clients
*In contrast to other node providers, alchemy does not implement a strict maximum blockRange, but allows for a dynamic range / suggest a dynamic range if the range contained to many matches Based on your parameters, this block range should work: [0x0, 0x270f]