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

292: Backfill gaps in the recent past on startup when tracking head. #395

Merged
merged 11 commits into from
Jun 24, 2023

Conversation

telackey
Copy link

@telackey telackey commented Jun 22, 2023

This adds a new Backfill check which is run at startup, which attempts to recover from two sorts of gaps which can occur when tracking head:

  1. A contiguous gap from the last statediff position to the current head position. Something like this can happen if statediffs are in-flight when geth is terminated, or if there is an error which prevents writing statediffs but not syncing the chain (eg, the DB goes down). On startup then, we might notice that the current chain block is 2500, but the current statediff position is only 2498. The next ChainEvent we can expect to see will be at 2501, so we want to trigger statediffing of 2498, 2499, and 2500.

  2. Discontiguous gaps in the recent past. These can happen from temporary errors (eg, a momentary disruption in DB connectivity) or if the process is terminated with in-flight statediffs that completed out-of-order. Eg, block 2500 got written but 2498 and 2499 were still in-flight, leaving a sequence like: 2496, 2497, 2500, ... In this scenario, the statediff and chain positions are in sync, but we still need to plug the hole behind the current position.

I set default limits of 7200 blocks (~1 day) in both cases. If the statediff position is more than 7200 blocks behind head, it will not attempt to backfill and will instead log an error. When looking for gaps, it will look no further back than 7200 blocks from the current statediff position. Both are configurable.

To handle more extreme situations, we also have chain-chunker fillgap which can detect and fill gaps across an arbitrary range.

Tests: https://git.vdb.to/cerc-io/system-tests/commit/aa53b8abcb981688d45a5e453338b9026ad43314

@telackey telackey self-assigned this Jun 22, 2023
@telackey telackey marked this pull request as ready for review June 22, 2023 20:00
Copy link
Collaborator

@i-norden i-norden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! One non-nitpick comment but it doesn't need to block this and we already discussed the testing situation 👍

statediff/service.go Show resolved Hide resolved
statediff/indexer/database/file/indexer.go Outdated Show resolved Hide resolved
statediff/indexer/database/file/indexer.go Outdated Show resolved Hide resolved
@telackey
Copy link
Author

Tests added here: https://git.vdb.to/cerc-io/system-tests/commit/aa53b8abcb981688d45a5e453338b9026ad43314

@telackey telackey merged commit 4ddaf43 into v1.11.6-statediff-v5 Jun 24, 2023
5 checks passed
@telackey telackey deleted the telackey/292 branch June 24, 2023 04:05
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.

None yet

2 participants