Skip to content

eth_getLogs optimizations #560

@s1na

Description

@s1na

Hello I got a report from @0xbeny that eth_getLogs can be slow at times. I want to list a few optimizations that have been applied upstream. They yielded around 30% improvement in speed. They need to be applied in order.

  1. core/rawdb: avoid unnecessary receipt processing for log filtering ethereum/go-ethereum#23147 Logs are stored as part of receipts in the database. Crucially not all fields of a receipt are persisted to disk. Some are re-computed on read. The most expensive field to re-compute is the bloom filter which will not even be returned in eth_getLogs. Here we define a new decoding of receipts specifically for this use-case which avoids extra processing.
  2. eth/filters: add global block logs cache ethereum/go-ethereum#25459 Previous PR caused an accidental regression in which receipts would not be cached anymore. Hence concurrently querying same blocks would slow down. This PR re-introduces a cache specifically for logs.
  3. eth/filters: avoid block body retrieval when no matching logs ethereum/go-ethereum#25199 as the title suggests we postpone fetching block bodies from disk until we are sure that it is a matching log that needs to be returned to user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions