Skip to content

Make the chain indexer#66

Open
clintjeff2 wants to merge 2 commits into
Adamantine-guild:mainfrom
clintjeff2:Make-the-chain-indexer
Open

Make the chain indexer#66
clintjeff2 wants to merge 2 commits into
Adamantine-guild:mainfrom
clintjeff2:Make-the-chain-indexer

Conversation

@clintjeff2

Copy link
Copy Markdown

Description

This PR implements a production-ready, reorg-safe blockchain indexer for membership events. It ensures data consistency and resiliency against chain rollbacks while decoupling core indexing logic from application-specific business actions.

Linked Issue

Closes #52

Type of Change

  • 🐛 Bug fix
  • ✨ New feature / enhancement
  • 📝 Documentation update
  • 🔧 Chore / refactor
  • 🧪 Tests only

Changes Made

  • Reorg Safety & Rollbacks: Implemented block hash verification within a configurable confirmation window (INDEXER_CONFIRMATION_DEPTH). If a chain mismatch is detected, the indexer rolls back both its checkpoint and the application-state memberships to a known safe block.
  • Finality Management: Configured the indexer checkpoint to lag behind the chain tip by the confirmation depth, ensuring only finalized data progresses.
  • Idempotency: Tracked events by transaction hash and log index to correctly handle re-included transactions after a reorg by re-processing events marked as reverted.
  • Decoupled Business Logic: Introduced a MembershipService to handle application-specific side effects, fully supporting both apply and revert operations.
  • Workspace Architecture: Initialized the apps/access-api workspace and packages/contracts package to facilitate clean ABI sharing across the project.

Checklist

  • [x ] I have read CONTRIBUTING.md
  • This PR is linked to an open issue
  • npm run typecheck passes with no errors
  • npm run lint passes (or issues are pre-existing and documented)
  • The Discord bot still starts and responds to commands (if bot code changed)
  • No secrets, tokens, or API keys are included in this PR
  • Environment variable changes are reflected in .env.example
  • I have updated documentation if new behaviour was introduced

google-labs-jules Bot and others added 2 commits June 27, 2026 06:20
- Initialized `packages/contracts` with Membership ABI.
- Initialized `apps/access-api` with Prisma schema for events and memberships.
- Implemented `MembershipIndexer` with:
    - Lagged finality window (configurable confirmation depth).
    - Reorg detection via block hash verification.
    - Automatic state rollback and reconciliation.
    - Idempotent log processing with re-processing of reverted events.
- Implemented `MembershipService` to handle transactional updates and reverts.
- Updated `.env.example` with indexer configurations.
- Added tests for indexer initialization and reorg logic.

Co-authored-by: clintjeff2 <119521983+clintjeff2@users.noreply.github.com>
…2410485

Make the chain indexer reorg-safe
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.

Add package-level test coverage for dashboard services

1 participant