Skip to content

Implement a reorg-aware Stellar event ingestion pipeline that detects ledger rollbacks and reverses affected database state #724

Closed

Description

@Chucks1093

Summary

The current event ingestion pipeline assumes Stellar ledgers are final on first observation. In practice, a network partition or validator disagreement can cause a short ledger rollback (reorg), invalidating previously ingested events. The pipeline must detect when the next ledger's previousLedgerHash does not match the stored hash of the last ingested ledger, trigger a rollback of all affected database records, and re-ingest from the fork point.

Scope

  • Store ledgerSequence and ledgerHash for every ingested event in a LedgerCheckpoint table
  • On each new ledger, verify incoming.previousLedgerHash === checkpoint[incoming.sequence - 1].hash
  • On mismatch: identify the fork point by walking backwards through LedgerCheckpoint until hashes agree, mark all events from the fork point forward as REORGED, reverse their database side effects (key balance changes, holder count changes, transaction history entries) inside a single database transaction, then re-ingest from the fork point
  • Emit a warn-level structured log with forkPoint, reorgedLedgerCount, and affectedEventCount on every reorg
  • Gate all buy/sell API responses on confirmed ledger depth ≥ 2 (no response until the ledger is 2 deep) to reduce reorg exposure
  • Add integration tests: clean ingestion advances the checkpoint, a simulated reorg triggers rollback and re-ingestion, rolled-back balance changes are correctly reversed, re-ingested events produce the same final state as if the reorg never happened

Acceptance Criteria

  • LedgerCheckpoint table stores hash and sequence for every ingested ledger
  • Hash mismatch triggers rollback of all events from the fork point forward
  • Rolled-back database side effects fully reversed in a single atomic transaction
  • Warn log emitted with fork point and affected counts on every reorg
  • Buy/sell responses gated on ledger depth ≥ 2
  • Re-ingestion after rollback produces identical final state

ETA: 24 hours


Coordinate on Telegram

Activity

  1. datagerl commented on Aug 15, 2026

    @datagerl

    Hi dev please allow me work on this issue

  2. devkryssie commented on Aug 16, 2026

    @devkryssie

    I’m interested in this issue because it combines backend engineering, database consistency, and Stellar blockchain event processing. I have experience building backend APIs and working with databases, and I’m confident I can implement reliable ledger checkpointing, reorg detection, atomic state rollback, and re-ingestion with thorough integration tests. I’m committed to delivering a robust solution that preserves data integrity and handles reorgs safely.

  3. bytebinders commented on Aug 16, 2026

    @bytebinders

    @Chucks1093 Follow-up on issue #724 Please assign this task to Bytebinders for implementation.

  4. lekanay2005-coder commented on Aug 17, 2026

    @lekanay2005-coder

    i will like to work on this issue pls

  5. AUWALANCHAU commented on Aug 19, 2026

    @AUWALANCHAU

    I have experience with web development and programming, particularly HTML, CSS, JavaScript, and Python. I approach technical issues by first understanding the problem, reproducing it when possible, identifying the root cause, and then testing a clear solution. I also value clean, maintainable code and documenting the changes so others can easily understand and contribute.

  6. dami-005 commented on Aug 20, 2026

    @dami-005

    hello maintainer, after reviewing this issue i am confident i can resolve in due time

  7. Ridwan-001-bip commented on Aug 20, 2026

    @Ridwan-001-bip

    Hello I’ve reviewed the issue description and I’m confident and competent to give you exactly your insight view on this issue I can work on it effectively.
    I will implement and fix this issue according to the requirement and to fit your acceptance criteria.

  8. nomsoscript commented on Aug 24, 2026

    @nomsoscript
    Contributor

    Can I work on this?

  9. ubongante7-create commented on Aug 29, 2026

    @ubongante7-create

    Gm maintainer please i would love to work on this issue and contribute to your project

    Please can you assign it to me

  10. guptakumarranjeet150 commented on Sep 14, 2026

    @guptakumarranjeet150

    Hello! I would like to work on this issue.

    I would like to resolve this issue. Here is my proposed execution plan:

    • Implementation: Implement Implement a reorg-aware Stellar event ingestion pipeline that detects ledger rollbacks and reverses affected database state with thorough authorization verification and clean data structures.
    • Testing: Ensure contract compiles cleanly and passes all cargo tests without warnings.

    I am ready to start immediately—please feel free to assign this to me!

  11. guptakumarranjeet150 commented on Sep 27, 2026

    @guptakumarranjeet150

    Hello team,

    I am interested in working on this issue.
    Plan:

    1. Structure Soroban contract handlers for Implement a reorg-aware Stellar event ingestion pipeline that detects ledger rollbacks and reverses affected database state following project idioms and storage invariants.
    2. Ensure contract compiles cleanly and passes all cargo tests without warnings.

    Looking forward to collaborating on this—please assign!

  12. 12 remaining items

  13. damilare0813 commented on Oct 17, 2026

    @damilare0813

    @damilare0813 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello, I'd like to work on this. I have experience with Rust/Soroban and I've worked on similar tests before. I can start now and open PR within 2 days. Here is my GitHub: [your link]"

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @damilare0813 to this issue.

  14. Ayfataan commented on Oct 17, 2026

    @Ayfataan

    @Ayfataan has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I’d like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Ayfataan to this issue.

  15. timiturn3r commented on Oct 17, 2026

    @timiturn3r
    Contributor

    @timiturn3r has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello @maintainer, I’d like to work on this issue. I have experience handling similar tasks and can start immediately. And I will deliver at the shortest possible time.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @timiturn3r to this issue.

  16. Anorakthegr8 commented on Oct 17, 2026

    @Anorakthegr8
    Contributor

    @Anorakthegr8 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hi maintainer
    Please can I be assigned to this issue ?

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Anorakthegr8 to this issue.

  17. DanbabaJr commented on Oct 17, 2026

    @DanbabaJr

    @DanbabaJr has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I'm an active contributor with a solid track record on Drips, having consistently taken on issues, delivered quality work, and contributed to successful project outcomes. I've gained valuable experience working with different repositories, understanding codebases, and collaborating with maintainers.

    I'm looking forward to another productive wave. I'm ready to take on challenging issues, deliver reliable results, and maintain the standard I've built so far. I'd appreciate the opportunity to contribute again.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @DanbabaJr to this issue.

  18. mysterio123865 commented on Oct 17, 2026

    @mysterio123865

    @mysterio123865 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Kindly assign

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @mysterio123865 to this issue.

  19. drips-wave commented on Oct 17, 2026

    @drips-wave

    Congratulations, @DanbabaJr! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @DanbabaJr: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  20. added a commit that references this issue on Oct 22, 2026
  21. grantfox-oss commented on Oct 22, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @DanbabaJr's PR #1184 was approved and merged by @Chucks1093.

    🏆 @DanbabaJr: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (560 total points). Track your full progress on GrantFox.

    👏 Great work, @DanbabaJr! Keep contributing to accesslayerorg.

  22. drips-wave commented on Oct 22, 2026

    @drips-wave

    This issue has been completed by @DanbabaJr as part of the Stellar Wave Program's 10th Wave 🥳

    😎 @DanbabaJr: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions