Skip to content

feat(indexer): scheduled event retention cleanup job for transaction audit log (closes #174) - #234

Draft
s6pa1rta3n-lab wants to merge 1 commit into
Cylo-Traders:masterfrom
s6pa1rta3n-lab:fix-issue
Draft

feat(indexer): scheduled event retention cleanup job for transaction audit log (closes #174)#234
s6pa1rta3n-lab wants to merge 1 commit into
Cylo-Traders:masterfrom
s6pa1rta3n-lab:fix-issue

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Closes #174

Summary of Changes

  • Added @nestjs/schedule to manage background recurring tasks.
  • Imported ScheduleModule.forRoot() in AppModule.
  • Created EventRetentionService in server/src/indexer/retention/event-retention.service.ts and registered it in IndexerModule.
  • Implemented @Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT) scheduled cleanup job that deletes generic Transaction audit log rows older than soroban.eventRetentionDays (configured via EVENT_RETENTION_DAYS, default 7).
  • Deletions are processed in batches (default: 500) to prevent table locks and memory overhead on large tables.
  • Audit-Only Scope Decision: Retention is strictly scoped to the generic Transaction audit log. Domain records (Investment, Tranche, Dispute, Order, Campaign, User) are permanently preserved to retain complete financial history and ledger auditability.
  • Emits observable logs and metrics (deletedCount, durationMs, batches, cutoffDate, retentionDays) on each cleanup run.
  • Documented EVENT_RETENTION_DAYS behavior in .env.example.
  • Added unit test suite in server/src/indexer/retention/event-retention.service.spec.ts covering cutoff calculation, batching, zero expired rows, domain data preservation, metric logging, and error handling.
  • Added E2E integration test in server/test/event-retention.e2e-spec.ts verifying that expired Transaction rows are pruned while recent transactions and domain rows (Investment, Tranche, Dispute, Campaign, User) remain intact.

Acceptance Criteria Checklist

  • A scheduled cleanup job exists, runs on the configured cadence, and respects EVENT_RETENTION_DAYS.
  • The job is scoped to audit-only data with explicit documentation preserving domain rows.
  • Covered by tests exercising both "older than retention" and "within retention" cases as well as domain entity preservation.

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

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.

[Backend] EVENT_RETENTION_DAYS is fully validated as a config option but no retention or cleanup job exists anywhere

1 participant