Feature/ledger backfill 419#502
Open
Babigdk wants to merge 3 commits into
Open
Conversation
…and idempotency - Add BackfillCheckpoint model to track backfill progress - Add ContractEvent model to store contract events with composite unique key - Implement LedgerBackfillService with full backfill logic: * triggerBackfill: Start new backfill job with checkpoint * resumeBackfill: Resume from last processed ledger * processBackfillBatch: Process batches of ledgers * processLedgerRange: Handle event fetching and storage * getBackfillStatus: Query checkpoint status * listCheckpoints: List and filter checkpoints * pauseBackfill: Pause running jobs - Add LedgerBackfillProcessor for BullMQ job processing - Enhanced LedgerAdminController with new endpoints: * POST /admin/ledger/backfill - Trigger backfill * GET /admin/ledger/backfill - List checkpoints * GET /admin/ledger/backfill/:checkpointId - Get status * POST /admin/ledger/backfill/:checkpointId/resume - Resume job * POST /admin/ledger/backfill/:checkpointId/pause - Pause job - Add comprehensive tests for LedgerBackfillService - Ensure idempotency through composite unique keys on ContractEvent - Support configurable batch sizes and max retry attempts Closes Pulsefy#419
|
@Babigdk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ledger Backfill Service for Testnet Contract Events (#419)
Closes #419
Overview
This PR implements a comprehensive ledger backfill service that scans historical contract events from the Stellar Testnet and populates analytics and timelines. The implementation follows best practices for idempotency, resumability, and observability.
✨ Key Features
1. Configurable Ledger Backfill
2. Progress Checkpoint System
3. Idempotent Event Storage
ContractEventmodel(contractId, ledgerSequence, transactionHash, eventIndex)4. Resilient Job Processing
📦 Database Changes
New Models
BackfillCheckpoint
id,jobId,contractId,startLedger,endLedger,lastProcessedLedgerContractEvent
🔌 API Endpoints
All endpoints require admin role and API authentication.
POST
/v1/admin/ledger/backfillTrigger a new backfill job
Request:
{ "contractId": "CCONTRACTID...", "startLedger": 1000, "endLedger": 2000, "campaignId": "campaign_123", "batchSize": 100 }