fix(leaderboard): manage instance storage TTL lifecycle - #111
Conversation
|
@Muyideen-js PR ready |
…RWA/SPulse-Contract into fix/leaderboard-instance-ttl
|
Hey @MJ-RWA, This PR cannot be reviewed automatically because it does not reference the issue it solves. Add |
7 similar comments
|
Hey @MJ-RWA, This PR cannot be reviewed automatically because it does not reference the issue it solves. Add |
|
Hey @MJ-RWA, This PR cannot be reviewed automatically because it does not reference the issue it solves. Add |
|
Hey @MJ-RWA, This PR cannot be reviewed automatically because it does not reference the issue it solves. Add |
|
Hey @MJ-RWA, This PR cannot be reviewed automatically because it does not reference the issue it solves. Add |
|
Hey @MJ-RWA, This PR cannot be reviewed automatically because it does not reference the issue it solves. Add |
|
Hey @MJ-RWA, This PR cannot be reviewed automatically because it does not reference the issue it solves. Add |
|
Hey @MJ-RWA, This PR cannot be reviewed automatically because it does not reference the issue it solves. Add |
|
Hey @MJ-RWA, This PR cannot be reviewed automatically because it does not reference the issue it solves. Add |
|
Needs review Linked to The pull request introduces a global instance storage TTL refresh but includes extensive unrelated refactoring, significant functional changes to point accrual and top player management, and modifies/removes several API functions which are outside the scope of managing instance storage TTL. Reviewed commit: |
Muyideen-js
left a comment
There was a problem hiding this comment.
@MJ-RWA This PR does not correctly solve the issue. It introduces unrelated refactors, removes essential public functions (set_token, claim_pending_rewards, add_bonus_pts, ban_player, reset_player), and breaks existing functionality. The TTL lifecycle is not consistently applied to all instance keys (e.g., Admin, MarketContract, ReferralContract, TopPlayerCount, SeqCounter). The new get_rank and get_top_players implementations are incomplete and contain syntax errors. Please revert unrelated changes, restore removed functions, ensure all instance keys are covered by TTL extension, and add regression tests for TTL expiry scenarios. Also, avoid modifying .kilo/kilo.jsonc as it is unrelated.
Summary
Fix the leaderboard's instance-storage TTL lifecycle so cached state such as
MinPointsandMinSlotdoes not silently expire without an appropriate refresh strategy.The leaderboard currently stores core state in Soroban instance storage without explicitly managing its TTL. After prolonged inactivity, this can cause cached values to expire and potentially leave subsequent leaderboard updates operating with missing/default state.
Problem
MinPointsandMinSlotare stored in instance storage, but their TTL lifecycle was not being managed.When the instance-storage TTL expires, the cached minimum can be lost. A subsequent leaderboard update may then observe the missing value as the default
u64::MAXand trigger the minimum-recomputation path unexpectedly.Because this state participates in leaderboard insertion and displacement decisions, TTL expiration can become a latent trigger for incorrect leaderboard behavior.
The same lifecycle concern also applies to other relevant instance-storage entries, so the fix addresses the storage lifecycle consistently rather than adding a narrowly scoped workaround for
MinPointsalone.What Changed
MinPointsandMinSlotare covered by the storage lifecycle strategy.Root Cause
The leaderboard relied on instance-storage values without explicitly managing their TTL lifecycle.
Soroban instance storage is subject to TTL expiration, meaning contract inactivity can cause cached instance state to disappear. The leaderboard's subsequent fallback behavior can then operate on missing cache state and trigger incorrect minimum handling.
The fix addresses the underlying TTL lifecycle rather than treating the resulting
MinPointsvalue as an isolated cache bug.Testing & Verification
The implementation was verified against the repository's applicable quality checks, including:
Acceptance Criteria
MinPointsis protected from unintended TTL expiration.MinSlotis protected from unintended TTL expiration.Scope
This PR is intentionally limited to the leaderboard instance-storage TTL lifecycle issue. It does not attempt to redesign the leaderboard's ranking algorithm or address unrelated leaderboard issues.
Review Notes
The implementation should be reviewed with particular attention to:
Closes #66