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

Save queried logs to avoid redundant queries #91

Open
mhchia opened this issue Aug 24, 2023 · 0 comments
Open

Save queried logs to avoid redundant queries #91

mhchia opened this issue Aug 24, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mhchia
Copy link
Member

mhchia commented Aug 24, 2023

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.

@mhchia mhchia changed the title Save queried logs to avoid redundant queries Save queried logs to save redundant queries Aug 24, 2023
@mhchia mhchia added enhancement New feature or request good first issue Good for newcomers labels Aug 24, 2023
@mhchia mhchia changed the title Save queried logs to save redundant queries Save queried logs to avoid redundant queries Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant