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

getlogs and internal timing polish #902

Merged
merged 13 commits into from
Dec 15, 2023
Merged

getlogs and internal timing polish #902

merged 13 commits into from
Dec 15, 2023

Conversation

shunjizhan
Copy link
Collaborator

@shunjizhan shunjizhan commented Dec 11, 2023

Context

we have a bug that returns false empty for the corner cases when:

  1. get log immediately on new block, since subql is usually a couple blocks delayed
  2. get receipt immediately on new block, since cache is still syncing latest block

1. was temporarily fixed by #828, but it has very poor performance.
2. was not fixed yet

To solve the whole issue completely, we need some bottom level refactor, instead of awkward patches like #828

core problem

We directly use node best block as eth best block, so we can query for this block before subql or cache is ready. In other words, latest block goes faster than latest state.

solution

We can redefine "latest block" as "latest cached block", so we can always get logs/receipts for the latest block.

For logs, we can't wait for subql to catch up, which takes 10+ seconds, instead we can make use of cache to query the blocks missed by subql

Change

  • updated blockcache so we can get logs from it, and it keeps track of last cached block info
  • updated latest block to return latest cached block
  • now we should always be able to get receipts and logs in latest block since:
    • latest block info is guaranteed to be in cache
    • there is a check to make sure no gap between subql and cache

fix #863

Test

  • updated some tests to wait for eth rpc to report new block before proceeding
  • add tests to make sure we can get logs as well as receipts for the latest block as soon as the block is ready

@shunjizhan shunjizhan changed the title Getlogs polish getlogs and internal timing polish Dec 11, 2023
@shunjizhan shunjizhan marked this pull request as ready for review December 12, 2023 11:57
@shunjizhan shunjizhan requested review from zjb0807 and xlc December 12, 2023 11:57
@shunjizhan shunjizhan merged commit 1547bd3 into master Dec 15, 2023
11 checks passed
@shunjizhan shunjizhan deleted the getlogs-polish branch December 15, 2023 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

polish getlogs when subql syncing last block
2 participants