Skip to content

Save queried logs to avoid redundant queries #91

@mhchia

Description

@mhchia

What’s wrong?

RLNContract.getLogs fetches all history logs from the provider every time it’s called. It’ll take much time for each log when the number of logs and the block height grows.

How to fix it?

We can get logs step by step and save them locally, to avoid getting all historical logs every time we call getLogs. For example, we can start from the block where the contract is deployed, query logs from a certain number of blocks each time, memorize the latest block height we’ve queried, and repeat.

We also need to make sure the logs are still valid even after a reorg. A naive way is that we only query blocks up to latest_block_height - num_blocks_delayed. num_blocks_delayed is large enough so that the blocks with height smaller than latest_block_height - num_blocks_delayed can barely reorg.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions