fix: reject set_personal_cap below lifetime_contribution (#441) - #744
Merged
davidmaronio merged 2 commits intoAug 6, 2026
Merged
Conversation
Validate the new personal cap against the caller's existing lifetime_contribution in set_personal_cap_fn. Setting a cap below what the contributor has already contributed is rejected with ValidationFailed, preventing self-freeze with no recovery path. Two regression tests added: - Rejects cap below lifetime_contribution - Asserts cap == lifetime blocks further contributions (boundary test)
Validate the new personal cap against the caller's existing lifetime_contribution in set_personal_cap_fn. Setting a cap below what the contributor has already contributed is rejected with ValidationFailed, preventing self-freeze with no recovery path. Two regression tests added: - Rejects cap below lifetime_contribution - Asserts cap == lifetime blocks further contributions (boundary test)
Contributor
|
thanks for the clean resubmission, this version is a proper 2 file diff and the guard plus boundary tests are correct. unfortunately #688 was opened earlier for the same fix (issue family #441/#457), has the same guard, and also updates the property test model in test_cap_interactions.rs so the proptest oracle stays in sync with set_personal_cap_fn, which this pr leaves stale. closing in favor of #688. happy to see you on another open issue. |
8 tasks
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.
PR #441: Reject personal cap below lifetime_contribution
Problem
set_personal_cap_fndid not validate the new cap against the caller's existinglifetime_contribution. A contributor could set their cap to 1 stroop after contributing 1000 XLM, permanently blocking further contributions with no way to raise the cap again.Fix
Added a validation check in
set_personal_cap_fn(src/contributions.rs) that rejects any personal cap value below the caller's currentlifetime_contribution:Setting a cap equal to
lifetime_contributionis intentionally allowed — it blocks future contributions without stranding anything, and the contributor can always set a higher cap later.Tests
Two regression tests in
src/tests/test_regressions.rs:test_set_personal_cap_below_lifetime_contribution_rejected— contributes 1000, asserts cap=500 is rejected, cap=1000 is accepted, cap=2000 is accepted.test_set_personal_cap_equal_lifetime_blocks_further_contributions— contributes 1000, sets cap to 1000 (equal to lifetime), asserts a subsequent contribution of 1 stroop is rejected withContributionCapExceeded. This documents the boundary behavior as intentional.Diff
Closes #441