Skip to content

wave4: add reliability, performance, and data accuracy improvements#188

Merged
ritik4ever merged 1 commit intoritik4ever:mainfrom
silhilston:feat/wave4-reliability-performance
Apr 25, 2026
Merged

wave4: add reliability, performance, and data accuracy improvements#188
ritik4ever merged 1 commit intoritik4ever:mainfrom
silhilston:feat/wave4-reliability-performance

Conversation

@silhilston
Copy link
Copy Markdown
Contributor

Summary

Wave 4 backend improvements focused on reliability, performance, and data accuracy for the StellarStream payment system.

Changes

Reliability (#133): Add retry with exponential backoff

  • retryWithBackoff() helper retries transient RPC errors up to 3 times
  • Exponential backoff: 1s, 2s, 4s delays
  • Only retries on network/timeout errors, not contract panics
  • Applied to sendTransaction() and getTransaction() in createStream

Performance (#132): Cache Soroban RPC responses

  • In-memory TTL cache (5 seconds) for get_stream simulation results
  • Cache keyed by stream ID
  • Lazy cache eviction on next access
  • Cache bypassed on createStream and cancelStream to ensure freshness
  • Reduces redundant RPC calls during high-traffic periods

Data Accuracy (#134): Propagate refund amounts from on-chain responses

  • Add refunded_amount column to streams table
  • Parse refund from cancel transaction return value
  • Include refundedAmount in StreamRecord interface
  • Include in API responses and webhook payloads

Performance & Maintenance (#137): Archive completed streams

  • New stream_archive table with identical schema plus archived_at column
  • archiveOldStreams() function moves streams completed > 30 days ago
  • Runs on server startup and every 24 hours
  • Archived streams excluded from listStreams() by default
  • ?include_archived=true query param includes archived streams
  • Keeps hot table performant

Bug Fixes:

  • Fixed missing canceledStream variable in cancel endpoint
  • Fixed missing newStartAt variable in start time update endpoint

Testing

  • Retry logic tested with mock failures (see test suite)
  • Cache tested for TTL expiration and invalidation
  • Archive function tested for date boundary conditions
  • All endpoints tested with new fields/parameters

Related Issues

Closes #133
Closes #132
Closes #134
Closes #137

…ents

Implements four interconnected enhancements:

1. Retry with exponential backoff (#133): Add retryWithBackoff helper to
   handle transient network errors in RPC calls. Retries up to 3 times
   with delays of 1s, 2s, 4s for timeout/network errors only.

2. RPC response caching (#132): Implement in-memory TTL cache (5s) for
   get_stream calls to reduce redundant RPC requests. Cache is invalidated
   on createStream and cancelStream operations.

3. Refund amount propagation (#134): Extract refund amount from on-chain
   cancel transaction response. Add refunded_amount column to streams table
   and include in API responses and webhooks.

4. Stream archival (#137): Add stream_archive table and archiveOldStreams()
   function to move completed streams older than 30 days. Runs on startup
   and every 24 hours. Archived streams excluded from listStreams() by default
   but can be included via ?include_archived=true query param.

Also fixes bugs in cancelStream and updateStreamStartAt API handlers.

Refs #133 #132 #134 #137
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

@silhilston is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 25, 2026

@silhilston 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

@ritik4ever ritik4ever merged commit 3fc5312 into ritik4ever:main Apr 25, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants