fix(maintenance-pool): restore balance on failed escrow withdrawal (#459) - #471
Open
Proxima84-code wants to merge 3 commits into
Open
Proxima84-code wants to merge 3 commits into
Proxima84-code wants to merge 3 commits into
Conversation
|
@Proxima84-code is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Hi @maintainers, Since the deadline for issue #459 passed on September 30 without a solution from the original assignee, I have submitted a complete and verified fix here (all 17 unit tests passing, clean TypeScript build). Could you please approve the CI workflow run and review the PR? Thank you! |
This branch has not been deployed
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.
Resolves #459.
Root Cause
In
MaintenancePoolService.assignReward(), the pool balance is atomically decremented in PostgreSQL before executingescrowService.poolWithdraw(). If the on-chain Soroban withdrawal fails (RPC simulation failure, recipient mismatch, or payment record persistence error), the deducted amount was never restored. This resulted in permanent database balance drift against the actual contract balance.Fix
escrowService.poolWithdraw()in atry/catchblock.this.poolRepo.increment({ id: pool.id }, 'balance', Number(amount))on error before rethrowing the original exception.poolWithdrawrejects.