Add MaxRollbackDepth to prevent deep reorg processing#3
Open
mpainenz wants to merge 3 commits intodogeorg:mainfrom
Open
Add MaxRollbackDepth to prevent deep reorg processing#3mpainenz wants to merge 3 commits intodogeorg:mainfrom
mpainenz wants to merge 3 commits intodogeorg:mainfrom
Conversation
Add optional MaxRollbackDepth parameter to WalkerOptions to stop the walker service when a reorg exceeds the configured depth limit. - Added MaxRollbackDepth int64 field to WalkerOptions (0 = unlimited) - Updated undoBlocks() to check rollback depth during backtracking - Walker stops (returns running=false) if depth exceeds limit This prevents processing dangerous deep reorgs that could corrupt downstream state by stopping before emitting an undo command.
Author
|
Sorry, not quite working as expected during e2e test. Moved to draft |
…g incomplete undo When MaxRollbackDepth is exceeded, undoBlocks() was returning a partially populated undo object (with UndoBlocks but without LastValidHeight/LastValidHash). This could allow an invalid undo command to be sent to consumers. Fix: - Return nil instead of incomplete undo when limit exceeded - Add nil checks in callers before sending undo commands This ensures deep reorgs exceeding the limit are properly stopped without sending invalid undo commands, while normal reorgs continue to work correctly.
- Add MaxRollbackWaitDuration option to WalkerOptions - Implement wait and retry mechanism when MaxRollbackDepth is exceeded - When deep reorg detected, wait configured duration before retrying - Prevents restart loop by giving RPC node time to re-index - Zero value (0) means return immediately (backward compatible) - Default wait duration: 5 seconds (configured in indexer)
Author
|
In this implementation, if the max undo block length is surpassed, the walker would resume once it reaches a new tip, and it wouldn't emit an undo. This would work in the case of a re-indexing, but perhaps not for some other event such as corruption. |
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.
Add optional MaxRollbackDepth and MaxRollbackWaitDuration parameters to WalkerOptions to gracefully handle deep reorgs that exceed the configured depth limit.
The wait-and-retry mechanism give the core node time to re-index after a deep reorg, allowing the walker to resume once blocks are back on-chain.
Example output while waiting:
And ones re-indexing catches up...