Skip to content

feat: Soroban event listener with reconnect, dedup, and polling fallback#94

Open
Arowolokehinde wants to merge 1 commit into
ericmt-98:mainfrom
Arowolokehinde:feat/soroban-event-listener
Open

feat: Soroban event listener with reconnect, dedup, and polling fallback#94
Arowolokehinde wants to merge 1 commit into
ericmt-98:mainfrom
Arowolokehinde:feat/soroban-event-listener

Conversation

@Arowolokehinde
Copy link
Copy Markdown

@Arowolokehinde Arowolokehinde commented May 27, 2026

Implements the background event streaming service for the escrow contract (closes issue on Horizon/Soroban event listener with polling fallback).

Closes #85

Key changes:

  • EscrowEventListener: cursor-based RPC polling with full-jitter exponential backoff, injectable deps for testability, and isHealthy() signal exposed on /health for the polling-fallback UX
  • event-dispatcher: pure parseEscrowEvent + idempotent applyEscrowEvent; released → completed, refunded → cancelled, both guarded with NOT IN terminal states to prevent double-mutations
  • Deduplication via existing processed_tx table (evt:{id} keys, O(1) PK lookup)
  • contract_trade_id column on trades (sha256 of secret_hash) for O(1) event → trade lookup; populated at lock time
  • event_cursor table persists polling position across restarts; atomic UPSERT on PostgreSQL, check-then-set on in-memory fallback
  • Graceful cursor reset when RPC 7-day window is exceeded after long downtime
  • 20 tests across 7 suites (no network or PostgreSQL required)
  • Existing frontend polling and Horizon confirmation loop untouched

Implements the background event streaming service for the escrow contract
(closes issue on Horizon/Soroban event listener with polling fallback).

Key changes:
- EscrowEventListener: cursor-based RPC polling with full-jitter exponential
  backoff, injectable deps for testability, and isHealthy() signal exposed
  on /health for the polling-fallback UX
- event-dispatcher: pure parseEscrowEvent + idempotent applyEscrowEvent;
  released → completed, refunded → cancelled, both guarded with NOT IN
  terminal states to prevent double-mutations
- Deduplication via existing processed_tx table (evt:{id} keys, O(1) PK lookup)
- contract_trade_id column on trades (sha256 of secret_hash) for O(1)
  event → trade lookup; populated at lock time
- event_cursor table persists polling position across restarts; atomic
  UPSERT on PostgreSQL, check-then-set on in-memory fallback
- Graceful cursor reset when RPC 7-day window is exceeded after long downtime
- 20 tests across 7 suites (no network or PostgreSQL required)
- Existing frontend polling and Horizon confirmation loop untouched
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@Arowolokehinde 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! 🚀

Learn more about application limits

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.

Horizon/Soroban event listener as latency upgrade

1 participant