feat: enforce and test aggregate holder share bps invariant - #863
Merged
thlpkee20-wq merged 3 commits intoAug 31, 2026
Merged
Conversation
|
@kosisochukwu1234 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! 🚀 |
5 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.
Closes #848
Implementation Approach
old_sharescoping insrc/lib.rs: The definition forold_sharewas previously restricted inside theif max_shares > 0block, which caused compilation errors because the variable was accessed later inset_holder_share_internalto correctly compute the aggregate share differences. It has been moved outside this block to properly update theHolderShareTotaldelta.test_holder_share_sum_invariant.rsto guarantee that theset_holder_sharerunning total enforcessum(share_bps) <= 10_000per offering. The test asserts happy paths (summing to exactly 10,000) and negative edge cases (sum exceeding 10,000). It also asserts the correctness of capacity reuse when an existing holder's bps is reduced.sum(share_bps)validation semantics, bounded to0-10000 per offering, mirroring the existing per-holdershare_bpschecks.Acceptance Criteria Covered
test_holder_share_sum_invariant.rsverifying that multiple holders within an offering correctly evaluate to a bounded capacity of10,000 bps.RevoraError::InvalidShareBpsis immediately raised before persistence if any new configuration causes the offering's allocated shares to exceed 100%. No backward compatibility issues are expected because the invariant aligns with preexisting system constraints, providing an extra safety boundary.Failure-Mode Handling
If an issuer issues >10,000 bps by accident, the invocation will fail gracefully with
InvalidShareBps.Files Affected
README.mdsrc/lib.rssrc/test_holder_share_sum_invariant.rs