You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
getLeaderboard() copies every registered address and bubble-sorts the full set on every call. This is O(n²) work and can become too expensive for an RPC eth_call. It also evaluates total - 1; with zero registered players, Solidity 0.8 checked arithmetic underflows and the empty leaderboard reverts.
Reproduction
Deploy a fresh MathBlocGame with no registered players.
Call getLeaderboard(10).
Observe an arithmetic panic instead of [].
Proposed scope
Return an empty array safely when registeredPlayers.length == 0 or topN == 0.
Replace full on-chain sorting with a scalable design (event-indexed/off-chain leaderboard, bounded top-K maintenance, or paginated unsorted reads with client/indexer ranking).
Define stable tie-breaking and pagination semantics.
Preserve a practical migration/compatibility path for existing consumers.
Acceptance criteria
Empty and topN=0 calls return [].
Behavior is deterministic for ties and topN > playerCount.
Gas/RPC performance is measured at realistic player counts and no longer grows quadratically per read.
Tests cover 0, 1, tied, large-N, and oversized topN cases.
Frontend and daily activity script use the new API safely.
Activity
Xaxxoo commentedon Aug 21, 2026
Hi, can I please take up on this issue ?
grantfox-oss commentedon Aug 22, 2026
🦊 GrantFox — @Xaxxoo has been assigned to this issue as part of the Third Campaign campaign!
Next steps:
Closes #8)Good luck! Track your progress on GrantFox.
grantfox-oss commentedon Aug 31, 2026
🎉 This issue has been marked as completed on GrantFox!
@Xaxxoo's PR #13 was approved and merged by @llinsss.
🏆 @Xaxxoo: You earned 40 FoxPoints for this contribution! Your current tier: Builder (1,668 total points). Track your full progress on GrantFox.
👏 Great work, @Xaxxoo! Keep contributing to DogStark.
Fix reverting leaderboard and replace O(n^2) sorting with bounded top-K
grantfox-oss commentedon Aug 31, 2026
🎉 This issue has been marked as completed on GrantFox!
@Xaxxoo's PR #16 was approved and merged by @llinsss.
🏆 @Xaxxoo: You earned 40 FoxPoints for this contribution! Your current tier: Builder (1,708 total points). Track your full progress on GrantFox.
👏 Great work, @Xaxxoo! Keep contributing to DogStark.
fix: replace reverting quadratic leaderboard with safe O(n*K) selection