Add Soroban event ingestion idempotency key derived from txHash and ledger in src/services/eventProcessor.ts
Description
src/services/eventProcessor.ts writes events to the processed_events table (db/migrations/20260225220000_create_processed_events.cjs) but does not derive the idempotency key from txHash:ledger:eventIndex, leaving duplicate-event detection brittle. Compute and persist a canonical key as a unique index so retries cannot insert duplicates.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- New Knex migration adding
event_key text unique not null
- Backfill existing rows where possible
- Update
src/services/eventProcessor.ts and src/services/eventParser.ts
- Add
src/tests/eventProcessor.idempotency.test.ts
- Update
docs/event-processing.md
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/event-key-idempotency
- Implement changes
- Add migration and backfill script
- Update processor and parser
- Add tests and docs
- Test and commit
- Run
npm run migrate:latest && npm test
- Include test output and notes
Example commit message
feat: canonical idempotency key for Soroban events
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Add Soroban event ingestion idempotency key derived from txHash and ledger in src/services/eventProcessor.ts
Description
src/services/eventProcessor.tswrites events to theprocessed_eventstable (db/migrations/20260225220000_create_processed_events.cjs) but does not derive the idempotency key fromtxHash:ledger:eventIndex, leaving duplicate-event detection brittle. Compute and persist a canonical key as a unique index so retries cannot insert duplicates.Requirements and context
event_key text unique not nullsrc/services/eventProcessor.tsandsrc/services/eventParser.tssrc/tests/eventProcessor.idempotency.test.tsdocs/event-processing.mdSuggested execution
git checkout -b feat/event-key-idempotencynpm run migrate:latest && npm testExample commit message
feat: canonical idempotency key for Soroban eventsGuidelines