Skip to content

feat(backend): implement horizon failover, transaction index, auth ra… - #1073

Merged
ONEONUORA merged 1 commit into
Fracverse:masterfrom
ibrahimMaryam-tech:feat/backend-services-and-indexer
Sep 24, 2026
Merged

ONEONUORA merged 1 commit into
Fracverse:masterfrom
ibrahimMaryam-tech:feat/backend-services-and-indexer

Conversation

@ibrahimMaryam-tech

Copy link
Copy Markdown
Contributor

Body:**

## Summary of Changes

1. **Stellar Horizon Failover Manager (#947):**
   - Updated `backend/src/services/stellar.rs` with round-robin failover pool across multiple Horizon RPC endpoints upon timeouts or 5xx server errors.

2. **Transaction Database Index Migration (#948):**
   - Added migration `backend/migrations/20260728000000_add_users_created_at_index.sql` adding `CREATE INDEX CONCURRENTLY` on `transactions (user_address, created_at DESC)`.

3. **Auth Rate Limiting Middleware (#949):**
   - Implemented Redis sliding window rate limiter in `backend/src/api/auth.rs` restricting IP attempts to 10 requests/minute, returning HTTP 429 on overflow.

4. **Soroban Event Streamer (#950):**
   - Built Soroban event subscriber in `backend/src/indexer/soroban.rs` consuming `getEvents` and broadcasting decoded events over a `tokio::sync::broadcast` channel to WebSocket frontend clients.

## Issue Resolution

Closes #947
Closes #948
Closes #949
Closes #950

## Verification

- [x] Horizon failover logic implemented in `stellar.rs`
- [x] Non-blocking PostgreSQL migration created
- [x] Redis sliding window rate limiter implemented in Axum middleware
- [x] Tokios broadcast channel event streamer added for Soroban ledger events

…te limiting, and soroban event streamer

- Fracverse#947: StellarClient keeps a sticky primary plus backup RPC endpoints
  (STELLAR_RPC_BACKUP_URLS). Timeouts, connect errors, 5xx and 429 put the
  endpoint on a 30s cooldown and fail over immediately to the next healthy
  one; backoff applies only after a full pass over the pool.
- Fracverse#948: Concurrent (zero-downtime) compound indexes on
  yield_transactions(user_id, created_at DESC) and
  payments(sender_id|receiver_id, created_at DESC), one per no-transaction
  migration, plus rollback scripts. The schema has no `transactions` table
  or `user_address` column, and the already-applied 20260728000000
  migration is left untouched to avoid a sqlx checksum mismatch.
- Fracverse#949: Auth rate limiter is now a sliding window (10 req/min/IP) backed by
  an atomic Redis sorted-set Lua script, falling back to an in-process
  sliding window when Redis is unset or unreachable. 429 responses carry
  Retry-After.
- Fracverse#950: indexer::soroban polls getEvents (via the failover client),
  decodes events with the indexer parser, and fans them out over a
  tokio broadcast channel to WebSocket clients at /api/events/ws. Lagging
  consumers skip ahead instead of blocking the producer. Enables axum "ws".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented Sep 24, 2026

Copy link
Copy Markdown

@ibrahimMaryam-tech 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

@ONEONUORA ONEONUORA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ONEONUORA
ONEONUORA merged commit 7a66578 into Fracverse:master Sep 24, 2026
10 of 11 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

Development

Successfully merging this pull request may close these issues.

3 participants