Repository navigation
Conversation
|
Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@MrOmale Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
closes #458
Related: #273, #274, #276
Fixes a regression in
MaintenancePoolService.assignReward()where the double-payout guard was mistakenly keyed on(pool, recipient)rather than(pool, issue).Problem
In the previous implementation (#273):
assignReward(pool, issue#1, ..., recipientA)followed byassignReward(pool, issue#1, ..., recipientB)both succeeded because the query only filtered onpayment.recipientId.recipientIdwas omitted, the condition becamepayment.recipientId = NULL(always false in SQL), allowing unlimited payouts for the same issue.const existingPayment = await this.paymentRepo.findOne(...)ran an unscoped query whose return value was discarded.Paymentto close concurrent-call races.Solution
Schema & Entity (
Payment):maintenanceIssueId: string | nulland relationmaintenanceIssue: Issue | null(ON DELETE SET NULL) toPayment.UQ_payment_escrow_maintenance_issueon(escrowId, maintenanceIssueId). In PostgreSQL, standard unique indexes allow multiple rows wheremaintenanceIssueId IS NULL(bounty/milestone payments) while strictly enforcing uniqueness for non-null maintenance issues per escrow.1785400000000-AddPaymentMaintenanceIssueIdAndIndex.ts.Escrow Service (
EscrowService.poolWithdraw):maintenanceIssueId?: stringand persists it on the createdPaymentrow.Maintenance Pool Service (
MaintenancePoolService.assignReward):existingPaymentquery.issueIdintothis.escrowService.poolWithdraw().23505), rolling back the balance decrement viathis.poolRepo.increment, and throwingConflictException.Tests Added / Updated
src/maintenance-pool/maintenance-pool.service.spec.ts:rejects when the same issue is rewarded a second time with a different recipient (409) (#458)allows two different issues to be rewarded to the same recipient (#458)rejects anonymous payout when issue was already rewarded (#458)catches unique constraint violation on concurrent insert and rolls back balance (#458)#273test to assertpayment.maintenanceIssueId = :issueId.#51to operate on distinct issues.src/common/entities/payment.entity.spec.ts:UQ_payment_escrow_maintenance_issueindex metadata onPayment.src/escrow/escrow.service.spec.ts:poolWithdrawpersistsmaintenanceIssueIdonPayment.Verification
npm test -- payment.entity.spec.ts escrow.service.spec.ts maintenance-pool.service.spec.ts