Skip to content

Make the chain indexer reorg-safe #52

Description

@Lakes41

Difficulty: Advanced

Type: Feature

Summary

Improve the membership event indexer so it handles chain reorganisations, finality windows, and duplicate event delivery safely.

Current Behaviour

The indexer can process membership events and persist progress, but simple last-block checkpointing can be unsafe if the chain reorganises after events have already been applied.

Expected Behaviour

The indexer should only finalise events after a configurable confirmation depth and should safely reconcile events if a reorg is detected.

Suggested Implementation

Add a configurable finality window. Store event block hash, block number, transaction hash, log index, and processed status. Re-scan recent blocks before advancing the finalised checkpoint.

Files or Areas Likely Affected

  • apps/access-api/src/workers/
  • apps/access-api/prisma/schema.prisma
  • packages/contracts/src/index.ts
  • apps/access-api/src/services/
  • .env.example

Acceptance Criteria

  • Indexer stores block hash and log identity for processed events
  • Confirmation depth is configurable
  • Recent blocks can be re-scanned safely
  • Duplicate logs are ignored idempotently
  • Reorg detection triggers safe reconciliation or retry
  • Tests cover duplicate logs, re-scans, and changed block hashes

Additional Notes

This builds on the membership event indexer and focuses specifically on production chain safety.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions