Skip to content

fix: saturating reputation increments and uniform VRF shuffle - #394

Merged
cypriannwokolo2-creator merged 2 commits into
cocor-tech:masterfrom
nekwasar:feat/stellar-drips-wave-284-285
Aug 31, 2026
Merged

fix: saturating reputation increments and uniform VRF shuffle#394
cypriannwokolo2-creator merged 2 commits into
cocor-tech:masterfrom
nekwasar:feat/stellar-drips-wave-284-285

Conversation

@nekwasar

@nekwasar nekwasar commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

What changed

Two bug fixes:

  1. Reputation registry overflow (Reputation-registry storage: unchecked u32 overflow in increment functions #284): increment_streak, increment_completions, and increment_defaults used bare current + 1, which panics on overflow on Soroban and aborts the whole transaction. Now use saturating_add(1).

  2. VRF uniform shuffle (VRF shuffle_positions produces non-uniform permutation (collisions) #285): shuffle_positions derived positions via vrf_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

Closes #284
Closes #285
Closes #288
Closes #289

nekwasar 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
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@cypriannwokolo2-creator
cypriannwokolo2-creator merged commit 6cd6394 into cocor-tech:master Aug 31, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants