fix: saturating reputation increments and uniform VRF shuffle - #394
Merged
cypriannwokolo2-creator merged 2 commits intoAug 31, 2026
Merged
Conversation
added 2 commits
August 31, 2026 11:50
Bare `current + 1` panics on overflow in Soroban, aborting the whole transaction. Use saturating_add so streaks/completions/defaults cap at u32::MAX instead of panicking. Closes cocor-tech#284
The naive `vrf_val % n` modulo approach could push duplicate positions, biasing payout order and leaving some members unshuffled. Replace with a Fisher-Yates swap per VRF evaluation, producing a uniform permutation. Closes cocor-tech#285
|
@nekwasar 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 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.
What changed
Two bug fixes:
Reputation registry overflow (Reputation-registry storage: unchecked u32 overflow in increment functions #284):
increment_streak,increment_completions, andincrement_defaultsused barecurrent + 1, which panics on overflow on Soroban and aborts the whole transaction. Now usesaturating_add(1).VRF uniform shuffle (VRF shuffle_positions produces non-uniform permutation (collisions) #285):
shuffle_positionsderived positions viavrf_val % n, which collides and produces a non-uniform permutation (some positions duplicated, some never selected). Replaced with Fisher-Yates using one VRF evaluation per swap.Notes
load_round_detailsimport) and Treasury inconsistent API: mixes Env and ExecCtx patterns #289 (treasury mixingEnv/ExecCtx) are already resolved onmaster, so no changes were needed there.Closes #284
Closes #285
Closes #288
Closes #289