Skip to content

fix(bounties): prevent bounties from getting permanently stuck on escrow release failure - #74

Open
windy202508 wants to merge 1 commit into
MergeFi:mainfrom
windy202508:fix/stuck-bounty-release-pending
Open

fix(bounties): prevent bounties from getting permanently stuck on escrow release failure#74
windy202508 wants to merge 1 commit into
MergeFi:mainfrom
windy202508:fix/stuck-bounty-release-pending

Conversation

@windy202508

Copy link
Copy Markdown

Problem

Fixes #46

When markMergedAndRelease() was called, the bounty status was persisted to MERGED before attempting the escrow release. If the release failed (e.g., Soroban RPC timeout, network error), the bounty was permanently stuck because:

  1. The state machine had no MERGED -> MERGED transition (no retry possible)
  2. The only other exit was REFUNDED, which would return funds to the sponsor for completed work

Solution

1. Added RELEASE_PENDING status to BountyStatus enum

This represents a bounty whose PR has been merged and is awaiting successful escrow release.

2. Modified state machine transitions

MERGED -> RELEASE_PENDING
RELEASE_PENDING -> PAID (success)
RELEASE_PENDING -> RELEASE_PENDING (retry on failure)
RELEASE_PENDING -> REFUNDED (admin override)

3. Refactored markMergedAndRelease()

  • First transition to MERGED and save (records the merge event)
  • Then transition to RELEASE_PENDING before attempting escrow release
  • On success: transition to PAID
  • On failure: stay in RELEASE_PENDING (allows retry via repeated calls)
  • Support retry: if called on a RELEASE_PENDING bounty, re-attempt the release

4. Updated dependent services

  • ReputationService and AnalyticsService now include RELEASE_PENDING in their "completed work" checks

Testing

  • ✅ Updated unit tests for state machine transitions
  • ✅ Added test: escrow failure → RELEASE_PENDING recovery
  • ✅ Added test: retry from RELEASE_PENDINGPAID
  • ✅ Added test: unfunded bounty merges directly to PAID

Manual Testing

  1. Create a bounty, fund it, claim it, mark in review
  2. Call markMergedAndRelease() with escrow service configured to fail
  3. Verify bounty status is RELEASE_PENDING (not stuck at MERGED)
  4. Re-configure escrow service to succeed
  5. Call markMergedAndRelease() again
  6. Verify bounty status transitions to PAID

…row release failure

## Problem
When markMergedAndRelease() was called, the bounty status was persisted to
MERGED before attempting the escrow release. If the release failed (e.g.,
Soroban RPC timeout), the bounty was permanently stuck because:
1. The state machine had no MERGED -> MERGED transition (no retry)
2. The only other exit was REFUNDED, which would return funds to the sponsor
   for completed work

## Solution
1. Added RELEASE_PENDING status to BountyStatus enum
2. Modified state machine to allow:
   - MERGED -> RELEASE_PENDING
   - RELEASE_PENDING -> RELEASE_PENDING (retry)
   - RELEASE_PENDING -> PAID
   - RELEASE_PENDING -> REFUNDED
3. Refactored markMergedAndRelease() to:
   - First transition to MERGED and save
   - Then transition to RELEASE_PENDING before attempting escrow release
   - On success: transition to PAID
   - On failure: stay in RELEASE_PENDING (allows retry via repeated calls)
   - Support retry: if called on RELEASE_PENDING bounty, re-attempt release

## Testing
- Updated unit tests for state machine transitions
- Added test for escrow failure -> RELEASE_PENDING recovery
- Added test for retry from RELEASE_PENDING -> PAID
- Updated reputation and analytics services to include RELEASE_PENDING

Fixes MergeFi#46
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

@realWindyTree is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

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