PLEX-2794 fix inconsistent head snapshots#438
Merged
dhaidashenko merged 23 commits intoMay 19, 2026
Conversation
Contributor
✅ API Diff Results - No breaking changes |
Base automatically changed from
fix/PLEX-2793-N-08-ensure-heads-not-nil
to
develop
May 19, 2026 14:09
Contributor
📊 API Diff Results
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR mitigates inconsistent head snapshots observed by logPoller by enforcing a consistent ordering across latest/safe/finalized block numbers before they’re used for backfill bounds and persisted into block checkpoints.
Changes:
- Consolidates retrieval of latest/safe/finalized into
latestBlocks(...)and introduceslatestAndFinalizedBlocks(...)to separate concerns. - Adds ordering/mitigation logic so returned values satisfy
latest >= safe >= finalized(preferring higher-confidence heads when they report higher numbers). - Updates internal tests to reflect the new helper APIs and adds coverage for “finalized ahead of latest” and “safe ahead of latest” scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/logpoller/log_poller.go | Refactors head tuple retrieval and applies ordering mitigation to prevent inconsistent persisted checkpoint metadata/backfill bounds. |
| pkg/logpoller/log_poller_internal_test.go | Updates mocks to new helper APIs and adds test cases for inconsistent head ordering scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Unheilbar
approved these changes
May 19, 2026
silaslenihan
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The pollAndSaveLogs function derives on-chain status from latestBlocks and latestSafeBlock, but those helpers only clamp zero values and never verify the basic ordering finalized <= safe <= latest before the numbers are used and persisted. The resulting latestFinalizedBlockNumber drives the finalized backfill bound lastSafeBackfillBlock := latestFinalizedBlockNumber - 1, and the finalized / safe values are written into block checkpoints during getUnfinalizedLogs. If the poller observes a self-inconsistent head tuple, it can make poor control-flow decisions such as attempting out-of-range backfills or persisting inflated confirmation metadata that later feeds confirmed-read cutoffs through withConfs.
Fix
Use blocks with higher confidence if their block number is higher to guarantee latest >= safe >= finalized.