fix(bounties): prevent bounties from getting permanently stuck on escrow release failure - #74
Open
windy202508 wants to merge 1 commit into
Open
Conversation
…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
|
@realWindyTree is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #46
When
markMergedAndRelease()was called, the bounty status was persisted toMERGEDbefore attempting the escrow release. If the release failed (e.g., Soroban RPC timeout, network error), the bounty was permanently stuck because:MERGED -> MERGEDtransition (no retry possible)REFUNDED, which would return funds to the sponsor for completed workSolution
1. Added
RELEASE_PENDINGstatus toBountyStatusenumThis represents a bounty whose PR has been merged and is awaiting successful escrow release.
2. Modified state machine transitions
3. Refactored
markMergedAndRelease()MERGEDand save (records the merge event)RELEASE_PENDINGbefore attempting escrow releasePAIDRELEASE_PENDING(allows retry via repeated calls)RELEASE_PENDINGbounty, re-attempt the release4. Updated dependent services
ReputationServiceandAnalyticsServicenow includeRELEASE_PENDINGin their "completed work" checksTesting
RELEASE_PENDINGrecoveryRELEASE_PENDING→PAIDPAIDManual Testing
markMergedAndRelease()with escrow service configured to failRELEASE_PENDING(not stuck atMERGED)markMergedAndRelease()againPAID