fix(escrow): deduplicate sponsor contributions to prevent MAX_SPONSORS exhaustion - #175
Open
rafaio1 wants to merge 1 commit into
Open
fix(escrow): deduplicate sponsor contributions to prevent MAX_SPONSORS exhaustion#175rafaio1 wants to merge 1 commit into
rafaio1 wants to merge 1 commit into
Conversation
…S exhaustion A single address could call contribute() repeatedly, each time consuming a new slot against MAX_SPONSORS (20) and permanently locking out other would-be co-funders. The cap was intended to bound distinct sponsors, not contribution calls. Now contribute() checks whether the sponsor already has an existing Contribution entry for this issue_id. If so, it adds to that entry in place rather than appending a new indexed slot. Only genuinely new sponsors consume a slot against MAX_SPONSORS. Closes MergeFi#139
|
Someone 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.
Summary
Fixes #139
Problem
contribute()incrementsescrow.contributor_counton every accepted call and rejects once it hitsMAX_SPONSORS(20), but never checks whether thesponsoralready has an existingContributionentry for thisissue_id. A single address callingcontribute19 times after the originalfundis accepted as 19 separate contribution slots, each counted against the cap. This permanently locks out every other would-be co-funder for thatissue_idwithTooManySponsors, while the design doc's own framing assumes the cap protects against a large number of different people joining, not one person calling repeatedly.Additionally,
refund()would issue N separate token transfers to the same address instead of one consolidated transfer.Fix
contribute()now iterates over existing contributions to check if the sponsor already holds aContributionentry for thisissue_id. If found, the new amount is added to the existing entry in place rather than appending a new indexed slot. Only genuinely new sponsors consume a slot againstMAX_SPONSORS.Testing
Impact
Prevents denial-of-service against crowdfunding participation and reduces unnecessary storage/gas overhead from duplicate contribution entries.