Skip to content

(Requires Audit) PLEX-2473 LogPoller Fix Reorg Handing on Replay (Part 1)#355

Merged
dhaidashenko merged 6 commits intodevelopfrom
feature/PLEX-2473-fix-reorg-handing-on-replay
Apr 24, 2026
Merged

(Requires Audit) PLEX-2473 LogPoller Fix Reorg Handing on Replay (Part 1)#355
dhaidashenko merged 6 commits intodevelopfrom
feature/PLEX-2473-fix-reorg-handing-on-replay

Conversation

@dhaidashenko
Copy link
Copy Markdown
Contributor

@dhaidashenko dhaidashenko commented Feb 12, 2026

TestCase that were previously failing:

  1. LogPoller processes blocks to block 11
  2. Reorg replaces block 11 with a new block (some additional blocks may be added on top of it)
  3. Replay is initiated from block below 11.

Expected behaviour:

  1. LogPoller must replace reorged block 11 with a new data.
  2. DB must not contain at any point logs from both old and new block 11.
  3. Finality Violation must not occur, since chain did not violate finality depth.

Supports: #356

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 12, 2026

⚠️ API Diff Results - Breaking changes detected

📦 Module: github-com-smartcontractkit-chainlink-evm

🔴 Breaking Changes (2)

pkg/logpoller.(*logPoller) (1)
  • PollAndSaveLogs — Type changed:
func(
  context.Context, 
  - int64
  + int64, 
  + bool
)
pkg/logpoller.LogPollerTest (1)
  • PollAndSaveLogs — Type changed:
func(
  context.Context, 
  - int64
  + int64, 
  + bool
)

📄 View full apidiff report

@dhaidashenko dhaidashenko force-pushed the feature/PLEX-2473-fix-reorg-handing-on-replay branch 2 times, most recently from fd687cd to abead20 Compare February 13, 2026 12:35
@dhaidashenko dhaidashenko changed the title PLEX-2473 LogPoller Fix Reorg Handing on Replay PLEX-2473 LogPoller Fix Reorg Handing on Replay (Part 1) Feb 13, 2026
@dhaidashenko dhaidashenko changed the title PLEX-2473 LogPoller Fix Reorg Handing on Replay (Part 1) (Requires Audit) PLEX-2473 LogPoller Fix Reorg Handing on Replay (Part 1) Feb 13, 2026
@dhaidashenko dhaidashenko marked this pull request as ready for review February 13, 2026 16:29
@dhaidashenko dhaidashenko requested a review from a team as a code owner February 13, 2026 16:29
Copilot AI review requested due to automatic review settings February 13, 2026 16:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes reorg (reorganization) handling in the LogPoller when replay operations encounter blocks that have been reorged. The core issue was that when LogPoller processed blocks up to block N, then a reorg replaced block N, and a replay was initiated from a block below N, the old and new versions of block N could coexist in the database, or a false finality violation could occur.

Changes:

  • Added isReplay boolean parameter to PollAndSaveLogs method and related internal functions to enable special reorg detection logic during replay operations
  • Extracted headerByNumber helper method to reduce code duplication when fetching block headers from RPC
  • Enhanced getCurrentBlockMaybeHandleReorg to detect reorgs during replay by checking if current and latest blocks in DB match their RPC counterparts
  • Refactored reorg handling logic into a new handleReorg method for better code organization
  • Added comprehensive test case covering three scenarios: replay immediately after reorg, replay a few blocks after reorg, and replay after reorged block is finalized

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
pkg/logpoller/log_poller.go Core implementation changes: added isReplay parameter, extracted headerByNumber and handleReorg methods, enhanced reorg detection logic for replay scenarios
pkg/logpoller/log_poller_test.go Updated all test calls to include isReplay=false parameter, added comprehensive TestLogPoller_Reorg_On_Replay test with three test cases
pkg/logpoller/log_poller_internal_test.go Updated all test calls to include isReplay=false parameter
pkg/logpoller/helper_test.go Updated PollAndSaveLogs wrapper to pass isReplay=false

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/logpoller/log_poller_test.go Outdated
Comment thread pkg/logpoller/log_poller_test.go Outdated
Comment thread pkg/logpoller/log_poller_test.go Outdated
Comment thread pkg/logpoller/log_poller.go Outdated
Comment thread pkg/logpoller/log_poller.go Outdated
Comment thread pkg/logpoller/log_poller_test.go Outdated
Comment thread pkg/logpoller/log_poller.go Outdated
Comment thread pkg/logpoller/log_poller_test.go
Unheilbar
Unheilbar previously approved these changes Feb 17, 2026
Krish-vemula
Krish-vemula previously approved these changes Feb 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/logpoller/log_poller_test.go
Comment thread pkg/logpoller/log_poller_test.go
Comment thread pkg/logpoller/log_poller.go
Comment thread pkg/logpoller/log_poller.go
@dhaidashenko dhaidashenko force-pushed the feature/PLEX-2473-fix-reorg-handing-on-replay branch from 29ffcf3 to ccc00f8 Compare February 26, 2026 15:14
@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity.
Remove the stale label or comment or this will be closed in 7 days.

@github-actions github-actions Bot added the Stale label Mar 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

This PR has been automatically closed because it has been stale for > 30 days.
If you wish to continue working on this PR, please reopen it and make any necessary changes.

@github-actions github-actions Bot closed this Apr 5, 2026
@github-actions github-actions Bot deleted the feature/PLEX-2473-fix-reorg-handing-on-replay branch April 5, 2026 01:02
@dhaidashenko dhaidashenko restored the feature/PLEX-2473-fix-reorg-handing-on-replay branch April 14, 2026 12:04
@dhaidashenko dhaidashenko reopened this Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 14, 2026

⚠️ API Diff Results - github.com/smartcontractkit/chainlink-evm

⚠️ Breaking Changes (2)

pkg/logpoller.(*logPoller) (1)
  • PollAndSaveLogs — Type changed:
func(
  context.Context, 
  int64, 
  + bool
)
pkg/logpoller.LogPollerTest (1)
  • PollAndSaveLogs — Type changed:
func(
  context.Context, 
  int64, 
  + bool
)

📄 View full apidiff report

@github-actions github-actions Bot removed the Stale label Apr 15, 2026
@dhaidashenko dhaidashenko enabled auto-merge (squash) April 24, 2026 12:16
Unheilbar
Unheilbar previously approved these changes Apr 24, 2026
yashnevatia
yashnevatia previously approved these changes Apr 24, 2026
ilija42
ilija42 previously approved these changes Apr 24, 2026
@dhaidashenko dhaidashenko dismissed stale reviews from ilija42, yashnevatia, and Unheilbar via 537a8e5 April 24, 2026 12:36
…b.com:smartcontractkit/chainlink-evm into feature/PLEX-2473-fix-reorg-handing-on-replay
@dhaidashenko dhaidashenko requested a review from ilija42 April 24, 2026 12:57
@dhaidashenko dhaidashenko merged commit eef8116 into develop Apr 24, 2026
34 checks passed
@dhaidashenko dhaidashenko deleted the feature/PLEX-2473-fix-reorg-handing-on-replay branch April 24, 2026 13:01
dhaidashenko added a commit that referenced this pull request Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants