Skip to content

More robust reorg detection logic - #447

Merged
DZakh merged 5 commits into
mainfrom
dz/rework-reorg-detection
Feb 5, 2025
Merged

More robust reorg detection logic#447
DZakh merged 5 commits into
mainfrom
dz/rework-reorg-detection

Conversation

@DZakh

@DZakh DZakh commented Feb 4, 2025

Copy link
Copy Markdown
Member
  1. Better data structure for scanned block data, to prevent duplications
  2. Remove timestamps from the reorg detection logic, to simplify it
  3. Don't clean up scanned block data for chains which didn't have a rollback
  4. Store firstBlockParentNumberAndHash in the scanned block data, so it's possible to use it to detect a rollback
  5. Removed complicated logic to handle multichain, since it's already done by the entity history
  6. If we, for some reason, couldn't find a valid block in the reorg threshold - fallback to the heighestBlockBelowThreshold instead of start of the chain or some other weird place.
  7. Improve latest fetch block after a rollback

@DZakh
DZakh requested a review from JonoPrest February 4, 2025 14:30
Comment on lines +121 to +127
) {
| Some(scannedBlock) if scannedBlock.blockHash !== lastBlockScannedData.blockHash =>
Some({
reorgGuard,
scannedBlock,
})
| _ =>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe leave a comment explaining why the check for lastBlockScannedData

let lastBlockQueriedPromise: promise<
ReorgDetection.blockData,
> = // switch pageUnsafe.rollbackGuard {
let lastBlockQueriedPromise = // switch pageUnsafe.rollbackGuard {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cleanup comment

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great work Dmitry! This looks much better than before 💪🏼

@DZakh
DZakh merged commit 433723f into main Feb 5, 2025
@DZakh
DZakh deleted the dz/rework-reorg-detection branch February 5, 2025 07:34
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.

2 participants