Skip to content

feat(flashblocks): add validation module for sequence ordering and reorg detection#21081

Closed
teddyknox wants to merge 1 commit intoparadigmxyz:mainfrom
op-rs:teddyknox/flashblock-sequencing
Closed

feat(flashblocks): add validation module for sequence ordering and reorg detection#21081
teddyknox wants to merge 1 commit intoparadigmxyz:mainfrom
op-rs:teddyknox/flashblock-sequencing

Conversation

@teddyknox
Copy link
Copy Markdown

Part of the speculative flashblock building design.

Motivation

The existing flashblocks implementation relies on implicit parent hash matching to reject invalid sequences, but lacks explicit detection of sequence gaps, duplicates, and reorgs. This PR adds the foundational validation types that subsequent PRs will use for canonical block reconciliation and speculative building.

Changes

Adds validation.rs with three stateless validators:

  • FlashblockSequenceValidator - Validates that incoming flashblocks follow expected ordering. Returns NextInSequence, FirstOfNextBlock, Duplicate, NonSequentialGap, or InvalidNewBlockIndex.

  • ReorgDetector - Compares transaction hash slices between tracked pending state and canonical blocks. Returns NoReorg or ReorgDetected with diagnostic counts.

  • CanonicalBlockReconciler - Determines reconciliation strategy when canonical blocks arrive: CatchUp, HandleReorg, DepthLimitExceeded, Continue, or NoPendingState.

All types are stateless with const fn where possible, making them easy to test and reason about.

Testing

Comprehensive unit tests covering:

  • Sequence validation: consecutive indices, block transitions, gaps, duplicates
  • Reorg detection: matching sequences, different order, different counts, different hashes
  • Reconciliation: all strategy branches and priority ordering

…d reconciliation

Add stateless validators for flashblock processing:
- FlashblockSequenceValidator: validates consecutive indices within blocks
- ReorgDetector: detects chain reorgs via transaction hash comparison
- CanonicalBlockReconciler: determines strategy when canonical blocks arrive
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Jan 14, 2026
@teddyknox teddyknox changed the title Add stateless validation primitives for flashblock sequencing and chain reorganization detection feat(flashblocks): add validation module for sequence ordering and reorg detection Jan 14, 2026
@teddyknox
Copy link
Copy Markdown
Author

Closing in favor of ethereum-optimism/optimism#18993

@teddyknox teddyknox closed this Jan 29, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in Reth Tracker Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant