Skip to content

Security: Implement Blockchain Reorganization Detection for Transaction Confirmations #514

Description

@Smartdevs17

Context

Blockchain reorganizations can reverse confirmed transactions. AgenticPay must wait for sufficient confirmations but also detect and handle reorgs properly.

Current Limitation/Problem

The system uses a fixed confirmation count without monitoring for chain reorganizations. If a reorg occurs deeper than the confirmation threshold, the system incorrectly treats transactions as final.

Expected Outcome

A reorg detection service that monitors for chain reorganizations beyond the safety threshold, marks affected transactions for review, and triggers remediation workflows.

Acceptance Criteria

  • Monitor new blocks for chain reorganization events (different parent hash)
  • Track reorg depth and affected transactions
  • Configurable confirmation thresholds per chain (Ethereum: 12, Polygon: 64, Stellar: 1)
  • Alert on reorgs deeper than safety margin
  • Mark affected transactions as pending_review with reorg details
  • Automatic re-verification of affected transaction status
  • Dashboard showing reorg events and affected transactions
  • History of past reorg incidents with resolution status
  • Test: simulate reorgs in integration tests

Technical Scope

  • backend/src/services/chain/reorg-detector.ts - reorg detection
  • backend/src/services/chain/confirmation-tracker.ts - confirmation management
  • Prisma: ReorgEvent, TransactionReorg models
  • BullMQ queue for reorg processing
  • Integration with existing transaction status service
  • Edge cases: deep reorgs (>100 blocks), chain splits, orphaned blocks, uncle blocks

Metadata

Metadata

Assignees

Labels

200-points200 point issueStellar WaveIssues in the Stellar wave programdrips-waveIssues in the Drips Wave programhighHigh complexity issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions