Repository navigation
feat: implement cursor-aware pagination and event-level idempotency - #17
Conversation
diiabblo
left a comment
There was a problem hiding this comment.
Review: Request Changes
Good direction -- cursor-based pagination and Redis-backed event idempotency are the right approaches. A few issues need fixing before merge:
Blocking
Missing migration for schema change (prisma/schema.prisma)
The TreasuryEvent model drops @unique from txHash and adds a new eventId unique field. No migration SQL is included. Add a prisma migrate dev --create-only migration that adds the event_id column with a unique index and safely removes the tx_hash unique constraint.
No tests
The issue requires tests for paginated responses, replay idempotency, crash recovery, and multiple events per transaction. The PR contains no test files.
Should address
(response as any).cursor (src/lib/indexer/engine.ts:347)
The SorobanRpc response type should include a cursor field. Use proper typing instead of any casting.
Redis Set grows unbounded
orbitpay:indexer:processed_events has no TTL. Add an expiry or periodic cleanup so this does not grow indefinitely as events accumulate.
|
great job @Richiey1 |
Closes #14
Summary of Changes
Implemented cursor-aware pagination for the Soroban event fetcher and enforced true event-level idempotency to prevent duplicate domain writes across checkpoints.
What changed
startLedgerpolling with cursor-based pagination inrpc.getEventscalls inside the indexer engine.event.idreturned by Soroban RPC instead of justtx_hash.TreasuryEventdatabase constraint fromtx_hashtoevent_idto cleanly support multiple distinct treasury events emitted within a single transaction.Testing / Local Verification