Skip to content

L-05 Ensure finality violation is detected even in cases of empty fin…#431

Open
dhaidashenko wants to merge 3 commits intofix/PLEX-2781-L-03-document-findBlockAfterLCA-behaviorfrom
fix/plex-2783-l-05-fix-missed-finality-violation-in-case-of-empty-block
Open

L-05 Ensure finality violation is detected even in cases of empty fin…#431
dhaidashenko wants to merge 3 commits intofix/PLEX-2781-L-03-document-findBlockAfterLCA-behaviorfrom
fix/plex-2783-l-05-fix-missed-finality-violation-in-case-of-empty-block

Conversation

@dhaidashenko
Copy link
Copy Markdown
Contributor

Problem

findBlockAfterLCA Can Miss Finality Violations in Sparse Finalized Gaps

The SelectNewestBlock function skips over unstored empty blocks to find the nearest stored ancestor. If the earliest reorged block is before the finalized block, and they both lie inside such an unstored empty-block gap, findBlockAfterLCA can jump below the violated finalized region to an older stored canonical ancestor.

Since that older ancestor's hash matches the parent hash of its RPC child, the function returns immediately. The finality violation check runs only on the mismatch branch, so it is never reached for the skipped finalized gap itself. As a result, a reorg affecting any unstored finalized block at or below latestFinalizedBlockNumber can be handled as a normal rewind instead of raising ErrFinalityViolated.

Fix

Always persist the latest finalized block, even if it's empty.

@dhaidashenko dhaidashenko requested a review from a team as a code owner April 17, 2026 13:17
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 17, 2026

✅ API Diff Results - No breaking changes


📄 View full apidiff report

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.

1 participant