fix(maintenance-pool): guard assignReward by issueId and enforce unique payout index (#458) - #472
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 #458 passed on September 30 without a solution from the original assignee, I have submitted a complete and fully tested fix here (all 78 unit tests passing locally, production build verified). 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 #458 (Regression on #273).
Root Cause
In
MaintenancePoolService.assignReward(), the idempotency guardexistingPoolPaymentfiltered onpayment.recipientId = :recipientIdinstead ofpayment.maintenanceIssueId = :issueId. This caused:ConflictException.recipientId = null) to bypass the guard entirely.existingPayment) executing on every call.Fix
maintenanceIssueIdandmaintenanceIssuerelation toPayment, along with composite unique indexUQ_payment_escrow_maintenance_issueon[escrowId, maintenanceIssueId]to close concurrent race conditions at the database level.maintenanceIssueIdparameter topoolWithdraw()and persisted it on the Payment row. Fixed Sorobanu64deadline expectation in test fixtures.existingPaymentquery.existingPoolPaymentto filter bypayment.maintenanceIssueId = :issueId.issueIdtopoolWithdraw().23505) on concurrent races, converting them intoConflictExceptionand restoring pool balance via compensating increment (assignReward decrements MaintenancePool.balance before poolWithdraw() and never restores it when the withdrawal fails #459).ACTIVEstatus on pool fixtures inmaintenance-pool.service.spec.ts.maintenance-pool.service.spec.tsand 58/58 inescrow.service.spec.ts.