(Requires Audit) PLEX-2473 LogPoller Fix Reorg Handing on Replay (Part 1)#355
(Requires Audit) PLEX-2473 LogPoller Fix Reorg Handing on Replay (Part 1)#355dhaidashenko wants to merge 3 commits intodevelopfrom
Conversation
|
fd687cd to
abead20
Compare
There was a problem hiding this comment.
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
isReplayboolean parameter toPollAndSaveLogsmethod and related internal functions to enable special reorg detection logic during replay operations - Extracted
headerByNumberhelper method to reduce code duplication when fetching block headers from RPC - Enhanced
getCurrentBlockMaybeHandleReorgto detect reorgs during replay by checking if current and latest blocks in DB match their RPC counterparts - Refactored reorg handling logic into a new
handleReorgmethod 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.
f60d8b4
There was a problem hiding this comment.
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.
29ffcf3 to
ccc00f8
Compare
TestCase that were previously failing:
Expected behaviour:
Supports: #356