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

Fix LatestFinalizedBlock=0 bug [BCI-3618](https://smartcontract-it.atlassian.net/browse/BCI-3618) #13861

Merged
merged 4 commits into from
Jul 17, 2024

Conversation

reductionista
Copy link
Contributor

@reductionista reductionista commented Jul 16, 2024

Some products rely on LatestBlock() to return a valid LatestFinalizedBlock (eg in order to compute where to start polling from).
This is always filled in for unfinalized logs, but for the case of backfilling finalized logs it was not being set.

Ordinarily, as soon as we're done pulling finalized logs we continue on to pull the unfinalized logs before returning from PollAndSaveLogs, but if there is an issue with the rpc server just as it's about to pull the first unfinalized log (or if the node gets restarted at that crucial moment), the db can be left in a state where the latest block saved is a finalized block with LatestFinalizedBlock set to 0. To fix this, we can just set LatestFinalizedBlock = BlockNumber (its own block number) for finalized blocks that get saved to the db.

If this is the last batch of blocks requested in a series of batches during a backfill, then it should always be true. If it's not the last batch, then the actual latest finalized block can be larger than the current block number. However, it still seems better to set these equal as returning LatestFinalizedBlock > LatestBlock seems awkward and more likely to cause the caller to get confused. It's still correct in that this is the latest finalized block that LogPoller has saved to the db (as well as the latest block).

@reductionista reductionista force-pushed the bug/logpoller_set_latest_finalized_block branch from 1693ce1 to d370a72 Compare July 16, 2024 02:26
@reductionista reductionista requested a review from a team as a code owner July 16, 2024 02:26
@reductionista reductionista added this pull request to the merge queue Jul 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 16, 2024
@reductionista reductionista added this pull request to the merge queue Jul 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 16, 2024
@reductionista reductionista added this pull request to the merge queue Jul 17, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 17, 2024
@reductionista reductionista added this pull request to the merge queue Jul 17, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 17, 2024
@reductionista reductionista added this pull request to the merge queue Jul 17, 2024
Merged via the queue into develop with commit b3c93a7 Jul 17, 2024
115 checks passed
@reductionista reductionista deleted the bug/logpoller_set_latest_finalized_block branch July 17, 2024 17:18
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.

6 participants