Skip to content

[BUG] /events/soroban pagination cursor breaks when events are indexed out of chronological order #893

Open

Description

@meshackyaro

Bug Description

Cursor-based pagination assumes monotonically increasing ledger sequence, but if the indexer backfills historical events after already indexing recent ones, the cursor can skip or repeat entries.

Component

  • Backend
  • Frontend
  • Smart Contract
  • SDK
  • Documentation
  • Other:

Steps to Reproduce

  1. Index a batch of recent events.
  2. Trigger a historical backfill for older events.
  3. Page through /events/soroban using the returned cursor.
  4. Check for skipped or duplicated entries across pages.

Expected Behavior

Pagination should remain correct regardless of indexing order, typically by using a stable, globally ordered key rather than insertion order.

Actual Behavior

Pages can skip or duplicate entries once a backfill has run after live indexing began.

Environment

  • Node Version: 20.x
  • OS: Linux / macOS
  • Browser (if applicable): N/A
  • Network (Testnet/Mainnet): Testnet

Error Messages/Logs

N/A — no error output; behavior is incorrect but silent.

Screenshots

N/A — backend/API issue, not applicable.

Additional Context

The cursor is derived from Redis's natural ordering (insertion order) rather than an explicit sort key.

Possible Solution

Use a sorted set keyed by (ledgerSeq, eventIndex) for pagination rather than relying on insertion order.

Activity

  1. added
    bug
    difficulty: hard
    priority: medium
    on Oct 29, 2026
  2. maxx-GENIUS commented on Nov 1, 2026

    @maxx-GENIUS

    Hi @trustflow-protocol maintainers,

    I can resolve this. Looking at the requirements, /events/soroban pagination cursor breaks when events are indexed out of chronological order. My plan is to implement a targeted fix for this following project standards, accompanied by tests to reproduce the scenario and confirm the fix passes all checks.

    Please assign this to me and I will put together a clean PR.

  3. ranjan1969x commented on Nov 2, 2026

    @ranjan1969x

    Hello maintainers,

    I reviewed the issue for /events/soroban pagination cursor breaks when events are indexed out of chronological order. Governance authorization checks, boundary caps, or state validation need to be enforced across contract invocations.

    Proposed Implementation:

    1. Implement strict administrative authorization checks (require_auth) and state transition validations.
    2. Enforce boundary rules and prevent state corruption or reentrancy hazards.
    3. Emit comprehensive audit events upon successful state modifications.

    Testing & Verification:
    I will write contract integration tests verifying both authorized state updates and unauthorized invocation rejections.

    Looking forward to working on it if assigned. Ready to implement the fix.

  4. GangDev6707 commented on Nov 3, 2026

    @GangDev6707

    Hello @trustflow-protocol team,

    I'd like to help resolve this issue. Governance authorization checks, boundary caps, or state validation need to be enforced across contract invocations. I plan to implement strict administrative authorization checks (require_auth) and state transition validations and enforce boundary rules and prevent state corruption or reentrancy hazards, followed by emit comprehensive audit events upon successful state modifications.

    I'll write contract integration tests verifying both authorized state updates and unauthorized invocation rejections to verify everything passes cleanly.

    Happy to take this on if you can assign it over. Will get a clean PR ready promptly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdifficulty: hardinfrastructurepriority: mediumweb3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions