Skip to content

BountiesService.refund and markMergedAndRelease commit the on-chain call and the local status flip separately #796

Closed

Description

@chonilius

Both methods move funds first and record the outcome in an unrelated transaction afterwards.

// refund, src/bounties/bounties.service.ts:269-274
    if (bounty.escrowId) { await this.escrowService.refund(bounty.escrowId); }
    bounty.status = BountyStatus.REFUNDED;
    return this.bountyRepo.save(bounty);

// markMergedAndRelease, :232-237
    assertTransition(bounty.status, BountyStatus.PAID);
    bounty.status = BountyStatus.PAID;
    bounty.paidAt = new Date();
    const paid = await this.bountyRepo.save(bounty);

escrowService.refund/release each commit their own Escrow (and Payment) writes before returning.

Why it matters: a failure of the final save leaves the chain and the local ledger disagreeing in the most consequential direction. For refund: the funder has their money back, the Escrow row says REFUNDED, and the bounty still says MERGED/FUNDED — so it remains refundable again, and assertTransition will happily permit a second escrowService.refund, which the contract rejects as AlreadyRefunded and which invokeOnLockedEscrow records as a lastFailure rather than a resolution. For markMergedAndRelease: the contributor is paid, Payment rows exist, and the bounty is stuck at MERGED, where a retry re-attempts the release.

EscrowService is careful about this internally — the #154 comments explain that the escrow flip and the Payment insert must be one transaction. The gap is at the service boundary, exactly as in BountiesService.fund.

Fix: have BountiesService own the transaction and pass the EntityManager into the escrow service (it already accepts one on releasePartial), so the status flip and the escrow/payment writes commit together. The on-chain call cannot be transactional, so it must be the last thing before commit, with the escrow row recording the hash for reconciliation if the commit then fails.

Activity

  1. added
    bug
    on Nov 12, 2026
  2. added
    Stellar Wave
    on Nov 19, 2026
  3. darkifyyy commented on Nov 19, 2026

    @darkifyyy

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

    Hello.
    I can work on this.
    Please ASSIGN
    Thank you

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

  4. SeveentWonder commented on Nov 19, 2026

    @SeveentWonder

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

    Hi Maintainer, I’d like to take this immediately and aim to get a working PR up within the next few hours.

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

  5. kanuemmanuel commented on Nov 19, 2026

    @kanuemmanuel

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

    Dear maintainr, please kindly assign , let's work on this

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

  6. jd-here-007 commented on Nov 19, 2026

    @jd-here-007
    Contributor

    @jd-here-007 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

    hi maintainer let me fix this please

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @jd-here-007 to this issue.

  7. drips-wave commented on Nov 19, 2026

    @drips-wave

    Congratulations, @jd-here-007! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.

    🧑‍💻 @jd-here-007: 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 🌊

  8. drips-wave commented on Nov 20, 2026

    @drips-wave

    This issue has been completed by @jd-here-007 as part of the Stellar Wave Program's 11th Wave 🥳

    😎 @jd-here-007: 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

Stellar Wavebug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions